7
$\begingroup$

I'm encountering some issues supersampling in HDR for an SDR result and was curious what the usual method for doing this is. Notice how pixelated the edge of the white sphere is.

enter image description here

Here's how I render the image:

  1. Get the (linear HDR) shaded color for 4 stratified samples per pixel.
  2. Apply a box blur (average them)
  3. Convert from linear to sRGB
  4. Clamp to [0,1]
  5. Convert from [0,1] to [0,255] and write the result.

I believe the issue here is that along the edge of the white ssphere, the values are either very low (background color aprox 0.02) or very high (the sphere has a color of 10,10,10), and that combining them makes a number much larger than 1 which ends up getting clamped to 1, completely destroying the blending at the edges.

That makes sense but now I'm not quite sure how to solve it.

I tried applying Reinhard tone mapping after step 3, thinking that would help by keeping everything in the [0,1] range, and preserving the smoothness between the colors. That helped only a very small amount.

enter image description here

My only other ideas for doing this are...

  1. Blend my samples in sRGB space. This would be incorrect though.
  2. At step 1.5 apply tone mapping to the samples, then at step 2.5, apply inverse tone mapping to the combined result. This feels like a hack.
  3. Use harmonic mean to combine the colors instead of a regular mean, to make the average favor smaller numbers when present.
$\endgroup$
  • $\begingroup$ Your steps 3-5 are already a kind of tone mapping operator (i.e. a map from HDR to LDR values). Interchange 3-5 with 2 and it should fix the problem. Later you can replace your naive "clamping" tone map with something else, like Reinhard, if you want. $\endgroup$ – Rahul Mar 28 '18 at 3:44
  • 1
    $\begingroup$ I've heard folks say that at 2 you should tone map the samples, combine them, reverse tone map the result, then continue the process at step 3. This link is relevant: gpuopen.com/optimized-reversible-tonemapper-for-resolve $\endgroup$ – Alan Wolfe Mar 28 '18 at 15:53
  • 1
    $\begingroup$ Combining tonemapped samples and then reversing the tonemap is also pretty commonly used in temporal AA, I think. It is a hack, but it may be necessary for small sample counts like 4 spp with box filtering. I suspect with larger sample count and a nicer filter (e.g. bicubic with 1.5–2px radius), the problem would solve itself the “right” way. $\endgroup$ – Nathan Reed Mar 28 '18 at 16:14
  • $\begingroup$ I agree with @NathanReed. If your filter radius is only 1 pixel and a small sample count, the high values are going to blow away any samples with lower values. Especially in HDR. $\endgroup$ – RichieSams Mar 28 '18 at 17:37
  • $\begingroup$ You're pretty much stuck with hacks. In situations where a single sample is bright enough to push the pixel filter past the display range, you're only option is to clamp or tone map the samples before filtering. Tone mapping before filtering will remove energy, which may not be a problem in this particular scene, but will become important with 'fuzzy' features like depth of field, glossy reflections, motion blur, etc. $\endgroup$ – Stefan Werner Mar 29 '18 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.