I want to tweak the alpha value based on the distance to the camera. But I see no way of passing the vertex position on to the surface function using surface shaders. Not a problem with frag shader.
It's for fading out vegetation and creating LOD systems.
Shader "asdf" {
SubShader {
CGPROGRAM
#pragma surface surf StandardSpecular alphatest:_Cutoff addshadow vertex:vert
struct v2f {
float4 pos : TEXCOORD1;
};
struct Input {
float2 uv_Maintex;
};
v2f vert (inout appdata_base v) {
v2f o;
o.pos = mul(unity_ObjectToWorld, v.vertex);
return o;
}
void surf (Input IN, inout SurfaceOutputStandardSpecular o) {
//Need vertex or pixel distance here:
//float dist = length(v2f.pos.xyz - _WorldSpaceCameraPos.xyz);
//o.Alpha = saturate(50/dist);
}
ENDCG
}
}