我想将 D3DXMatrices 向量的内容用于我的着色器。
m_pLightMatrices->SetMatrixArray(¤tLightMatrices[0].m[0][0],0,numLights);
正如我们所知道的向量的内部结构,这不会造成任何问题(因为它只是一个动态数组)。
现在,当我在 hlsl 中访问这个矩阵来填充一个结构时,我得到了这个奇怪的行为:
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}
在调试时,我看到我的矩阵很好地填充了我想要的变量。当我尝试硬编码检查结构中的内容时,我得到全零,除了 LightRange。
如您所见,我尝试了访问 float4x4 的不同方法,但没有任何其他结果。
为什么哦,为什么 hlsl 不复制我所有的变量?