View Full Version : Filling rooms with light (Lighting)

03-16-2004, 11:16 AM
OK, I've got two rooms. Both are seen at same time. I want one room to be filled with light, second should be dark. If I would have used OpenGL lights in one room, polygons in both rooms would be bright in similiar way (I don't want to use attenuation).
So, are there any possibilities to fill one room with light and not to fill second room?

03-16-2004, 11:30 AM
I haven't done much with lighting, but I think you can draw the lit room, then disable lighting for the dark room.

03-16-2004, 11:33 AM
The easy way: If it's possible, draw the fully lit room with the lights you want turned on, and draw everything inside the room as well. Before drawing the second room, either turn off or modify the lights you used previously to represent the lighting state of the room. For example:


// Draw the walls to room 1

// Draw the contents of room 1


// Draw the walls to room 2

// Draw the contents of room 2

The hard way: if the above method is impossible (say there are shared walls or objects between the two rooms), you might need to determine whether something is shared between two rooms, and either (1) redraw the shared part of the object with the new lighting or (2) light the object or wall using spot lights which approximate the lighting in the room. Obviously, this is a much more difficult algorithm, but should give you an idea where to go.

In OpenGL, lighting only affects the currently rendering object. If you need different lights, modify the lighting state, and keep rendering. ^^

[This message has been edited by Nychold (edited 03-16-2004).]

03-16-2004, 12:47 PM
Thaks a lot. The problem of the method you wrote is that, I have to determine objects lighted up, and those which are not. With dynamic lighting it may cause some problems. But Thanks a lot, one more time.