A few days ago, I was standing in front of the same old problem with multiple render targets (MRT) in OpenGL (at least on NVidia Geforce 7 series): All buffers have to use the same bit depth. If you want to have a depth buffer, this is usually 32 bits. Now you can either rely on 8 bit per color channel (rgba*8 = 32) as in the good old days, or you have to find a work-around. One option is to increase the number of image buffers, using two buffers with two 16 bit float channels each. if that’s not possible, you might consider the following trick: Ward’s RGB encoding is basically a float format with a shared exponent. You rewrite your channels as mantissa*2^exponent, determine the largest exponent and scale each mantissa according to this exponent. This loses some resolution for the minor channels, but all in all it takes little bandwidth, covers a large range of values and is still computable in reasonable time:
vec4 HdrEncode(vec3 value)
value = value / 65536.0;
vec3 exponent = clamp(ceil(log2(value)), -128.0, 127.0);
float commonExponent = max(max(exponent.r, exponent.g), exponent.b);
float range = exp2(commonExponent);
vec3 mantissa = clamp(value / range, 0.0, 1.0);
return vec4(mantissa, (commonExponent + 128.0)/256.0);
vec3 HdrDecode(vec4 encoded)
float exponent = encoded.a * 256.0 - 128.0;
vec3 mantissa = encoded.rgb;
return exp2(exponent) * mantissa * 65536.0;
Note that this snippet uses a rather strange scaling factor of 65536.0. I had to add this to avoid a bug with exponents near 0, and since my values where all below 65536.0, I just avoided and ignored this. And since I was able to change my MRT code to avoid the depth buffer at all (and therefore avoid this custom HDR coded), I’m not going to fix this. However, I still think it might be useful.
I’ve been working on something completely different for the last year. The result is the German recipe platform Rezeptefuchs. However, now I’m back and already working on scenes with more plants.
Equation (3) of the Spherical Clipmaps paper is broken. Replace “cos… – sin…” in the first line with “cos… + sin…” and you’re done. Thanks to Ian Fisher for pointing this out.
It’s been a while since the last post. I’ve been working mainly on invisible internals for the last six months. However, today some nice pictures appeared on my screen for the first time, and I think I should share them with you:
Btw, the icons you see on the large images are distributed by the Tango Desktop Project.