How do hardware lights work?

Blitz3D Forums/Blitz3D Programming/How do hardware lights work?

In that test, with just one light your framerate is cut in half, and with three it's cut in a third. Ouch.

You know though, this test assumes that all polygons in the world are affected by the lights. And you've got 400,000 polygons there.

Could you do a test with all the objects set to fullbright? I'd like to see if haivng objects set to fullbright means the lights cause no performance hit on them.


"I set a light range of 1 for all 8 lights"

A light range of 1 just means that the light STARTS falling off a that distance. It actually carries out quite a long ways from there. If the radius is 80, then the light will fall off completely 5200 units away from the light source. That's where it reaches 0.99 and gets clipped to 0.

I don't know if 3D cards stop having them affect objects even at that great a distance though.



The question is though not wehther hardware lights are slow, but whether dynamic lightmaps are slower.

You could do up to 9 passes to render 8 dynamic lights, with no other lightmaps. 10 passes if you have other lightmaps.

However, multitexturing would probably be possible and cut that down quite a bit. However you need to remember that to do just one dynamic lighting pass you actually need to use two texture units, one for X and Y axis mapping, and one for Z, to create a 3D sphere texture.

So, because most cards only have 4 texture units, you could only really cut that 9 passes in half. So you'd still need to do about 5 passes to render 8 lights plus your textures and maybe your lightmaps.


142fps / 5 = 30fps So that is faster than the 8 hardware lights IF you can do that lighting in just 5 passes.

But I'm not convinced that you CAN combine two dynamic lighting passes into one.

To do a dynamic lighting pass you need a 2d texture in texture channel 0 set to multiply, and a 1d texture in texture channel 1 set to multiply. Texture channel 1 darkens the result after texture channel 0 has been applied, and this creates the 3d texture. You then use ADD blending to add this dynamic light pass on top of the static lightmap pass.

But can you do this twice in one pass? I'm not sure you can with the way texture unit operations work.

But I could be wrong. It's complicated.


Anyhow, it's not cut and dry which is faster in this situation. However, with far fewer polygons in the scene, I think the scales might tip in favor of the hardware lights.