# Concerning Lightmaps

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

## Recommended Posts

Was gonna write "Concerning Hobbits, a tale by Bilbo Baggins", but that would have been way off. Well, I am trying to grasp the concept of using lightmaps for static lights. Here is an example of what I'd like to be able to do with lightmaps: I have two rooms with 4 walls, ceiling and floor; and a corridor connecting them both. In the first room, I have two lights, each giving off a nice sky blue sheen that should reach into the corridor as well (about half way). In the other room, I have three torches, each on one of the "free walls" (i.e. with no opening), that give off the standard "fire sheen" in orange. How would I go about accomplishing this with lightmaps? I don't know where to start, and most articles out there (I am doing this with OpenGL, but there should not be a difference with DX) does not mention the mechanics behind this. [Edited by - Eldritch on August 11, 2006 1:11:06 PM]

##### Share on other sites
For a set of faces and lights.

-Define a radius for each light how far it can illuminate
to restrict far away faces from computing light gradient.

-Pick a pel size /geometry on wich you going to calculate
light gradient. eg: Each 2 units on U and V along each face.

-For each face(your wall) calculate the squared bounding rectangle (SBR).
by holding minimum and maximum of all vertexes.
-For each SBR hold the minimum o(xyz) and the 2 vectors Vu and Vv that
are on the U and V edges. Keep the extends (EX(u,v)) of SBR as well
-Calculate polygon light map texture coordinates for each vertex as:
V(s,t) = (V(xyz)-o(xyz))/Ex(xyz);

(Vmax-Vmin).
[code lang=cpp]
| * * * * (pels are 2 units apart on this surface on U and V)
| * * * *
^(Vv) * * *
|->--------
o(Vu)

-Calculate the lightmap image size Lmsz(u,v) = EX(u,v)/pel; that will be
associated to the face on wich you process the SBR.
-Allocate memory for the light maip RGB*Lmsz

-For each pel position (pelpos = o + Vu*peldim*i + Vv*peldim*j)
calculate light gradient by any light to point formula
based on distance or/and incident angle.
Take the RGB values from the pel at (j,i) and store them at Lmsz[i,j].
Build a texture from Lmsz buffer using openGl or di'rect'x and render
the faces.

1. 1
Rutin
44
2. 2
3. 3
4. 4
5. 5

• 9
• 9
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632983
• Total Posts
3009706
• ### Who's Online (See full list)

There are no registered users currently online

×