Thanks for taking time to read and reply to my question. I really was’nt expecting it.
Well, I want to target as many as possible.
But I’m certain that the graphic card MUST support at least register combiners (which almost every NV cards support, I hope).
I think I’ve cornered myself a bit do, because I also require support for Vertex Object Buffer.
I dont know which cards that support this feature, but I suppose only newer do.
But I will support Display Lists as an alternative too, if time given.
But If I cant get a speed improvement from writing shaders for per-pixel lightning I think it’s a waste of time, or ?
I will, however, have some other shaders too (optional, if card supports them).
Since the program Im writing is for a game contest I want to throw in as much features as possible to impress the jury.
Here is the code for setting up the register combiners :
// Set up texture unit 1 for the 1D radial ramp map texture
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_1D);
glBindTexture(GL_TEXTURE_1D, PointLight1D);
// Set up texture unit 0 for the 2D radial map texture
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, PointLight2D);
//setup the register combiners to use 1 general combiner
glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);
/*
SMALL CODE PART HERE THAT I REMOVED, ALL IT DOES
IS CHANGE THE Mod_Color DEPENDING ON A TIMER FUNCITON
*/
//store the light mod_color
//into the Constant Color 0 register
glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, (float*)&Mod_Color);
//setup combiner 1 to calculate the attenuation factor
//(1*Texture0 + 1*Texture1), and store it in the Spare 0 register
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV,
GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV,
GL_ZERO,GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV,
GL_TEXTURE1_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV,
GL_ZERO, GL_UNSIGNED_INVERT_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV,
GL_SPARE0_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);
//setup the final combiner to calculate (1-Attenuation)*Color
glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_SPARE0_NV,
GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO,
GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_CONSTANT_COLOR0_NV,
GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_ZERO,
GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_G_NV, GL_ZERO,
GL_UNSIGNED_INVERT_NV, GL_ALPHA);
//enable the combiner
glEnable(GL_REGISTER_COMBINERS_NV);
// END OF CODE.
I assume that with changing it you mean how often I call this function (the code above is the function “activate_light()”).
I do this for every world-polygon drawn (a polygon that is part of the world, not enemies or items, just the polygons contained in a bsp leaf), I also check if the light can reach the polygon (if not, then that light is’nt considered for the polygon).
After that, the dynamic lightmaps that is created by doing this are blended with the original texture.