Is this a problem with my shader? (the code is generated automatically by my 3d engine, so the code looks a little weird) Vertex shader (3.0):
float4x4 matWorldViewProj;
float4x4 matWorld;
float3 EyePosition;
float3 PointLight0Pos;
float PointLight0Range;
struct VS_OUTPUT
{
float4 Pos: POSITION;
float3 Normal: NORMAL;
float4 Col: COLOR0;
float3 View: TEXCOORD0;
float3 Reflect: TEXCOORD1;
float4 PointLight0: TEXCOORD2;
};
VS_OUTPUT vertexMain(float4 Pos: POSITION, float4 Col: COLOR0, float2 Tex: TEXCOORD0, float3 Normal: NORMAL, float3 Tangent: TEXCOORD1, float3 Binormal: TEXCOORD2)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Pos = mul(Pos, matWorldViewProj);
Out.Normal = normalize(mul(Normal, matWorld));
Out.Col = Col;
float3 worldPos = mul(Pos, matWorld);
float3 Incident = normalize(worldPos - EyePosition);
Out.Reflect = reflect(Incident, Out.Normal);
float3 vecPointLight0 = PointLight0Pos - worldPos;
float distPointLight0 = saturate(1 - dot(vecPointLight0 * PointLight0Range, vecPointLight0 * PointLight0Range));
Out.View = EyePosition - worldPos;
Out.PointLight0.xyz = normalize(vecPointLight0);
Out.PointLight0.w = distPointLight0;
return Out;
}
float ReflectionFactor;
float ShininessFactor;
float4 PointLight0Col;
float4 AmbientColor;
struct VS_OUTPUT
{
float4 Pos: POSITION;
float3 Normal: NORMAL;
float4 Col: COLOR0;
float3 View: TEXCOORD0;
float3 Reflect: TEXCOORD1;
float4 PointLight0: TEXCOORD2;
};
sampler reflectionMap : register(s2);
float4 pixelMain(VS_OUTPUT In) : COLOR
{
float4 baseColor = In.Col;
float4 Color = AmbientColor * baseColor;
Color = Color + ReflectionFactor * texCUBE(reflectionMap, In.Reflect);
float DotPointLight0 = dot(In.Normal, In.PointLight0.xyz);
float PointLightDiffuse0 = saturate(DotPointLight0);
float PointLightShadow0 = saturate(4 * DotPointLight0);
float3 PointLightReflect0 = normalize(2 * PointLightDiffuse0 * In.Normal - In.PointLight0.xyz);
float PointLightSpecular0 = min(pow(saturate(dot(PointLightReflect0, In.View)), 3), ShininessFactor);
Color = Color + (PointLightShadow0 * (baseColor * PointLight0Col * (PointLightDiffuse0 + PointLightSpecular0)) * (In.PointLight0.w));
return Color;
}

