Skip to main content
GameDev.net gamedev.net
🔒 Locked

Lightmap calculation / drawing

Started by illuzion Aug 1, 2001 at 5:17 AM 1 replies 1.1k views
Original Post
illuzion
illuzion
This is another question about lightmaps. Not how to use them (I know, multi-texturing...) but how to calulate and draw the actual bitmap used. I have the following information: - an array of triangles, each withx y and z coords, and uniques texture u and v coordinates - an array of (omni) lights, each with a rgb color and an xyz position coordinate. I want to calculate the amount of light (rgb values) for each triangle (I suppose; would at each vertex be better? How would you do that though?) I suppose I have to calulate the normals for each triangle, and then find the angle between those / the light. How do I do this? (Please explain clearly, or link to a site that explains it clearly, preferably with code examples). Once I have a value for each triangle, I want to draw this to a bitmap. I suppose I could just draw a flat shape, but that would result in flat-shaded triangles in-game, wouldn''t it? So how do I go about blending between the triangles? Does anyone have a code snippet for drawing triangles with a different colour at each vertex? Or should I draw them flat, and then use a blur function? (Now I need to know code for a blur... and how do you calulate how much blur to use?) Sorry this is such a long post, and asks such a lot... I''m fairly new to OpenGL, and I''ve never used lightmaps before. TIA, Illuzion.
illuzion
illuzion
ok, thanks. That''s very useful, thankyou.

Just a couple of questions, though:

Shadows. I suppose to calulate those, I need to implement a simple raycaster. How?
(yes, I could look on the net, and I have, but you people probably have the best (and simple!) links that are difficult to find...)
I''ve been thinking (wow). I suppose you could calculate the equation for the triangle''s plane (how, the only explanations I''ve seen I don''t really understand), and then somehow see if the normal (extended, cast as a ray) for a triangle passes through the plane... within the bounds of the triangle. Sound good?

The other thing is blurring. Do you know a good blur algorithm? These should be easy to find on the ent, but I''ve been wondering about the difference between ''normal'' blurs and gaussian blurs. What is the difference?

thanks. illuzion.

Topic Locked

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

Sign in to reply to this topic.