LogLuv Encoding For HDR

Started by
14 comments, last by MJP 15 years, 9 months ago
Quote:Original post by wolf
I actually skipped the log part and stored the luminance value in two 8-bit channels ... this is much much faster and looks quite cool.


Interesting...does it still look okay with multi-sampling or other linear filtering? I suppose I'll just have to try it myself when I get home...
Advertisement
Quote:Original post by wolf
I actually skipped the log part and stored the luminance value in two 8-bit channels ... this is much much faster and looks quite cool.

Yep, that works as well if you don't need to support insane dynamic ranges :)
Actually it's also possible to save the alpha channel for something else and encode logarithmic luminance in just 8 bits. If one wants so support a medium dynamic range the final results are totally acceptable.


I wonder MJP if you might explain the whole process of using LogLUV/downsampling/etc to get the final glow on your ship and on the road?
Sure, no problem. What I have going now is basically this:

1. Render the scene to an R8G8B8A8 texture, encoded in LogLuv (using the LogLuvEncode function)

2. Downscale to 1/16th size
-grab 16 samples
-decode samples using LogLuvDecode
-combine the samples and divide by 16
-encode the samples

3. Decode, threshold, and re-encode

4. Vertical Gaussian blur, similar to downscale (decode, filter, re-encode)

5. Horizontal Gaussian blur, don't re-encode (output linear RGB)

6. Combine with original texture


Obviously I'm doing a lot of encoding/rencoding here which removes some of the benefit of working with LogLuv, so when I have some time I'm going to experiment with filtering in linear space with one or some of those steps. When I just did everything in linear space the results weren't that great, so it'll probably take some trial and error to figure out.
So those textures that are blurred just have a value higher than the threshold?
Quote:Original post by jstroh
So those textures that are blurred just have a value higher than the threshold?


I just do a very simple threshold, like this:

float4 ThresholdPS (	in float2 in_vTexCoord    : TEXCOORD0,			uniform bool bUseNAO32	) : COLOR0 {    float4 vSample = tex2D(PointSampler0, in_vTexCoord);	    if (bUseNAO32)        vSample = float4(LogLuvDecode(vSample), 1.0f);		    vSample -= g_fThreshold;    vSample = max(vSample, 0.0f);    	    if (bUseNAO32)        vSample = LogLuvEncode(vSample.rgb);	    return vSample;}



Then I feed the result of that pass into the blur shaders. There's obviously a lot fancier things you could do, but for me this is working well enough for now.

This topic is closed to new replies.

Advertisement