Shader "Custom/NewShader" {
Properties
{
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_GeometryDist ("_GeometryDist", float) = 100
_TextureDist ("_TextureDist", float) = 150
}
SubShader
{
Tags { "RenderType"="Opaque" }
CGPROGRAM
#pragma only_renderers d3d9 gles
#pragma glsl
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
fixed4 _Color;
float _GeometryDist;
float _TextureDist;
struct Input
{
float2 uv_MainTex;
float z;
};
void vert (inout appdata_full v, out Input o)
{
//o.z = -(mul( UNITY_MATRIX_MV, v.vertex ).z * _ProjectionParams.w) * _MixMtl;
o.z = -mul( UNITY_MATRIX_MV, v.vertex ).z;
o.z = smoothstep(_GeometryDist, _TextureDist, o.z);
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = lerp(_Color.rgb, c.rgb, IN.z);
o.Alpha = c.a * _Color.a;
}
ENDCG
}
}