Lighting in shadows

I have an issue i’m a little confused over how to best resolve. In the picture below, a car headlight beam shows that in shadows the light is muted by the shadow.

I can understand why this is happening - the shadows are being rendered in relation to a different light source (the sun / moon), therefore the my car headlights have no influence on the shadows, and are thus the light additive is being reduced by the shadow. Expected behaviour, but not desired. Is there a known way around it?

erf tricky one…
I can’t see any simple workaround…
You 'd have to make your own post shadow pass sahder and pass the light parameters to it…compute the lighting and exclude pixels that are lighted…

@nehon said: erf tricky one... I can't see any simple workaround... You 'd have to make your own post shadow pass sahder and pass the light parameters to it...compute the lighting and exclude pixels that are lighted...

Could he not just set the light source position in the shadow shader according to the only (or closest) flash light location?

Sorry, had to take a lunch break.

Ok, well cards on the table, I’m writing a single-player game, keeping in mind in the back of my head that multiplayer will be added at some point, and implementing everything accordingly.

Passing the nearest light source around will produce undesired effects in daytime, for example, if the player turns on the headlights in the day, even more so with say 10 people driving at night. I think maybe a better solution would be to get the shadow shader to ignore other light sources. I’m not overly-concerned about those other light sources creating shadows, that would be scary-heavy in a multi-player situation - but if the shadow were to ignore other light sources, it would at least produce a more friendly appearance.

I’ll see if I can modify the existing filter to accomodate my requirements.

I have a few questions. The most important one is, what light is actually casting that shadow?

After rethinking, its only one question :slight_smile:

The sun or moon, depending on the time of day.

Sounds to me like a heavy design flaw if the shadow map of one light source affects all light sources… For me that would no be expected behaviour.
@nehon, to make things clear:
Shadow pre pass calculated depth from lights point of view
Shadow post pass darkens the shadowed areas to ambient light?

@zzuegg said: @nehon, to make things clear: Shadow pre pass calculated depth from lights point of view Shadow post pass darkens the shadowed areas to ambient light?
nope. Shadow pre pass calculated depth from one light point of view. "lights point of view" doesn't make a lot of sense. For several lights you need several processors Shadow post pass renders the shadowed areas over the already rendered geometries (as in rendered with lighting or not). That's a problem because for example specular highlights are visible in shadowed area. This is mostly unnatural but several AAA games have this flaw (on the top of my head Darksiders 2 for example). Usually you only notice it if you are a monkey freak like all of us. :p

One way to alleviate this issue would be to render shadows during the lighting pass and zero the specular contribution to lighting in shadowed areas.
Though…this wouldn’t fix the OP’s issue.

The OP’s problem is that another light is lighting a shadowed area. In real life the second light contribution would cancel the shadows on the area… but in a game engine with a forward rendering process and multipass lighting there is no way it can.
Single pass lighting could alleviate the issue, (providing the post shadows are rendered during the lighting pass)…but really all this leads to deferred rendering.

The only way to have a correct handling of shadows with multiple light source is to somehow compute all the lights contributions at once to modulate the shadow map.

1 Like

Sure, i know that you need several processors for several lights. Lost in translation i think.

Don’t know if the specular light is the problem, looks actually realistic on the pics above.
Well after finished harvesting that damn apples (The real fruit) i have to give those shadowing stuff a better look.

Still i don’t get how the actual shadow is applied. Looks like it removes all the applied light values and not only those from the shadow casting source. I never noticed that behaviour in a game, but since i bought darksiders 2 in one of the last humbe bundles i will also look at that :wink:

Thanks for the description of the system

And this ladies and gentelman is the reson many games do not use real lights for cars, but projected textures /meshes that look alike. Wich would probably work for this case, if the projected stuff would be excluded from shadowing.

As it stands right now, the shadow filter mutes everything, so regardless of whether it was a texture or a light, it would still be muted just the same.

Except the texture is on a mesh, and that mesh could be set to none shadow recieving

Yeah actually, the shadows are rendered on the ground, a projected texture wouldn’t fix it.
@jayfella IMO you have two workaround to consider, a easy and a tricky.

  • Don’t make the moon cast shadows, or at least reduce the shadow intensity. the issue will be less noticeable. Have the cars shut their lights out at day to avoid the issue during daytime.

  • Make your own shadow post pass shader and have an array of spotlight parameters and cancel the shadows in lighted areas. (this can be done for the renderer or the post process).

Yeah the second option is probably the route I’ll have to go down. If a job’s worth doing… I’ll make some in-roads when I’ve finished doing the entity composition for my game.

Or… do the headlights as a reverse shadow… project out and lighten anything it hits…

Or maybe you could do something in screen space by again projecting the light and marking the pixels and then in the shadow renderer not shadow anything that is marked.

I don’t know much about rendering, but here’s something I’m thinking about for my own game.

Suppose the scene has two lights. What if one were to turn off one light and render the frame with shadows to a buffer. Then turn off the other light and render the frame with shadows to another buffer. Then display the pixel-by-pixel sum of the two buffers?

It seems to me that ought to work. Or would it be too inefficient?

I will mention that my drop shadow filter could emulate headlights if the color of the “shadow” was set to white… and since it is rendered as a post processing pass it would be done after shadows. It’s a “volume” so it lights the bottoms of things it intersects, too but for headlights maybe that doesn’t matter.

@pspeed said: I will mention that my drop shadow filter could emulate headlights if the color of the "shadow" was set to white... and since it is rendered as a post processing pass it would be done after shadows. It's a "volume" so it lights the bottoms of things it intersects, too but for headlights maybe that doesn't matter.
I don't think it would work neither. the problem here is that the light can cover shadowed areas from another light source and non shadowed areas. So rendering the light before or after shadow have no importance. So unless you also pass the 2nd light source in the shader that is rendering the shadows, you'll end up with that kind of artifact.
@nehon said: I don't think it would work neither. the problem here is that the light can cover shadowed areas from another light source and non shadowed areas. So rendering the light before or after shadow have no importance. So unless you also pass the 2nd light source in the shader that is rendering the shadows, you'll end up with that kind of artifact.

But in my case, they aren’t real lights. In real life, all lights will cast a shadow. Some lights will negate a shadow.

If you paint white on a shadow it will go away. So I’m not sure I understand what you are getting at.

The problem is that in that case you’re not painting on a shadow, you’re painting on a shadowed texture.
See the op’s screen shot,the headlights lights the ground where there are shadowed and not shadowed areas.
Here the shadows are applied after the lights are all rendered.

I guess your drop shadow filter would paint semi transparent white but you’d still see the shadows cast by the moon.