I am trying to export images with transparency, ie not composite them on a white background. So … anyway. I am wondering is it possible to do this
char *fragmentTransComposite =
"uniform sampler2D tex1;
"
"uniform sampler2D tex2;
"
"void main()
"
"{
"
"float alpaTotal;
"
"vec4 colourFinal;
"
"vec4 colour1;
"
"vec4 colour2;
"
"colour1 = texture2D( tex1, gl_TexCoord[0].st );
"
"colour2 = texture2D( tex2, gl_TexCoord[0].st );
"
"alphaTotal = colour1.a + colour2.a;
"
"colour1.rgb = colour1.rgb * (colour1.a/alphaTotal);
"
"colour2.rgb = colour2.rgb * (colour2.a/alphaTotal);
"
"colourFinal.rgb = colour1.rgb + colour2.rgb;
"
"colourFinal.a = alphaTotal;
" // <-- will get clamped
"gl_FragColor = outColour;
"
"}
";
without a shader? With just the standard blending modes.
Essentially for alpha I just want to add the values together.
For colour I want to multiply them by
SourceColour * SourceAlpha / Alpha Total
then
DestColour * DestAlpha / Alpha Total
then sum them together