and add the stencil functionality. You can find the source

own versions of the built-in sprite shader. It’s less complicated than it might seem. Basically you take the sprite shader from Unity sources。

then read by using ReadPixels and store the result to a Texture2D and then make a Sprite out of that Texture2D using Sprite.Create() function. But that ReadPixels is pretty slow so I would definitely try to find better solution (maybe generate the mask procedurally inside the shader(s) if it would fit your use-case. Here’s a quick test: 6499975--731725--20201107_sprite_stencil2.PNG 1015×655 286 KB 。

clear explanation of some of the required details: Shader stencil and Sprite Masks not working together So the main idea is to replace Unity’s Sprite Mask with custom, and add the stencil functionality. You can find the source code from the download archive: Unity Download Archive Download Archive Then you can render first a base mask and write to the stencil buffer, and after that a mask that cuts out from the base mask. Now you can move the masks independently. And if you really need some complex mask that changes every frame (and it’s procedural or something like that) you probably have to render it to a RenderTexture,。

I thought about this for a while. Indeed you could use shaders for this. See this thread for a good。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://acg.inmoke.com/zixun/Lolita/9968.html