Vertex Shader Question

Started by
0 comments, last by griffin2000 17 years, 7 months ago
Hi Im working on my effect class. When i make a shader in Rendermonkey e.g. this code from my skybox


   Out.Pos = mul(matWorld, float4(Input.Pos.xyz + view_position.xyz, 1));

where the matWorld is the WorldViewProjection matrix. this positions the skybox around the camera. okay. but when i exprot the effect, I have to swap over the code so that its:


   Out.Pos = mul(float4(Input.Pos.xyz + view_position.xyz, 1)matWorld);

The way i bind the matricies in my effect class is as follows


matrix = worldMatrix; 
D3DXMatrixMultiply(matrix,matrix,viewMatrix);
D3DXMatrixMultiply(matrix,matrix,projectionMatrix);

pEffect->SetMatrix(currentSemantic->name,matrix);
alright it works fine as long as i swap over the order of the world matrix in the shader before using it, but this means that i have to do that every time i export an effect. Does anyone know the reason why this would be the case? thanks
Advertisement
This is all todo with whether you matrices are column-major or row-order. Its compile option in the HLSL compiler. If your implementation does not match what the FX expects you either have to transpose your matrices before you send to the shader (an unnessacary expense) or swap the order you do your matrix multiply.

I don't know about rendermonkey but Nvidia FX composer has an option to swap row/column order.

This topic is closed to new replies.

Advertisement