I know nothing of making shaders in Unity, and I’m trying to make a Solid Color shader which is transparent. I currently have the following, which works:
Properties
{
_Color ("Color", Color) = (1,1,1,.5)
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 100
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
Lighting Off
Color [_Color]
}
}
The problem is though that you can see parts of the model itself that are behind it:
Anyone knows how to fix this? I need/want a solid color, without those bright spots.
This is an old question, but I implemented the two pass shader (with texturing) suggested by @ScroodgeM and it works great. This was tested on Unity 4 and the vertex/fragment shaders were based on the samples from the Unity docs here.
The secret ShaderLab sauce is ColorMask and Blend, as seen on the stoned dino below. Enjoy! =)
Shader below is do what you want. But your platform should support GrabPass technology. this can be not supported by some mobile platforms.
i can propound 2 more ways without grabpass:
create a 2-pass shader that first draws only to alpha-channel and the second draws just color based on alpha value, this can be achieved by blending options
create a object mask using render-texture and put it to main camera on top. this way is same as previous but uses render texture instead of shader calculations and blending
anyway issue is not so simple. with a just default blending two surfaces will be drawn twice and it will look not same as single surface.
Hello,
I am trying to achieve exactly this effect in my URP project. Neither of the two shaders work in my environment. Is there a solution for current Unity version?
Thanks , Jan