deferred shading VS deferred lighting

# brief
- 所谓tile based deferred shading(渲染算法,非mobile gpu的tbdr架构),就是把deferred shading的shading阶段的二层循环的顺序换一下,不再是一个个光源地draw,而是一个个tile地draw(每个tile有light list)
- tile based forward shading,就是先把影响每个tile的lightlist搞出来,然后用texture来存。接下来就是正常的forward shading,唯一的不同是shader上去找当前fragment所在的tile的light list,然后循环算光照叠加
- clustered shading使劲吹,但是需要compute shader,而且自己都承认了有时候light assign的消耗offset了更少的光源计算的消耗

# 17.1 introduction
- deferred shading的优势
    - decouple shading&lighting from geometry management, allow efficient submission
    - minimize lighting computation, 文中说这点变得不重要了(我觉得胡扯吧,啥时候不重要了)
- deferred shading的劣势
    - bandwidth(如果一个pixel被N个光源照到,那这个点的gbuffer要被访问N次,而这点可以被tiled deferred shading优化)
    - memory占用(tiled deferred shading对此无任何作用)
- tiled deferred shading
    - tile based deferred 在没MSAA和transparency的情况下比tile based forward shading有效率优势
    - 支持transparency
    - 不再有GBuffer的要求
    - 能用MSAA(deferred说是在同等MSAA quality下效率就差很多了),另外在8x情况下deferred还有memory contraint的问题


# 17.2 Recap: Forward, Deferred, and Tiled Shading
- deferred的tiled和非tiled区别
    - 在shading阶段,是个2层循环,loop over light和loop over pixel
    - tiled的外层loop是pixel:把屏幕划分成tile,要找出影响每个tile的light。渲染每个tile的时候就是对pixel来loop light
    - 非tiled的外层是light:loop over light,对每个light cover到的区域算光照然后累加到extant radiance buffer上
    - key difference:tiled deferred shading只需要读gbuffer once、framebuffer也只要写1次,common term可以缓存使用(在shader的local变量种),执行更coherent
- cluster shading
    - 随便一提:说是能更rebust地处理complex的geometry和light configuration
    - 是tiled shading的改进,更复杂


# 17.3 Tiled Forward Shading: Why?
- deferred shading的weakness
    - transparency/blend没法直接搞
    - memory和bandwidth,再加上MSAA memory就更不好搞了
    - 多种shader支持
- tiled forward shading硬件支持要求低

# 17.4 Basic Tiled Forward Shading
- walkthrough
    - subdivide screen into tiles
    - optional pre-Z pass
    - optional find minZ,maxZ of each tile
        - 通过loop来reduce出每个tile的min max,用来判断light到底是否影响这个tile
    - assign lights to tile
        - 可以cpu上做,比如1080p 32x32 tile的时候只有2k个tile,而且light的数量一般也少(书上说几k个light还少。。。)
        - 也可以GPU上用compute shader
    - render geometry, compute shading

# 17.5 Supporting Transparency
- tile min max做文章

# 17.6 Support for MSAA
- 强行用带宽、memory、高MSAA倍数来对比deferred和forward

# 17.7 Supporting Different Shaders
- deferred shading只能用material id + dynamic branch来搞了吗?

# 17.8 Conclusion and Further Improvements
- 吹clustered shading

# after thought
- 如果我们能在纯forward shading里,把primitive也按照tile做排序,会有性能提升嘛?在mobile上

你可能感兴趣的:(GPUPro)