Shader optimization: Is a ternary operator equivalent to branching?
Actually this depends on the shader language one uses. In HLSL and Cg a ternary operator will never lead to branching. Instead both possible results are always evaluated and the not used one is being discarded. To quote the HLSL documentation: Unlike short-circuit evaluation of &&, ||, and ?: in C, HLSL expressions never short-circuit … Read more