[x3d-public] Gamma correction in X3D and glTF

Michalis Kamburelis michalis.kambi at gmail.com
Mon Jan 20 14:21:15 PST 2020


Thank you for this information.

The fact that X3DOM is already consistent with glTF here (doing
"pow(x,2.2)" on textures, but not on parameters like
"Material.diffuseColor") makes things simpler. And it makes direction
of X3D future more obvious: when doing gamma correction, just follow
glTF and X3DOM tested approaches for gamma correction.

I have updated the wiki page
https://github.com/michaliskambi/x3d-tests/wiki/Gamma-correction-in-X3D-and-glTF
.

So the only difficult decision left is, I think, "what should be the
default". Should we do gamma-correction by default (like in glTF,
where it's not even switchable) or not. I think that most systems now
default to have gamma correction?, so this approach is better in the
long-term. Examples of software that has gamma correction possible,
but defaults to "no gamma correction" are welcome. I am not sure what
latest Unity does now -- I'll test tomorrow.

Regards,
Michalis

pon., 20 sty 2020 o 21:56 Andreas Plesch <andreasplesch at gmail.com> napisał(a):
>
> Thanks for this nice summary.
>
> Here is what the default shader for x3dom does:
>
> First it decodes Gamma:
>
> https://github.com/x3dom/x3dom/blob/810d5cd36f766bd9161f79881cab24dc6771aba5/src/shader/ShaderDynamic.js#L818
>
> but only for textures, judging from the shader code. So this behaviour
> seems to follow the glTF convention of treating textures differently
> from straight color values.
>
> Decoding means pow(color, 2,2):
>
> https://github.com/x3dom/x3dom/blob/b27bda43ee1662bb7cf3488d16051477a99d7601/src/shader/ShaderParts.js#L183
>
> Then it goes through lighting and at the very end it encodes again:
>
> https://github.com/x3dom/x3dom/blob/810d5cd36f766bd9161f79881cab24dc6771aba5/src/shader/ShaderDynamic.js#L1270
>
> encoding means pow(color, 1/2.2). This is applied regardless of the
> origin of the color.
>
> Tonemapping happens before encoding but applying fog happens after
> encoding, as the very very last step. Tonemapping seems to be a way to
> bring out colors in High Dynamic Range source images.
>
> Monitor color calibration by colorimetry and OS level color
> adjustments (color management) all also exist but have to be assumed
> to be set up as truthful as possible.
>
> I remember seeing long discussions about the linear workflow in the
> glTF github issues section but I think they have settled down. I think
> one aspect is that the PBR rendering equations assume that their input
> is gamma corrected, "linear".
>
> I am not sure if it was a good idea have 'linear' as the default gamma
> correction in x3dom since most existing scenes were tuned, either
> automatically or manually, to look correct already, without gamma
> correction. Perhaps textures from linear workflows were already
> decoded/altered to look better.
>
> -Andreas
>
>
> > Date: Sun, 19 Jan 2020 21:31:17 +0100
> > From: Michalis Kamburelis <michalis.kambi at gmail.com>
> > To: X3D Graphics public mailing list <x3d-public at web3d.org>
> > Subject: [x3d-public] Gamma correction in X3D and glTF
> > Message-ID:
> >         <CAKzBGZPuG=-c1vN0zuifR68RccWmgY103mp-5ZBnd+XCzkYd3Q at mail.gmail.com>
> > Content-Type: text/plain; charset="UTF-8"
> >
> > Hi,
> >
> > I was following information about gamma correction from the other
> > thread, in particular information from Andreas Plesch about what X3DOM
> > does (thank you -- your mention of X3DOM + gamma correction was
> > incredibly important for me, it jump-started a small reading session
> > after which I'm hopefully smarter :) )...
> >
> > I looked at glTF specification and sample implementation, in regards
> > "what do they say about gamma-correction".
> >
> > I collected my conclusions on
> > https://github.com/michaliskambi/x3d-tests/wiki/Gamma-correction-in-X3D-and-glTF
> > . Comments are of course welcome.
> >
> > A summary, along with notes "what to do in X3D spec (4.0 or future
> > spec version)" are at the bottom.
> >
> > Regards,
> > Michalis
>
> --
> Andreas Plesch
> Waltham, MA 02453
>
> _______________________________________________
> x3d-public mailing list
> x3d-public at web3d.org
> http://web3d.org/mailman/listinfo/x3d-public_web3d.org



More information about the x3d-public mailing list