Jump to content
  • Advertisement
iradicator

Shadows on parallax mapped meshes

Recommended Posts

I have a sphere casting a shadow on a quad that has parallax mapping.
I was wondering how to displace the shadowmap to get the correct shadow results for the parallaxed fragment.
BTW, what's the solution for shadow volumes?

Share this post


Link to post
Share on other sites
Advertisement

how about keeping a copy of the diffuse texture. on that blend in the shadow per frame on the copy and use that during sampling. the shadow would offset when the texel offset. What do you think? Might look right?

Share this post


Link to post
Share on other sites

Shadow volumes are still a thing? Well, with them you're most certainly screwed as they are basically vertex-ops.

Back when I played parallax mapping I derived a true world position from the displacement. Ugly and slow, but mixed correctly and easily, a combo I strongly raccommend.

Share this post


Link to post
Share on other sites

If i'm not wrong, what you need is modify the depth that you're comparing with shadow map depth with height that was returned by your POM alghorithm.

Basically instead of:

float shadow = currentDepth > closestDepth  ? 1.0 : 0.0;

you should do:

float shadow = currentDepth - pomDepth > closestDepth  ? 1.0 : 0.0;

Never tested this, but it should work :)

What is also important, when building shadow map, you should write altered depth to depth buffer, otherwise you will get incorrect self shadowing. However, this introduces some performance penalty, as you've to do POM for every shadow map, as well as, outputting custom depth in pixel shader disables some optimizations on depth buffer (early-z test? hierarchical z-buffer?).

Check yourself if effect(subtle) is worth performance penalty yourself. If you want to have detailed, shadowed geometry, go for tessalation instead.

 

Share this post


Link to post
Share on other sites

For self-shadowing you can also ray-march the height field in the direction of the light source. I believe the original parallax occlusion mapping article/sample from ShaderX did this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!