Jump to content
  • Advertisement
  • entries
    743
  • comments
    1924
  • views
    584208

Light and Shadow Musing - Call for opinions/experience please

Sign in to follow this  
Aardvajk

1280 views

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.

Sign in to follow this  


9 Comments


Recommended Comments

>>  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.

Share this comment


Link to comment
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.

Share this comment


Link to comment

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).

Share this comment


Link to comment
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.

Share this comment


Link to comment
New lines still getting eaten by the comment editor on mobile I see. Sorry for the wall of text :)

Share this comment


Link to comment

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. 

Share this comment


Link to comment

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?

Share this comment


Link to comment

 

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

Share this comment


Link to comment

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!