I’m trying to find out the best way to use the shader variables.
We have some kind of parameters which can be used in the shaders. For example some light parameters:
_WorldSpaceLightPos0 - Directional lights: (world space direction, 0). Other lights: (world space position, 1).
So I have two ways:
1)
half3 lightPos = _WorldSpaceLightPos0.xyz;
o.diff = v.color * max(0, dot(o.worldNormal, lightPos));
o.lightDir = dot(o.worldNormal, normalize(lightPos + o.worldViewDir));
o.diff = v.color * max(0, dot(o.worldNormal, _WorldSpaceLightPos0.xyz));
o.lightDir = dot(o.worldNormal, normalize(_WorldSpaceLightPos0.xyz + o.worldViewDir));
Could you please clarify which one will be more optimized?