I am writting deferred shading (in XNA) with 3 buffers:
1. Albedo
2. Normals moved from range [-1,1] to [0,1]
3. Depth Buffer [0,1], with inverted ViewProj reconstruction into world space
After (finally) adding phong I notice it's looking ugly. I Noticed that there are some kind of square shapes near specular. I think I did something wrong with specular. Also it looks like as I am using to small precision for depth map.
I attach 2 screenshots. First is better, but with halfVector4 for Albedo and Normals, Vector2 for Depth(I did it for test). The correct surface format I want to use is Color for Albedo and Normals, Single for depth, but second screenshot shows what happenes.
Here's the function for phong:
float3 doPhong(float3 Normal, float3 Position)
{
float3 LightVector = normalize(Light - Position.xyz);
float3 CameraVector = normalize(Eye - Position.xyz);
float3 LightReflect = reflect(-LightVector, Normal);
float NdL = max(0.0f, dot(Normal, LightVector));
float specular = 0.0;
specular = pow(max(0.0, dot(LightReflect, CameraVector)), 20);
return saturate(NdL * LightColor)+specular;
}
For those who suspect I have bad precission my nearPlane is .1f and farPlane is 30.
I feel so stupid to post question like that since it's second DS engine I am wirtting...