Jump to content
  • Advertisement
Sign in to follow this  
Migi0027

DX11 DX11 Shadow Maps - Render targets

This topic is 2002 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 guys,

 

right now I render the scene with a depth buffer from the lights position and aim, though it's actually a directional lights. So what I do is that i make the difference in the aim and the position large so that the 'rays' almost become parallel, so it seems like a directional light. The only problem with this is that the shadows become very edgy, as the size of the depth rendering map is quite small compared to the area that needs to be covered with shadows (the cameras position is very far away from the shadows position), to make it detailed. So what I though could be possible was to change the size of the render target with the device to a larger and then render the texture, and then change the size back and then use the texture, but wouldn't that be quite slow?

 

So how should this be done? As it is done in previous games, like e.g. Battlefield 3: (look at the building or the trees shadows on the grass)

 

943231915d1319140158-battlefield-3-name-

 

Share this post


Link to post
Share on other sites
Advertisement

Are you talking about downsampling the render target in order to get soft shadows? Usually, a blur filter is applied for that effect. This is commonly used in Variance Shadow Mapping where the square of the depth value is stored along with the original, and using both for a visibility test to see where some area should be shadowed. It usually gives some good results with smaller render targets, compared to traditional shadow mapping.

Share this post


Link to post
Share on other sites

EDITED:

 

So e.g. we split the scene up into like 4 parts  (or something else) and then render shadows for each of them depending on the depth?

 

Right now I'm using a spot light lighting, so should i render 4 (in this case) shadow maps for this spotlight, each time moving it to the new 'layer of shadows', so making a new position and aim, to seem as global shadows?

Edited by Migi0027

Share this post


Link to post
Share on other sites

Is it something like this (below) ? I'm not finished reading yet but I'm just trying to understand if I'm on the right path...

 

2r2bz0w.png

Red, shadow map 1, Green, shadow map 2, Blue, shadow map 3. Detail decreasing down the shadow map number. Arrows represent cameras

Edited by Migi0027

Share this post


Link to post
Share on other sites
It sounds like you're using a perspective camera. Directional lights should use an ortographic projection so that it's "parallel". The only problem then to solve is the size of the AABB calculated from receviers and casters to know where to place the camera and which objects to render (if the aabb isn't big enough, some casters may be left out, as a trade off for quality, that's why we use cascaded maps)

Share this post


Link to post
Share on other sites

Is it something like this (below) ? I'm not finished reading yet but I'm just trying to understand if I'm on the right path...

 

2r2bz0w.png

Red, shadow map 1, Green, shadow map 2, Blue, shadow map 3. Detail decreasing down the shadow map number. Arrows represent cameras

 

That's right. Render all cascades to a single depth stencil target (example size: 4096x1024) using viewports to draw to the correct part of the depth stencil target.

 

There's a good example implementation in the DirectX SDK 2007 and a lot of topics in this forums about it (like this one).

Edited by TiagoCosta

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!