Texture.Parse not parsing _useSRGBBuffer flag

Hello,

As the caption says, it seems like the _useSRGBBuffer is not parsed correctly in the Texture.Parse function.
The issue occured in the following workflow:

  • Create GLB file from Blender with albedoTexture in gamma space
  • Load into Babylon.js scene
    • _useSRGBBuffer is set to true, colors look correct
  • Export scene to babylon file
  • Load babylon file into Babylon.js scene again
    • now the colors are off, also _useSRGBBuffer is set to false, as one can also see in the inspector

Here is a PG example with both files in it.
On the left you can see the GLB file with the correct colors, on the right we have the re-imported babylon file.

First investigations make the issue quite clear.
The call of Texture.CreateFromBase64String is missing the onError callback, therefore the last 2 parameters are on the wrong position.

Also the other path (loading from URL) seems to be just missing the _useSRGBBuffer flag.

Side question

Could you give some insights about the interaction with the gammaSpace property?
This one seems to be parsed correctly and also fixes the color issue.
However, according to the workflow of our 3d artists, that doesn’t seem to be exported by the Blender Gltf plugin.

1 Like

cc @Evgeni_Popov

Thank you for the report and the investigation!

Here’s the PR:

Regarding gammaSpace, the getter does return this._texture._gammaSpace && !this._texture._useSRGBBuffer;. So, if useSRGBBuffer is false, gammaSpace will take over (assuming it is set to true).

2 Likes

Thx a lot for the quick fix :+1: