Cloning a material that uses a CubeTexture with an IrradianceTexture causes the IrradianceTexture to be lost from both the original and the cloned material

When you clone a material that uses a CubeTexture with an irradianceTexture, the irradianceTexture is lost from both the original and the cloned material.

Some specific environment textures have their irradianceTexture set when loaded as a CubeTexture by Babylon. (Others do not. I don’t know why this happens.)

When you clone a material that uses a CubeTexture with an IrradianceTexture as its ReflectionTexture, the IrradianceTexture is lost from both the original and the cloned material. As a result, even though the ReflectionTexture exists, the IrradianceTexture becomes null.

As a result, depending on the scene, the following error may occur. (I was unable to reproduce this specific error in the Playground, but I was able to reproduce that value becomes null. Please check the repro for details.)

Uncaught TypeError: Cannot read properties of null (reading '_dominantDirection')

BJS - [14:04:58]: [Frame 151] WebGPU uncaptured error (1): [object GPUValidationError] - Destroyed texture [Texture "D3DImageBacking_D3DSharedImage_WebGPUSwapBufferProvider_Pid:52508"] used in a submit.
 - While calling [Queue].Submit([[CommandBuffer from CommandEncoder "[151|0] - UploadEncoder"], [CommandBuffer from CommandEncoder "[151|0] - RenderEncoder"]])

_LogEnabled @ logger-CmYsbW8L.js?v=0a553e18:39
(anonymous) @ engine.multiRender-BDuWWWyg.js?v=0a553e18:6691Understand this warning
room?zen:1 Destroyed texture [Texture "D3DImageBacking_D3DSharedImage_WebGPUSwapBufferProvider_Pid:52508"] used in a submit.
 - While calling [Queue].Submit([[CommandBuffer from CommandEncoder "[151|0] - UploadEncoder"], [CommandBuffer from CommandEncoder "[151|0] - RenderEncoder"]])

Here is minimum repro: Babylon.js Playground

I apologize if this is a known issue or if I am using it incorrectly.
However, I could not find any mention of this on the forums.

Thank you for this great framework!

I am using machine translation, please excuse the awkward English.

1 Like

Thanks for reporting, here’s the fix:

1 Like

Thank you for confirming and fixing that so quickly!