This question was
closed Jul 15, 2017 at 04:22 PM by
Shifty-Geezer for the following reason:
Didn't notice the Help Room is for noob questions, so posted in wrong place. Unity needs to explain the structure as noob questions still being posted in the Default (which is badly named as I thought that was the 'default option', not a forum choice)
Question by
Shifty-Geezer · Jul 15, 2017 at 03:51 PM ·
rendertextureimage effectsalpha-channel
Does alpha blending work on image effects?
I've two cameras rendering my background and foreground separately, and want to composite them with an image effect. This is working except that the alpha value for the foreground provided as 'src' in the OnRenderImage() is always 1, despite setting the camera's clear flags to (0,0,0,0).
half4 frag_composite(v2f_img i) : SV_Target {
float4 s;
s = tex2D(_MainTex, i.uv);
s = lerp(s, _black, s.a);
return s;
}
ENDCG
Subshader {
Pass { // 0, quarter size
ZTest Always Cull Off ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag_composite
ENDCG
}
}
private void OnRenderImage(RenderTexture src, RenderTexture dest){
Graphics.Blit(src, dest,shader_compositor);
}
This just draws _MainTex without drawing yellow in the transparent background.
Comment