Transparency for webm Video texture

Hi Everyone,

I am trying to add a video textured geometry inside the scene. For POC, I am trying to map the texture of plane geometry. Eventually, I would be loading it on other geometries like cylinders. The video is being played but transparency is not being set. I have added a transparent property to material and format as RGBA to texture property

Any help on this would be great.

        video = document.createElement( 'video' );
        video.src = "testAudio.webm";
	videoImage = document.createElement( 'canvas' );
	videoImage.width = 240 * 2;
	videoImage.height = 102 * 2;

	videoImageContext = videoImage.getContext( '2d' );
	videoImageContext.fillStyle = '#000000';
	videoImageContext.fillRect( 0, 0, videoImage.width, videoImage.height );

	videoTexture = new THREE.Texture( videoImage );
	videoTexture.minFilter = THREE.LinearFilter;
	videoTexture.magFilter = THREE.LinearFilter;
	videoTexture.format = THREE.RGBAFormat;

        var movieMaterial = new THREE.MeshBasicMaterial( { map: videoTexture, transparent: true } );
	var movieGeometry = new THREE.PlaneGeometry( 120* 2, 50* 2, 4, 4 );
	var movieScreen = new THREE.Mesh( movieGeometry, movieMaterial );

Please create your video texture like so and try again:

<video id="video" loop crossOrigin="anonymous" playsinline style="display:none">
    <source src="testAudio.webm">
const video = document.getElementById( 'video' );;

const texture = new THREE.VideoTexture( video );
texture.format = THREE.RGBAFormat;

When using VideoTexture, minFilter and magFilter are already set to THREE.LinearFilter.

Notice that you need a user interaction before starting the video (otherwise you violate the autoplay policy and it won’t work). Besides, you should definitely add a MP4 version of your video since WebM is not supported by all browsers. Use the following example as a code template:

I have been trying to get video with alpha working on all devices. On desktop browsers (Chrome, Safari) webm and mov (codec hvc1) are working great when using them as videotexture with format sRGBA.

But none of the mobile devices work: video (iOS = mov, Android = webm) is shown without alpha.

On Quest2 Oculus browser the video (webm) doesn’t load at all (the video element control shows a spinning pause button). here i might have to change to another codec.

Anyone experienced the same and found a solution? Especially for the Quest2 I am eager to hear a solution for videotexture with alpha.

FYI: this is the video element for the video texture:

<video autoplay="" loop="" muted="" playsinline="" preload="metadata" crossorigin="anonymous" controls="" style="display:none">
    <source src="" type="video/mp4; codecs=&quot;hvc1&quot;">
    <source src="movie-A.webm" type="video/webm">
    Sorry, your browser doesn't support this video.

Interesting @Jo_Mantelers
My curiosity itches me. I tried with FF and Chrome, and it now works on desktop and Android 7.0.
Is it still not working for you on iOS and Quest2 with webm?
Not related but I think for HTML you can remove the ="" and simply quote:

<video autoplay loop muted playsinline preload="metadata" crossorigin="anonymous" controls style="display:none">
    <source src="" type="video/mp4; codecs='hvc1';">
    <source src="movie-A.webm" type="video/webm">
    Sorry, your browser doesn't support this video.

did you find a more cross browser/ cross device solution for this ?

Have you seen this approach?

Using a matted fragment shader. Seems to be iOS compatible.

1 Like

I just tested transparent video textures (webm+hvc) and can confirm it works on Desktop+Mobile including iOS, but not on the native Oculus Quest 2 browser. It works on Firefox Reality for Oculus though.