SetMatrix() does not copy all values to HLSL
Posted
by Tili
on Stack Overflow
See other posts from Stack Overflow
or by Tili
Published on 2010-05-29T20:20:42Z
Indexed on
2010/05/29
20:32 UTC
Read the original article
Hit count: 173
Hi,
I want to use the contents of a vector of D3DXMatrices to my shader.
m_pLightMatrices->SetMatrixArray(¤tLightMatrices[0].m[0][0],0,numLights);
As we know the internals of a vector this poses no problems (as it is just a dynamic array).
Now when I access this matrix in hlsl to fill up a struct I get this strange behavior:
struct LightTest
{
float3 LightPos;
float LightRange;
float4 LightDiffuse;
float3 LightAtt;
};
float4x4 currentLight = gLights[0];
LightTest lt;
lt.LightPos = currentLight._m00_m01_m02; //{0,0,0}
lt.LightDiffuse = currentLight[1].rgba; //{0,0,0,0}
lt.LightRange = currentLight._m03; //this gives me a value
lt.LightAtt = currentLight[2].xyz; //{0,0,0}
While debugging I see that my matrix is nicely filled with the variables I want. When I try to hardcode check what is in the struct I get all zero's, except the LightRange.
As you can see I tried different methods of accessing the float4x4 but without any other results.
Why oh why is hlsl not copying all my variables ?
© Stack Overflow or respective owner