- Home /
Question by
Woj_Gabel_FertileSky · Feb 28, 2014 at 08:18 PM ·
shaderalphatransparentsame
Shader alpha value consistent with all transparent objects
Hi!
I have been recently learning to write shaders. I want to achieve effect like in the image, but I dont really know how to do that. I was trying to make a pass with blend options in a surface shader, with no luck.
I want a transparent, unlit surface shader with consistent alpha on all overlapping transparent objects. Is it possible? And I need the surface type, because of other effects that are in this shader, that I have cut out for simplicity.
Shader code for reference:
Shader "Custom/TransparentConstant" {
Properties
{
_ColorTint ("Main Color", Color) = (1,1,1,1)
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
LOD 200
Pass
{
ZWrite on
Lighting off
Blend SrcAlpha OneMinusDstAlpha
}
CGPROGRAM
#pragma surface surf Unlit alpha noambient nolightmap nodirlightmap novertexlights
half4 LightingUnlit(SurfaceOutput s, half3 lightDir, half atten)
{
return half4(s.Albedo, s.Alpha);
}
float4 _ColorTint;
struct Input {
float4 color : COLOR;
};
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = _ColorTint;
o.Alpha = _ColorTint.a;
}
ENDCG
}
Fallback "Transparent/VertexLit"
}
Comment