Lighting | Support for shadows from omnidirectional sources

I’ve been playing with shadows a bit - there’s a good chance I’m missing something here, but I can’t quite work out how to get omnidirectional sources to work. I had assumed that point lights would behave this way, but I haven’t had any luck.

I’d either love a proper hint at how to achieve this effect, or support for shadows from omnidirectional sources :slight_smile:

Having done some googling, I think I’d need to do this with a depth map from a cube map render from the position of the light, and then a bit of GLSL handling. Before I dive deep down a rabbit hole though, it’d be great to know if there’s something I’m missing.

1 Like

It’s a missing feature right now. You could do it with cubemap or the dual paraboloid depth outputs, but it would need to be a custom shader. Sorry.

Thanks for confirming my suspicion here @malcolm! If I end up working on a shader approach I’ll be sure to share.

yeah +1 to this, i could really use nice turn key point light shadows but am nearing the point of needing to work out a custom solution as well! What kind of customization would need to occur? You can’t just point a equirect depth map at the light’s custom shadow map then?

@archo-p

I was looking here for some ideas about how to move forward:
https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping
https://learnopengl.com/Advanced-Lighting/Shadows/Point-Shadows

Some essential principles in the first, and then thinking about point shadows in the second. I don’t have a ton of time to throw at this for next couple weeks, but later in August I might try to pick this up.

+1 as well

I was going to suggest the equirectangular approach as well, it covers a full sphere but in a different format, and with some stretching in different ways than a cube map, though maybe overall lighter than a cube map, not sure… might need a non square res for equirect to balance out the distribution of shadow samples on x and y.

I haven’t tried this, but to convert to world space came across this:

the u/v of the texture converted to a point on a unit sphere, then maybe scaled/offset by the radius/position of the sphere?

+1 from a person with no glsl skills as of now.
I am getting to a point where I can achieve quite good rendering results with TD but this is a limitation nonetheless.

Thank you so much @raganmd for picking this up

ok reading a bit more on it here:

seems like to get 360 shadows, you do infact need a cube map for the shadows as the basis (unless you’re purely ray marching ). can convert that to an equirect but not sure what benefit that would give since you cannot really skip the cubemap stage (6x90 degree renders). Think this has to do with vertex shaders, nature of culling, linearity of vertex interpolation, etc… but I am by no means 100% on any of this.

Also… can one even describe an equirect projection through a matrix? I’d assume not… so that puts a big wrinkle in things too in terms of specifying a custom matrix to a camera comp.

Maybe the way to do this is to render the scene depth as a cube map from the lights perspective, then convert the rendered pixel’s position from world space to cubemap space, then compare depths there.

That’s the direction I was thinking - since you’d need a cube map of the world from the position of the light. Seems like this could get resource hungry fast.

Yep that’s exactly how you’d do it. The dual paraboloid is another projection that can be used for this that is faster since it’s only two renders instead of 6 for the cube.

2 Likes