Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Per Pixel Llighting, or Per Pixel Pain :-(

This topic is 6089 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, one long post coming. I''m trying to do per pixel lighting on a landscape. Accutally the extent of my ambtion right now is to get my dumb geforce 2 rendering lightmaps in realtime with register combiners. The way I''m trying to do it is this. From what I understand of lighting, you have a light postion, and you have normal. You do a dot product and bingo, lights on(well, ok you still have some work to do after that, but not as difficult)! So, for my lighting, I take my light postion, and I generate a normal map texture, and dot product them together with register combiners, and then finish the equations with the final combiner. It''s not working right, so I decided to start out I''d just make a flat quad, with uniform normal map, and get the per pixel lighting working there, and then go on. Unfortanitly, I''m having trouble(hence this post). It''s not that I don''t get anything on the quad, I do, and it even resembles a lightmap(which is of course what I''m looking for), but it''s not paying attention to the postion of the light. I''m not sure why this is. Maybe I''m not gerenating the normals right? Using the register combiners wrong? I''m not sure. Below is my code. I tried to keep it down to a minimum, but I''m not totaly sure exactly which part is correct and which isn''t. If someone who has done this before could help, I''d be gratefull. Thanks,Jesse www.laeuchli.com/jesse/ #include #include #include #include #include #include #include GLuint texturest; GLuint texturest2; #define csize 256 float lightpos[]={1,0,0,1}; float color[]={ 1,1,1,1}; float ptexture[csize][csize][4]; PFNGLCOMBINERPARAMETERFVNVPROC glCombinerParameterfvNV; PFNGLCOMBINERPARAMETERFNVPROC glCombinerParameterfNV; PFNGLCOMBINERPARAMETERIVNVPROC glCombinerParameterivNV; PFNGLCOMBINERPARAMETERINVPROC glCombinerParameteriNV; PFNGLCOMBINERINPUTNVPROC glCombinerInputNV; PFNGLCOMBINEROUTPUTNVPROC glCombinerOutputNV; PFNGLFINALCOMBINERINPUTNVPROC glFinalCombinerInputNV; void setupcombiners() { glCombinerParameterfvNV=(PFNGLCOMBINERPARAMETERFVNVPROC)wglGetProcAddress("glCombinerParameterfvNV"); glCombinerParameterfNV=(PFNGLCOMBINERPARAMETERFNVPROC)wglGetProcAddress( "glCombinerParameterfNV"); glCombinerParameterivNV=(PFNGLCOMBINERPARAMETERIVNVPROC)wglGetProcAddress( "glCombinerParameterivNV"); glCombinerParameteriNV=(PFNGLCOMBINERPARAMETERINVPROC)wglGetProcAddress( "glCombinerParameteriNV"); glCombinerInputNV=(PFNGLCOMBINERINPUTNVPROC)wglGetProcAddress( "glCombinerInputNV"); glCombinerOutputNV=(PFNGLCOMBINEROUTPUTNVPROC)wglGetProcAddress( "glCombinerOutputNV"); glFinalCombinerInputNV=(PFNGLFINALCOMBINERINPUTNVPROC)wglGetProcAddress( "glFinalCombinerInputNV"); } PFNGLACTIVETEXTUREARBPROC glActiveTextureARB=NULL; PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB=NULL; void setuptext() { glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2fARB"); } void combinercode() { glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1); ///// glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, (float*)&lightpos); glCombinerParameterfvNV(GL_CONSTANT_COLOR1_NV, (float*)&color); /// 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_CONSTANT_COLOR0_NV,GL_SIGNED_IDENTITY_NV, GL_RGB); ///////////////////// glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB); glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_D_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB); //////////////// glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_SPARE0_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_TRUE, GL_FALSE, GL_FALSE); //////////Should Be working by now :-).... 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_COLOR1_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_IDENTITY_NV, GL_ALPHA); } void blackwhite() { for(int y=0;y

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!