Skip to main content
gamedev.net
🔒 Locked

Lightmap generation

Started by Basiror Nov 8, 2002 at 4:29 PM 0 replies 650+ views
Original Post
Basiror
Basiror
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????
http://www.8ung.at/basiror/theironcross.html
JuNC
JuNC
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.