directx - Why do we need dynamic branch to render multiple light sources -
i reading real-time rendering (third edition). in section 7.9 combining lights , materials, says "if dynamic branches not used, different shader needs generated each possible combination of lights , material type".
i think static branch suited problem. right?
presumably 'engine' code determining sorts of lights , materials in scene, , (usually) dynamic. communicate shader, need pass information in way - through uniforms, textures or buffers. data not static, , thus, conditional expressions based on information contained in them dynamic branching.
some graphics apis/drivers optimization under-the-hood, , recompile shaders multiple branches predicted, , call 'static branching'. example, shader documentation d3d9, states that:
static branching allows blocks of shader code switched on or off based on boolean shader constant.
in other apis such opengl, it's not advertised when these sort of optimizations occur, although presumably happen. may (will) different driver driver. however, it's far more reliable write combinations yourself, way know type of branching being used (none!).
if scene has unchanging lights , materials, "hardcode" light , material types in shader (say constants). however, quote saying - can use static branches, different shader needs generated every combination of lights , materials.
Comments
Post a Comment