[Qt-interest] GLSL and two semi-transparent textures
Josiah Bryan
jbryan at productiveconcepts.com
Wed Aug 11 13:24:14 CEST 2010
Sean Harmer wrote:
> Hi,
>
> On Wednesday 11 August 2010 02:31:11 Josiah Bryan wrote:
>
>> Josiah Bryan wrote:
>>
>>> Just one problem - When I draw two textures, one over top of the other
>>> (think a PiP), and the top (pip) has an alpha channel (say, the Qt cube
>>> logo from the pbuffers examples), the qglClearColor shows thru in the
>>> transparent areas of the top texture, NOT the bottom texture!
>>>
>
> I've not had time to look at your code in detail but from your description it
> sounds like the fragment shader is hard-wired to blend in the clear color as
> opposed to the existing framebuffer color when your incoming fragment has an
> alpha channel.
>
> Can you post a small compilable example that reproduces the problem please?
> Perhaps one that uses static images as the textures?
>
Possibly - but first, how about just the shader itself?
// Paints an RGB(A) frame.
static const char *qt_glsl_rgbShaderProgram =
"uniform sampler2D texRgb;\n"
"uniform mediump mat4 colorMatrix;\n"
"varying highp vec2 textureCoord;\n"
"void main(void)\n"
"{\n"
" highp vec4 color = vec4(texture2D(texRgb,
textureCoord.st).rgb, 1.0);\n"
" color = colorMatrix * color;\n"
" gl_FragColor = vec4(color.rgb, texture2D(texRgb,
textureCoord.st).a);\n"
"}\n";
Note this is straight fr
// Paints an RGB(A) frame.
static const char *qt_glsl_rgbShaderProgram =
"uniform sampler2D texRgb;\n"
"uniform mediump mat4 colorMatrix;\n"
"varying highp vec2 textureCoord;\n"
"void main(void)\n"
"{\n"
" highp vec4 color = vec4(texture2D(texRgb,
textureCoord.st).rgb, 1.0);\n"
" color = colorMatrix * color;\n"
" gl_FragColor = vec4(color.rgb, texture2D(texRgb,
textureCoord.st).a);\n"
"}\n";
Anything stand out to you in the shader? It looks like it correctly uses
the original alpha from the texture itself there in the last line with
the vec4 call.
-Josiah
More information about the Qt-interest-old
mailing list