Sign in to follow this  

shader compile issues....(phong shading)

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i have my phong shader that works fine, but when i add four light sources instead of one it won't compile. The issue is only with the combined specular component. It works if i add 3 out of the four (doesn't matter which ones) but fails if i use all four. It doesn't matter how or where i add them. I've rearranged the code to make the additions simpler and using seperate variables for each component. Take note that it also works if i dont add the final specular value in when it returns. Any ideas??? Heres the PS code... (all the Lights are float4) // Calc light 1 float3 R = normalize(2 * dot(Norm, Light1.xyz) * Norm - Light1.xyz); float4 D = lA1 * mA1 + lD1 * mD1 * max(0, dot(Norm, Light1.xyz))*Light1.w; float4 S = lS1 * mS1 * pow(max(0, dot(R, View)), mP1/4)*Light1.w; // Calc light 2 R = normalize(2 * dot(Norm, Light2.xyz) * Norm - Light2.xyz); D += lA2 * mA1 + lD2 * mD1 * max(0, dot(Norm, Light2.xyz))*Light2.w; S += lS2 * mS1 * pow(max(0, dot(R, View)), mP1/4)*Light2.w; // Calc light 3 R = normalize(2 * dot(Norm, Light3.xyz) * Norm - Light3.xyz); D += lA3 * mA1 + lD3 * mD1 * max(0, dot(Norm, Light3.xyz))*Light3.w; S += lS3 * mS1 * pow(max(0, dot(R, View)), mP1/4)*Light3.w; // Calc light 4 R = normalize(2 * dot(Norm, Light4.xyz) * Norm - Light4.xyz); D += lA4 * mA1 + lD4 * mD1 * max(0, dot(Norm, Light4.xyz))*Light4.w; S += lS4 * mS1 * pow(max(0, dot(R, View)), mP1/4)*Light4.w; return tex2D(sTex0, Tex)*D+S;

Share this post


Link to post
Share on other sites
Did you check the ppCompilationErrors buffer that D3DXCreateEffect*() fills? It will be holding detailed information about your compiler error. You could also throw the shader into FX Composer.

Since it works with 3 lights and not 4, I think you are exeeding your maximum PS instruction count.

Share this post


Link to post
Share on other sites

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this