Jump to content
  • Advertisement

Archived

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

InsanE

lightmaps in OGL?

This topic is 6426 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

Advertisement
OpenGL doesn''t have any built in support for lightmaps. To actually use a lightmap, you either use the multitexture extension or you use multi-pass rendering.

With multitexturing you just activate the base texture and lightmap texture and specify two sets of texture co-ordinates for each primitive, assuming you''ve checked that the extension is supported and used wglGetProcAddress to get the addresses of the relevant functions.

  
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, baseTextureID);

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, lightmapID);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);


Multi-pass rendering is a bit harder, you have to render each primitive twice, once with the base texture and once with the lightmap texture setting the appropriate blending mode each time.

To generate your lightmaps you can use any technique, radiosity, ray tracing etc.

Share this post


Link to post
Share on other sites
Thanks for the help! I will use Multitexturing and check your link out.

BTW: is there a nice tut talking about the creation of well looking lightmaps?

Share this post


Link to post
Share on other sites
As I said you can use any method for generating the lightmaps. Just create an array of width x height x bpp, where width and height corresponds to the width and height of the lightmap texture and bpp represents the required number of bits per pixels for the lightmap texture. Then fill the array with colour values you calculate using the technique of your choice. When that''s done you can write the array to a file. For specific information on generating the values in the lightmaps check the articles section on gamedev and flipcode or search the net for topics like lightmaps, radiosity, Lambertian, ray tracing and so on.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!