Working on the terrain shader for my terrain editor, and having some issues with the D3D11 version. I am declaring an array of float uniforms as:
static const int numlayers=8;
#ifdef COMPILEPS
cbuffer CustomPS : register(b6)
{
float cLayerScaling[numlayers];
};
#endif
Then, I access it to scale a terrain texture layer by a specified amount:
float4 SampleDiffuse(float3 detailtexcoord, int layer, float3 blend)
{
return tDetailMap2.Sample(sDetailMap2, float3(detailtexcoord.zy*cLayerScaling[layer], layer))*blend.x +
tDetailMap2.Sample(sDetailMap2, float3(detailtexcoord.xy*cLayerScaling[layer], layer))*blend.z +
tDetailMap2.Sample(sDetailMap2, float3(detailtexcoord.xz*cLayerScaling[layer], layer))*blend.y;
}
In Lua script, I pass the material an array Variant object constructed like so:
local buf=VectorBuffer()
buf:WriteFloat(2)
buf:WriteFloat(2)
buf:WriteFloat(1.0)
buf:WriteFloat(1.0)
buf:WriteFloat(1.0)
buf:WriteFloat(1.0)
buf:WriteFloat(1.0)
buf:WriteFloat(0.25)
local ary=Variant()
ary:Set(buf)
TerrainState.terrainMaterial:SetShaderParameter("LayerScaling", ary)
But for some reason, the shader isn’t receiving all of the floats in the array. It receives the first float correctly, it receives an incorrect value for the second one, and the rest it receives the value of 0.
It works on the OpenGL version just fine, so I don’t think it’s a problem with constructing the VectorBuffer and setting the parameter:
Anybody have any ideas?