Dot3 Shader

Started by
11 comments, last by noaktree 19 years, 1 month ago
cool i think i've got it now, i'll give it a try myself later.

Thanks again
Advertisement
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.:

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.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks again Simon.
This is way better solution compared to sending the redundant matrix.

_Neil
game development is liek a state of mind man.. it's liek when you liek... think... and then you liek make it fun++

- Yes I'm drunk.

This topic is closed to new replies.

Advertisement