dukey
02-28-2011, 04:51 PM
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;\n"
"uniform sampler2D tex2;\n"
"void main()\n"
"{\n"
"float alpaTotal;\n"
"vec4 colourFinal;\n"
"vec4 colour1;\n"
"vec4 colour2;\n"
"colour1 = texture2D( tex1, gl_TexCoord[0].st );\n"
"colour2 = texture2D( tex2, gl_TexCoord[0].st );\n"
"alphaTotal = colour1.a + colour2.a;\n"
"colour1.rgb = colour1.rgb * (colour1.a/alphaTotal);\n"
"colour2.rgb = colour2.rgb * (colour2.a/alphaTotal);\n"
"colourFinal.rgb = colour1.rgb + colour2.rgb;\n"
"colourFinal.a = alphaTotal;\n" // <-- will get clamped
"gl_FragColor = outColour;\n"
"}\n";
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
char *fragmentTransComposite =
"uniform sampler2D tex1;\n"
"uniform sampler2D tex2;\n"
"void main()\n"
"{\n"
"float alpaTotal;\n"
"vec4 colourFinal;\n"
"vec4 colour1;\n"
"vec4 colour2;\n"
"colour1 = texture2D( tex1, gl_TexCoord[0].st );\n"
"colour2 = texture2D( tex2, gl_TexCoord[0].st );\n"
"alphaTotal = colour1.a + colour2.a;\n"
"colour1.rgb = colour1.rgb * (colour1.a/alphaTotal);\n"
"colour2.rgb = colour2.rgb * (colour2.a/alphaTotal);\n"
"colourFinal.rgb = colour1.rgb + colour2.rgb;\n"
"colourFinal.a = alphaTotal;\n" // <-- will get clamped
"gl_FragColor = outColour;\n"
"}\n";
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