Skip to main content
gamedev.net
🔒 Locked

vertex program based lighting for multiple lights

Started by _walrus Dec 17, 2002 at 1:17 PM 5 replies 400+ views
Original Post
_walrus
_walrus
Just working on a vertex program based lighting system. I'm just wondering how to support multiple lights since the GL_VERTEX_PROGRAM_ARB doesn't support looping (as far as i know). I can easily pass several points to the vertex program indicating light locations, but how would i iterate through these lights. If it where a fixed number of lights that I know when writing the vertex program I could just cut and paste the code for each light and accumulate it in the result, but I can't assume that the number of lights is known at write time. I also realize that the specs for GL_VERTEX_PROGRAM_ARB specify: " Vertex programs execute a finite fixed sequence of instructions with no branching or looping." But their must be a way to handle an unknown amount of imput at run time. Thanks for any help or suggestions [edited by - _walrus on December 17, 2002 2:23:42 PM]
zedzeek
zedzeek
i assume u mean dot3 lighting (using vp to help)
each light normally is done in one pass, if an objects gets light from 10 lights u8 must draw the object 10x (though it is possible to do more than one l;ight per pass, most ppl dont)

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
_walrus
_walrus
quote:
though it is possible to do more than one l;ight per pass, most ppl dont


Thanks for the reply, it''s helps out greatly, but if could you elaborate on your comment, it would be of great help (i would like to be able to do lighting in a single pass for several lights). Is there pit falls for this process (other than performance)? thanks for your help.
Yann L
Yann L
question: do you want multiple vertex lights, or multiple per-pixel lights ? The former one is very easy, you can get tons of vertex lights per pass using a vertex program. The later one is more difficult, as zedzeek mentioned.
_walrus
_walrus
"o you want multiple vertex lights, or multiple per-pixel lights ? The former one is very easy, you can get tons of vertex lights per pass using a vertex program"

I want multiple vertex lights. But for n lights, would i have to render the vertex being lit n times? or is there another way of doing it? Since I don''t know the number of lights a the time i''m writing the vertex program, would this involve dynamically constructing a new vertex program and uploading it to the card each time i add or remove a light? Would there be a large performance hit for re-uploading vertex programs, I guess this won''t be happening that offten since lights won''t be added or removed that frequently. This method seams a bit cumbersome and reminds me of the days i was writing CGI''s for web pages . So is there a more natural way to address this issue? Thanks for your help.
chronos
chronos
Why not just assign each unused light a color value of (0.0, 0.0, 0.0, 0.0)?
_walrus
_walrus
that would produce unneccessary computation at the vertex level. if I support 8 lights and there is only one on, then the vertex program would have a lot of wasted computation. I"m looking for more of an elegant solution, plus it requires that we define a max number of lights initially.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.