> On 11 Nov 2014, at 12:17, Nuno Santos <nunosan...@imaginando.pt> wrote:
> 
> 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[6].set(_rect.left(), _rect.bottom(), r * a, g * a, b * a, a );

Use premultiplied alpha as the docs state, otherwise you will end up getting 
something closer to additive blending which is not what you are after in this 
case.

cheers,
Gunnar

> 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
> 
> 
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to