Light and Shadow Musing - Call for opinions/experience please

Published February 24, 2017
Advertisement

This is more of a design ramble than a technical issue that I have today. I was hoping to take the approach of having multiple point lights in my game levels, but just use a single shadow caster, but as you can see from the screenshot, this creates some weird situations where a shadow can be cast directly onto a light source which creates a really incorrect result.

shadowandlights.png

As I see it I have three main options here.


  • Live with unrealistic lighting. It isn't that important that a dungeon-crawler presents a realistically lit scene.
  • Continue to experiment with multiple shadow casters and try to overcome the problems I had. If I use 512x512x512 texture cubes, I seem to be able to render up to about five or six shadow cubes per frame without sacrificing frame rate on my mid-range hardware, so this is technically possible.
  • A new approach of maybe fading shadows out if they are falling on pixels that have been lit by another light source. I haven't really thought this through but might be another option.

I'm interested in canvassing for people's experience with this issue. I cannot seem to find the correct terms to Google to find other people's thoughts on this. Everything I look up is taking me to techniques for doing multiple shadow casting. I cannot be the only person to want to use a single shadow caster in an environment with multiple point lights, so if anyone wants to chip in with their experience and what they tried or ended up doing, I'd be fascinated to hear.

In the meantime, work has me pretty busy so will just keep a thread running at the back of my brain on this and see if I get any sudden inspiration.

I'm really hoping that whatever solution I come up with doesn't mean I have to apply a lot of restrictions to level design to accomodate. Will be a real pain if the only way I can get acceptable results is to apply a set of very rigid rules to how the level layouts work in terms of where lights and shadow casters are allowed. Obviously I can't expect "just anything" to work properly, but be very nice to be fairly free to design levels without having to worry too much about this.

Thanks for stopping by and please do contribute any thoughts you have on the subject.

[EDIT] Woo hoo

multiple.png

Colour me pretty damn happy with that :)

Loads to do to improve but that will be next post.

[EDIT again]

And one more screenshot for tonight... :)

multiple3.png

We are maintaining a steady 60 fps at 1280x768 on my mid-range laptop so seems three lights is going to work fine. Four starts to push it unless I drop the cubemaps down to 256x256x256 at which point the shadow edges start looking a bit ropey, but I reckon I can live with three lights active at a time in a dungeon crawler.

The main thing is that lights can be mobile, as I can see a lot of good gameplay coming from the player having to carry a light source around dark areas.

1 likes 9 comments

Comments

Norman Barrows

>> I cannot be the only person to want to use a single shadow caster in an environment with multiple point lights

while multiple lights and a single shadow caster might be convenient, its also physically impossible in the real world. So I would not expect there to be much research on a technique that does not produce correct results in the first place. Especially something that can be as complex as shadows. All that work for something that's incorrect?

I'd do what you can that is believable, and forget about the rest. So maybe multiple lights and no shadows whatssoever.

The other option is to fake it by using a single shadow caster, then designing levels with a "main light" that casts shadows, and "other lights" which can only be placed where the main light does not shine on them.

February 24, 2017 12:36 PM
Aardvajk
Yeah, I know what you mean. You're quite right, although game graphics rendering is not entirely constrained by realism so thought someone might have wanted to do the same.

The other option is to fake it by using a single shadow caster, then designing levels with a "main light" that casts shadows, and "other lights" which can only be placed where the main light does not shine on them.


That is the problem though. I'd like the main character to be able to carry a torch, which means there would be no such places.

Hmm, its a thinker.

Playing around with casting shadows from all point lights at the moment. Will see how that works out instead for now.
February 24, 2017 02:10 PM
xycsoscyx

What's actually going on with the screenshot? It's a little hard to tell because of the saturation, but it looks as though you are doing lighting first, then subtracting the shadows over top of that? If that's the case, then you need to flip it around a bit. Shadows should restrict what a light contributes to the scene, not subtract from it after doing all lights. Each shadow casting light source will only add to the non-shadowed area of the scene, so the shadowed areas still get the full light from other sources affecting that area (instead of looking like the shadow is dulling down the additional light sources).

February 24, 2017 02:44 PM
Aardvajk
To be honest, I can't remember exactly what I was doing when I took they screenshot. Trying loads of different approaches at the moment. I'm encouraged by the speed at which I can render the cube maps though. I'm starting to think that multiple shadow casters might be possible after all. As long as I can support the player carrying a light source, I reckon I can live with, say, two other active lights at any given point. This seems feasible if I can get it working. My current code seems on the right track. My level is semi-transparent at the moment but I think I might just need to render a depth only pass first to solve this. Stuck on a bus pondering this at the moment (one of our two bridges is shut so going to have plenty of time to ponder) but will update my journal as soon as I can try this. Thanks for all the input.
February 24, 2017 04:13 PM
Aardvajk
New lines still getting eaten by the comment editor on mobile I see. Sorry for the wall of text :)
February 24, 2017 04:14 PM
phil_t

Your screenshot definitely looks weird. Either you're doing something wrong, or that far away light source is much much weaker than the one casting shadows.

A shadow should simply indicate whether or not the light casting the shadow contributes its light to a pixel - as xycsoscyx mentioned.

Are you doing proper gamma correction? That is, doing the lighting calculations in linear space, and then converting back to sRGB before display? Ignoring the different color spaces is another thing that can make the lighting look bad. Bare plain surfaces also accentuate any lighting issues.

Having a single shadow caster with multiple light sources is very commonly done - it shouldn't look that weird.

February 24, 2017 11:44 PM
Aardvajk

Having a single shadow caster with multiple light sources is very commonly done - it shouldn't look that weird.


I'm not really fussed now, since I've got multiple shadow casting working and much prefer it, but I'm curious as to how, if this is commonly done, people usually solve the problem of a shadow caster casting a shadow directly onto another light? I kind of agree with Norman that unless you can rig it so that the shadow caster is limited so it cannot cast a shadow onto another light, it is always going to look wrong but perhaps I'm missing something?
February 25, 2017 06:41 AM
phil_t

I'm not really fussed now, since I've got multiple shadow casting working and much prefer it, but I'm curious as to how, if this is commonly done, people usually solve the problem of a shadow caster casting a shadow directly onto another light? I kind of agree with Norman that unless you can rig it so that the shadow caster is limited so it cannot cast a shadow onto another light, it is always going to look wrong but perhaps I'm missing something?

I'm actually not sure what you mean... why is "casting a shadow directly onto another light" a problem? Don't think of a shadow being "cast". Shadow just means the pixel at the position isn't affected by the light that is casting a shadow.

Attached a picture to (I guess?) show what I mean. In this case, there is a single shadow-casting directional light, and a point light (located where the fire is) that does not cast a shadow. Does it look wrong? I mean, it would be nice if the fire cast some shadows of the logs against the wall, but it's not terribly noticeable that it doesn't. You can just make out the shadow of the tree against the wall, but its mostly invisible because the pointlight is so much brighter than the directional light at that location.

hyloth.png

February 25, 2017 08:08 PM
Embassy of Time

Looks really interesting, I would love to see an actual tutorial for this!

April 07, 2017 11:32 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement