Lights2D - Module - TBA

Community Forums/Showcase/Lights2D - Module - TBA

TartanTangerine (was Indiepath)(Posted 2006) [#1]
Lights in 2D? Why? Because it looks cool and BMAX should have had them from the start.

The module can be plugged in to any existing application with very little modification.

NOTE: A change must be made to the official directx.mod (d3d7.bmx), BRL did not define the lighting methods correctly.

Features:-

- DX and OGL (Win and OSX)
- World Ambient Light
- Up to 8 individual Lights
- Point Light or Spot
- Ambient Color (with Alpha)
- Diffusive Color (with Alpha)
- Specular Color (with Alpha)
- Range
- Position (3d)
- Direction (3d Vector)
- Attentuation (Constant, Linear and Quadratic)
- On/Off States
- Falloff
- Coneangles (Phi & Theta, Theta as % of Phi)

** Dot3 may be added if there is a need for it.

Download Demo : http://indiepath.com/public/light_example.rar

Screenshot :

Code for this example :



xlsior(Posted 2006) [#2]
Nice...

Hey, since you seem to be getting into the graphic modules lately -- any chance of a Gamma correction module, to brighten/darken a screen?


TartanTangerine (was Indiepath)(Posted 2006) [#3]
Lol, I'm having a small break from igLoader and c++.


Haramanai(Posted 2006) [#4]
Cool.
Are you planing to do and shadows?


TartanTangerine (was Indiepath)(Posted 2006) [#5]
Nope, however lighting here is performed by vertex normals so in theory you could workout which normals are not in "line-of-sight" for the light and turn them away from the viewer - hence preventing them from getting lit.

Ahem, you would need my New Poly Module (unreleased) to get access to stuff like Vertex Normals, Vertex Diffuse and Vertex Specular.


TartanTangerine (was Indiepath)(Posted 2006) [#6]
Nice...

Hey, since you seem to be getting into the graphic modules lately -- any chance of a Gamma correction module, to brighten/darken a screen?

You could use the Global Ambient Light to darken the screen and then a White Directional light to lighten the screen (with specular). This would also save on recalculation of color palettes.


Grey Alien(Posted 2006) [#7]
That's very neat Tim. Any chance of an FPS counter or something to measure speed?


TartanTangerine (was Indiepath)(Posted 2006) [#8]
@Grey, this is all hardware lighting, speed should really not be a concern.


Grey Alien(Posted 2006) [#9]
I realise it's hardware based. Does this mean it occurs during the v.refresh? Surely if you had a lot of lights it would slow down on some cards that couldn't handle it? I just wondered if there was a way to measure this speed?


TartanTangerine (was Indiepath)(Posted 2006) [#10]
Lighting occurs when the object is drawn to the buffer. Both modes, OpenGL and DirectX are state based. If you had 200,0000 vertices and 8 lights then yes there will be a large overhead, especially if the lights had a large range.

Light1.Lit(True)
DrawRect 100,100,20,20 ' **THIS WILL BE LIT
Light1.Lit(False)
DrawRect 130,100,20,20 ' **THIS WILL NOT BE LIT
Flip



Robert Cummings(Posted 2006) [#11]
I asked for fake lights via verts to be in since bmax was released but no-one really seemed interested in doing it. Some of the people said that it really wasn't even "2D" so therefore shouldn't be in the max 2D module. I don't know, I think it is pertinent. I would use this module, and I do have a use for it.

If it's no trouble I have a few questions about your modules:

1) Will they break in the future with new bmax releases?

2) Do they work seamlessly with DX and OpenGL?

3) Cross platform?

4) If DX fails, Bmax retries with OpenGL automatically. Does this mean this behaviour breaks any of your code?

Thanks Tim!


Robert Cummings(Posted 2006) [#12]
Also I think your lighting module would be nicer if you only had rgb, radius and brightness from a creativity point of view... and make sure radius really does terminate at the radii specified. Not sure brightness is even needed.

Blitz3D's radius actually extends to nearly infinity, it's subtle but it shows up under certain conditions.


TartanTangerine (was Indiepath)(Posted 2006) [#13]
1) Will they break in the future with new bmax releases?
The small change to the DirectX mod will break if it's updated - I can't avoid this as BRL have not defined all the methods. The render commands are direct to the renderpipeline, they can not break.

2) Do they work seamlessly with DX and OpenGL?
Yes, however OGL does not have a Range Parameter, you will have to manually fiddle with that to make them appear exactly the same.

3) Cross platform?
Yes, if you don't count Linux. I don't have linux installed so I can't test it - should work though.

4) If DX fails, Bmax retries with OpenGL automatically. Does this mean this behaviour breaks any of your code?
Nope, my code checks the renderdevice when you initialise the module. If the RenderDevice changes you will need to re-intialise the module.

Also I think your lighting module would be nicer if you only had rgb, radius and brightness from a creativity point of view... and make sure radius really does terminate at the radii specified. Not sure brightness is even needed.
That does not account for spotlights, ambient reflection or specular highlights. You can always build a wrapper function.

Blitz3D's radius actually extends to nearly infinity, it's subtle but it shows up under certain conditions.
Actually only the Directional Light extends to infinity as it is used to represent light sources such as the sun. I can build in a directional light if people really need it.


TartanTangerine (was Indiepath)(Posted 2006) [#14]
Sprites with Lights and Collision Hull...


Vector Editor



Robert Cummings(Posted 2006) [#15]
Actually Blitz3D's omni lights are infinite. If you turn one off with tiny range at collossal distances, you will still see the change on screen.

After hacking into Blitz's dx structure thanks to scouse (Tom Speed) I was able to see why: it's the attenuation model used by Blitz3D. This made light re-use very difficult on my platformer I had in development.

I think your libraries are very nice but not worth paying for until they can be cleanly integrated just like Blitzmax native commands and are more sensitive to graphics / system changes.

I think you are mainly doing this for your projects though so it shouldn't matter...


IPete2(Posted 2006) [#16]
FABTASTIC!


TartanTangerine (was Indiepath)(Posted 2006) [#17]
I can't be arsed to argue about DX Lights, I suggest anyone who is interested should read the DX SDK.

If you want to know why BLitzMax does not have lights already then go speak to BRL.

If you have no interest in these modules then go bother someone else.

See ya.


GW(Posted 2006) [#18]
what modules? its just a demo app.


gellyware(Posted 2006) [#19]
I would be interested in these modules.