Jump to content
  • Advertisement
Sign in to follow this  
jeffkingdev

Cascade Shadow Map Pixel Shader

This topic is 2148 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

Hello,

So, I have CSM working. Looks great. In order for it to work properly, I need to figure out the cascade index in the pixel shader and then do the multiply with it's 1 of 4 matrices (one for each map) again in the pixel shader. I'd rather do this in the vertex shader, but then I get shadows with lines across it (shadow, no shadow, shadow, no shadow, etc.).

Is this possible to do in the vertex shader? If so, any ideas how?

Maybe I can't do this because of the nature of the shadow, it really does need to be a pixel operation. It just sucks I have to pass all 4 matrices into my pixel shader for the operation.

Thanks
Jeff.

Share this post


Link to post
Share on other sites
Advertisement
You cannot generally do it in the VS because a triangle can cross over cascade boundaries. If you can guarantee that it doesn't (using frustum checks on the CPU) then you can do it on the VS.

Typically for orthographic projected cascades you only need to do a single vector by matrix transform. Each cascade can then be done via a bias and scale operation which is a single MAD operation per cascade check.

Share this post


Link to post
Share on other sites
To elaborate more on what Alias said...all of your cascades are going to use the same light direction, which means that the bounding boxes formed by the projection for each cascade will all be aligned to the same axes. With that in mind you can transform from the coordinate space of one cascade to the coordinate space of another cascade by figuring out how much to translate, and how much to scale. Ultimately it should be just a just a bit of math in shader, and it shouldn't even be a blip in terms of performance on GPU that's not more than 5 years old.

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!