If not already familiar; please refer <link linkend="cogl-Blend-Strings">here</link> for an overview of what blend strings are, and their syntax.
Blending occurs after the alpha test function, and combines fragments with the framebuffer.
Currently the only blend function Cogl exposes is ADD
. So any valid blend statements will be of the form:
<channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))
This is the list of source-names usable as blend factors: <itemizedlist> <listitem><para>SRC_COLOR: The color of the in comming fragment</para></listitem> <listitem><para>DST_COLOR: The color of the framebuffer</para>< /listitem> <listitem><para>CONSTANT: The constant set via set_blend_constant</para></listitem> </itemizedlist>
The source names can be used according to the <link linkend="cogl-Blend-String-syntax">color-source and factor syntax</link>, so for example "(1-SRC_COLOR[A])" would be a valid factor, as would "(CONSTANT[RGB])"
These can also be used as factors: <itemizedlist> <listitem>0: (0, 0, 0, 0)</listitem> <listitem>1: (1, 1, 1, 1 )</listitem> <listitem>SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])</listitem> < /itemizedlist>
<note>Remember; all color components are normalized to the range [0, 1] before computing the result of blending.</note>
<example id="cogl-Blend-Strings-blend-unpremul"> <title>Blend Strings/1</title> <para>Blend a non-premultiplied source over a destination with premultiplied alpha:</para> <programlisting> "RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR* (1-SRC_COLOR[A]))" "A = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))" </programlisting> </example>
<example id="cogl-Blend-Strings-blend-premul"> <title>Blend Strings/2</title> <para>Blend a premultiplied source over a destination with premultiplied alpha</para> <programlisting> "RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]) )" </programlisting> </example>
The default blend string is:
RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))
That gives normal alpha-blending when the calculated color for the pipeline is in premultiplied form.
this |
A Pipeline object |
blend_string |
A <link linkend="cogl-Blend-Strings">Cogl blend string</link> describing the desired blend function. |
true if the blend string was successfully parsed, and the described blending is supported by the underlying driver/hardware. If there was an error, false is returned and throws is set accordingly (if present). |