Pixel shader wierd compilation error
Posted
by ytrewq
on Stack Overflow
See other posts from Stack Overflow
or by ytrewq
Published on 2010-03-22T18:13:04Z
Indexed on
2010/03/22
18:31 UTC
Read the original article
Hit count: 497
hi, I'm experiencing with shaders a bit and I keep getting this weird compilation error that's driving me crazy!
the following pixel shader code snippet:
DirectionVector = normalize(f3LightPosition[i] - PixelPos);
LightVec = PixelNormal - DirectionVector;
// Get the light strenght factor
LightStrFactor = float(abs((LightVec.x + LightVec.y + LightVec.z) / 3.0f));
// TEST!!!
LightStrFactor = 1.0f;
// Add this light to the total light on this pixel
LightVal += f4Light[i] * LightStrFactor;
works perfectly, but as soon as i remove the "LightStrFactor = 1.0f;" line, i.e. letting 'LightStrFactor ' value be the result of the calculation above, it fails to compile the shader.
LightStrFactor is a float LightVal & f4Light[i] are float4 All the rest are float3.
my question is, besides why it doesn't compile, is how come DX compiler cares about the value of a float? even if my values are incorrect, shouldn't it be run-time? the shader compilation code is this:
/* Compile the bitch */
if (FAILED(D3DXCompileShaderFromFile(fileName, NULL, NULL, "PS_MAIN", "ps_2_0", 0, &this->m_pCode, NULL, &this->m_constantTable)))
GraphicException("Failed to compile pixel shader!"); // <-- gets here :(
if (FAILED(g_D3dDevice->CreatePixelShader( (DWORD*)this->m_pCode->GetBufferPointer(), &this->m_hPixelShader )))
GraphicException("Failed to create pixel shader!");
this->m_fLoaded = true;
any help is appreciated thanks!!! :]
© Stack Overflow or respective owner