I’m trying to perform a log during my rendering on an Intel X3100 under Linux (using the default Ubuntu driver). The code looks something like as follows:
vec4 frag_color;
frag_color.rgb = log(frag_value.rgb);
frag_color.a = frag_value.a
gl_FragColor = frag_color;
where frag_value is derived from a texture lookup. Now, I can set the texture such that the log of frag_value should give a sensible answer (i.e, it’s in a sensible range to give a frag_color 0.0->1.0), but it always renders as black (so I assume it’s just setting it to zero). Of course, I can verify I’m sensibly setting frag_value by removing the log (and setting the frag_value texture to be in the range 0.0->1.0), which does what I expect, and multiplication and other trivial operations work fine.
My question is, is this expected behaviour? Am I missing something? Are some GPUs or drivers lacking the some built in functions (e.g. sqrt seems to not work either)?
Solved it:
Texture uploads are usually clamped to the range 0.0->1.0 (despite what might be inferred from the internal format type name), so of course
logis not going to give anything useful. Full range floats were introduced with ARB_texture_float, which extends the internal types to include full range floats, such as LUMINANCE_ALPHA32F_ARB. Using that solves the problem.