ShaderMaterial, RenderTargetTexture and FreeCamera - SOLVED

Hello Babylonjs community!

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

See:
https://playground.babylonjs.com/#LRF4JU

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:
ex4

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,

José

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 https://playground.babylonjs.com/#LRF4JU#5 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,

Jose

It is because you see the alternate portal through the render targets. You can see here the correct behavior without renderlist https://playground.babylonjs.com/#LRF4JU#6

2 Likes

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

Here is the pg with the required changes:

https://playground.babylonjs.com/#KLT0SD

Regards,

Jose

1 Like