Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Transitioning between realtime shadow lights

Author
Message
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 17th Jun 2012 10:29 Edited at: 17th Jun 2012 10:33
I wanted to discuss with you lot ideas for transitioning between shadow lights in a level. This is an area of confusion for me, because I can't think of a good way to do it.

What I mean is, imagine you have 1 light in your game which can cast realtime shadows. This light is in the middle of a room on the ceiling. All the shadows cast from this light. Fine, but what happens when you leave the room and move into the adjacent room which also has a single light source in the middle? You want shadows cast from there too. (Assume this is an FPS and that only one shadow source is allowed).

In a previous game, I placed the shadow light source at blended points between game lights. So in the above example, as I moved from room 1 to room 2, I interpolate the shadow light position between the two light positions as the main character moves. This meant the shadows were always smooth, and the player had a correct looking shadow, but all the scenery and other characters ended up with bizarrely moving shadows which didn't really make sense.

So there has to be a better way ...

One thing I think is a given is that objects outside the range of the closest light source to the player shouldn't cast shadows. So while you could still have a light source in room 2, illuminating stuff correctly, nothing in that room should cast shadows while the shadow source in room 1 is active (because the player is there). Otherwise their shadows wouldn't make sense.

Using that method you could blend shadows in and out based on proximity to light sources. So when the player is right next to the light in room 1, the light source shadow intensity is full. Everything in range of that light source casts a full darkness shadow. As the player moves away, there is a point at which this shadow intensity dims, and when the player is exactly half way between light source 1 and 2, no shadows are cast at all. As the player moves closer to the light in room 2, the shadow intensity increases again and this becomes the new shadow source.

The problem with that method is, levels would have to be intelligently designed so that no shadow source is too close to another one, otherwise you would have noticeable shadow intensity changes. If light A had a range of 10 and light B had a range of 10, both lights would have to be at least 20 units apart, otherwise there would be a noticeable switch when the shadow source changed.

Anyway, there are probably other approaches, and I'd be curious to know what people think. I'm also interested in multiple shadow source locations, but I think single shadow sources are particularly interesting because of performance.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Jun 2012 15:49 Edited at: 17th Jun 2012 15:51
What you are saying is that you don't want the shadows around the rooms to move, so just have them pre-rendered. Shadows that don't move are best to pre-render. The shadows from your main character can do what you did before, have them move around, turn off the lighting on the room objects.

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 17th Jun 2012 16:55
There are other enemy characters, moving objects, doors etc. to take into consideration though, not just the main character. Plus I would be interested in achieving moving lighting effects, e.g. flickering flames or a rotating light siren type thing, which would look much better with realtime shadowing.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 17th Jun 2012 17:09 Edited at: 17th Jun 2012 17:14
That's difficult. I think that Van-B made a plain mould to meshes for a shadow tile with Alpha for an RPG. That's all I can think of with 1 light. I think I would prefer to find a solution with more lights. I'm sure that 2 lights is the most that you should design your level to handle. Always have a corner to turn, or a wall in the way.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Jun 2012 02:17
You could use the shadow mapping technique for two lights I posted a while back. Then you could use two lights at a time. Not foolproof of course - for example you could be in a rectangular hallway with open doors on each wall in which case you'd need five lights. Five lights would be overkill of course but two should give you more flexibility.
Mr Bigglesworth
18
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 18th Jun 2012 04:57
Could you use shaders for unlimited lights?
Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jun 2012 11:04
@Bigglesworth - I would use shaders, but you can't have unlimited lights. There's still a finite amount of lights you can pass to the shader, and for shadow sources, you need to render a camera for each one, so as Green Gandalf alluded to, more than 2 and it'd start to slow down.

@Green Gandalf - Two would definite improve things, but there has to be a fairly fool proof solution for the transitioning. I'm wondering how AAA titles do it. I'll have a think about it today and try and come back with another idea and see what you guys think ...

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Jun 2012 14:22 Edited at: 18th Jun 2012 14:30
Quote: "I'm wondering how AAA titles do it."
Well we have 8 lights, but our code isn't as fast as C++. There is the old way of flattening your objects in the Y, colour them black to create fake shadows. keep you enemy away from walls, and things so that their shadow is always flat. You could add alpha now as well.

Fallout
23
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 18th Jun 2012 14:41
I remember that old technique Pincho. It worked well in its day, but modern games need a shader based shadows. I don't want to be limited by flat floors and not going near walls.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 18th Jun 2012 14:43 Edited at: 18th Jun 2012 14:44
Quote: "I remember that old technique Pincho. It worked well in its day, but modern games need a shader based shadows. I don't want to be limited by flat floors and not going near walls."


It's only whilst you are looking into the next room that the enemies must keep away from walls, once you enter the room you can use real shadows, and the enemies spread out. In fact doorways limit what you see to the middle of the room anyway.

cyril
18
Years of Service
User Offline
Joined: 6th Aug 2007
Location: 7 miles away from big ben
Posted: 18th Jun 2012 15:53
This might be a bit old fashion, but normally if the player is not in a room; nothing dramatic normally happens.

So, if we say an enemy is patrolling a path and there is 2 lights along that path, because the path is predefined you can have a low-res animated lightmap(Sprite) layer for the enemy and map, when the player is far away.

Once you enter the room you can activate the real time shadow system to take over and activate the enemy AI response; of course you'll have to trap the player in the room to avoid any shadow mis-match; or use a corner or turns to hide any mismatch, so you can silently reposition the AI to the predefined position if the player runs too far.(Basically designing the map so no object receive more than 2 light and remain in the sight of the player).

Sadly this technique might not work with non-AI Characters; or scenes with more than 2 lights (assuming we were to use GG's 2 light shadow mapping as a base of modification.)
Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 19th Jun 2012 07:55
Real time lighting like the type used in AAA titles is going to be hard to do. Many AAA don't even have realtime unlimited lights. What we are really talking about is Unreal, Quake, and games built off of licensed world class game engines that themselves are massive multi-million dollar projects.

You can't do some of the things they do, with DBP. It's more realistic to accept some limitations. They can add additional cameras without taking nearly the performance hit we take. And everything is super optimized.

I would agree with those above that you should use lightmaps. However use one realtime light for effects. Suppose a gun is fired or a flashlight or something.

You just need to stick to effects you can pull off well or the game will look bad. Many AAA do this and they merely give the illusion that they support many effects when they don't.

Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 19th Jun 2012 12:01
you can use advanced lighting which gives you the possibility to use multiple lights with shadows

Login to post a reply

Server time is: 2026-07-10 15:15:26
Your offset time is: 2026-07-10 15:15:26