Skip to main content
gamedev.net
🔒 Locked

Multitexturing and dynamic lightmaps

Started by Scarfy 3 replies 600+ views
Original Post
Scarfy
Scarfy
I'm making a turn based strategy game with a map drawn simply as flat quads. I wish to add in dynamic light maps and thought the best approach would be to use multitexturing. From reading example I understand the principle of multitexuring on a single quad, however I wish to apply the lightmap to a larger radius, so it may end up covering many quads. The purpose behind this is to allow the units and other things in the game to generate lights around themselves. I can't find any information as to how I might achieve this but I'm pretty sure this is a common thing. Anyone know of any resources or have any information available?
Parallel RealitiesProject: Starfighter
Optus
Optus
Yes this is a common approach to dynamic lighting effects. The problem with the way you describe the problem is that of Texture Coordinates. If you have a quad with a texture that repeats 4 times, and you used those default texcoords for your dynamic light, then you would end up with a dynamic light that tiles across a single quad. Doesn't look good. Basically, the crux of this technique is to be able to dynamically generate texture coordinates for the desired texture. This technique is often-called Projective Texturing. Googling for these keywords should provide lots and lots of results.
swordfish
swordfish
Think of it like a puzzle. The lightmap is broken into many pieces (texture-coordinate-maps) which can fit on top of any quad. For each quad you have, you need to find the puzzle piece that not only fits on the quad, but the piece that also 'completes' that portion of the image on the puzzle (a region on the lightmap).

If you have 4 quads arranged in a square, and you need the lightmap to 'span' all of the quads, then the top-left quad would have texture-coordinates something like so:

0.0,0.5 ; 0.0,1.0 ; 0.5,1.0 ; 0.5,0.5

and the bottom-right quad would have:

0.5,0.0 ; 0.5,0.5 ; 1.0,0.5 ; 1.0,0.0
http://blog.protonovus.com/
Scarfy
Scarfy
Righto, thanks guy. I'll take a look at that :)
Parallel RealitiesProject: Starfighter
Nickolay_Smirnov
Nickolay_Smirnov
When I created a simple program, where there was a ball, which lighted a floor, texture coordinates forestall ball coordinates in 12.5 times!

posx += 0.05f; // That's ball x coordinate
dx1 -= 0.05f/12.5f; // That's texture s coordinate of left lower corner
dx2 -= 0.05f/12.5f;
Cogito ergo sum (Descartes)

Topic Locked

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

Sign in to reply to this topic.