Archived

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.

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 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:

INPUT:
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

OUTPUT:
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.

FOR EACH LIGHT
{
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]

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5
frob
13

• 9
• 15
• 10
• 9
• 17
• Forum Statistics

• Total Topics
632602
• Total Posts
3007363

×