Updating mesh material to transmissive crashes in refreshUniformsPhysical

In my scene I’m having meshes that first get a simple preview material and then asynchronously (after the required data has been loaded in the background) more advanced MeshPhysicalMaterial material

In some of the cases the advanced material is transmissive (i.e. it has a transmission> 0 and transparent = true). As soon as I assign this material (even though it has needsUpdate = true) the rendering crashes with the following error


It seems that the transmissive render target is not initialized. By looking at the three code, I can see that it is only initialized if there is at least 1 transmissive object in the scene. However, it does not seem to understand that one mesh suddenly became transmissive.

I can workaround this by also making all preview materials transmissive, but this is a bit ugly in my opinion. I would need some way to tell three that - even though the objects in the scene are the same - some of them became transmissive and thus the transmissive render target needs to be initialized.

Is there any way to do this?

Any chances to demonstrate this issue with a live example?

I would like to debug this issue since I currently don’t understand how the error can happen. If transmissive objects are in the scene, the renderer should detect this when preparing the internal render lists. When rendering the render items of the transmissive render list, it should detect that there is no transmission render target and then create one.

The line you are referring to in your screenshot comes later at a point where the render target should be available for the uniforms refresh.

Thanks, and sorry for my late reply. I’ll try to generate a live example where this happens (I hope it is not specific to the setting of my particular project).

I was able to create a minimal reproducible example

It seems to be related the node materials and the transmissionNode.
Apparently the transmission node is ignored when it is being decided whether the transmissive render target needs to be initialized.
However, during rendering it is required nevertheless when the transmissionNode is setup which leads to the crash.

material.transmissionNode = THREENodes.float(0.9); //This crashes

Setting the transmission value directly works (but this is undesired for node materials)
material.transmission = 0.9; //This works

I’m afraid we will not further support node classes in webgl-legacy. This directory will be removed sooner or later.

Does the runtime error also happen with WebGPURenderer with its WebGL backend?

I’m having problems setting up any example using WebGPURenderer in CodeSandbox. When I import WebGPURenderer it immediately crashes:

CodeSandbox Example