Unity shader中真的可以动态关闭Stencil Test吗?

这个问题很多年前就有人问了:

https://discussions.unity.com/t/how-to-disable-the-stencil-block-via-shader-properties/600273/1

最后的答案是:

set [_StencilComp] to CompareFunction.Disabled to disable the Stencil Op completely.

但是我测试了一下,Disabled只出现在了Frame Debugger中,使用RenderDoc截帧分析(DX11),设置的渲染状态仍然是StencilEnabled True:

但是我没有测试移动平台和DX12,但这应该是RHI无关的逻辑吧。

另外,如果Shader中根本不包含Stencil这段,则Stencil Eanble为false。

可是Stencil这段没法动态关闭。

由此可知,如果我上面的测试是正确的,UGUI的 UI/Default shader由于包含了Stencil,那么Stencil Test对于所有的UGUI Drawcall都是开启的。那么使用Mask似乎也不会额外影响性能了是吧,那还优化个啥呢

相关推荐
郝学胜-神的一滴31 分钟前
深入理解Mipmap:原理、实现与应用
c++·程序人生·unity·游戏程序·图形渲染·unreal engine
一个笔记本10 小时前
godot log | 修改main scene
游戏引擎·godot
nnsix12 小时前
Unity PicoVR开发 实时预览Unity场景 在Pico设备中(串流)
unity·游戏引擎
一只一只17 小时前
Unity之UGUI Button按钮组件详细使用教程
unity·游戏引擎·ugui·button·ugui button
神米米20 小时前
Maya快速安装UE4 布料权重绘制插件PhysX导出apx
游戏引擎·ue4·maya
WarPigs20 小时前
Unity阴影
unity·游戏引擎
一只一只21 小时前
Unity之Invoke
unity·游戏引擎·invoke
技术小甜甜1 天前
【Godot】【入门】信号系统从 0 到 1(UI/玩法彻底解耦的通用写法)
ui·游戏引擎·godot
技术小甜甜1 天前
【Godot】【入门】节点生命周期怎么用(避免帧循环乱写导致卡顿的范式)
游戏引擎·godot
tealcwu1 天前
【Unity踩坑】Simulate Touch Input From Mouse or Pen 导致检测不到鼠标点击和滚轮
unity·计算机外设·游戏引擎