Hiya,
In my spare time I'm working on a game engine and associated editing tool as a self improvement, I'm currently attempting to implement HDR rendering, and I have it working to a point but, I think, I am missing some minor detail. My engine is using deferred rendering which is working fine, and I've added HDR support over the last evening. This is the first time I've looked at both deferred rendering as well as HDR, so it's most likely my own fault or misunderstanding.
So, I'm rendering a simple scene which consists of some terrain, a sky and a couple of other things. After I've combined my lighting in my deferred shader and added the transparent objects (into a R16G16B16A16 floating point target) I then compute the luminance for the scene and finally tonemap the render target onto the back buffer.
My issue, is that the HDR tonemap process is always lifting the images brightness such that it always looks like it's in the middle of the day. For example, if I reduce the sun brightness very low. The scene should be dark, because there isn't much light. However the HDR tonemapper determines that the scene is very dark and lifts the brightness such that the scene becomes too bright.
To show what I mean, here is an image showing the scene in low lighting conditions with HDR disabled:
This next image shows the same scene, with the same lightingg with HDR enabled:
Now, I understand what HDR is doing and that the luminance is low so, therefore, the HDR tonemap process tries to fit the image into the correct range, raising the brightness. My issue is that, I *want* the image to remain dark as the lighting *is* dark. The situation deteriorates if I adjust the camera to look down, as the sky is artificially raising the average luminance in the previous image, so when that disappears off the screen the HDR thinks the scene is even darker, and thus brightens it even further (screenshot below, with the *same* lighting conditions).
For example, if it is the middle of the night I do not want the tonemap to adjust the scene's brightness so much that it looks like it's the middle of the day!
A thought I had is that, perhaps, there should be another luminance value that I can specify that tells the system 'This is the luminance I'm expecting' and I have a max( expectedLuminance, averageLuminance) in the shader, but that seems to go against the grain of what HDR is supposed to achieve. So, I think I'm missing a minor detail in the theory and wondered if anyone could point me in the right direction.
Thanks,
n!