统一剪影着色器
Unity Silhouette Shader
有谁知道免费的 Unity/ShaderLAB 这只是默认的 sprite 着色器,但是当你走到某个东西后面并且再也看不到玩家,或者只是其中的一部分时,它会显示一个完全不透明的,一种覆盖一切的颜色轮廓。
它应该看起来像这样:http://i.stack.imgur.com/iByV7.png(来自泰坦之魂)
您可以将此着色器应用于您的播放器对象。对于它绘制的每个像素,它将用 1 标记模板标志。
Shader "Custom/StencilHole" { //also used for silhouetted objects
Properties {}
SubShader {
// Write the value 1 to the stencil buffer
Stencil
{
Ref 1
Comp Always
Pass Replace
}
Tags { "Queue" = "Geometry-1" } // Write to the stencil buffer before drawing any geometry to the screen
ColorMask 0 // Don't write to any colour channels
ZWrite Off // Don't write to the Depth buffer
Pass {}
}
FallBack "Diffuse"
}
然后您可以在 "tinted glass" 上使用下面的着色器。它检查每个像素的模板值:如果等于 1,则使用轮廓颜色(样本中为黑色),否则为主要颜色(样本中为灰色)和纹理(样本中为 none)的组合).注意:只有应用了 ABOVE 着色器的对象才会被剪影 - 因此您可以选择使玻璃颜色透明并允许,比如.. 地面花朵,显示出来。
Shader "GUI/silhouetteStencil"
{
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_silhouetteColor ("silhouette Color", Color) = (0,1,0,1)
}
SubShader {
Tags { "Queue"="Transparent-1" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting On Cull back ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
// Only render texture & color into pixels when value in the stencil buffer is not equal to 1.
Stencil
{
Ref 1
Comp NotEqual
}
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
constantColor [_Color]
combine texture * constant
}
}
Pass
{
// pixels whose value in the stencil buffer equals 1 should be drawn as _silhouetteColor
Stencil {
Ref 1
Comp Equal
}
SetTexture [_MainTex]
{
constantColor [_silhouetteColor]
combine constant
}
}
}
}
有谁知道免费的 Unity/ShaderLAB 这只是默认的 sprite 着色器,但是当你走到某个东西后面并且再也看不到玩家,或者只是其中的一部分时,它会显示一个完全不透明的,一种覆盖一切的颜色轮廓。
它应该看起来像这样:http://i.stack.imgur.com/iByV7.png(来自泰坦之魂)
您可以将此着色器应用于您的播放器对象。对于它绘制的每个像素,它将用 1 标记模板标志。
Shader "Custom/StencilHole" { //also used for silhouetted objects
Properties {}
SubShader {
// Write the value 1 to the stencil buffer
Stencil
{
Ref 1
Comp Always
Pass Replace
}
Tags { "Queue" = "Geometry-1" } // Write to the stencil buffer before drawing any geometry to the screen
ColorMask 0 // Don't write to any colour channels
ZWrite Off // Don't write to the Depth buffer
Pass {}
}
FallBack "Diffuse"
}
然后您可以在 "tinted glass" 上使用下面的着色器。它检查每个像素的模板值:如果等于 1,则使用轮廓颜色(样本中为黑色),否则为主要颜色(样本中为灰色)和纹理(样本中为 none)的组合).注意:只有应用了 ABOVE 着色器的对象才会被剪影 - 因此您可以选择使玻璃颜色透明并允许,比如.. 地面花朵,显示出来。
Shader "GUI/silhouetteStencil"
{
Properties {
_MainTex ("Texture", 2D) = "white" {}
_Color ("Color", Color) = (1,1,1,1)
_silhouetteColor ("silhouette Color", Color) = (0,1,0,1)
}
SubShader {
Tags { "Queue"="Transparent-1" "IgnoreProjector"="True" "RenderType"="Transparent" }
Lighting On Cull back ZWrite Off Fog { Mode Off }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
// Only render texture & color into pixels when value in the stencil buffer is not equal to 1.
Stencil
{
Ref 1
Comp NotEqual
}
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
constantColor [_Color]
combine texture * constant
}
}
Pass
{
// pixels whose value in the stencil buffer equals 1 should be drawn as _silhouetteColor
Stencil {
Ref 1
Comp Equal
}
SetTexture [_MainTex]
{
constantColor [_silhouetteColor]
combine constant
}
}
}
}