The Canvas Renderer has a checkbox labeled “cull transparent mesh”. The
documentation
says this allows geometry emitted by the renderer to be ignored when alpha is near zero.
What are the practical effects of this? Does it affect raycasting or user interactions? (e.g. does it make a button unclickable?) When should you use this or not use this?
That doesn’t really help. Regardless of when during development you start checking that box on some objects, you need some rule for determining which objects should have it checked and which should not.
If the answer is either “all of them” or “none of them” then the checkbox shouldn’t exist in the first place; Unity should just do the right thing automatically because it’s always the same. So there must be some situations where it should be checked and some where it should not.
I assume this culling test has a cost, which is why it’s not enabled by default/done automatically.
You have to profile, find potential expensive renderings of transparent meshes that are not visible.
I just used it for a vignette that is only used in some situations but it was hidden the rest of the time by setting alpha to zero. It was taking 1.5ms to render in an older device (while being completely invisible) and now it’s virtually zero.
Shader "UI/Default"
Properties
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0