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

*To*: steve@sjbaker.org*Subject*: Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D*From*: Benoit Jacob <bjacob@mozilla.com>*Date*: Fri, 3 Sep 2010 11:51:57 -0700 (PDT)*Cc*: Chris Marrin <cmarrin@apple.com>, Kenneth Russell <kbr@google.com>, public webgl <public_webgl@khronos.org>, Adrienne Walker <enne@google.com>*In-reply-to*: <29c135daaf4793a5e64da07193a81e15.squirrel@webmail.sjbaker.org>*Sender*: owner-public_webgl@khronos.org

----- Original Message ----- > > 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). Doesn't GLSL ES have pow(x,y) ? Even if we couldn't rely on a pow(x,y) function being available we could still approximate it with basic arithmetic without having to do such an approximation as 2.2 ~= 2.0. For example, could do pow(x,y) = exp(y*log(x)) and if needed implement exp() and log() using polynomial approximations (taylor series for exp and Pade approximant for log). Benoit > > 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: ----------------------------------------------------------- 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:

**References**:**Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D***From:*steve@sjbaker.org

- Prev by Date:
**Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D** - Next by Date:
**Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D** - Previous by thread:
**Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D** - Next by thread:
**Re: [Public WebGL] Gamma correction and texImage2D/texSubImage2D** - Index(es):