# Video Texture with Mask

**URL:** <https://forum.babylonjs.com/t/video-texture-with-mask/39649>\
**Category:** Questions\
**Created:** [April 5, 2023, 10:14pm UTC](https://forum.babylonjs.com/t/video-texture-with-mask/39649 "2023-04-05T22:14:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgonzosan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jgonzosan/32/10007_2.png) [@jgonzosan](https://forum.babylonjs.com/u/jgonzosan)\
**Post date:** [April 5, 2023, 10:14pm UTC](https://forum.babylonjs.com/t/video-texture-with-mask/39649/1 "2023-04-05T22:14:33Z")

</div>

I’m creating a project that involves playing a video and I’m using a video texture for this. I also wanted to add a mask to this so that I can view the video through a unique shape. I wanted to create something like this: [https://playground.babylonjs.com/#YDO1F#18](https://playground.babylonjs.com/#YDO1F#18) where the visible parts of the texture would be the visible parts of the video.

This is the playground I’m using to test this: [https://playground.babylonjs.com/#ZMCFYA#518](https://playground.babylonjs.com/#ZMCFYA#518) it includes a glb model of a star to verify the video texture works fine with a custom model. Is this possible using only textures?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 6, 2023, 10:51am UTC](https://forum.babylonjs.com/t/video-texture-with-mask/39649/2 "2023-04-06T10:51:14Z")

</div>

The PG does not work for me:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/1/d14513179ad42fbbfe8644ffec3f5a62c0d41bb6.png)

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [April 6, 2023, 2:33pm UTC](https://forum.babylonjs.com/t/video-texture-with-mask/39649/3 "2023-04-06T14:33:33Z")

</div>

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#8G9QLI%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

A quick Chromakey shader

---

<div class="post-metadata">

**Author:** ![jgonzosan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jgonzosan/32/10007_2.png) [@jgonzosan](https://forum.babylonjs.com/u/jgonzosan)\
**Post date:** [April 6, 2023, 4:28pm UTC](https://forum.babylonjs.com/t/video-texture-with-mask/39649/4 "2023-04-06T16:28:30Z")

</div>

Sorry about that, looks like the file was blocked on your end. Nonetheless, I know the custom shape works so I just replaced it with a box. The Chroma Key example looks great, though the video I’m using does not have a green screen. I think the video texture with the 3d mesh would work just fine now that I’m playing around with it, although I would like to use the 3d mesh as the mask. I saw a playground using the stencil buffer which may be what I’m looking to implement.

It’s been a while since I played with shaders but I’m looking to create a portal-like effect where I can see through one end like this: [Impossible Geometry with Stencil Shaders in Unity URP - YouTube](https://www.youtube.com/watch?v=EzM8LGzMjmc) . If there’s something already like that available in a playground I’d love to see it, otherwise I’ll attempt to create it myself.
