I'll write a tutorial for dynamic lights and decals if Blitz3D gets more than two texture coord sets.

Blitz3D Forums/Blitz3D Programming/I'll write a tutorial for dynamic lights and decals if Blitz3D gets more than two texture coord sets.

You don't need another set of UV coordinates to create dynamic lights.

First of all, unless you're writing for ulta high end cards (higher than Geforce 2 say) you can't assume the user even has more than two texture channels. And if the user doesn't have four texture channels you're gonna end up using one additional surface for every texture unit you attempt to make use of past number 2. So four simulated texture units will actually create three surfaces, and waste one texture unit on each of those two extra surfaces that you could have used for better effects.


"I considered that, but then each face requires a separate copy of the texture, right?"

No, each dynamic light requires a seperate texture and surface.

To do dynamic lights, you need one adidtional surface for each object that will be dynamically lit. This surface has two sets of texture coordinates. The first set you set the U to the X coordinate of the vertex, and the V to the Y coordinate of the vertex, and the second set you set the U to the Z cooridnate of the vertex, and the V to 0.

You leave both set to multiply mode, but set the blend mode of the surface to whatever you need to for your particular game to blend it with your lightmaps or texture. IF you're just blending with a texture then multiply. Lightmap, you probably want add.

Then you simply apply the texture and offset and scale it as neccessary.


The textures need to be loaded with UV clamping on, and the XY texture needs to be a circle of light that fades to black at the edge of the texture. The Z texture needs to be a linear gradient going left to right from black to white to black.


Obviously this is not the least expensive way to do dynamic lights. A method which takes advantage of hardware vertex lighting would probably be a lot faster since you could do it with just a single surface. You'll have to subdivide large walls though if you want them to look good with a vertex light in the center though. But even if you subdivide each wall into 32 polygons, that's gonna be a lot less expensive than having even 2 dynamic lights with the texture method. You can probably have 4-8 vertex lights lights and still have it be less expensive than just 2 texture lights.