Lighting types

BlitzMax Forums/MiniB3D Module/Lighting types

SystemError51(Posted 2012) [#1]
Hi all,

sorry to bother you again with a probably silly question, I guess I am looking for reassurance.

So I know there are 3 lighting types in MiniB3D.

CreateLight(1) does some sort of general light.
CreateLight(2) does kind of the same thing, only has minor differences.

But what exactly is CreateLight(3)? Is this this the spotlight?

I think basically my question is this:

Which is a generic light (sphere), directional, and the spotlight?


Cheers guys, sorry to bother you again with my n00b questions.


ima747(Posted 2012) [#2]
http://www.blitzbasic.com/b3ddocs/command_list_3d_cat.php
specifically
http://www.blitzbasic.com/b3ddocs/command.php?name=CreateLight&ref=3d_cat

Since MiniB3D is basically a port of the B3D command set the documentation is basically the same (which is quite handy for referencing things :0)

Note that since lighting is vertex based you probably won't get the effect you expect without playing around with things until you understand how it works....


SystemError51(Posted 2012) [#3]
Arigatou :)

(Thanks)


Kryzon(Posted 2012) [#4]
#1 is a Directional light. Any polygons facing this light are lit, regardless of how far away the might be. This light has no radius or range - it works for the entire world.
It's perfect as a "sun" light if it's angled like a sun should be (positioning it doesn't make a difference, but it can be more reassuring).

#2 is the Point\Omni light. It's a spherical light, lighting in all directions. You can use this for lamps, torches, laser shots flying through the air etc.
Position and range matters, whilst rotation doesn't (since it lights in every direction anyway).

#3 is the Spotlight. It's a light where position, range and the cones' radii do matter. You can use this for car lights, batman-style lights and lighthouses.

Do know that MiniB3D, just like Blitz3D, uses hardware lights. These are limited to 8 turned on at once.
You can create hundreds or even thousands of them if you wish, but the hardware will only compute the first 8 that are turned on - if you use shaders you can override this and compute yourself as many lights as you want.

This is not because of how B3D or mB3D were programmed; it's a limit of using Fixed-Function rendering. You're using the hardware's pre-programmed effects and behaviours.
If you use shaders (programmable shaders, like they're commonly called), you're bypassing the fixed-function, using a 'programmed' function instead, and calculating vertex properties and pixel properties in whatever way you wish, allowing for the complex effects and optimizations shaders are known for.

Last edited 2012


SystemError51(Posted 2012) [#5]
Wow thanks Kryzon!
Is there a shader mod (per se) for MiniB3D?


ima747(Posted 2012) [#6]
There are a number of works in progress and a few abandoned branches that support shaders but nothing official and release. Of note you can use more than 8 lights with fixed rendering but it requires a bunch of overhead. Essentially the limit is per object, so if you find the 8 most relevant lights for any given object and turn off the others before rendering it you can have as many as you like. This would require modifying minib3d but shouldn't really be that hard. I think there are a few threads on this (try a search if interested). I've been meaning to look into this method for a little project I want to find time for... But I've also been wanting to Finnish aminib3d and a number of other things...


Kryzon(Posted 2012) [#7]
There are some experimental modules which allow you to compile and run GLSL code. It's always advisable to have some basic knowledge of OpenGL for you to be able to use them and maybe make your own changes\improvements.

Klepto2's: http://blitzbasic.com/Community/posts.php?topic=89447 (runs under his own fork of MiniB3D, so it'll need to be adapted to the original.)
Kevin Primm's engine: http://blitzbasic.com/Community/posts.php?topic=96675

In case this low-level fiddling proves too difficult (most of the time we're just interested in something that works as it is - just like Blitz3D), you can try an engine which supports it more officially such as GMan's wrapper for Irrlicht, which is cross-platform afaik.

Last edited 2012