Dynamically rendering circle mask

Ah right, so you can do that relatively easily by grabbing the canvas draw surface (pixels) and creating or updating a pc.Texture.

This Playcanvas take a screenshot example does exactly that:

https://playcanvas.com/project/605131/overview/capturing-screenshot-from-camera

So, basically the steps are:

  • Use a Canvas2D to draw on it. You can find several examples on the web about it.
  • Grab the pixels from that canvas.
  • Use the pixels to populate a pc.Texture which you can use in your UI elements.

Though if you plan in doing that per frame, it’s going to be quite slow, not recommended. Take a look at this post:

1 Like