Return to main page
HDRI on GPU
This demo show how to display High Dynamic Range (HDR) Image on a screen by using luminance adaptation and gamma correction. The HDR image is computed by rendering a scene with some HDR light and dot3 bump-mapping in a 16 bits RGB float buffer.
To achieve luminance adaptation, we must compute scene mean luminance on screen. For that, we downsample the rendered scene to an acceptable size to compute the mean of the luminance on CPU. Then we use the following formulas to compute the current exposition :
frame exposure value
exposure = ALPHA/(DELTA + lumAvg);
currentExposure = currentExposure + (exposure-currentExposure)*exposureAdaptationSpeed*elapsedTime;
- lumAvg, average luminance of the scene
- DELTA, a small value to avoid division by 0
- ALPHA, a constant value. (my value is 0.085)
- exposureAdaptationSpeed, adaptation speed to luminance
- elapsedTime, elapsed time since last frame
When we finally render the scene for displaying it on the screen, we blend the sharp scene and a blurred version of it to have a cinematic display like in nVidia's timbury demo. Moreover, we blur the downsampled buffers of the scene and use it to compose with the final rendering and achieve large glow effect like proposed by Masaki Kawase. Last, we combine these buffers to compute the final rendering :
= ((blurScene1 + blurScene2 + blurScene3)/3.0 + blurScene4)/2.0;\n"
FinalColor = ( (1.0-bluriness)*scene + bluriness*(blurScene) + bloomLvl*bloom) * exposure) ^gamma)
- blurScene1, 2, 3 and 4, blurred version of the HDR scene and respectivally size (in pixel) reduced by 4, 8, 16 and 32.
- blurScene, blurred version of the HDR scene with size (in pixel) reduced by 4.
- bluriness, the blur factor for the cinematic-like effect
- bloomLvl, the glow level of the HDR scene
- exposure, exposure level
- gamma, gamma correction
Download source and executable
An HDR scene with glow and gamma correction. Let's get closer to the light source...
... The light source dazzle us showing luminance adaptation
(this light is 40 times brighter than the global light).
It's hard to perceive the surrounding environment.
Powerfull glow generation
A scene with two lights. Green light is brighter than blue light.
Return to main page