My XNA HLSL Compiler keeps telling that I have unexpected ')' at the end of a subtraction. The PixelShader:

float3 lightDir = normalize(LightDirection);
float3 viewDir = normalize(input.View);
float3 normal = input.Normal;

float diff = saturate(dot(input.Normal, lightDir));
float3 reflect = normalize(2 * diff * normal - lightDir);
float specular = pow(saturate(dot(reflect, viewDir)), SpecularIntensity);

return tex2D(ColorMapSampler, input.TexCoord)
   * DiffuseIntensity * DiffuseColor * diff + SpecularColor * specular);

Sometimes though it randomly works there after at another spot it "bugs" again.

有帮助吗?

解决方案

return tex2D(ColorMapSampler, input.TexCoord) 
            * DiffuseIntensity * DiffuseColor * Diff + SpecularColor * specular);

That's 1 opening brace and 2 closing braces; one of these should be removed. I'm guessing it's the first one?

其他提示

It's because you really have an unexpected ), at the end of this line

return tex2D(ColorMapSampler, input.TexCoord)
   * DiffuseIntensity * DiffuseColor * Diff + SpecularColor * specular);
                                                                      ^
                                                                      |
                                                            Here ------

Either remove it or remove the first one :

return tex2D(ColorMapSampler, input.TexCoord
   * DiffuseIntensity * DiffuseColor * Diff + SpecularColor * specular);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top