Hi guys, I'm trying to play with arrays for dynamic lights in HLSL but am coming across this problem in my HLSL:
Quote:
Error (209): error X5589: Invalid const register num: 32. Max allowed is 31.
this is my HLSL
Quote:
PixelToFrame MeshPixelShader(VS_OUTPUT PSIn)
{
PixelToFrame Output = (PixelToFrame)0;
float DiffuseLightingFactor = 0;
for (int i=0; i<xNumLights; i++) {
DiffuseLightingFactor += DotProduct(xLightPos, PSIn.Pos3D, PSIn.Normal);
}
float4 OutColor;
OutColor = tex2D(ColoredTextureSampler, PSIn.Tex0) * DiffuseLightingFactor;
Output.Color = OutColor;
return Output;
}
the strange thing is that the error is coming up for line:
Quote:
OutColor = tex2D(ColoredTextureSampler, PSIn.Tex0) * DiffuseLightingFactor;
this is how I am registering my light variables at the top of my HLSL
Quote:
static const int MAX_LIGHTS = 26;
float4 xLightPos[MAX_LIGHTS];
int xNumLights = 0;
I don't understand where it's getting 32 from and why that line instead of my for loop which is obviously where it's falling down because that's where the array is, it's quite obviously something stupid that I'm doing through my lack of understanding of HLSL.
Thanks guys,
Andy