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.
Here's how I render the image:
- Get the (linear HDR) shaded color for 4 stratified samples per pixel.
- Apply a box blur (average them)
- Convert from linear to sRGB
- Clamp to [0,1]
- 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.
My only other ideas for doing this are...
- Blend my samples in sRGB space. This would be incorrect though.
- 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.
- Use harmonic mean to combine the colors instead of a regular mean, to make the average favor smaller numbers when present.