Hi there.
Is it possible to write a shader that does not render its own transparency into the alpha channel of the camera image, but some custom value?
I'm using the glow post processing effect that adds a glow based on the alpha channel that is rendered in the scene (The value that can be seen if you switch the view port in Unity from RGB to Alpha in the top left dropdown list). I also use semi-transparent objects who's glow behavior is hard to control: They can not carry a complete glow when they are semi transparent, because alpha 1 = full glow but also full opacity.
Maybe someone can also shed some light into the relation between the rendered image's alpha channel ("alpha-buffer"?) and alpha value of a shader?
Thank you!
Take this simple vertex lit transparent ShaderLab code for instance:
Shader "Transparent/Vertex Lit Alpha" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_Emissive ("Emissive", Color) = (0,0,0,0)
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Lighting Off
Material {
Diffuse [_Color]
Ambient (1,1,1,1)
Emission [_Emissive]
}
Lighting On
SeparateSpecular On
SetTexture [_MainTex] {
Combine texture * primary DOUBLE, texture * primary
}
}
}
}
If I understand correctly, the statements
Diffuse [_Color]
and
Combine texture * primary DOUBLE, texture * primary
together define the transparency as well as the rendered alpha of the object. If I wanted an additional property like
_RenderedAlpha ("RenderedAlpha", Range(0,1)) = 0.5
that should not influence the object's transparency, but only the level of gray that is visible if I switch from RGB to alpha view... how could I go about doing that?