High Dynamic Range Rendering in Irrlicht
High Dynamic Range Rendering in Irrlicht
HDR is a staple of almost every modern video game, and I bring it to Irrlicht.
A while back I showed off bloom, a simple effect that blurs the bright areas of the image to make them appear to glow. Now I present to you full HDR rendering with tone mapping.
For those of you who aren't familiar with the concept of HDR, I'll explain. Without HDR, the color space of a video game is limited from black (SColor(255, 0, 0, 0)) to white (SColor(255, 255, 255, 255)). This is quite unlike real life, as the white of paint on a wall is much, much dimmer than the light of the sky or the sun. HDR simulates real life much more closely by rendering the entire scene using floating-point render targets which are able to store a much broader light spectrum than standard color buffers.
Since your screen can still only display the low dynamic range (24-bit black to white), tone mapping is then used to scale the image back down to the screen color space. It does this by calculating the average brightness of the entire image (a "middle gray") and dividing all color values by this amount.
Put shortly and simply, the scene now mimics your eye. In darker areas, the scene adapts and things become brighter. In brighter areas, darker objects look even darker compared to bright lights. Looking at the first screenshot, we can see that the tone mapped image and the original image are fairly similar since nothing is exceptionally bright. Looking at the second image, however, we can see that the sun (which is 7 times brighter than the rest of the scene) makes everything else look much darker in comparison.
Click on each pic to view it in its full 1440 x 900 glory.
The screenshots can't really speak for HDR - you have to see the transition from darkness to light and then back again:
http://www.youtube.com/watch?v=mZXZyMTHFKg
You can also check it out by downloading it below. The source is included. Note that it requires DirectX 9.0 with Shader Model 2, though as with all but the simplest of post-processing, decent hardware is required to get > 20 fps. Anyone who wants to port this to OpenGL/GLSL can feel free to do so and post it here.
Download:
http://www.filefront.com/17272734/HDR.zip
EDIT: I compiled my Irrlicht.dll with the June 2010 DirectX SDK (the latest version). This means you need to either make sure you have the latest DirectX runtime (found at http://www.microsoft.com/downloads/en/d ... laylang=en) or you need to recompile the solution with your build of Irrlicht. Either way it shouldn't be a big deal at all.
Enjoy!
A while back I showed off bloom, a simple effect that blurs the bright areas of the image to make them appear to glow. Now I present to you full HDR rendering with tone mapping.
For those of you who aren't familiar with the concept of HDR, I'll explain. Without HDR, the color space of a video game is limited from black (SColor(255, 0, 0, 0)) to white (SColor(255, 255, 255, 255)). This is quite unlike real life, as the white of paint on a wall is much, much dimmer than the light of the sky or the sun. HDR simulates real life much more closely by rendering the entire scene using floating-point render targets which are able to store a much broader light spectrum than standard color buffers.
Since your screen can still only display the low dynamic range (24-bit black to white), tone mapping is then used to scale the image back down to the screen color space. It does this by calculating the average brightness of the entire image (a "middle gray") and dividing all color values by this amount.
Put shortly and simply, the scene now mimics your eye. In darker areas, the scene adapts and things become brighter. In brighter areas, darker objects look even darker compared to bright lights. Looking at the first screenshot, we can see that the tone mapped image and the original image are fairly similar since nothing is exceptionally bright. Looking at the second image, however, we can see that the sun (which is 7 times brighter than the rest of the scene) makes everything else look much darker in comparison.
Click on each pic to view it in its full 1440 x 900 glory.
The screenshots can't really speak for HDR - you have to see the transition from darkness to light and then back again:
http://www.youtube.com/watch?v=mZXZyMTHFKg
You can also check it out by downloading it below. The source is included. Note that it requires DirectX 9.0 with Shader Model 2, though as with all but the simplest of post-processing, decent hardware is required to get > 20 fps. Anyone who wants to port this to OpenGL/GLSL can feel free to do so and post it here.
Download:
http://www.filefront.com/17272734/HDR.zip
EDIT: I compiled my Irrlicht.dll with the June 2010 DirectX SDK (the latest version). This means you need to either make sure you have the latest DirectX runtime (found at http://www.microsoft.com/downloads/en/d ... laylang=en) or you need to recompile the solution with your build of Irrlicht. Either way it shouldn't be a big deal at all.
Enjoy!
Last edited by slavik262 on Wed Sep 08, 2010 2:26 am, edited 5 times in total.
-
- Posts: 1691
- Joined: Sun May 18, 2008 9:42 pm
Cool. This looks awesome! I can't believe it works with SM2.0.
That would be illogical captain...
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
I get this Error messagebox when I launch
The console only outputs windows version and irrlicht version.
Graphics card : NVidia GeForce GTS 250
Code: Select all
---------------------------
Error
---------------------------
An error occurred in the following function: Graphics::Amplifier::Amplifier
The error is:
Amplifier shader couldn't be loaded
---------------------------
OK
---------------------------
Graphics card : NVidia GeForce GTS 250
Working on game: Marrbles (Currently stopped).
I think it looks great. I'm a little confused about the transition from light to dark however. If you are staring at a dark area for a long time, and you look at a bright area, it should be REALLY bright and then fade down to normal brightness. In your video towards the end, it looks like the exact opposite happens when you look at the bright nebula, are you sure you're not doing something backwards regarding that part of the algorithm?
EDIT: Ok so I suppose the sun is brighter than the nebula, my bad.
EDIT: Ok so I suppose the sun is brighter than the nebula, my bad.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
serengeor wrote:I get this Error messagebox when I launchThe console only outputs windows version and irrlicht version.Code: Select all
--------------------------- Error --------------------------- An error occurred in the following function: Graphics::Amplifier::Amplifier The error is: Amplifier shader couldn't be loaded --------------------------- OK ---------------------------
Graphics card : NVidia GeForce GTS 250
Sorry for the inconvenience. Maybe I'll re-upload later with the standard Irrlicht build.slavik262 wrote:I compiled my Irrlicht.dll with the June 2010 DirectX SDK (the latest version). This means you need to either make sure you have the latest DirectX runtime (found at http://www.microsoft.com/downloads/en/d ... laylang=en) or you need to recompile the solution with your build of Irrlicht. Either way it shouldn't be a big deal at all.
The sun is the only bright part of the scene (7x brighter than the standard range). The rest of the scene is standard brightness (including the nebula, which is just part of the skybox). The reason the nebula lights back up at the end of the YouTube clip is because it's a "darker" object, so looking away from the sun and back at it drops the luminance and brings out the "darker" objects more (look at the luminance textures in the upper left as this happens). Sorry if this isn't that realistic (nebulae are probably pretty bright too); this demo was just a proof of concept for the game I'm working on. Also, I know the sun looks a little cheesy being solid yellow, but again, it was just a quick test.BlindSide wrote:I think it looks great. I'm a little confused about the transition from light to dark however. If you are staring at a dark area for a long time, and you look at a bright area, it should be REALLY bright and then fade down to normal brightness. In your video towards the end, it looks like the exact opposite happens when you look at the bright nebula, are you sure you're not doing something backwards regarding that part of the algorithm?
EDIT: Ok so I suppose the sun is brighter than the nebula, my bad.
Last edited by slavik262 on Wed Sep 08, 2010 11:51 am, edited 2 times in total.
Just a simple naming issue. Where you say "Bloom" you should say "Blur" "Bloom" is a slightly diferent effect, it is just the same scene render + blur but without the tonemapping step. The effect is that all the scene blurs a little, and becomes a bit more bright. Just that. Looks great!
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
The standard definition of bloom involves running a bright pass (which only captures the brighter parts of the image), then blurring the result of the bright pass before adding it into the final image. It's not just a simple blur operation.
I'm not confused as to what bloom is.
My demo takes the original scene render, calculates bloom and adds it in, then performs tone mapping on the original render + the bloom.
I'm not confused as to what bloom is.
My demo takes the original scene render, calculates bloom and adds it in, then performs tone mapping on the original render + the bloom.
Re: High Dynamic Range Rendering in Irrlicht
The download at Filefront.com get redirected, and even though it looks like the download is about to start, it never happens and there is no error.
Did anyone mange to download the source?
Did anyone mange to download the source?
-
- Posts: 10
- Joined: Fri Oct 23, 2015 7:59 pm
Re: High Dynamic Range Rendering in Irrlicht
Link broken.