[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D

> El 3 de septiembre de 2010 08:47, Chris Marrin <cmarrin@apple.com>
> escribió:
>> I think it would be useful to have the unlit case behave the same as
>> rendering to a 2D canvas, which would gamma correct. I believe the
>> differences in the lit case would be subtle and it's only if authors are
>> trying to be very precise that they will care. In that case, they can
>> turn it off. But my opinion on this is not strong.
> I agree that the unlit case should ideally behave the same as
> rendering to a 2D canvas. However, as Steve points out, this would be
> much better implemented as a context creation attribute that the
> compositor could respect.  It could default to having gamma correction
> turned on.
> Additionally, if you need a packing flag for texture loads, I think
> the most useful operation is the opposite of the one proposed--to
> transform non-linear input textures into the appropriate linear space
> for lighting.  Using non-linear textures as storage and input arguably
> gives you more color resolution in the dark part of the spectrum, so
> it might be useful to support that.  D3DSAMP_SRGBTEXTURE is an example
> of this sort of texture load flag.
> -enne

Yes - the reverse operation (to turn a pre-gamma-corrected image into a
linear color space texture) is much more useful - especially in an
environment where JPEG images are common and we might wish to take as
input other things that the browser has generated that might already be
gamma corrected.

At first sight, fixing pre-gamma'd images back to linear seems do-able in
the shader.

(Since the gamma operation is  Vout=pow(Vin,1.0/2.2) - the inverse of that
is Vin = pow(Vout,2.2)...which you can approximate as pow(Vout,2.0) -
which is Vin=Vout*Vout).

However, you can only do that after texture-lookup - and because that
entails a bunch of linear interpolations, you shouldn't really be doing
that in gamma-space.  So there is certainly justification for reversing
the gamma correction as the texture is loaded.  Moreover, many image file
formats actually tell you what gamma they were stored with - so the loader
could do a really excellent job by honoring that number.

  -- Steve

  -- Steve

  -- Steve

You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: