Cascading shadow maps - best approach to learn
Members - Reputation: 254
Posted 10 October 2012 - 07:50 AM
What do you think is the best approach for me to learn to one day be able to implement this in my game?
I am thinking about this approach:
1, make sure to get full control with RenderToTexture
Being able to change camera and render to texture and then draw the texture in my scene at the same time
2. Reflection and DepthBuffers
This is a part of the technique that is used in Cascading shadows, but i cant think of an example to laborate with...
Maybe be able to render the the ShadowMap only...
There is a Sample in the DirectX SDK that has both D3DX11 and Cascading shadow Mapping.
Maybe i am wrong, but i don´t understand why these examples has so lazy/bad code in them?
First there is 100 options in the GUI that complicates all parameters and there is often too much functionality build within the sample.
Maybe people like DXUtil, but i hate it, i want to know from the basics what i am doing.
Under category this sample is marked as "beginner". How can this be "beginner" sample, is it me that is that stupid but you have to have understanding of lots of things to get shadow-mapping to work.
Should i try to outbreak the SDK Sample and remove code by code to try to see the basics?
How would you do to learn shadow mapping? (Cascading especially)
Members - Reputation: 1521
Posted 10 October 2012 - 01:06 PM
For the code, I get the idea from MJP here -> http://mynameismjp.wordpress.com/2009/02/17/deferred-cascaded-shadow-maps/
Maybe it will help you too ;)
Moderators - Reputation: 17296
Posted 10 October 2012 - 01:18 PM
Anyway, I definitely think you should have a firm handle on using render targets and depth buffers if you haven't done so already. If you haven't done shadow mapping yet, you might want to try doing it for a single spot light first. A spot light is a *much* easier case than directional lights. After that, you can try getting a basic directional light shadow map without cascades. That will introduce you to some of the particular issues tackled by CSM, without having to implement the whole thing.
Members - Reputation: 463
Posted 11 October 2012 - 10:10 PM
It really helped me understand how the technique works.
Members - Reputation: 787
Posted 12 October 2012 - 09:03 AM
Steps I took:
1) I visually draw my view frustum
2) I split my view frustum into 4 slices and then draw those.
3) I setup an orthographic camera that uses each frustum (I didn't draw anything for this, but I set my main camera to each orthographic view slice of the frustum to see if I was seeing exactly what's in the view frustum.
4) Then I setup my render targets to a large texture and draw each orthographic view into them so you have 2x2 using the 4 slices of the view frustum.
5) Lastly, project that shadow map onto the scene, but you'll need to figure out the depth to figure out which 2x2 area you are projecting on the scene. This is a very confusing step, but it's the last step, so if you get to this point, keep working on it!
Good luck! It took me about a week or two to get this working, take your time and understand each step. If you don't understand a reason for something, you might miss something crucial.
Members - Reputation: 1410
Posted 14 October 2012 - 03:36 PM
How the actual orthogonal-ligh-shadow-map is correlated with the camera scene to determine if the pixel is in the shade is what I can't get.