cool i think i've got it now, i'll give it a try myself later.
Thanks again
Dot3 Shader
A simpler and cheaper way to use the top left 3x3 portion of the matrix is to cast the matrix to a 3x3, e.g.:
That way you don't need to send what is essentially the same matrix to the shader twice and reduce the number of vertex shader constant registers used.
float4x4 g_ObjectToWorldMatrix : WORLD;...VS_OUTPUT VertexShader( VS_INPUT in ){ float3 position; float3 normal; ... // multiply position by the full 4x4 matrix // to rotate *and* translate vertex position position = mul( in.position, g_ObjectToWorldMatrix ); ... // multiply position by only the top left 3x3 portion of the matrix // to rotate the vertex normal *without* any translation normal = mul( in.normal, (float3x3)g_ObjectToWorldMatrix );}
That way you don't need to send what is essentially the same matrix to the shader twice and reduce the number of vertex shader constant registers used.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement