Why are their bumps in my shadow mapping?

Started by
14 comments, last by Paul C Skertich 9 years, 7 months ago

I just started implemending Shadow Mapping in my engine and I see inside the editor there's bumps inside the shadow map. I'm wondering what they are?

The current set up I have is an orthographic Left Handed view for rendering depth. The depth stencil is rendered as DXGI_FORMAT_D24_UNORM_S8_UINT and is bounded both as depth stencil and shader resource. The texture format for the depth stencil is DXGI_FORMAT_R24G8_TYPELESS The shader resource view is formated as DXGI_FORMAT_R24_UNORM_X8_TYPELESS.

Is it a format issue?

[attachment=23358:Snapshot1.jpg]

If anyone needs to see sniplets of code I'll share.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX
Advertisement

Having a stair-step pattern is totally expected, since it's just aliasing due to rasterization. However in your picture the edges are rounded, which is strange. Are you using bilinear filtering when sampling the shadow map, or performing any other filtering/blurring on the shadow map before you sample it?

No, I double checked to see what my sampler state was set to and it was originally set to D3D11_FILTER_MIN_MAG_MIP_LINEAR_POINT I can't remember but it was point sampling. So, I thought it could be what you were mentioning about biLinear filtering - so I changed it to D3D11_FILTER_MIN_MAG_MIP_LINEAR and kept the clamp still there.

When I perform the projection I did :


float2 projTexCoord;
projTexCoord.x = +input.lightVector.x / input.lightVector.w / 2.0f + 0.5f;
projTexCoord.y = -input.lightVector.x / input.lightVector.w / 2.0f + 0.5f;

The lightVector is the camera orthographic video from the light into the constant buffer inside the shader.

At first I thought that was the issue but like you asked - no bluring or any bilinear filtering was used At least I don't think - I'm unsure what bilinear filtering is actually. The depth stencil is not MSAA and the sample count is set to 1 and the quality is set to 0.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

Wait I corrected my statement above - I checked what bilinear filter is and apparently the point sampling is bilinear. So yes; I did - I didn't know it. I changed it to trilinear and apparently the same result. Do you think just antsicopy filtering or perhaps point sampling will help?

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

The rounded edges are due to your shadow filtering, perhaps try D3D11_FILTER_MIN_MAG_MIP_POINT for your filter.

[size="1"]

Now I got the stair stepping that MJP was mentioning by using point sampling. Just to make sure I was using point sampling - I changed it from clamp to border. Inside the rendering


ID3D11SamplerState *Samplers = { device->pointSampler, device->clampSampler };
device->getDeviceContext()->PSSetSamplers(0,2,Samplers);

the clampSampler is configured for the D3D11_FILTER_MIN_MAG_MIP_POINT and address modes are set to border.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

So, the resulting image I received is [attachment=23363:Snapshot1.jpg]

I looked at Crysis 3 shadowing and was completely amazed - voxel cone tracing techniques were used but I'm far away from even implementing that in my engine. A lot more to read and research.

Now back to reading DirectX 11 by Frank Luna because he covers the stair stepping issue and suggests to use PCF Kernels to reduce the stair stepping.

Are Kernels specially designed in the hardware? I kept on seeing in shader tutorials about Kernels - which through me off a bit. There was a shader tutorial of edge detection using 3x3 kernel and a simple gaussian blur using a 3x3 kernel.

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX
http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/

PCF is covered. All samples have full source code and explanations.
Since it is WebGL, they are all basic enough for beginners.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Most of the stuff from that website L. Spiro is able to translated to DirectX? I added the site to my home page for later reading.

What I understand is the hard edges are shadow artifiects from the shadow map's boundary - which is normal. The shadow acne I was getting was due to the light's camera view relative to the camera. I didn't show the shadow acne.

In what depth sohuld ia have the shadow map 1 - 1000 (max) or 1 - 100?

Game Engine's WIP Videos - http://www.youtube.com/sicgames88
SIC Games @ GitHub - https://github.com/SICGames?tab=repositories
Simple D2D1 Font Wrapper for D3D11 - https://github.com/SICGames/D2DFontX

The range of the depth of the shadow depends on the projection matrix you use to render into it and later to retrieve from it, and that matrix is derived from the farthest and nearest objects’ bounding boxes from the light’s point of view. He has hard-coded it for the tutorials for the sake of simplicity.

It is trivial to translate to Direct3D. Mostly, use lerp() instead of mix() and ddx()/ddy() instead of dFdx()/dFdy(). Other little things will be easy to spot and translate as you go.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement