Jump to content

  • Log In with Google      Sign In   
  • Create Account


Cascade Shadow Map Pixel Shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 jeffkingdev   Members   -  Reputation: 738

Like
0Likes
Like

Posted 29 November 2012 - 02:05 PM

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.

Sponsor:

#2 AliasBinman   Members   -  Reputation: 416

Like
2Likes
Like

Posted 29 November 2012 - 05:23 PM

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.

#3 MJP   Moderators   -  Reputation: 10281

Like
0Likes
Like

Posted 30 November 2012 - 01:07 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS