Is it possible to use video as a mesh reflection?

Hi team,

I wanted to check if it’s possible to display any video as a reflection texture for the mesh material.

Something like this, but I want the mesh to have its own material—just with a video reflection instead of an environment reflection. Maybe even a video environment.

@Evgeni_Popov

1 Like

You can assign the video to the reflection texture, and set the right coordinate mode to coordinatesMode:

4 Likes

Awesome, that works.
My only last question is that texture scaling doesnt seem to work in Projection mode:

1 Like

Yes, that’s how this coordinate mode works. You can try to provide your own reflection matrix by overriding the Texture.getReflectionTextureMatrix method:

I simply copied/pasted the bits of Babylon.js/packages/dev/core/src/Materials/Textures/texture.ts at master · BabylonJS/Babylon.js · GitHub which correspond to the “Projection” mode, and factored the uScale/vScale properties in the projection matrix.

2 Likes

Thank you! Works perfect

How would it be possible to rotate video texture with TEXTURE_FIXED_EQUIRECTANGULAR_MODE

I tried different option, but got no result.

The second option I wanted to try is to rotate TEXTURE_SPHERICAL_MODE
Even though that code works, but it appears that it actually rotates the sphere instead of charging the texture position, I just want to rotate the video by 30-180 degrees so that right corner of the video is in the center of the sphere

@Evgeni_Popov

1 Like

You can try to update our projection shader code to take into account some offsets.

Here’s one way to do it for the fixed equirectangular case:

The projection code is in the reflectionFunction.fx file, so I simply copy/pasted this code in the PG and added a opOffsets uniform to the computeFixedEquirectangularCoords function, which is added to the longitude/latitude calculated lines 135/136. A material plugin is used to set values to this uniform.

1 Like

Awesome, worked for me!

1 Like