相关文章推荐
鬼畜的水煮肉  ·  Dolphinscheduler ...·  2 年前    · 
爱笑的葫芦  ·  js读取excel文件-CSDN博客·  2 年前    · 
爽快的花卷  ·  ehcache ...·  3 年前    · 
善良的水煮鱼  ·  linux socket ...·  3 年前    · 

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?

Did you know? Since Unity 2018.2, Canvas Renderer has a tiny but super helpful toggle: Cull Transparent Mesh! It does culls geometry of your transparent UI objects (e.g. Image with 0 alpha). BTW Canvas Group with 0 alpha also culls out =) #unitytips #unity3d #gamedev

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.

TwoTailsGames/Unity-Built-in-Shaders/blob/master/DefaultResourcesExtra/UI/UI-Default.shader

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