fake HDR lighting

Community Forums/Showcase/fake HDR lighting

Bouncer(Posted 2004) [#1]
I've become obsessed in HDR lighting a few days ago... since then I have been trying to dublicate that effect in blitz. Without the pixel shaders it's hard to do any hardware blurring and software blurring is too slow. I managed to get some kind of hw blurring in it and it runs pretty fast on my radeon 9600.... this is the first working version. people with old gfx cards... don't even try this :)

www.kotiposti.net/naama/fakeHDR.zip

[EDIT]

a little update... now it's starting to look like the bloom effect I wanted... thanks to sswifts excellent texture blurring function. Same download.




sswift(Posted 2004) [#2]
I've been thinking about HDR myself lately.

I don't really think this effect you have is really that similar to HDR though. I know you reffered to it as "fake HDR" though.

You only have one texture... I presume what you are doing is similar to the effect Halo 2 does, which is not really HDR lighting.

I assume that you are copying the screen buffer to a texture, and then stretching a quad over the viewport, applying this texture to 2-4 texture channels with multiply blending to exponentially darken the dark areas of the image, and then setting the quad to additive blending to blend with the scene.

It's kind of like HDR, but I think that this method probably has a lot of problems with it. You probably get a lot of color banding with less noisy textures, and it would be very difficult to draw textures that look the right brightness.


One thing I thought of which is more like real HDR rendering would be to render the same scene multiple times, reducing the brightness of the lights in each pass until all lights go below 255 in brightness in R, G, and B. Each scene would be rendered over the last with additive blending. Thus one could make lights which brighten surfaces up way more than is normally possible (I think... I haven't actually tested this) and control the "exposure" of the camera by adjusting the brightness of... well something else. I haven't really thought this through completely.

The reason I ahven't thought it through completely is because having only dynamic lights for HDR is worthless to most people. A way would need to be found to render lightmaps in this manner as well. Also, one would obviously one would not want to render 10 passes of the same scene, so one would be limited to perhaps 4 passes, which means lights 4x brighter than normal... Hardly similar to the ability of true HDR lighting to model the brigthness of the sun. Additionally, this alone would not simulate the blurring effect you have above. You also have the problem of not being able to render the lighting in a first pass before rendering the textures, because to render the textures in a second pass one needs to use multiply blending which means the resulting image would have areas of pure black, and no areas lighter than the original texture color at that point.


Bouncer(Posted 2004) [#3]
I was after the prince of persia type of gloom effect... the hardest part of this all is to generate the blur... gaussian blur would be ideal i guess... but it looks nice after about 20 passes... and I find it difficult to come up with anything like it in hardware... my blur is kind of circular blend... i move the quad doing a full circle and constantly additive blend it with the last frame. works pretty nice but leaves some artifacts...

Yes... it would indeed be nice to be able to do real HDR lighting... but I'm happy with this kind of effect. This looks pretty nice when you don't render a whole scene with it, but you only render the glooming objects.


sswift(Posted 2004) [#4]
Look in the code archives for a hardware blur function I wrote. It minimizes the artifacts. You might be surprised to know that if you don't have a multiple of four passes, at angular offsets that are divsible by 4, that you will get all sorts of artifacts that reduce the quality of the blur. Ie, 9 layers offset in a circle looks worse than 8.

It's not perfect though. You get circular cutouts on the corners of things that are blurred. I wonder if perhaps using an angular offset in each sucessive 4-layer pass would serve to combat this.

I imagine we won't have to wait too much longer before we have true HDR imaging rather than the hacks we use now. We already have floating point texture formats on high end cards as far as I know. I give it five years.


Paul "Taiphoz"(Posted 2004) [#5]
I duno about you lot but that looks sweet.

Wouldnt mind seeing the code.


Filax(Posted 2004) [#6]
Lol :)


koekjesbaby(Posted 2004) [#7]
it reminds me of this: http://www.blitzbasic.com/Community/posts.php?topic=30216


napole0n(Posted 2004) [#8]
Hmm, nice effect. Doesn't run too well on my work machine (nVidia Quadro2 Pro, a 'pro' edition of the GeForce2), but I guess my GeForce4 at home will have no problems with it.


Bouncer(Posted 2004) [#9]
koekjesbaby: Actually it's not at all the same... this is no feedback effect.


mrtricks(Posted 2004) [#10]
Me too, I'd love to know how this was done, it looks great.


koekjesbaby(Posted 2004) [#11]
bouncer: i know, but it still reminds me of some effects than can be accomplished with feedback. ;)


jhocking(Posted 2004) [#12]
What is HDR lighting? Mostly, what does HDR stand for?


jfk EO-11110(Posted 2004) [#13]
it means - hey-dut-rocks - where do you live? :P just kiddin. it means: Human Development Reports - no wait, Harddisk Data Recovery . Uhm, no, High Dynamic Range, or Heavy Service Drive Regional or maybe Hyper Dense Radiation ... grrrr darn TLAs!


Dustin(Posted 2004) [#14]
High Dynamic Range [Image]. While colors normaly range from 0-255 an HDR allows images outside that range to be incorporated. Think of taking a series of pictures where the iris is stopped up and down and incorporating all of those images into one. So when an image goes dark the colors don't simply clip into a sea of black. Also, bright images don't simply clip into a sea of pure white. It does make a significant difference and I can't wait to see what kind of magic Bouncer manages to come up with!!!


HNPhan(Posted 2004) [#15]
oh nice effect :D

this is like glow, but faster


sswift(Posted 2004) [#16]
HDR means High Dynamic Range, like Dustin said.

It means that instead of 24 bit color, with R G and B having one byte each, you have 16 or 32 bit floating point values for R G and B.

If digital cameras supported HDR images, then when you took a picture of a sunset, you would be able to adjust the exposure in Photoshop without losing any details in areas which are too light or too dark.

In other words, if you took a photo of someone standing in front of a bright source of light, like the sky, normally the sky wouldturn white in the final image and all detail would be lost. But with HDR images, the data that is neccessary to correct those areas is still there. It just gets clamped to white for display on your monitor.

HDR is also useful for computer graphics, because it allows you to place very bright light sources in a scene, and then blur the HDR image, and get a result that looks spectacular.

For example, you can have a single HDR pixel that is 10,000 times brighter than the surrounding pixels, and if you then blur the image and apply it back over the original with an add blend after bringing the brightness down a bit, you'll have a huge flare around that single point. Normally, blurring a single white pixel would have little effect on it's surroundings. The difference just isn't actually that great.


Bouncer(Posted 2004) [#17]
update... it looks much better now... thanks sswift for you excellent blur function.

I will release source when I get this good enough to be usefull...


Dustin(Posted 2004) [#18]
> I will release source when I get this good enough to be usefull...

Can't wait! Thanks Bouncer for another amazing creation.


sswift(Posted 2004) [#19]
Btw the thing runs just fine on my Radeon 7200. Do you don't need that high end a video card for this.


Mathieu A(Posted 2004) [#20]
how do you do that? I want to know! It's a very interesting FX!!!
Congratulation


Dustin(Posted 2004) [#21]
@sswift: It runs like crap on my laptop here at work (3fps). But I'd expect it to: P3 850 w/ GeForce2Go-16meg. That would measure up as extreme low end.


sswift(Posted 2004) [#22]
"how do you do that?"

I explained in the second post down.


Zenith(Posted 2004) [#23]
That's amazing, perfect for non-hardcoded suns! :O


HNPhan(Posted 2004) [#24]
nice to hear bouncer, thanks for your contribution :D


Beaker(Posted 2004) [#25]
I get 30 FPS on my crappy Matrox g400 (+AMD1300).


Bouncer(Posted 2004) [#26]
sswift: I have trouble getting the final overlay to fit the scene perfectly. It seems that when you copy backbuffer to texture and use that texture again on a quad of the size of the screen there's some drift if you do multiple passes. If I for example use your blurring function many times in a row (1 pass each) the more blurs I do in a row ... the more the texture drifts. I haven't found a perfect fix for this yet.. it's really bugging me.

Do you have any ideas? or anyone?