Single pass multi-depth buffer generation

Started by
2 comments, last by Jason Z 11 years, 1 month ago

I've recently implemented shadowing in my game engine. Currently it only has one shadow map and I want to expand it to at least 3 to 4. I was going to try to attempt doing it using a MRT but ran into the issue of only being able to use 1 depth/stencil buffer which is required to keep the depth pixels in order. So any ideas on how to accomplish this? Using a single texture for all will get around the depth/stencil buffer problem but haven't been able to come up with a way to use the MRT or a single channel to a 1/4 slice of the texture.

I am looking to use a cascade shadow mapping technique since I simple calculate a quaternion based position for the shadow map placement directly in front of the player. The reason is I can easily fine-tune the overlap amount.

******************************************************************************************
Youtube Channel

Advertisement

You can use a single texture but divide it into multiple parts (by adjusting the viewport during rendering and the loopup inside the shaders).

If you have 4 cascades, divide the texture into four parts so that the first quarter (1 in the ascii art) is cascade 0,the second (2 in the ascii art) would be cascade 1.....

----------------------

| | |

| 1 | 2 |

| | |

----------------------

| | |

| 3 | 4 |

| | |

----------------------

Well that is along the lines of how I would like to do it but AFAIK there is only one viewport that can be active at one time. Also, I was looking into the possibility of using POSITIONx (x= 0 to 3) to provide the correct coordinates, problem is MS documentation on that command is pretty sparse as to what it's used for beyond POSITION0.

******************************************************************************************
Youtube Channel

With D3D9 there is indeed only one viewport active at a time. With D3D11 there is an array of both scissor rects and viewports that are available to use. Unfortunately, I don't think there is a way to render your geometry into multiple areas with a single pass through the pipeline.

You can minimize the cost of multiplying the geometry by using instancing to render multiple copies of your geometry, and then use the instance data to manipulate the geometry into the right portion of the screen. You would have to profile to get a good idea of how the performance compares to just rendering it four times, but it would be worth a try I suppose.

This topic is closed to new replies.

Advertisement