Click to See Complete Forum and Search --> : HLSL4 - When setting struct values, order matters?


trufooser
February 12th, 2010, 10:36 AM
I can't wrap my head around this. I'm trying to teach myself DirectX10 and am working on a lighting shader. I have a function that I call to move a vector from Local space to world space to camera space, and another that moves from local to WVP. My problem is the function to move to it WorldSpace is not working properly. It seems to be returning vertices that have NOT been transformed, ie they are still in their original locations.

I have a switch/case statement in the function in there, that multiplies the vertex with a specified rotation matrix. I have verified that this is working correctly, ie the right matrix is used to multiply. I've verified that I'm setting the rotation matrix with the correct value.

I cant think of anything else. Below is the shader function that I'm using, just wondering if anyone can see anything glaringly wrong. If anyone needs more code, I will be more than happy to post more. I just dont understand why the vertices are not transforming. Thanks for any help.

<code>
float3 MoveToWorldSpace(float3 vec, int index)
{
float4 temp = float4(vec, 1);
float4 t = float4(0,0,0,1);
[branch]
switch(index){
case 0:
t = mul(temp, trans0w);
break;
case 1:
t = mul(temp, trans1w);
break;
default:
break;
};
float4 v;
v.x = t.x;
v.y = t.y;
v.z = t.z;

return v;
};
</code>

trufooser
February 12th, 2010, 10:39 AM
And sorry about the innacurrate title name, I started asking a different question, but changed what I wanted to ask, and I can't figure out how to edit my post.