ShaderMaterial, RenderTargetTexture and FreeCamera - SOLVED

Hello Babylonjs community!

I’m having trouble with two ShaderMaterials (which are fed seperate RenderTargetTextures) overwriting each other.


I have a master camera:

When the slave cameras are set as FreeCamera -see below- (which is needed to correctly apply a matrix) the ShaderMaterials overwrite each other.

When the slave cameras are set as ArcRotateCamera -see below- the ShaderMaterials are correct (albeit incorrectly positioned by the matrix)

I can see the correct material is displayed when I cull the backface of each ShaderMaterial:

Is there a difference in rendering between FreeCamera and ArcRotateCamera?
Can anyone see why/where the shaderMaterials are overwriting each other?
Is there a better way to explain what is going on?

Hope someone can help.

Kind Reagards,


it is because if you cull faces you can see through the plane(depth not being written):

You can better grasp what is happening in this pg where the clear color of the rtt have been changed and then playing in the inspector :slight_smile:

Thanks sebavan!

Unfortunately I’m still having trouble.

It seems to be a problem when using a FreeCamera in a renderTargetTexture.
When this is combined into a shaderMaterial, it displays incorrectly:

It displays correctly when using an ArcRotateCamera:

Is there a difference between a FreeCamera and an ArcRotateCamera when using renderTargetTexture?

How can I use a FreeCamera in a renderTargetTexture without it affecting other materials?

Thanks for your help.

Kind Regards,


It is because you see the alternate portal through the render targets. You can see here the correct behavior without renderlist


Thank you so much sebavan!
I thought it was something stupid my end.

Here is the pg with the required changes:



1 Like