🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

How to remove dark area behind a light with shadow mapping effect

Started by
7 comments, last by JoeJ 2 years, 6 months ago

Hi !

I am trying to implement shadow mapping with a spot light and my problem is that in the area of the back of the spot light, the scene is in shadow.

I would like that this area be lit like when I don't use shadow mapping.

Can you help me ?

Advertisement

You could use an unshadowed fill light at the area that you want to be lit up.
Or you could make the shadows darkening depending on distance to light source, by changing related shaders.

Ok thank you, but there isn't a more simple way ?

All of my proposed solutions are simple. I assume you work with some engine like Unity and you don't want to ‘hack’ default lighting systems?
Also, your request is somewhat unusual. I mean, you could just turn shadows off if you don't want them. Oh wait - only now i realize you talk a about a spotlight, so even with no shadows the area behind the light would not receive lighting at all and only the fill light proposal can help. The fill light would need to be a omni directional light with some small radius ofc.

However, i think you miss the true reason of the issue, which might be missing GI, or the expected shortcomings form using point lights which just are not natural. And you may lack experience about the tricks and hacks we use to get acceptable results.
So a screenshot / better description would help. Maybe a working solution is very different from what you have in mind currently.

In fact, I am writing my own engine in opengl es 3 and I have the same problem as in this article in the “over sampling” section. They provide a solution but I can't use it because it concerns classic opengl, I don't have any access to the same parameters.

It is the reason for which I was thinking that a “miraculous” solution could exist like in this article. https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping

If you mean the GL_CLAMP_TO_BORDER you can try replacing it with a scissor test and GL_CLAMP_TO_EDGE.

hmmm… I hear you, but now i assume you maybe do not model a cone shaped falloff for the spot light, and thus you get discontinuities at the frustum pyramid of the projected shadow map?
It's actually correct there should be no light outside this pyramid, so also not behind the light. But the cone falloff is additionally necessary to hide such harsh transitions from light to no light. And this is independent form having shadows on or off.

Tried to paint a picture to illustrate:

The blue line is the shadow map, and the black lines show the spot lights frustum. Inside this frustum there may be light, outside there won't be any.
But we don't want a hard switch. light should gradually decrease to wards the frustum, illustrated by the gradient of white → grey → black areas.

So we probably need a tutorial about implementing such cone falloff. Same site has one here: https://learnopengl.com/Lighting/Light-casters

This topic is closed to new replies.

Advertisement