Unity 粒子渲染层级出错!!!
如图所示,美术添加个粒子特效,但是有个特效却显示在了UI上方,正确的应该是特效在UI下方,被遮挡部分不显示才对。
经查找分析发现是shader的问题,为什么呢?
因为我们的界面下方是scrollview,scrollview是用了模板测试的,但是看错误的粒子shader却没有模板的参数设置,可能是由于模板测试成功了,导致uI上方的粒子也被渲染出来了。
如下所示
Shader "Mobile/Particles/Additive" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
SetTexture {
combine texture * primary
}
}
}
}
}添加了模板参数后,如下所示:
Shader "Mobile/Particles/Additive" {
Properties {
_MainTex ("Particle Texture", 2D) = "white" {}
}
Category {
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
Stencil
{
Ref 1
Comp Equal
Pass Replace
ReadMask 1
WriteMask 0
}
BindChannels {
Bind "Color", color
Bind "Vertex", vertex
Bind "TexCoord", texcoord
}
SubShader {
Pass {
SetTexture {
combine texture * primary
}
}
}
}
}模板测试正常了,特效也正常显示了。
如果对你有帮助,欢迎点赞+关注
页:
[1]