- Home /
This question was
closed Jun 18, 2017 at 07:25 PM by
Whirligig231 for the following reason:
The question is answered, right answer was accepted
Question by
Whirligig231 · Jun 15, 2017 at 12:24 AM ·
shadersshader programmingshader writingsurface shader
Shading is visible through object using surface shader
I currently have the following surface shader:
Shader "Custom/Blend 4 Textures, Vertex Color" {
Properties
{
_Layer1("Texture 1", 2D) = "black" {}
_Layer2("Texture 2", 2D) = "black" {}
_Layer3("Texture 3", 2D) = "black" {}
_Layer4("Texture 4", 2D) = "black" {}
}
SubShader
{
Tags{ "Queue" = "Geometry" }
Lighting Off
CGPROGRAM
#pragma surface surf Lambert
sampler2D _Layer1;
sampler2D _Layer2;
sampler2D _Layer3;
sampler2D _Layer4;
struct Input
{
fixed4 color : COLOR;
fixed2 uv_Layer1 : TEXCOORD0;
};
void surf(Input i, inout SurfaceOutput o)
{
half4 l1 = tex2D(_Layer1, i.uv_Layer1);
half4 l2 = tex2D(_Layer2, i.uv_Layer1);
half4 l3 = tex2D(_Layer3, i.uv_Layer1);
half4 l4 = tex2D(_Layer4, i.uv_Layer1);
float4 color = float4(1, 1, 1, 1);
color.rgb = l1.rgb;
color.rgb = l2.rgb * (1 - i.color.r) + color.rgb * i.color.r;
color.rgb = l3.rgb * (1 - i.color.g) + color.rgb * i.color.g;
color.rgb = l4.rgb * (1 - i.color.b) + color.rgb * i.color.b;
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
}
I'm using this for a model of terrain, so that I can blend four different terrain textures. However, the shading on other objects seems to be visible through the object with the surface shader:
The tree here is using the Tree Creator shaders, but with Standard it does the same thing. Therefore, I suspect the issue is with the custom surface shader. Does anyone have an idea what is wrong?
Comment
Does changing the order of the $$anonymous$$aterial in the render Queue fix this?
Follow this Question
Related Questions
How to add Zbuffer to Custom Surface Shader 1 Answer
Shader Color 1 Answer
CRT shader but NOT for camera 0 Answers