<div dir="ltr"><div dir="ltr"><div>I guess the question from Patrick was more about the "S" letter in GL_SRGB vs GL_RGB :) Not about the "A" letter.</div><br>And grepping the latest White Dune source code -- as far as I can see, you do not use GL_SRGBA. You use a variant without "S", that is GL_RGB (when no alpha) or GL_RGBA (when alpha).<br><br>Sure a texture with alpha channel has to use a version with "A" suffix, so GL_SRGBA or GL_RGBA.<br><br>Using GL_SRGB (or GL_SRGBA) means that OpenGL takes care of converting the values from texture into linear space. IOW, the point 2.2. from description on <a href="https://github.com/michaliskambi/x3d-tests/wiki/Gamma-Correction-in-Future-X3D">https://github.com/michaliskambi/x3d-tests/wiki/Gamma-Correction-in-Future-X3D</a> , """To use the image as a texture (that multiplies e.g. the "diffuse" light factor), you need to get back physical value from images""" -- this point can be done by hardware if you use the format with "S" in the name. It is described e.g. in <a href="https://www.khronos.org/opengl/wiki/Image_Format#sRGB_colorspace">https://www.khronos.org/opengl/wiki/Image_Format#sRGB_colorspace</a> .<br><br>Castle Game Engine (right now) doesn't use the format with "S", we use regular GL_RGB / GL_RGBA, and we do "pow(xxx, 2.2)" is GLSL code. So it's not a problem if we apply gamma in one case, and not apply it in other -- we just use a different shader variant. The texture data is the same.<br><br>I know that the same goes for glTF sample implementation (see here for their implementation: <a href="https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/master/src/shaders/tonemapping.glsl">https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/master/src/shaders/tonemapping.glsl</a> ).<br><br>And the same goes for X3DOM. They apply the proper operation in the shader (depending on "Environment.gammaCorrectionDefault").<br><br>So, nobody (from above 4 implementations) is using the format with "S" in the name.<br><br>And Patrick, you make an excellent point here: using the format with "S" in the name is a *good* idea. And it is easily possible only if the specification has an extremely simple rule: "apply gamma correction always" (otherwise you would need to use different texture formats, depending on whether your material node indicates gamma or not).<br><br>Thank you for this insight!<br><br>I also agree with John -- it does seem counter-intuitive that you would need "Environment" node to have consistent gamma treatment in all browsers.<br><br>That said, I'm still left with one problem -- if we just say in the spec """X3D browsers should just apply gamma correction, always, unconditionally""" then we have lots of benefits (simplicity, consistency with glTF) but one big drawback -- we break compatibility in case of browsers that didn't implement gamma correction before. All the X3D models, tested on X3D browsers without gamma, will suddenly look different, as we would change how "Material" effectively looks (how it is mixed with a diffuse texture).<br><br>Opinions welcome :) I'm still at the cross-roads, what is the best way ahead :)</div><div dir="ltr"><br></div><div>Regards,</div><div>Michalis<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">śr., 2 wrz 2020 o 11:57 J. Sheurich <<a href="mailto:mufti11@web.de">mufti11@web.de</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
On 2020-09-02 11:41, Patrick Dähne wrote:<br>
> Hi Michalis,<br>
><br>
>> 7. Castle Game Engine by default applies gamma correction on PhysicalMaterial, and *does not* apply gamma correction on Material or UnlitMaterial.<br>
> Ok. Let’s say you have something like that:<br>
><br>
> Shape {<br>
>    appearance Appearance {<br>
>      material Material {<br>
>        texture DEF tex ImageTexture {<br>
>          url "foo.png"<br>
>        }<br>
>      }<br>
>    }<br>
>    geometry Box {}<br>
> }<br>
><br>
> Shape {<br>
>    appearance Appearance {<br>
>      material PhysicalMaterial {<br>
>        baseTexture USE tex<br>
>      }<br>
>    }<br>
>    geometry Box {}<br>
> }<br>
><br>
> What’s the internal OpenGL texture format of the ImageTexture?  GL_RGB or  GL_SRGB?<br>
><br>
a png-file can have alpha information, therefore it would be logical to<br>
have GL_SRGBA for .png and .gif<br>
<br>
white_dune uses GL_SRGBA ....<br>
<br>
so long<br>
<br>
MUFTI<br>
<br>
<br>
<br>
_______________________________________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a><br>
</blockquote></div></div>