Hi,
I am kinda new when it comes to shaders, so I am trying to make a few things in order to learn.
One the things i am trying to do is a flage made of four textures in differents layers, each layer with its own color. The thing is, it is almost ok, but th parts that i need not being transparent are a little see through
here’s my shader:
Shader "Custom/CustomLayers"
{
Properties
{
_FirstTex("Texture", 2D) = "white" {}
_FirstColor("Color", Color) = (1,1,1,1)
_SecondTex("Texture", 2D) = "white" {}
_SecondColor("Color", Color) = (1,1,1,1)
_ThirdTex("Texture", 2D) = "white" {}
_ThirdColor("Color", Color) = (1,1,1,1)
_FourthTex("Texture", 2D) = "white" {}
_FourthColor("Color", Color) = (1,1,1,1)
}
SubShader
{
Tags { "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows alpha
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _FirstTex;
sampler2D _SecondTex;
sampler2D _ThirdTex;
sampler2D _FourthTex;
struct Input
{
float2 uv_FirstTex;
float2 uv_SecondTex;
float2 uv_ThirdTex;
float2 uv_FourthTex;
};
fixed4 _FirstColor;
fixed4 _SecondColor;
fixed4 _ThirdColor;
fixed4 _FourthColor;
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o)
{
// Albedo comes from a texture tinted by color
fixed4 c0 = tex2D(_FirstTex, IN.uv_FirstTex) * _FirstColor;
fixed4 c1 = tex2D(_SecondTex, IN.uv_SecondTex) * _SecondColor;
fixed4 c2 = tex2D(_ThirdTex, IN.uv_ThirdTex) * _ThirdColor;
fixed4 c3 = tex2D(_FourthTex, IN.uv_FourthTex) * _FourthColor;
fixed4 tt = c0 + c1 + c2 + c3;
tt.rgb = lerp(c0.rgb, c1.rgb, c1.a);
tt.rgb = lerp(tt.rgb, c2.rgb, c2.a);
tt.rgb = lerp(tt.rgb, c3.rgb, c3.a);
o.Albedo = tt.rgb;
o.Alpha = tt.a;
}
ENDCG
}
FallBack "Diffuse"
}
Anyone can light my candle?