Although I should probably profile first, but what would you think would be better, performance wise?
The case is that I need two 'paths' in my shader, one including normal mapping and one without.
1. Different PS and VS for with and without normal mapping, use 2 different Techniques
2. Send a bool or something to the shader, and branch (one VS and PS, and one technique)
(if normalmap do some things, in both the VS and PS)
The actual differing code for WITH normal mapping is as follows:
// VS // Worldspace to Tangent space for normalMapping Out.WorldToTangent = mul(normalize(input.Tangent), World); Out.WorldToTangent = mul(normalize(input.Binormal), World); Out.WorldToTangent = mul(normalize(input.Normal), World); // PS float3 normalMap = normalize(2.0f * tex2D(normalMapSampler, input.TexCoord).xyz - 1.0f); normalMap = mul(normalMap, input.WorldToTangent); // instead of // float3 normalMap = normalize(input.Normal);
I'm using FX files and could also decide to have 2 separate effects/ FX files, but that sounds like waste too me.