Couple q's about vertex programs & lights

  1. looking through the NVIDIA labs on vertex programs, and the first one, to do with per pixel lighting has material color. Now, say i want to have a ‘red’ light, then i just change the material color? I think that’s right, because isn’t that the way it is done with normal vertex lighting? I think i’ve prob answered my own question

  2. If i wanted more than one light (different colours) would i have to draw the scene each time for each light? or do i have multiple vertex programs operating on at a time?

  3. What is the easiest way to do bump-mapping and per pixel lighting together?

thanks!

Originally posted by robert:
If i wanted more than one light (different colours) would i have to draw the scene each time for each light? or do i have multiple vertex programs operating on at a time?

You can do it a single program. Vertex programs can use up to 96 constant registers. You can pass many lights’ directions (or position) / colors to a program using these.

[b]

  1. What is the easiest way to do bump-mapping and per pixel lighting together?[/b]

Using the core GL only, try looking at the combine textures abilities (it was called ARB_texture_env_combine in OpenGL 1.2). If you plan to make things faster (and driver dependent), look at NV_texture_shader (GeForce3/4Ti), NV_register_combiners(TN2, gf256, gf2/3/4), or ATI_fragment_shader(Radeon).

Julien.

You can do it a single program. Vertex programs can use up to 96 constant registers. You can pass many lights’ directions (or position) / colors to a program using these.

How would i do this in a vertex program? Say at one time i need two lights, at another i only need one. Would i have to write a vp that would work on three lights?

Thanks