# Problem with constant table

## Recommended Posts

Currently I'm using the constant table I get from compiling (i.e. D3DXCompileShaderFromFile) my hlsl file to bind uniform variables. Previously, I've just put all my code into my 'ps_main' entry function. In an effort to organize things a bit though, I've split things up into a couple of functions to make my file a bit cleaner. However, now my constant table is empty. Is there any way to get a table of the uniform variables used, even if they don't appear directly in your ps main function? To clarify, the hlsl code that I'm having troubles with looks something like:
float g_SpotCutoff;

void SpotLight(in float4 Pos, in float3 Normal, in float4 PosLight, inout float4 Diffuse, inout float4 Specular)
{
// Do stuff that involves using g_SpotCutoff
}

PS_OUTPUT ps_main( in float4 Diffuse : COLOR0, in float4 Pos : TEXCOORD0, in float3 Normal  : TEXCOORD1, in float4 PosLight : TEXCOORD2 )
{
PS_OUTPUT Output;

float4 oDiffuse = float4(0.0, 0.0, 0.0, 0.0);
float4 oSpecular = float4(0.0, 0.0, 0.0, 0.0);

SpotLight(Pos, Normal, PosLight, oDiffuse, oSpecular);
Output.Colour = oDiffuse * Diffuse + oSpecular * oDiffuse;
}


And g_SpotCutoff doesn't show up in the constant table.

##### Share on other sites
When you're compiling the shader code and the compiler doesn't find any logic that actually uses your uniform data they are excluded from the constant table.

If you started using the variable for something non-trivial it would show up as normal I would expect.