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似乎也不会额外影响性能了是吧,那还优化个啥呢

相关推荐
孟无岐15 小时前
【Laya】Component 使用说明
typescript·游戏引擎·游戏程序·laya
weixin_4093831215 小时前
cocos shader三角流光
游戏引擎·cocos2d
Mars-xq17 小时前
godot 毛玻璃效果着色器shader
游戏引擎·godot·着色器
绀目澄清18 小时前
unity3d AI Navigation 中文文档
游戏·unity
绀目澄清19 小时前
Unity 的AI Navigation 系统详细总结
人工智能·unity·游戏引擎
绀目澄清21 小时前
Unity3D AI Navigation 详解:从基础概念到实战应用
unity·游戏引擎
weixin_4093831221 小时前
cocos shader流光文字 不显示透明部分
游戏引擎·cocos2d
绀目澄清1 天前
Unity3D AI导航系统完全指南:从核心概念到动画耦合
人工智能·unity
__water1 天前
RHK《模型贴图自由更换位置》
unity·贴图·模型贴图·移动不丢失
JIes__1 天前
Unity(二)——3D数学
unity·游戏引擎