im having trouble with one constantbuffer:
struct CameraConstData
{
urd::Matrix projection; // 64 ( 16 floats)
urd::Matrix view; // 64 ( 16 floats)
urd::Vec3 viewPosition; // 12 ( 3 floats)
urd::Vec3 viewDir; // 12 ( 3 floats)
// 104 bytes (26 * 4)
float offset[26];
};
inside the shader its defined like:
// desc heap cbv
cbuffer CameraConstBuffer : register(b0)
{
float4x4 projectionMatrix;
float4x4 viewMatrix;
float3 viewPos;
float3 viewDir;
}
now viewdir is always filled with wrong buffer indices.
viewDir.x is the passed y value viewDir.y is the passed z value viewDir.z is 0.0
checked it in the shader like:
float3 vpos = normalize(float4(viewDir, 0.0)).xyz;
//float value = vpos.x; // uses the passed y value
//float value = vpos.y; // uses the passed z value
color = float4(vpos, 1.0);
GPU Debugging shows that the constant buffer looks fine:
i checked the vectors against the cpu side and they match.
So why is the shader reading index 36-38 instead of 35-37?
Its always affecting the 4th member of the struct. If i switch viewPosition with viewDir, viewPosition is false.
