Hi, i just know one mask for gameobject, but those way with low fps on mobile device.So how can i do for sharing the mask to gameobject with different position.
That’s the sample code:
To clarify, when I said that multiple Game Objects can use a single mask, it only works if those Game Objects do not overlap. Masks are rendered in world space, not local space, so you can draw multiple shapes to a single mask and each shape can be at the position of a Game Object.
Internally the mask is cached, so if, for example, 20 Game Objects all use the same mask, no extra processing happens as the mask is only set-up and torn-down once (as long as those Game Objects are consecutively ordered in the render list)
Geometry Masks use the stencil buffer in WebGL, or Canvas Path API, so the more complex the shape (especially circles and arcs), the bigger the stencil buffer becomes and it just all takes a lot more processing power. Bitmap Masks use a custom shader, so are faster, but still require flushing the WebGL batch first.
If you need to use them in large volumes, you should look at generating textures instead, rather than using an actual mask at run-time.