<p>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.</p>

<p><a href="https://i.sstatic.net/IRvHA.png" rel="noreferrer"><img src="https://i.sstatic.net/IRvHA.png" alt="enter image description here"></a></p>

<p>Here's how I render the image:</p>

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

<p>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.</p>

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

<p>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.</p>

<p><a href="https://i.sstatic.net/HjhjK.png" rel="noreferrer"><img src="https://i.sstatic.net/HjhjK.png" alt="enter image description here"></a></p>

<p>My only other ideas for doing this are...</p>

<ol>
<li>Blend my samples in sRGB space. This would be incorrect though.</li>
<li>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.</li>
<li>Use harmonic mean to combine the colors instead of a regular mean, to make the average favor smaller numbers when present.</li>
</ol>

CC BY-SA 3.0
2018-03-28T15:53:52.723Z
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:
https://gpuopen.com/optimized-reversible-tonemapper-for-resolve/
Alan Wolfe
CC BY-SA 3.0
2018-03-28T16:14:01.930Z
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.
Nathan Reed
CC BY-SA 3.0
2018-03-28T17:37:07.263Z
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.
RichieSams
CC BY-SA 3.0
2018-03-29T11:22:52.240Z
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.
Stefan Werner
<rendering><texture><subpixel-rendering>
Supersampling HDR
Alan Wolfe
# Supersampling HDR

(Asked by: username_0 on 2018-03-27)

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](https://i.sstatic.net/IRvHA.png)](https://i.sstatic.net/IRvHA.png)

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](https://i.sstatic.net/HjhjK.png)](https://i.sstatic.net/HjhjK.png)

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.

**Tags:** rendering, texture, subpixel-rendering

> **Comments:**
> **username_0**: 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: https://gpuopen.com/optimized-reversible-tonemapper-for-resolve/  
> **username_1**: 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.  
> **username_2**: I agree with @username_1. 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.  
> **username_3**: 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.  

---

## 0 answers

