Hello everyone;
Consider the attached image of a bottle as rendered in unity with the shader below.
The white arrow and the checker grid are added via post processing to emphasize the problem here:
I want the plastic of the bottle to appear translucent, and the label to be solid. When the plastic overlaps the label, the label is also made translucent.
The shader code is based off of what is described at the end of this article: Unity - Manual: ShaderLab: legacy alpha testing
The image is being rendered to a texture, which is how I scraped it for this post.
I’m aware that there exists the Transparent/Diffuse shader, but areas containing non-one alpha chanels render black for some reason.
What I find curious, is that “Blend SrcAlpha OneMinusSrcAlpha” causes the same results in other cases that I’ve experimented with.
Any help would be much appreciated.
Thanks,
Lunpa
[edit]
It occurs to me in retrospect that the red/green/gray color scheme in the attached image might be hard to see for some. If so, let me know, and I’ll post a different version.
[/edit]
Shader "Custom/Transparent" {
Properties {
_MainTex ("Texture", 2D) = "white" { }
}
SubShader {
Cull Off
Pass {
AlphaTest Equal 1.0
SetTexture [_MainTex] {}
}
Pass {
ZWrite off
ZTest Less
AlphaTest Less 1.0
Blend SrcAlpha OneMinusSrcAlpha
SetTexture [_MainTex] {}
}
}
}



