Jump to content
  • Advertisement
Sign in to follow this  
Eldritch

Concerning Lightmaps

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

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 this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!