XNA意外')'效果编译器

时间:2014-01-31 16:43:28

标签: c# xna shader hlsl pixel-shader

我的XNA HLSL编译器在减法结束时一直告诉我有意外的')'。 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);

有时虽然它会在另一个地方随机工作,但它会再次“破坏”。

2 个答案:

答案 0 :(得分:4)

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

这是1个开口支撑和2个闭合支撑;其中一个应该被删除。我猜它是第一个?

答案 1 :(得分:4)

这是因为你在这一行的末尾确实有一个意外的)

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

删除它或删除第一个:

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