The attached image of the model is a 1:1 screen-crop of the problem (A). I've included a crop from the DXViewer (D) as I don't think the model is faceted by default. I've also included images of the model using the problem shader, 2D-lit but with no normal mapping (C). And also as the model appears in the corresponding Advanced Lighting demo, using the AL spotlight system (B) just as an example of smoothing and how the model responds to it.
To clarify, I cannot get (A) to looks anything like (B).
The 2D Shadow Mapping demo looks like one of his older demos judging by its layout - but I chose to use it because of its ease of portability with other older shaders. I'm using a bond1 zombie as the test subject because its one of the more complex bone-animated models I had lying around.
EDIT: further note:
The pixel shader here is essentially divided into five parts:
- Base Texture (no modification)
- Normal (modification based on light/view vectors)
- Light (2D projection image)
- Shadowmap (based on depth map, independent of other stages)
- Return (obvious, combines them all)
If I set the return value of the Normal Map to "1" then the affect it has on the base texture is *1, which means no effect. Hence (C) int he attached pic. (C) is still affected by the "light" component, as you'd expect.
EDIT redux!!!: I've included the current pixel shader code to complement my previous edit. As I understand it, the problem is occurring here and not in the vertex shader - but implementing phong would require more info than this pixel shader can receive (no more texcoords!).
float4 PS_NormalMap(OUT_NormalMap IN) : COLOR
{
float4 Texture=tex2D(Base,IN.Tex);
float3 NormalMap=tex2D(Normal,IN.Tex)*2-1;
float3 LightV=normalize(IN.LightVec);
float3 ViewV=normalize(IN.ViewVec);
NormalMap=normalize(NormalMap);
float Normal=saturate(dot(reflect(-ViewV,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float3 Projetlight=tex2Dproj(Projet,IN.Proj)*saturate(IN.Proj.z);
float3 Light=LightColor*(1-saturate(dot(IN.Attenuation,IN.Attenuation)))*Projetlight;
float Depth=(IN.Proj.xyz/LightRange); //MMM uses .xyz instead of .z
float shadowmap=1-(tex2Dproj(DepthMap,IN.Proj+float4(-0.8,-0.8,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0,-0.8,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0.8,-0.8,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(-0.8,0,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0,0,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0.8,0,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(-0.8,0.8,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0,0.8,0,0)) < Depth ? 0.111f:0.0f);
shadowmap=shadowmap-(tex2Dproj(DepthMap,IN.Proj+float4(0.8,0.8,0,0)) < Depth ? 0.111f:0.0f);
return float4(Texture*((Normal*Light*shadowmap)+Ambient),Texture.w);
}