Sign in to follow this  
speciesUnknown

OpenGL Opengl Lighting Method: Will this work:

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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).

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