Opengl Lighting Method: Will this work:

Started by
2 comments, last by Krohm 16 years, 10 months ago
Hi, In my game, static geometry can use light maps, through multitexturing, to calculate shadows at loading time. Dynamic objects are more of a problem. My game idea relies alot on having nice shadows, but i want to cheat. I wish to use a system where a light_control class is generated for each model, and a parent class is used to store the data on which lights are illuminating each object. The object is then lilluminated using an opengl light, of which there are only 8. I cant therefore give each object I render one light to itself. My question is as follows: Can I render each model using all 8 lights, then start the lighting over with the next model, and so on? For example, if my character is standing under a street lamp, I cast a few rays from its light and, if they contact the character, the character is illuminated by creating an opengl light nearby which only affects that object. It is unlikely that more than 8 light sources will affect each dynamic object, but I can use some system or other to accumilate lights coming from similar directions. Can I somehow have the lights affect only that model, and then re-set them and start afresh with the next model? Or does the pipeline not allow this? here is some psudocode:

begin static_display_list();
    calculate_burned_in_shadows();
    calculate_light_maps();
    render_static_geometry();
end static_display_list();

for (each frame)
    call_static_display_list();

    for (each dynamic_object){
        calculate_lights();
        calculate_dynamic_shadows();

        apply_opengl_lights();
        apply_shadows();
        render_object();
        reset_opengl_lights();
    end for
end for






is it worth my time to spend two or three days researching this? [Edited by - speciesUnknown on May 25, 2007 9:30:11 PM]
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Advertisement
it is possible. simple set up the 8 lights, with color, position, ambient etc., render the object, then set up the 8 lights again, render the next object and so on
http://3d.benjamin-thaut.de
Thanks, if its that simple then my question is answered.
Ive read somewhere that certain implementations have more than 8 lights, is there a way to test this for a given platform?
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
All implementations in the last few years allows to compute several more lights per pass using the shading pipe.
GL FFP exposes a MAX_LIGHTS value you could probably uses for your purposes but I would expect this to be set to 8 anyway.
The shading pipe provides considerably more power. I've been able to render tens of lights per vertex in a single pass and more than a hundred of lights per pixel (always in single pass).

Previously "Krohm"

This topic is closed to new replies.

Advertisement