I’m trying to make fade in/out object. All of what I found on web is change color.a in a transparent shader. I add the transparent/Diffuse shader (alpha = 1) and don’t get result similar as Diffuse shader.
How can I fix that or may be you know better solution for making a fade in/out object?
This is because transparent shaders do not write to the depth buffer. So for complex geometry like yours, you will get “wrong rendering order” effects.
A workaround could be making a shader that is transparent, but also writes to the depth buffer, perhaps in a separate pass. Here’s an example:
Shader "Transparent/Diffuse ZWrite" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
}
SubShader {
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
// extra pass that renders to depth buffer only
Pass {
ZWrite On
ColorMask 0
}
// paste in forward rendering passes from Transparent/Diffuse
UsePass "Transparent/Diffuse/FORWARD"
}
Fallback "Transparent/VertexLit"
}