Skip to main content
gamedev.net
🔒 Locked

generating lightmaps

Started by Shike Sep 18, 2000 at 4:57 AM 1 replies 350+ views
Original Post
Shike
Shike
Hi all, I've read a few docs/tuts on this subject, but I still need a few more hints How do I create a 2d bounding rectangle (my lightmap texture) for my 3d triangle? How do I convert my triangles' 3d vertices to 2d UV coordinates? (I'd prefer not to just discard an axis.) How do I convert the 2d UV coordinates of my lightmap to 3d viewspace coordinates for lighting calculations? ... I have a feeling that all these questions have the same answer ... Please enlighten me Thankful for any help, João A Gândara Edited by - Shike on 9/18/00 4:58:33 AM
Spark
Spark
Hi,

I have newer implemented a lightmap renderer but hopefully I can give answers to some of your questions.

2)

Every face in your scene is a plane, and a plane only have two axis, so you don''t have to discard an axis because it doesn''t have one... great explanation I realy don''t know a good way of explaining it.

3)

OK, lets say that your lightmaps are 64x64 pixels in size and you wan''t to calculate the values between vertex 1 and 2. Then you do something like:


3dpoint = vertex1 + (vertex2-vertex1)/64*k


k = 0..63

it gives you the lightvalues for one of the edges in your lightmap.

then you calculate the colorvalue for the point "3dpoint" and store it in the lightmap texture. Then you interpolate between vertex 2 and 3 and get another point (3dpoint2), after that you interpolate between 3dpoint and 3dpoint2 to get the values between the edges - much like a when you are drawing triangles in software.


Note:

As I said - I have newer implemented a lightmap renderer and I feel that my explanation wasn''t to good. You can email me if you want and I can try explaining it in swedish.
Shike
Shike
Spark, I might as well answer you in this forum - gives people a chance to see how lost I am

You say that a plane only has two axis - I agree of course. I could find the two unit vectors that describe the plane, and use them to define uv coords. Trouble remains - I need an origin to define where my uv space starts (0,0 in my texture)... How do I find it? I''m guessing I need a bounding rectangle for the triangle?

Your formula for calculating 3d points for the lightmap assumes I already have 3d vertex data for the texture... I don''t. Other than that, there''s nothing wrong with it

Please keep throwing suggestions at me - it helps

Grateful for help,
João A Gândara

Topic Locked

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

Sign in to reply to this topic.