Light limit

Blitz3D Forums/Blitz3D Programming/Light limit

Jaydubeww(Posted 2010) [#1]
According to the Online manual for lights, there is a limit of 8 or 16, depending on your graphics card.

http://www.blitzbasic.com/b3ddocs/command.php?name=CreateLight&ref=3d_cat

Question: does this number include the ambient light? Second, does this mean only 8 (or 16) can be in view at any given time? So, I can have a total of 8 lights within field of view? Thanks!


Rob the Great(Posted 2010) [#2]
From my understanding, ambient light isn't really a light, it's more like a command to brighten every entity in the scene. Ambient light doesn't carry shading abilities like the rest of the lights do, and shading is what consumes resources and therefore limits the amount available.

To answer your second question, you are limited to 8 (or 16) lights, period. I know this because when I first started programming, I tried to write a function that would generate a new light with every shot fired, and that light would travel with the bullet. With bad programming practice, the lights would neither reposition or delete themselves after created, and it created some really strange results. It's strange, though, because blitz never actually failed. Instead, all of the polygons would sparkle with their own individual shades and colors, allowing me to see every single triangle with a harsh seam between each one.

This happened about four years ago, and there very well may have been changes to blitz since then, so I'm not sure how blitz will react now.

Set up a mini program to test it if you want. I'll bet that either blitz will give you the "memory access violation", or you'll start to see the triangle seams like I did.


Yasha(Posted 2010) [#3]
Creating lights as you need them isn't the only way. You can also engage in some trickery:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1246

Search around for similar examples (I think there are a few variations on the same idea).


Rroff(Posted 2010) [#4]
Pretty sure ambient light isn't included in that count as its just applied to every vertice at setup time.

Your limited to 8 active lights in your gameworld period - IIRC even tho some cards support more D3D7 was never updated to handle more than 8. You will need some code to create pseudo light entities and then manually enable and disable real light entities on the most appropriate 8 pseudo entities. Usually done based on distance and occlusion.


Jaydubeww(Posted 2010) [#5]
Thanks guys, that's what I thought I had to do. Also, thanks for the example!