HDR RGBD Packed Cubemap Bug in Alpha 24 Build

Hey guys… @Deltakosh and @sebavan and @Evgeni_Popov

Something changed in the HDR RGBD PACKED Cubemaps from Version Alpha 22 to Alpha 24.

In the toolkit i was packing the HDR lightmap image from unity into a RGBD png. So in my GLTF parser when assigning the material lightmap texture, once the texture is loaded, i set the texture.isRGBD = true like so:

And it works perfect… as has been perfect since i made the new exporter. So a scene that looked like this in Unity

Renders like this in Version 5 from Alpha 1 all the way thru Alpha 22

As picture perfect as its gonna get…

But since the Alpha 24 update they are now really dark and dont have that HDRness

So something in Alpha 24 changed in either the texture.isRGBD = true not working from the the texture on loaded observable or something in the shader for when its RGBD packed images.

I think it is because we are now using sRGB buffers by default in the glTF loader if the texture we load is a color data, meaning ITextureInfo.nonColorData = false for the texture.

If that is the problem, adding:

BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce(function (loader) {
    if (loader.name === "gltf") {
        loader.useSRGBBuffers = false;
    }
});

should fix it.

A better way to fix it would be to flag your lightmap texture as a non color data texture because it really holds non color data.

So, before calling loadTextureInfoAsync, set:

commonConstant.lightmapTexture.nonColorData = true;
1 Like

I will let @Evgeni_Popov replied more precisely but can you try to set this on your engine on load:

engine.getCaps().supportSRGBBuffers = false;

So it looks like I can set the engine caps srgb flag in the gltf loader onLoading state

Thank you @Deltakosh and @Evgeni_Popov

I always appreciate your help and advice :blush:

That would prevent any color data texture to use sRGB buffers (if available), which is unfortunate because using sRGB buffers is better than not using them. If you can do it, you should instead set nonColorData = true on the lightmaps that are using RGBD format.

At the very least, you should use:

BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce(function (loader) {
    if (loader.name === "gltf") {
        loader.useSRGBBuffers = false;
    }
});

and not setting the caps to false at the engine level, so that sRGB buffers are still available to users that would like to use them.

It’s expected, the filtering is not exactly the same when using sRGB buffers which can lead to some small visual differences in some cases. But using sRGB buffers is closer to the right rendering (that’s why it is the default) because the filtering is done after the conversion from gamma to linear space, whereas when you don’t use sRGB buffers the filtering is done on gamma values then converted to linear, which is wrong.

As explained above, using sRGB buffers can explain the differences. Only assets read by the glTF loaders use sRGB buffers by default (if nonColorData = false for them). Skyboxes are not read by the glTF loader, so it does not use sRGB buffers by default. Also, for the time being, cube textures don’t support sRGB buffers (going to fix that).

1 Like

Thanks @Evgeni_Popov … You made good points… I will use the TextureInfo.nonColorData = true

:slight_smile:

1 Like