Another per pixel lighting system :)

BlitzMax Forums/BlitzMax Programming/Another per pixel lighting system :)

fredborg(Posted 2005) [#1]
Hi,

As mentioned in the other thread: http://www.blitzbasic.com/Community/posts.php?topic=49403
You can use the accumulation buffer for lighting as well. It should be a lot faster on newish graphics cards, but maybe not on older ones?

Anyway, it's OpenGL only. If someone can do it in DX then show us!

Here's some simple code:


[edit]Screenie of how it should look with an image, instead of the boxes...



Dreamora(Posted 2005) [#2]
Works great ... *somehow beeing a little shocked that it can be done "that simple" ...*


Space_guy(Posted 2005) [#3]
How is it supposed to look?
I imadgine it doesnt look like it should on my computer here at work. awfully slow and colors that doesnt seem to be correct. ascreenshot of a working one pls :)


Beaker(Posted 2005) [#4]
Looks a bit of a mess here as well (on my old machine at least - GF4 MX 440).


boomboommax(Posted 2005) [#5]
ditto slow mess, ermmmmmm o_O


fredborg(Posted 2005) [#6]
It's probably dog slow on GeForce 4 and older. It will need a hardware accumulation buffer to work properly, otherwise it will chug along and probably not work correctly.


Tom(Posted 2005) [#7]
Nice effect from the king of lightmapping! :)

Runs very fast here, I'm on what's probably an average card these days FX5600.


altitudems(Posted 2005) [#8]
Great job fredborg!

Very fast!

WinXP SP1, AMD-XP 2400+, 512 MB, GF-FX5200


tonyg(Posted 2005) [#9]
Hi Fredborg, very nice but how can you stop the lights 'blobbing' together? If I have two lights and shine them on the same wall the result is a light equal to the brightest of the two not the sum of them (if you know what I mean). I'm guessing this is what the accum buffer does.


fredborg(Posted 2005) [#10]
Um, I would think decreasing the brightness of the individual lights, while pumping up the overall light intensity would do the trick.

It happens because the values the accum buffer can store are limited (from -1 to 1)...


Bot Builder(Posted 2005) [#11]
I think you'll find two lights together equals their sum, tonyg.


tonyg(Posted 2005) [#12]
Surely not! Shine a very bright light on a wall and then a dim torch. The result is the same very bright light and not a bright light with a brighter section where the torch is shining.
e.g. A 'force 5' torch shining with a 'force 6' torch makes a force 6 light not a force 11 light.... surely?


Dreamora(Posted 2005) [#13]
perhaps using alphablend with Alpha instead of LightBlend works? *haven't tried as I am trying to kick my windows system ;-)*


fredborg(Posted 2005) [#14]
If you scale your light colors so that the sum of them will not exceed 255,255,255 and then increase the Intensity, you shouldn't have any problems. Example:

As you can see this results in some artifacts, but if you tweak it, it'll look fine.


SillyPutty(Posted 2005) [#15]
wow, great work fredborg !


Proger(Posted 2005) [#16]
Wow! Its cool! ...how use it in DX 7? ;)
Please...


Proger(Posted 2005) [#17]
Accumulation Buffer Techniques with DirectX® 7
http://www.ati.com/developer/sdk/RadeonSDK/Html/Samples/Samples.html