Here is an image of the wrong highlight:
http://www.trueharmo...ongSpecular.jpg
Now at first i thought it was my specular map so i added the n . h directly and got the same result. I can only assume this is something to do with my raising to the power of 1024.
This is my HLSL code
// Define the Pixel shader.
float4 BumpMapPixelShader( BumpMapPixelShaderInput input ) : COLOR0
{
// Excessive view transform inverse per-pixel ... should be done CPU side once really.
float4x4 ViewInv = inverse( View );
// Can same time by passing in the Camera position in view space.
float3 CameraPosition = mul( float4( 0, 0, 0, 1 ), ViewInv );
// Build a light to fragment vector.
float3 LightDir = input.PixelPos - PointLight.Position;
float LightDist = length( LightDir );
LightDir = normalize( LightDir );
// Cheesy attenuation. Should use a betetr attenuation function.
float Attenuation = 1.0f;//saturate( PointLight.Range - LightDist ) / PointLight.Range;
//vector from eye to fragment
float3 EyeVector = normalize( input.PixelPos - CameraPosition );
// Sample the normal map (Specular Map is held in w)
float4 Normal = tex2D( NormalSampler, input.UV );
Normal.xyz = (Normal.xyz * 2) - 1;
// Build the tangent frame matrix.
float3x3 tangentFrame = { input.Tangent, input.BiTangent, input.Normal };
// Transform the Normal.
Normal.xyz = normalize( mul( Normal.xyz, tangentFrame ) );
// Sample the Diffuse texture.
float4 Diffuse = tex2D( DiffuseSampler, input.UV );
// Do the N . L
float nDotl = saturate( dot( Normal.xyz, -LightDir ) );
float4 ColourOut = (nDotl * float4( PointLight.Color, 1.0 ) * input.Diffuse * Attenuation) * Diffuse;
// Build the half vector.
float3 halfVec = normalize( -EyeVector + -LightDir );
// Do the N . H
float nDoth = dot( halfVec, Normal.xyz );
// Raise to a specular power (1024 by default).
nDoth = pow( nDoth, SpecularPower );
// Multiply by specular map, light colour and per-vertex specular.
ColourOut += nDoth; //* Normal.w * float4( PointLight.Color, 1.0 ) * input.Specular;
return ColourOut;
}
If i change the last line to simply output nDoth i still get the wrong highlight. Can i really not raise it to such a high power or is there something im just failing to spot?
Any ideas would be much appreciated because i really do prefer the nice high power :)












