有没有人知道一个免费的Unity/ShaderLAB,它只是默认的精灵着色器,但是当你走在某个物体后面,不能再看到它的一部分时,它就会显示一个完全不透明的,一个颜色的轮廓来绘制所有的东西。
它应该是这样的:http://i.stack.imgur.com/iByV7.png (来自泰坦灵魂)
发布于 2015-10-22 06:29:17
您可以将此着色器应用于播放机对象。它将用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"
}然后,你可以使用下面的着色玻璃上的着色器。它检查每个像素的模板值:如果等于1,则使用剪影颜色(样本中为黑色),否则是主颜色(样本中为灰色)和纹理(样本中为无)的组合。注意:只有上面的着色对象才会被剪影-所以你可以选择使玻璃颜色透明,并允许,比如说..。地面上的花朵,展现出来。
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
}
}
}
}https://stackoverflow.com/questions/32161998
复制相似问题