71 lines
1.4 KiB
Plaintext
71 lines
1.4 KiB
Plaintext
Shader "Custom/Transparent Diffuse (Improved)" {
|
|
Properties {
|
|
_Color("Main Color", Color) = (1, 1, 1, 1)
|
|
_MainTex("Base (RGB) Trans (A)", 2D) = "white" { }
|
|
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
|
_Metallic ("Metallic", Range(0,1)) = 0.0
|
|
|
|
_BumpMap ("Normalmap", 2D) = "bump" {}
|
|
}
|
|
|
|
SubShader {
|
|
Tags { "Queue"="Transparent" "IgnoreProjector"="False" "RenderType"="Transparent" }
|
|
|
|
// First Pass: Only render alpha (A) channel
|
|
Pass {
|
|
ColorMask A
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
fixed4 _Color;
|
|
|
|
float4 vert(float4 vertex:POSITION) : SV_POSITION {
|
|
return UnityObjectToClipPos(vertex);
|
|
}
|
|
|
|
fixed4 frag() : SV_Target {
|
|
return _Color;
|
|
}
|
|
|
|
ENDCG
|
|
}
|
|
|
|
// Second Pass: Now render color (RGB) channel
|
|
ColorMask RGB
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
CGPROGRAM
|
|
#pragma surface surf Standard alpha
|
|
|
|
sampler2D _MainTex;
|
|
fixed4 _Color;
|
|
|
|
sampler2D _BumpMap;
|
|
|
|
half _Glossiness;
|
|
half _Metallic;
|
|
|
|
struct Input {
|
|
float4 color:COLOR;
|
|
float2 uv_MainTex;
|
|
float2 uv_BumpMap;
|
|
};
|
|
|
|
void surf(Input IN, inout SurfaceOutputStandard o) {
|
|
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
|
o.Albedo = c.rgb;
|
|
o.Alpha = c.a;
|
|
o.Metallic = _Metallic;
|
|
o.Smoothness = _Glossiness;
|
|
|
|
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
|
|
}
|
|
ENDCG
|
|
}
|
|
|
|
Fallback "Legacy Shaders/Transparent/Diffuse"
|
|
}
|