PDA

View Full Version : Filling rooms with light (Lighting)



EraZer
03-16-2004, 12:16 PM
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?

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

Nychold
03-16-2004, 12:33 PM
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:



glEnable(GL_LIGHT0);
//...
glEnable(GL_LIGHTn);

// Draw the walls to room 1
DrawWalls(room[0]);

// Draw the contents of room 1
DrawContents(room[0]);

glDisable(GL_LIGHT0);
//...
glDisable(GL_LIGHTn);

// Draw the walls to room 2
DrawWalls(room[1]);

// Draw the contents of room 2
DrawContents(room[1]);


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

EraZer
03-16-2004, 01: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.