Light Limit?

BlitzMax Forums/MiniB3D Module/Light Limit?

AvestheFox(Posted 2014) [#1]
I was wandering if MiniB3D also had the 8 light limit like B3D does.

and if so, has there been a work-around for more lights?

I ask because I'd like to apply lights to some projectiles so they could light up the scenery as they fly by.


Kryzon(Posted 2014) [#2]
Yes, it has that limit. Blitz3D and MiniB3D use "hardware lights," lights that are created and managed by the hardware - the graphics card.
However, they use different APIs, with Direct3D for Blitz3D and OpenGL for MiniB3D. I believe this causes different amounts of lights to be allowed for each.

The total amount of hardware lights that you can use at once is given by the user's graphics card.
After you have initiated your MiniB3D graphics, you can retrieve the total amount of hardware lights with the following:
Local value:Int
glGetIntegerv( GL_MAX_LIGHTS, Varptr( value ) )

Print value

One work-around to make it seem like you have infinite lights is to bake the lighting information on the textures of most of your static objects - such as your levels - by making use of lightmaps. All the lightmapped objects need to be "fullbright" with EntityFX 1, which causes the hardware lights not to influence their colours.
Then you can dynamically reposition the hardware lights around the level as the player travels through it so that they light only the dynamic objects (characters, props etc.), giving the impression that there are limitless lights.


Streaksy(Posted 2014) [#3]
I find things render slower with fullbright on (entityfx 1), for some reason. I set the ambientlight to 255,255,255 instead. :D


Kryzon(Posted 2014) [#4]
I find that unlikely. This is what the engine does to a mesh that has the "fullbright" effect:
' fx flag 1 - full bright ***todo*** disable all lights?

If fx & 1
	ambient_red#  =1.0
	ambient_green#=1.0
	ambient_blue# =1.0
Else
	ambient_red#  =TGlobal.ambient_red#
	ambient_green#=TGlobal.ambient_green#
	ambient_blue# =TGlobal.ambient_blue#
EndIf
It is the same thing as setting a maximum ambient light, but without affecting the entire scene like the AmbientLight command does.


Streaksy(Posted 2014) [#5]
Yeh. I've seen the code and I don't get it. I did time them at one point when I was getting strange slow-down after I'd made everything FX-1. It made no sense to me at all, but turning the FX-1 off and setting full ambient light instead fixed it. Try it.

If I'm wrong it must be one of those stupid anomalies but it's happened a couple of times now. I don't think it happened in B3D.

I know. It's mental.