- Home /
Question by
aarquea_unity · Aug 15, 2020 at 12:10 PM ·
materialshader programmingwalls
Show object behind the wall
Hello, i'm trying to show object behind the wall. I loss shadows trying it. My objective is when the object is behind the wall show white silhouette but when is not behind the wall show a simple standard material.
Shader "Unlit/ThrowWall"
{
Properties
{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Gloss (A)", 2D) = "white" {}
}
Category
{
SubShader {
Tags { "Queue" = "Overlay+1"
"RenderType" = "Transparent"}
CGPROGRAM
#pragma surface surf Lambert
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
void surf(Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
Pass
{
Cull Off
ZWrite Off
ZTest Greater
Lighting Off
Color[_Color]
}
Pass
{
ZTest Less
SetTexture[_MainTex] {combine texture}
}
}
}
FallBack "Diffuse"
}
Comment
Hello! thanks for you answer. Finally I just moved Pass to top.
Shader "Unlit/ThrowWall"
{
Properties
{
_Color("$$anonymous$$ain Color", Color) = (1,1,1,1)
_$$anonymous$$ainTex("Base (RGB) Gloss (A)", 2D) = "white" {}
}
SubShader {
Pass
{
Cull Off
ZWrite Off
ZTest Greater
Lighting Off
Color[_Color]
}
Pass
{
ZTest Less
SetTexture[_$$anonymous$$ainTex] {combine texture}
}
Tags { "Queue" = "Overlay+1"
"RenderType" = "Transparent"}
CGPROGRA$$anonymous$$
#pragma surface surf Lambert
struct Input {
float2 uv_$$anonymous$$ainTex;
};
sampler2D _$$anonymous$$ainTex;
void surf(Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_$$anonymous$$ainTex, IN.uv_$$anonymous$$ainTex).rgb;
}
ENDCG
}
FallBack "Diffuse"
}
This is the result and worke like I want
Your answer

Follow this Question
Related Questions
How to use materials in shaders? 0 Answers
Shining shader 1 Answer
Material.Lerp() with different shaders problem! 1 Answer
How come edititng "_Glossiness" through script doesn't work? 1 Answer