Advertisement

Multiple tiles lightmap

Started by July 01, 2000 11:08 PM
2 comments, last by Darkening 24 years, 5 months ago
I have a isometric engine that I render with Direct3D and D3DTLVERTEX. What I would like to do is having dynamic lightning on my map using lightmap. What I want to know is how I would apply my lightmap over multiple tiles. I know how to apply it on one tile but on more than one, I really don''t know how to do it. Do I have to assign the lighmap to each tile which is in the light range and change the tu, tv of the lightmap texture to make an illusion of a ball of light ? If so, I would you do that ? Can I draw my lightmap over the map, after I rendered all my tiles, by assigning my lightmap to a "zone" over the part of my map I need to be lit ? I''m open to any other kind of dynamic lightning algorithm I could use in my engine but if you do so, please include some code or be specific. Don''t just tell me to use vertex lightning (Which I don''t want to). Thanks for any help you can give me, Darkening --------------------------- Unfortunately, no one can be told what a bug is. You have to see it for yourself...
---------------------------Unfortunately, no one can be told what a bug is.You have to see it for yourself...
Yes its a difficult subject....
I think you first have to calc which tiles are affected by the lighting and then you could calc a lightmap for every tile and merge them into one(But I dunno if it is faster to change the current texture very often or to calc one big lightmap for all tiles affected(or some of them)).Yes this involves creating new lightmap-texcoords too for every tile affected....
I think it sould work if you do it like I say but I think it will be way too slow and surely there are algorithms out there developed by some Sweenys\Carmacks which are alot faster.Look throuh carmacks plans during the q3-development,I think in one plan he wrote about dynamic lighting.He said he had done weeks of theoretic work on this one and didn´t get a good solution but after coding for some hours and trying the simplest idea he found his solution(described in the plan).

However this is a very difficult subject and my little try to help you won´t help you too much....

Greets,XBTC!
Advertisement
I think the Carmack .plan file XBTC hinted at was the one talking about 3D textures. Carmack argues, that a point light (in essence), is just a sphere with varying color intensities, bright in the middle, dark on the outside. In order to get the dynamic lightmapping to work, he would have to translate, rotate, project a 2D texture on the world polygons. The natural solution would have been to just ''drop'' a 3D texture in there and let geometry do the rest. Unfortunately, 3D textures aren''t supported by A LOT of hardware out there, so it''s no viable option (Look out for next-gen cards, though).

Regarding your problem, XBTC is correct, you have to determine the tiles which are affected by the dynamic light source. Then you have to project, rotate, translate your lightmap on the surface. Unfortunately, the math of this eludes my grasp.

Ciao,

MK42
I don''t know what you have against vertex lighting and I would like to hear your reasons.

I''m writing my tile engine in direct3d as well and for my dynamic lighting I''m using vertex lighting. What I do is during the pre-calculations for every frame I generate a "lightmap", I say lightmap in quotes as it isn''t a texture but an array containing calculated light values. What I do is go through each light source and fill in the appropriate parts of the array with these light values, averaging colors and such as I go. Then when I get to the tile rendering step I use this array to index into to get light values. For lighting sprites I find the light value cloest to the sprites coords and use that one value for the whole sprite.

I have a little test app I made (Took the isometric d3d rendering demo 4 and messed with it) that I can send you if you e-mail me.

-Zims

This topic is closed to new replies.

Advertisement