Original Post
Hi I got problems with bump mapping and would be very pleased if someone could help me. Here is a screenshot from what my rendering looks like. 
As you can see the normals is opposite in left and right side and washed out in the middle. My shader looks like this. g_vLightPosition is given by g_Camera2.GetEyePt(). Does anybody have a clue of what’s wrong? I suspect that something has to be done with the light vector? Thanks
As you can see the normals is opposite in left and right side and washed out in the middle. My shader looks like this.
struct TEST_VS_OUT
{
float4 Position : SV_Position;
float3 WorldNormal : NORMAL;
float3 LightVector : TEXCOORD4;
float2 TextureUV : TEXCOORD5;
};
TEST_VS_OUT RenderTestVS( float4 vPos : POSITION, float3 vNormal : NORMAL, float2 vTexCoord0 : TEXCOORD0)
{
TEST_VS_OUT Output;
Output.Position = mul( vPos, g_MatWorldViewProj_C);
Output.WorldNormal = vNormal;
Output.LightVector = g_vLightPosition - vPos.xyz;
Output.TextureUV = vTexCoord0;
return Output;
}
float4 RenderTestPS( TEST_VS_OUT Input) : SV_Target0
{
float4 vBump = g_BumpTexture.Sample( MeshTextureSampler, Input.TextureUV);
vBump *= 2.0f;
vBump -= float4( 1.0f, 1.0f, 1.0f, 0.0f);
float3 Normal = normalize(Input.WorldNormal);
float3 vUp = float3( 0.0f, 1.0f, 0.0f);
if( abs(Normal.x) < abs(Normal.y))
vUp = float3( 1.0f, 0.0f, 0.0f);
float3 Tangent = cross( vUp, Normal);
float3 Binormal = cross( Normal, Tangent);
float3x3 BTNMatrix = float3x3( Binormal, Tangent, Normal);
float3 TransBump = mul( vBump.xyz, BTNMatrix);
float Shading = dot( TransBump, normalize(Input.LightVector));
return Shading * g_MeshTexture.Sample( MeshTextureSampler, Input.TextureUV);
}