I am looking for a shader that will not draw part of objects that are below 0 on the y plane. My goolge-fu has failed me so I can’t quite find one myself. Any help would be greatly appreciated.
Hey there,
You are in luck, I had just started looking at shader scripting for a previous question!
This is based on the ‘Slices via World Space Position’ shader here
Just change the y cutoff value to the desired world cutoff position in the inspector:
Shader "Custom/underY" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_YCutoff ("Y Cutoff", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
Cull Off
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
uniform float _YCutoff;
struct Input {
float3 worldPos;
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
clip (IN.worldPos.y-_YCutoff);
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Scribe