I’m creating a circle progress bar. For this kind of effect I normally use a full circle image and then apply a mask to it rendering part of a circle in an offscreen canvas element.
However I have never done this in PlayCanvas, and I’m not sure what would be the process to assign the bitmap of the canvas to a masking sprite on runtime, and I don’t think there is any example on how to do this.
Has anyone done this before or could you give me any hint? Thanks!
Masks are supported in Playcanvas UI element components, though for the moment I think only 1-bit precision is available. That means only yes/no (transparent or not), no nice fading out pixels based on the alpha texture.
For a progress bar you can take a look at this tutorial project, it uses a scaled up element to fill the bar, of course not sure how that would work in your case (with a circle progress bar):
What I want to do is generate the mask dynamically to have a circle progress bar, not a rectangle one. I have done this several times in other engines by rendering the pie section that I want masked on a canvas context, and then using that as the mask.
So, my question in this case is if someone know how could I use that canvas context bitmap as a mask in Play Canvas.
Which can act then like a texture for a sprite, and it doesn’t have a big cost, just as much as rendering a few more pixels offscreen, no noticeable impact on the game performance.
I’ll give this method a try to see how it performs, but I’m sure there must be a not very expensive way, I just can’t figure out which one yet
Hey there, have you ever figured out a straight forward solution for this? Looking for a quick one and don’t really have the resources to spend time on playing with fragment shaders (unfortunately).