Qt Quick Particles Examples - CustomParticle▲
This is a collection of small QML examples relating to using CustomParticle in the particle system. Each example is a small QML file emphasizing a different way to use CustomParticle.
Blur Particles adds a blur effect to the particles, which increases over the particle's life time. It uses a custom vertex shader:
Sélectionnez
vertexShader:"
uniform lowp float qt_Opacity;
varying lowp float fFade;
varying lowp float fBlur;
void main() {
defaultMain();
highp float t = (qt_Timestamp - qt_ParticleData.x) / qt_ParticleData.y;
highp float fadeIn = min(t * 10., 1.);
highp float fadeOut = 1. - max(0., min((t - 0.75) * 4., 1.));
fFade = fadeIn * fadeOut * qt_Opacity;
fBlur = max(0.2 * t, t * qt_ParticleR);
}
"to propagate life time simulation to a custom fragment shader:
Sélectionnez
fragmentShader: "
uniform sampler2D source;
uniform sampler2D blurred;
varying highp vec2 qt_TexCoord0;
varying highp float fBlur;
varying highp float fFade;
void main() {
gl_FragColor = mix(texture2D(source, qt_TexCoord0), texture2D(blurred, qt_TexCoord0), min(1.0,fBlur*3.0)) * fFade;
}"which has access to both the normal image sampler and a blurred sampler, the image plus a ShaderEffect.
Fragment Shader just uses the particle system as a vertex delivery system.
Sélectionnez
fragmentShader: "
varying highp vec2 fPos;
varying lowp float fFade;
varying highp vec2 qt_TexCoord0;
void main() {//*2 because this generates dark colors mostly
highp vec2 circlePos = qt_TexCoord0*2.0 - vec2(1.0,1.0);
highp float dist = length(c


