Skip to main content
GameDev.net gamedev.net
🔒 Locked

scene depth map & artefacts

Started by gjaegy Apr 13, 2007 at 8:43 AM 0 replies 1.1k views
Original Post
gjaegy
gjaegy
Hi guys, I really need your help, as I am getting very confused. During my rendering process, I generate a scene depth texture, which is basically a 32 bits floating point render target storing the distance between the camera and the point being shaded. This distance is stored as a normalized distance (thus in [0.0..1.0]) by dividing the result by the camera z far. So far so good. However, the generated texture get heavy banding artefact, as shown in the following picture: Please not the concentric circles in the bottom of the picture. The shaders I use to generate this depth map are the following:

Varying mainvert(VertexInput IN,
		uniform float jcamerazfar,
		const uniform float4x4 matworldview,
		const uniform float4x4 matworldviewproj)
{
	Varying OUT;
	OUT.vPosition   = mul(matworldviewproj, IN.vPosition);
	OUT.vPosCam     = mul(matworldview, IN.vPosition);
	
	return OUT;
}

FragmentOutput mainfrag(Varying IN,	uniform float jcamerazfar)
{
	FragmentOutput OUT;
	
	float fDist = length(IN.vPosCam.xyz / IN.vPosCam.w) / jcamerazfar; // scale to [0..1]	

	OUT.Color = float4(fDist,fDist,fDist,fDist);

	return OUT;	
}
I would really appreciate any input, as I have no idea what the problem could be. Also please not that reducing the z far value to increase the precision doesn't help. I am using HLSL, full floating point precision. I understand the banding in the screenshot could be caused by the f32 value being converted in a 8bits value. However, I experience the same banding problem when using the f32 value in another shader (where it should not suffer from this effect, as the value remain a float during the whole process). Any idea ? Thanks Gregory
Gregory Jaegy[Homepage]
gjaegy
gjaegy
hmmm, the banding artefact in the final shader seems to come from the fact that I was using pre-multiplied alpha (and the corresponding blending mode one / invsrc_alpha).

using regular alpha blending (src_alpha / invsrc_alpha) I have no banding artefact anymore.

strange.
Gregory Jaegy[Homepage]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.