I try to understand how blend works.
First, I wrote a shader, which paints material with red color.
Then, I added Blend One Zero
instruction. According to manual, it should return color already present on screen + 0*(generated color)
as output color.
I thought that “color already present on screen” refers to color of pixels hidden by the object and “generated color” to pixels of the object. Thus, the shader should draw picture hidden by the object and represent an invisible material.
I created a cube, assigned material with my shader to it and put the cube between a camera and a sprite. The result looks this way:
It doesn’t differ from Blend One One
or completely disabled Blend.
Can you explain it?
Shader "Custom/Test"
{
SubShader
{
Pass
{
Blend One Zero
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
float4 vert(appdata_base v) : POSITION
{
return mul (UNITY_MATRIX_MVP, v.vertex);
}
fixed4 frag(float4 sp:WPOS) : COLOR
{
return fixed4(1,0,0,1);
}
ENDCG
}
}
}