trustedhaa.blogg.se

Unity 2019 additive sprite not transparent
Unity 2019 additive sprite not transparent






unity 2019 additive sprite not transparent unity 2019 additive sprite not transparent

Half4 color = tex2D(_MainTex, IN.texcoord) * IN.color OUT.vertex = UnityObjectToClipPos(IN.vertex) _StencilReadMask ("Stencil Read Mask", Float) = 255 _StencilWriteMask ("Stencil Write Mask", Float) = 255 _StencilOp ("Stencil Operation", Float) = 0 _StencilComp ("Stencil Comparison", Float) = 8 _MainTex ("Sprite Texture", 2D) = "white" But if Canvas is using CanvasGroup, pixels can be discarded earlier, and the mask won't work.ĬanvasImageMask shader hides Stencil settings (convenience) and adds a flag, which will hide all pixels from the mask yet still do the job.ĬanvasImageMask: Shader "Custom/CanvasImageMask" But this solution has a problem: how to create such a mask, that shouldn't be drawn? The best solution would be alpha channels set to 1 (out of 255). The developer can create 2 materials (clones of default image material), and modify Stencil settings in the editor. This material will discard any pixels with a buffer's value equal or higher than 1. Keep in mind that objects with such material (that hold CanvasImageMask shader) should come first in Canvas because during rendering they will modify pixel buffers, which can be used later.Īll objects that should be masked have to use another material that is based on default UI image shader with Stencil adjustments. The second shader reacts to this change and discards new pixels in that location. When mask rendering is happening, Stencil will set the pixel buffer's value to 1 in the place where it actually drew something.

unity 2019 additive sprite not transparent

This tool maintains pixel buffer that can be used to discard pixels.ĬanvasImageMask shader: it is a clone of default UI image shader, except Stencil adjustments and tiny addition for comfort work. Shaders in Unity has a tool called Stencil. Shader creation can be avoided in some situations! Resolution: a new shader and its material, plus one additional material.








Unity 2019 additive sprite not transparent