Mirror Texture in CustomShader

Hello.
I’m struggling with the use of a mirror texture in a Custom Shader.

I managed to get it to work but only if the MirrorTexture is also associated with a babylon object with a standard BackgroundMaterial (I found an example somewhere that worked)

Basically my current state is :
Object A - Custom shader that uses the mirror with “.setTexture”
Object B - BackgroundMaterial that uses the mirror with "BackgroundMaterial.reflectionTexture = mirror; "

The problem is : The mirror texture only gets updated if the Object B exists AND is in the view.

Is there any way to control when and if the mirror texture must be updated without using “Object B”.

Thanks

i think it could be easier with a real example in the PG but you should be able to just move the mirror texture into the scene.customRenderTargets array to make it work

Thanks :slight_smile: it seems to work in playground !

https://playground.babylonjs.com/#3UM95Y

However, with your suggestion, on my real project, which is bit more complex and loads some asset async, I get

Uncaught TypeError: Cannot read property ‘_internalAbstractMeshDataInfo’ of undefined
on first scene.render();

unfortunately it will be hard to troubleshoot without a playground repro :frowning:

I know. Unfortunalty, I can’t share the full project. It would be one hell of a Playground code ! :slight_smile:
I’m trying to figure out where and why this error occurs.
I’ll post my progress here. Maybe it will help someone else someday.

1 Like