Jump to content
  • Advertisement
Sign in to follow this  
michaelmk86

Shadow artifacts

This topic is 2340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,
does any one can provide any clues on why I don't get shadow on certain areas (the screenshots will illustrate the problem)
69946698.png

and the shadow map, as seen by the light
66538760.png

format of the shadow texture is D3DFMT_R32F

here is how i calculate light view and orthographic projection matrix

D3DXMatrixLookAtLH(&lightsView, &lightPos, &(D3DXVECTOR3(lightPos.x - 10.0f, 0.0f, lightPos.z - 10.0f)), &(D3DXVECTOR3(0.0f, 1.0f, 0.0f)));
D3DXMatrixOrthoOffCenterLH(&ortho, 10, orthoX, 10, orthoY, 0, orthoZ);
*lightsViewProjection = lightsView * ortho;

Share this post


Link to post
Share on other sites
Advertisement
The artifact is called "shadow acne", it's caused by lack of precision in the depth values, and a common work-around is to bias your depth values (towards the camera a bit if drawing backface depth, or away from the camera if using frontface depths).

Share this post


Link to post
Share on other sites

The artifact is called "shadow acne", it's caused by lack of precision in the depth values, and a common work-around is to bias your depth values (towards the camera a bit if drawing backface depth, or away from the camera if using frontface depths).

how I am going to bias the depth values on the polygons that are not looking the light?

Share this post


Link to post
Share on other sites
You are not performing standard lighting.

Under a standard lighting model, polygons that are so close to being perpendicular to the direction of the light will be shaded fairly dark.

You have acne because the polygon is facing almost perpendicularly to the light, but this should also mean that the polygon is fairly dark anyway. This helps to hide a lot of shadow artifacts such as acne.

Why are your boxes so bright except under shadows?

You can’t fully fix acne at steep angles, so your options are to use a standard lighting model and to blur/filter the shadow.


L. Spiro

Share this post


Link to post
Share on other sites

You are not performing standard lighting.

Under a standard lighting model, polygons that are so close to being perpendicular to the direction of the light will be shaded fairly dark.

You have acne because the polygon is facing almost perpendicularly to the light, but this should also mean that the polygon is fairly dark anyway. This helps to hide a lot of shadow artifacts such as acne.

Why are your boxes so bright except under shadows?

You can’t fully fix acne at steep angles, so your options are to use a standard lighting model and to blur/filter the shadow.


L. Spiro

yes, the problem is the lighting direction is not align with the direction of the shadow .

I need to properly adjust the the correct direction [color=#ff0000](1, 1, 0) but i am not sure how.

D3DXMatrixLookAtLH(&lightsView, [color=#ff0000]&lightPos, &lightPosLookAt, &(D3DXVECTOR3(0.0f, 1.0f, 0.0f)));
D3DXMatrixOrthoLH(&ortho, orthoX, orthoY, 0, orthoZ);
*lightsViewProjection = lightsView * ortho;
...
float3 DiffuseLightDirection = float3(1, 1, 0);// my light direction

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!