   Concerning Lightmaps
  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]
  For a set of faces and lights.-Define a radius for each light how far it can illuminateto 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). <br>|    *    *    *    * (pels are 2 units apart &#111;n this surface &#111;n U and V)<br>|    *    *    *    *<br>^(Vv)   *    *    *<br>|-&gt;--------<br>o(Vu)<br></code><br><br>-Calculate the lightmap image size Lmsz(u,v) = EX(u,v)/pel; that will be<br> associated to the face &#111;n wich you process the SBR.<br>-Allocate memory for the light maip RGB*Lmsz<br><br>-For each pel position (pelpos = o + Vu*peldim*i + Vv*peldim*j)<br> calculate light gradient by any light to point formula<br>based &#111;n distance or/and incident angle.<br>Take the RGB values from the pel at (j,i) and store them at Lmsz[i,j].<br>Build a texture from Lmsz buffer using openGl or di'rect'x and render <br>the faces.