# Preventing Outside Lights from Lighting Inside Objects

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys. I've encountered a problem in a scene I've been working on. Basically, I have an object, in this case, a house. The house is simply 6 quads for the base and 5 quads for the roof. I have a light source at an infinite distance away, as the sun, and I have the sun coming in at an angle. What appears to be happening is the faces with normals facing in the direction of the sun get lit, which makes sense. Except that the problem I'm now having is that when the house is viewed from the outside, let's say walls 1 and 2 are lit, as expected. When I move inside, walls 3 and 4 are lit by the outside. Ultimately, I wanted the inside of the house to be just affected by the interior lights, since there are no windows. Obviously, it doesn't appear that the walls are occluding each other. I guess my question is what do I have to do to make this work correctly? Thanks in advance. :)

##### Share on other sites
You basically have two options, and they are not mutually exclusive.

For scenes with lots of mixed interior/exterior, this might be the best option. But imagine transitioning into a cave; it ceases to make a lot of sense to continue applying the sun light to everything inside the cave, especially as you go deeper into it. This is a situation where option 2 becomes more appealing.

2) Assign lights to surfaces using some higher level logic (e.g., assigned in the level editor, or using some runtime determination using "interior"/"exterior" tags on surfaces/objects, etc.)

With this scheme, when rendering the interior surfaces of the house, you won't even have the outside lights enabled/set, only the interior, and vice versa for the exterior.

##### Share on other sites
emeyex is entirely corect, but it is worth noting that as soon as you want a more complex building (i.e. with windows or doors), shadows become the only sane way to deal with this. Additionally, if you are using a portal scheme to manage interior culling, it becomes very efficient to cull shadow casters and lights, which can be great for performance.

##### Share on other sites
Okay, I think what's being said makes sense. I think the second approach wouldn't be too difficult for now. My one question, when marking polygons as internal or external is does this mean I need twice as many polygons? There's no way to disable lighting for a specific light on one side of a polygon, but set it differently on the other, is there?

##### Share on other sites
Quote:
 Original post by RydinareThere's no way to disable lighting for a specific light on one side of a polygon, but set it differently on the other, is there?

Yes there is:

glEnable(GL_CULL_FACE);glCullFace(GL_BACK);glEnable(GL_LIGHT0);// draw front faces with light 0glCullFace(GL_FRONT);glDisable(GL_LIGHT0);// draw back faces without light 0

##### Share on other sites
Just gave this a try. Sure enough it did fix my problem. Thanks so much. I can definitely see how this would get overly complicated, though, once there's a decent amount of lights and complex objects in the scene.

I am curious about the shadows. Can you guys suggest some good OpenGL resources that will go into shadows?

##### Share on other sites
If you don't need dynamic shadows, just bake some lightmaps. It's dead easy, and it's 'free' assuming you are running a GPU that isn't 9 years old. You just assign the new textures to another texture unit.

DeleD Lite can build your house and lightmap it for free too. You can then get something a lot nicer than a few quads. The scenes are saved as very simple XML.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013607
×