Jump to content
  • Advertisement


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


Lightmap generation

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

i know how to get the u,v coordinates but what i am wondering about is when i have a quad with 25 points i know whether there is light at the point or not so i should have all the information i need to generate the RGBA values for the lightmap but how do i generate it so that it looks smooth as if id specify different colors for every vertex with glcolor3f...???? any idea???? algorithm????

Share this post

Link to post
Share on other sites
Sorry, that question made no sense to me at all, if you mean how do you calculate the value for each point on the lightmap then something like this should work:

pt = point on lightmap
N = normal of polygon

(for each light which could see the surface)
l_pt = point light source
l_col[3] = floating point colour of light source

col[3] = the computed value (to be stored in your lightmap)

col[0] = col[1] = col[2] = 0; // could initialize these to some value greater than black.

dir = normalize( pt - l_pt ); // direction from point to light

cosalpha = dot( dir, N );

if(cosalpha > 0)
col[0] += l_col[0] * cosalpha;
col[1] += l_col[1] * cosalpha;
col[2] += l_col[2] * cosalpha;



This is a very basic diffuse lighting equation, it doesn't take distance attenuation into account, nor any properties of the surface. It also doesn't take into account whether the light point can actually see the point on the surface.

[edited by - JuNC on November 8, 2002 5:58:14 PM]

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!