Jump to content
  • Advertisement
Sign in to follow this  
CoreMeltdown

OpenGL HDR Bloom and Tone Mapping

This topic is 4227 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have some questions on HDR: 1) In the HDR pipeline, where do exactly bloom take place? Before or after tone mapping? 2) If it's before: if we use a tone map operator which uses some luminance information (average log(luminance), max luminance, ...), should this luminance parameter be calculated before or after blooming? 3) Tone Mapping Operators: which operator is currently the most used? (accuracy/speed/eye-candy tradeoff) The most common operators I have found are: Reinhard1: average_luminance = exp(1/n * sigma(log(delta + pixel_luminance))); image_key = some constant (tipically 0.18); exposure = image_key / average_luminance; (or user defined) luminance_scaled = exposure * color; tone_mapped = luminance_scaled / (1.0 + luminance_scaled); Reinhard2: same as before, except luminance_white = maximum value mapped to pure white; (should be use maximum luminance of the scene? should it be user defined?) tone_mapped = (luminance_scaled * (1.0 + luminance_scaled / (luminance_white^2))) / (1.0 + luminance_scaled); Exponential: exposure = same as in Reinhard tone_mapped = 1.0 - exp(-exposure * color); I actually found many sources which behave differently wrt question 1 and perform the tone mapping step almost always in a custom manner. As I am trying to implement a pluggable HDR pipeline (I actually have it in OpenGL, with the 3 aforementioned operators and exposure adaption), I'd like to know how a reasonable implementation should be. Thank you!

Share this post


Link to post
Share on other sites
Advertisement
1) Before
2) Before
3) Don't know. But at least I use always the formula that works for me (looks good). :)

Share this post


Link to post
Share on other sites
3) Reinhard and exponential are the most common ones, because it can be copy/pasted from the directx sdk examples.

Histogram based tonemappers are also feasible, (valve uses them if i remember correctly). You can implement histogramming using scatter ops on the gpu (check ATI gdc07 slides). The nvidia histogramming approach using occlusion queries is not practical imho.

Then there are receptor-based mappers...

There was a comparison some operators a few years ago, i think by patrick ledda. But dont have the link to the paper anymore. And not targeted at real-time graphics but CGI.

Share this post


Link to post
Share on other sites
Quote:
Original post by CoreMeltdown
1) In the HDR pipeline, where do exactly bloom take place? Before or after tone mapping?


Before or after, there is no rule. Blending/filtering in float format is more expensive, and you need to keep that surface around, so some games prefer to render directly to tonemapped and apply the bloom on top of that. Most games do bloom without any form of HDR rendering per se.

Note that bloom is not a totally necessary step (more of an artistic choice..).

Quote:
Original post by CoreMeltdown2) If it's before: if we use a tone map operator which uses some luminance information (average log(luminance), max luminance, ...),
should this luminance parameter be calculated before or after blooming?


If you want to take into account the info you lose by tonemapping then you need to do it before. But there is no rule that says you cannot do after (some games do, for the same reasons given above).

Quote:
Original post by CoreMeltdown3) Tone Mapping Operators: which operator is currently the most used? (accuracy/speed/eye-candy tradeoff)


The one I've seen frequently used in games is
color = color / global_key;

There are some advantages of doing so, speed of execution, fast implementation as they were resource constrained and couldn't redo their art (they usually took their LDR renderer and converted to HDR, or needed to support both targets at the same time), distorsion introduced with texture filtering by other non linear space operations..

You should consider that hdr rendering in games is mostly tips and tricks at the moment and the most advanced papers described in academia don't usually take into account the constraints of real time. And that bloom is optional.

LeGreg

Share this post


Link to post
Share on other sites
as LeGreg says, there is not really a rule. Different games do this differently. I like the idea of having the high range of values through the whole postfx pipeline and then tone map it down at the end.

- Wolfgang

Share this post


Link to post
Share on other sites
Quote:
Original post by Ysaneya
HDRI and Blooming

I realized that my implementation of the bloom effect was wrong. It seems like in a lot of litterature on the net, white papers or even gpu presentations, one has to run a bright pass filter on the raw fp16 buffer, blur it a few times, then add it back to the scene, and then apply tone mapping.

And then i was wondering why in some of my scenes, i had very bright areas that didn't bloom.

Well, that's logic: the bloom effect should come after tone mapping. The more i think to it, the more it makes sense: by tone mapping, you're basically remapping the brightness range from HDR to [0-1] so that it's displayable on your monitor. The areas on your screen that bloom, are the areas that end up with values higher than 1 after tone mapping; not before.

An example: let's say that i have a very dark scene, most values being in the [0-0.1] range, but i have a small area that has a 0.2 color. After tone mapping, this area will end up being very bright and should bloom. If blooming is applied before tone mapping, the bright pass filter will discard a value as small as 0.2, and there will be no bloom.


Quote:
Original post by Anonymous Poster
That’s exactly right; tone mapping should come before doing any blooming. The reason for that is that even though humans are able to see intensities from 10^8 to 10^-6 candela per square meter, the response range is much smaller so to be able to deal with those intensities we adapt our vision based on the intensities. So that should be the aim of tone mapping, not to just clamp values to fit a low dynamic range output but to simulate the adaptation process that takes place in humans. So in the end the blooming happens when light source intensity is higher than the adaptation level. If you want to make your scene look more realistic I suggest you use a local tone-mapping operator (such as Pattanaik’s operator) supposing that you have the time and desire to implement that.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!