Exposing only necessary variables

Exposing unnecessary variables from our shader to the accompanying Material can be costly, as the GPU can't assume these values are constant, which means the compiler cannot compile away these values. This data must be pushed from the CPU with every pass since they can be modified at any time through a Material object's methods such as SetColor() and SetFloat(). If we find that, toward the end of the project, we always use the same value for these variables, then they should be replaced with a constant in the shader to remove such excess runtime workload. The only cost is obfuscating what could be critical graphical effect parameters, so this should be done very late in the process.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.103.8