Sign in to follow this  
MarkS

How do I go about lighting only polygons visible to the light?

Recommended Posts

MarkS    180
There is a maze game that I have been wanting to write for some time now. In it, the character walks around with a lantern. One of the enemies in the game can steal the lantern and run off with it. When this happens and the enemy turns a corner, I want the walls visible to the light (and only them) to be lit. How would I go about this? All geometric-based lighting schemes take the polygons that are visible to the viewer to calculate lighting. This, of course, will not work. Rather than doing complicated testing to see if the character has the lantern and then switching lighting modes if he does not, I would rather test the position of the light each frame and calculate lighting based on that. One method I thought of was to test the visible (to the viewer) polygon list to see which polys were also visible to the light, but that will not work since floor and ceiling polys are technically always visible to the light source. The levels will be generated dynamically (and potentially infinite), so I don't know if screen-space lighting techniques (i.e., light maps) will be viable. How would I go about this?

Share this post


Link to post
Share on other sites
Sneftel    1788
I'm not sure what the difficulty here is. Standard diffuse lighting equations do not take the viewer's position into account, only the light's position. Combine it with any shadowing technique and a reasonable maximum radius of illumination and it'll look fine. You could improve performance with various culling techniques, but see if it's too slow without them first.

Share this post


Link to post
Share on other sites
MarkS    180
Quote:
Original post by Sneftel
I'm not sure what the difficulty here is. Standard diffuse lighting equations do not take the viewer's position into account, only the light's position.


I understand that, but they *do* take the position of the polygons visible to the viewer into account. As such, any and all polygons visible to the player will potentially be lit, even if the light source is no longer visible (due to occlusion by walls) to the viewer.

And to be clear, I haven't actually implemented anything as of yet. This is just a potential problem I see cropping up and one I want to address quickly. It doesn't help that my knowledge of lighting techniques is about 10 years out of date.

Share this post


Link to post
Share on other sites
Atrix256    539
You might check out something called portals to be able to keep track of what polygons your light can see.

What happens though when only part of a polygon is visible to your light?

Because of this i think what you really want is to check out one of these 2 things:

#1 - volumetric shadows
#2 - shadow maps

both of those guys are common techniques used to only light what should be lit from a light source.

HTH!

Share this post


Link to post
Share on other sites
MarkS    180
Quote:
Original post by Atrix256
You might check out something called portals to be able to keep track of what polygons your light can see.

What happens though when only part of a polygon is visible to your light?

Because of this i think what you really want is to check out one of these 2 things:

#1 - volumetric shadows
#2 - shadow maps

both of those guys are common techniques used to only light what should be lit from a light source.

HTH!


Ah. Thanks for that. I'll look into those techniques. Actually, I've already decided on portals. Considering the dynamic nature of the levels, their potentially massive size and the regularity of a grid-based maze, they seem to be the only viable choice for visible surface detection and occlusion.

Share this post


Link to post
Share on other sites
Atrix256    539
If you go with portals what are you going to do about partial polygon visibility from a light source? Or is that not a problem for your situation?

(:

Share this post


Link to post
Share on other sites
Atrix256    539
Do you think you could combine portals and volumetric shadows or light maps?

Maybe you could use portals to cull out un-necesary polygons (ones you know are not lit) to make the other algorithms more efficient?

Share this post


Link to post
Share on other sites
MarkS    180
I'm really making this far harder than it needs to be.

The level(s) will be based on a standard grid-based maze algorithm. As such, there is occlusion information available at all times from the player and light position, assuming they are not the same. If the light is on the other side of a wall from the player, then it is in another cell. If this is the case, then the light simply cannot have an effect on the polygons in the cell containing the player. All that would be required is checking the type of cell that the light is in with the type of cells visible to the player. If there is a wall between the light source and a visible cell, then that entire cell is in shadow. In this case, lighting can simply be turned off while rendering that particular cell. Of course, there will always be a low level ambient lighting effect to prevent the level from going totally dark, but the light source can be safely ignored.

Share this post


Link to post
Share on other sites

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

Sign in to follow this