[Interest] Using QSGVertexColorMaterial transparency

Nuno Santos nunosantos at imaginando.pt
Tue Nov 11 12:17:04 CET 2014


Hi,

I want to give a flashing effect on a quad. My idea is to draw two quads. One with the base color, and one above it with a white color but with transparency oscillating. This will give the flashing effect. 

I’m not being able to do it with QSGVertexColorMaterial. There is no opacity on quad there is placed above. I have found the following post answer but I still can’t understand it quite well.

"The blend mode used by the scene graph is glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) which gives you premultiplied blending. A “valid” color in premultiplied mode must have r <= a (same for g and b of course). If it doesn’t, then that color channel will overflow, giving you additive blending instead.”

Will it be possible to implement this with a QSGVertexColorMaterial?

// quad below

v[0].set(_rect.left(), _rect.bottom(), r, g, b, a);
v[1].set(_rect.left(), _rect.top(), r, g, b, a);
v[2].set(_rect.right(), _rect.top(), r, g, b, a);

v[3].set(_rect.left(), _rect.bottom(), r, g, b, a);
v[4].set(_rect.right(), _rect.top(), r, g, b, a);
v[5].set(_rect.right(), _rect.bottom(), r, g, b, a);

// flashing quad above

a=128+128*qSin(phase),r=0xff,g=0xff,b=0xff;

v[6].set(_rect.left(), _rect.bottom(), r, g, b, a);
v[7].set(_rect.left(), _rect.top(), r, g, b, a);
v[8].set(_rect.right(), _rect.top(), r, g, b, a);

v[9].set(_rect.left(), _rect.bottom(), r, g, b, a);
v[10].set(_rect.right(), _rect.top(), r, g, b, a);
v[11].set(_rect.right(), _rect.bottom(), r, g, b, a);

Thanks,

Regards,

Nuno





More information about the Interest mailing list