Hi everyone. I’m trying to make a script that fade out objects between camera and player and then show them again. It works fine with Unity Standard Shader and you can also choose the rendering mode to use (fade, cutout, trasparent and opaque).
Problem is I want shadows to remain when the object fade out. So I’m trying to write custom shaders that keep shadows, ignoring transparency.
- Fade shader with shadows works well.
dirtythornyelkhound
- Cutout one does its job removing the object but shadows on object surface remain visible.
mediumpinkblackrussianterrier
Shader "Custom/CutoutKeepShadows" {
Properties {
_Color ("Color", Color) = (1, 1, 1, 1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0, 1)) = 0.5
}
SubShader
{
ZWrite Off
Tags {"Queue" = "Geometry"}
LOD 200
Lighting Off
CGPROGRAM
#pragma surface surf Standard fullforwardshadows
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
fixed4 _Color;
float _Cutoff;
//#pragma instancing_options assumeuniformscaling
UNITY_INSTANCING_BUFFER_START(Props)
// put more per-instance properties here
UNITY_INSTANCING_BUFFER_END(Props)
void surf (Input IN, inout SurfaceOutputStandard o) {
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
clip(c.a-_Cutoff);
}
ENDCG
}
FallBack "VertexLit"
}
- I have no ideas for the trasparent one… I just want to generate shadows using a constant alpha value.
Every help will be very appreciated! ![]()