diff options
22 files changed, 199 insertions, 76 deletions
diff --git a/src/particles/CMakeLists.txt b/src/particles/CMakeLists.txt index 0eb0b89587..2fb7617f87 100644 --- a/src/particles/CMakeLists.txt +++ b/src/particles/CMakeLists.txt @@ -64,12 +64,14 @@ qt_internal_add_resource(QuickParticles "particles" ${particles_resource_files} ) set(particles1_resource_files + "shaders_ng/imageparticle_simplepoint.frag.qsb" + "shaders_ng/imageparticle_simplepoint.vert.qsb" + "shaders_ng/imageparticle_coloredpoint.frag.qsb" + "shaders_ng/imageparticle_coloredpoint.vert.qsb" "shaders_ng/imageparticle_colored.frag.qsb" "shaders_ng/imageparticle_colored.vert.qsb" "shaders_ng/imageparticle_deformed.frag.qsb" "shaders_ng/imageparticle_deformed.vert.qsb" - "shaders_ng/imageparticle_simple.frag.qsb" - "shaders_ng/imageparticle_simple.vert.qsb" "shaders_ng/imageparticle_sprite.frag.qsb" "shaders_ng/imageparticle_sprite.vert.qsb" "shaders_ng/imageparticle_tabled.frag.qsb" diff --git a/src/particles/particles.pri b/src/particles/particles.pri index e3d83c431c..975ae0e070 100644 --- a/src/particles/particles.pri +++ b/src/particles/particles.pri @@ -63,12 +63,14 @@ SOURCES += \ $$PWD/qquickgroupgoal.cpp OTHER_FILES += \ + $$PWD/shaders_ng/imageparticle_simplepoint.frag.qsb \ + $$PWD/shaders_ng/imageparticle_simplepoint.vert.qsb \ + $$PWD/shaders_ng/imageparticle_coloredpoint.frag.qsb \ + $$PWD/shaders_ng/imageparticle_coloredpoint.vert.qsb \ $$PWD/shaders_ng/imageparticle_colored.frag.qsb \ $$PWD/shaders_ng/imageparticle_colored.vert.qsb \ $$PWD/shaders_ng/imageparticle_deformed.frag.qsb \ $$PWD/shaders_ng/imageparticle_deformed.vert.qsb \ - $$PWD/shaders_ng/imageparticle_simple.frag.qsb \ - $$PWD/shaders_ng/imageparticle_simple.vert.qsb \ $$PWD/shaders_ng/imageparticle_sprite.frag.qsb \ $$PWD/shaders_ng/imageparticle_sprite.vert.qsb \ $$PWD/shaders_ng/imageparticle_tabled.frag.qsb \ diff --git a/src/particles/particles.qrc b/src/particles/particles.qrc index 5e76563842..a21d149447 100644 --- a/src/particles/particles.qrc +++ b/src/particles/particles.qrc @@ -6,15 +6,17 @@ <file>particleresources/star.png</file> </qresource> <qresource prefix="/particles"> - <file>shaders_ng/imageparticle_simple.vert.qsb</file> - <file>shaders_ng/imageparticle_simple.frag.qsb</file> - <file>shaders_ng/imageparticle_tabled.vert.qsb</file> - <file>shaders_ng/imageparticle_tabled.frag.qsb</file> + <file>shaders_ng/imageparticle_simplepoint.vert.qsb</file> + <file>shaders_ng/imageparticle_simplepoint.frag.qsb</file> + <file>shaders_ng/imageparticle_coloredpoint.vert.qsb</file> + <file>shaders_ng/imageparticle_coloredpoint.frag.qsb</file> + <file>shaders_ng/imageparticle_colored.vert.qsb</file> + <file>shaders_ng/imageparticle_colored.frag.qsb</file> <file>shaders_ng/imageparticle_deformed.vert.qsb</file> <file>shaders_ng/imageparticle_deformed.frag.qsb</file> + <file>shaders_ng/imageparticle_tabled.vert.qsb</file> + <file>shaders_ng/imageparticle_tabled.frag.qsb</file> <file>shaders_ng/imageparticle_sprite.vert.qsb</file> <file>shaders_ng/imageparticle_sprite.frag.qsb</file> - <file>shaders_ng/imageparticle_colored.vert.qsb</file> - <file>shaders_ng/imageparticle_colored.frag.qsb</file> </qresource> </RCC> diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index 1331032e7a..d2f418021a 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -304,13 +304,13 @@ private: QSGMaterialType SpriteMaterial::m_type; -class ColoredMaterialRhiShader : public QSGMaterialShader +class ColoredPointMaterialRhiShader : public QSGMaterialShader { public: - ColoredMaterialRhiShader() + ColoredPointMaterialRhiShader() { - setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_colored.vert.qsb")); - setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_colored.frag.qsb")); + setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_coloredpoint.vert.qsb")); + setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_coloredpoint.frag.qsb")); } bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override @@ -350,6 +350,34 @@ public: } }; +class ColoredPointMaterial : public ImageMaterial +{ +public: + QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override { + Q_UNUSED(renderMode); + return new ColoredPointMaterialRhiShader; + } + QSGMaterialType *type() const override { return &m_type; } + + ImageMaterialData *state() override { return &m_state; } + +private: + static QSGMaterialType m_type; + ImageMaterialData m_state; +}; + +QSGMaterialType ColoredPointMaterial::m_type; + +class ColoredMaterialRhiShader : public ColoredPointMaterialRhiShader +{ +public: + ColoredMaterialRhiShader() + { + setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_colored.vert.qsb")); + setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_colored.frag.qsb")); + } +}; + class ColoredMaterial : public ImageMaterial { public: @@ -368,13 +396,13 @@ private: QSGMaterialType ColoredMaterial::m_type; -class SimpleMaterialRhiShader : public QSGMaterialShader +class SimplePointMaterialRhiShader : public QSGMaterialShader { public: - SimpleMaterialRhiShader() + SimplePointMaterialRhiShader() { - setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_simple.vert.qsb")); - setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_simple.frag.qsb")); + setShaderFileName(VertexStage, QStringLiteral(":/particles/shaders_ng/imageparticle_simplepoint.vert.qsb")); + setShaderFileName(FragmentStage, QStringLiteral(":/particles/shaders_ng/imageparticle_simplepoint.frag.qsb")); } bool updateUniformData(RenderState &renderState, QSGMaterial *newMaterial, QSGMaterial *) override @@ -414,12 +442,12 @@ public: } }; -class SimpleMaterial : public ImageMaterial +class SimplePointMaterial : public ImageMaterial { public: QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override { Q_UNUSED(renderMode); - return new SimpleMaterialRhiShader; + return new SimplePointMaterialRhiShader; } QSGMaterialType *type() const override { return &m_type; } @@ -430,7 +458,7 @@ private: ImageMaterialData m_state; }; -QSGMaterialType SimpleMaterial::m_type; +QSGMaterialType SimplePointMaterial::m_type; void fillUniformArrayFromImage(float* array, const QImage& img, int size) { @@ -814,7 +842,7 @@ void QQuickImageParticle::setColor(const QColor &color) m_color = color; emit colorChanged(); m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -825,7 +853,7 @@ void QQuickImageParticle::setColorVariation(qreal var) m_color_variation = var; emit colorVariationChanged(); m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -836,7 +864,7 @@ void QQuickImageParticle::setAlphaVariation(qreal arg) emit alphaVariationChanged(arg); } m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -847,7 +875,7 @@ void QQuickImageParticle::setAlpha(qreal arg) emit alphaChanged(arg); } m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -858,7 +886,7 @@ void QQuickImageParticle::setRedVariation(qreal arg) emit redVariationChanged(arg); } m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -869,7 +897,7 @@ void QQuickImageParticle::setGreenVariation(qreal arg) emit greenVariationChanged(arg); } m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -880,7 +908,7 @@ void QQuickImageParticle::setBlueVariation(qreal arg) emit blueVariationChanged(arg); } m_explicitColor = true; - if (perfLevel < Colored) + if (perfLevel < ColoredPoint) reset(); } @@ -1066,30 +1094,45 @@ void QQuickImageParticle::createEngine() reset(); } -static QSGGeometry::Attribute SimpleParticle_Attributes[] = { +static QSGGeometry::Attribute SimplePointParticle_Attributes[] = { QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), // Position QSGGeometry::Attribute::create(1, 4, QSGGeometry::FloatType), // Data QSGGeometry::Attribute::create(2, 4, QSGGeometry::FloatType) // Vectors }; -static QSGGeometry::AttributeSet SimpleParticle_AttributeSet = +static QSGGeometry::AttributeSet SimplePointParticle_AttributeSet = { 3, // Attribute Count ( 2 + 4 + 4 ) * sizeof(float), - SimpleParticle_Attributes + SimplePointParticle_Attributes }; -static QSGGeometry::Attribute ColoredParticle_Attributes[] = { +static QSGGeometry::Attribute ColoredPointParticle_Attributes[] = { QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), // Position QSGGeometry::Attribute::create(1, 4, QSGGeometry::FloatType), // Data QSGGeometry::Attribute::create(2, 4, QSGGeometry::FloatType), // Vectors QSGGeometry::Attribute::create(3, 4, QSGGeometry::UnsignedByteType), // Colors }; -static QSGGeometry::AttributeSet ColoredParticle_AttributeSet = +static QSGGeometry::AttributeSet ColoredPointParticle_AttributeSet = { 4, // Attribute Count ( 2 + 4 + 4 ) * sizeof(float) + 4 * sizeof(uchar), + ColoredPointParticle_Attributes +}; + +static QSGGeometry::Attribute ColoredParticle_Attributes[] = { + QSGGeometry::Attribute::create(0, 2, QSGGeometry::FloatType, true), // Position + QSGGeometry::Attribute::create(1, 4, QSGGeometry::FloatType), // Data + QSGGeometry::Attribute::create(2, 4, QSGGeometry::FloatType), // Vectors + QSGGeometry::Attribute::create(3, 4, QSGGeometry::UnsignedByteType), // Colors + QSGGeometry::Attribute::create(4, 4, QSGGeometry::UnsignedByteType), // TexCoord +}; + +static QSGGeometry::AttributeSet ColoredParticle_AttributeSet = +{ + 5, // Attribute Count + ( 2 + 4 + 4 ) * sizeof(float) + (4 + 4) * sizeof(uchar), ColoredParticle_Attributes }; @@ -1243,9 +1286,9 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) perfLevel = Deformable; } else if (m_alphaVariation || m_alpha != 1.0 || m_color.isValid() || m_color_variation || m_redVariation || m_blueVariation || m_greenVariation) { - perfLevel = Colored; + perfLevel = ColoredPoint; } else { - perfLevel = Simple; + perfLevel = SimplePoint; } for (auto groupId : groupIds()) { @@ -1270,10 +1313,10 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) // Points with a size other than 1 are an optional feature with QRhi // because some of the underlying APIs have no support for this. // Therefore, avoid the point sprite path with APIs like Direct3D. - if (perfLevel < Deformable && !m_rhi->isFeatureSupported(QRhi::VertexShaderPointSize)) - perfLevel = Deformable; + if (perfLevel < Colored && !m_rhi->isFeatureSupported(QRhi::VertexShaderPointSize)) + perfLevel = Colored; - if (perfLevel >= Colored && !m_color.isValid()) + if (perfLevel >= ColoredPoint && !m_color.isValid()) m_color = QColor(Qt::white);//Hidden default, but different from unset clearShadows(); @@ -1356,10 +1399,16 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) m_material = new ColoredMaterial; } Q_FALLTHROUGH(); + case ColoredPoint: + { + if (!m_material) + m_material = new ColoredPointMaterial; + } + Q_FALLTHROUGH(); default://Also Simple { if (!m_material) - m_material = new SimpleMaterial; + m_material = new SimplePointMaterial; ImageMaterialData *state = getState(m_material); if (!imageLoaded) { if (!m_image || !m_image->pix.isReady()) { @@ -1402,13 +1451,15 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) else if (perfLevel == Deformable) g = new QSGGeometry(DeformableParticle_AttributeSet, vCount, iCount); else if (perfLevel == Colored) - g = new QSGGeometry(ColoredParticle_AttributeSet, count, 0); + g = new QSGGeometry(ColoredParticle_AttributeSet, vCount, iCount); + else if (perfLevel == ColoredPoint) + g = new QSGGeometry(ColoredPointParticle_AttributeSet, count, 0); else //Simple - g = new QSGGeometry(SimpleParticle_AttributeSet, count, 0); + g = new QSGGeometry(SimplePointParticle_AttributeSet, count, 0); node->setFlag(QSGNode::OwnsGeometry); node->setGeometry(g); - if (perfLevel <= Colored){ + if (perfLevel <= ColoredPoint){ g->setDrawingMode(QSGGeometry::DrawPoints); if (m_debugMode) qDebug("Using point sprites"); @@ -1425,8 +1476,10 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); else if (perfLevel == Deformable) initTexCoords<DeformableVertex>((DeformableVertex*)g->vertexData(), vCount); + else if (perfLevel == Colored) + initTexCoords<ColoredVertex>((ColoredVertex*)g->vertexData(), vCount); - if (perfLevel > Colored){ + if (perfLevel > ColoredPoint){ quint16 *indices = g->indexDataAsUShort(); for (int i=0; i < count; ++i) { int o = i * 4; @@ -1557,7 +1610,8 @@ void QQuickImageParticle::prepareNextFrame(QSGNode **node) case Tabled: case Deformable: case Colored: - case Simple: + case ColoredPoint: + case SimplePoint: default: //Also Simple getState(m_material)->timestamp = time; break; @@ -1762,6 +1816,8 @@ void QQuickImageParticle::initialize(int gIdx, int pIdx) } Q_FALLTHROUGH(); case Colored: + Q_FALLTHROUGH(); + case ColoredPoint: //Color initialization // Particle color if (m_explicitColor) { @@ -1792,7 +1848,8 @@ void QQuickImageParticle::commit(int gIdx, int pIdx) SpriteVertex *spriteVertices = (SpriteVertex *) node->geometry()->vertexData(); DeformableVertex *deformableVertices = (DeformableVertex *) node->geometry()->vertexData(); ColoredVertex *coloredVertices = (ColoredVertex *) node->geometry()->vertexData(); - SimpleVertex *simpleVertices = (SimpleVertex *) node->geometry()->vertexData(); + ColoredPointVertex *coloredPointVertices = (ColoredPointVertex *) node->geometry()->vertexData(); + SimplePointVertex *simplePointVertices = (SimplePointVertex *) node->geometry()->vertexData(); switch (perfLevel){//No automatic fall through intended on this one case Sprites: spriteVertices += pIdx*4; @@ -1883,8 +1940,8 @@ void QQuickImageParticle::commit(int gIdx, int pIdx) } break; case Colored: - coloredVertices += pIdx*1; - for (int i=0; i<1; i++){ + coloredVertices += pIdx*4; + for (int i=0; i<4; i++){ coloredVertices[i].x = datum->x - m_systemOffset.x(); coloredVertices[i].y = datum->y - m_systemOffset.y(); coloredVertices[i].t = datum->t; @@ -1903,19 +1960,40 @@ void QQuickImageParticle::commit(int gIdx, int pIdx) } } break; - case Simple: - simpleVertices += pIdx*1; + case ColoredPoint: + coloredPointVertices += pIdx*1; + for (int i=0; i<1; i++){ + coloredPointVertices[i].x = datum->x - m_systemOffset.x(); + coloredPointVertices[i].y = datum->y - m_systemOffset.y(); + coloredPointVertices[i].t = datum->t; + coloredPointVertices[i].lifeSpan = datum->lifeSpan; + coloredPointVertices[i].size = datum->size; + coloredPointVertices[i].endSize = datum->endSize; + coloredPointVertices[i].vx = datum->vx; + coloredPointVertices[i].vy = datum->vy; + coloredPointVertices[i].ax = datum->ax; + coloredPointVertices[i].ay = datum->ay; + if (m_explicitColor && datum->colorOwner != this) { + QQuickParticleData* shadow = getShadowDatum(datum); + coloredPointVertices[i].color = shadow->color; + } else { + coloredPointVertices[i].color = datum->color; + } + } + break; + case SimplePoint: + simplePointVertices += pIdx*1; for (int i=0; i<1; i++){ - simpleVertices[i].x = datum->x - m_systemOffset.x(); - simpleVertices[i].y = datum->y - m_systemOffset.y(); - simpleVertices[i].t = datum->t; - simpleVertices[i].lifeSpan = datum->lifeSpan; - simpleVertices[i].size = datum->size; - simpleVertices[i].endSize = datum->endSize; - simpleVertices[i].vx = datum->vx; - simpleVertices[i].vy = datum->vy; - simpleVertices[i].ax = datum->ax; - simpleVertices[i].ay = datum->ay; + simplePointVertices[i].x = datum->x - m_systemOffset.x(); + simplePointVertices[i].y = datum->y - m_systemOffset.y(); + simplePointVertices[i].t = datum->t; + simplePointVertices[i].lifeSpan = datum->lifeSpan; + simplePointVertices[i].size = datum->size; + simplePointVertices[i].endSize = datum->endSize; + simplePointVertices[i].vx = datum->vx; + simplePointVertices[i].vy = datum->vy; + simplePointVertices[i].ax = datum->ax; + simplePointVertices[i].ay = datum->ay; } break; default: diff --git a/src/particles/qquickimageparticle_p.h b/src/particles/qquickimageparticle_p.h index 894d31c300..78e914ec4c 100644 --- a/src/particles/qquickimageparticle_p.h +++ b/src/particles/qquickimageparticle_p.h @@ -69,7 +69,7 @@ class QQuickStochasticEngine; class QRhi; -struct SimpleVertex { +struct SimplePointVertex { float x; float y; float t; @@ -82,6 +82,21 @@ struct SimpleVertex { float ay; }; +struct ColoredPointVertex { + float x; + float y; + float t; + float lifeSpan; + float size; + float endSize; + float vx; + float vy; + float ax; + float ay; + Color4ub color; +}; + +// Like Colored, but using DrawTriangles instead of DrawPoints struct ColoredVertex { float x; float y; @@ -94,6 +109,9 @@ struct ColoredVertex { float ax; float ay; Color4ub color; + uchar tx; + uchar ty; + uchar _padding[2]; // feel free to use }; struct DeformableVertex { @@ -224,7 +242,8 @@ public: enum PerformanceLevel{//TODO: Expose? Unknown = 0, - Simple, + SimplePoint, + ColoredPoint, Colored, Deformable, Tabled, diff --git a/src/particles/shaders_ng/compile.bat b/src/particles/shaders_ng/compile.bat index 334191bdf6..cc6ecb68d3 100755 --- a/src/particles/shaders_ng/compile.bat +++ b/src/particles/shaders_ng/compile.bat @@ -43,17 +43,22 @@ :: For SPIR-V the optimizer is requested (-O argument) which means spirv-opt must be :: invokable (e.g. because it's in the PATH from the Vulkan SDK) -qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_simple.vert.qsb imageparticle.vert -qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_simple.frag.qsb imageparticle.frag +qsb -DPOINT -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_simplepoint.vert.qsb imageparticle.vert +qsb -DPOINT --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_simplepoint.frag.qsb imageparticle.frag -qsb -DTABLE -DDEFORM -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_tabled.vert.qsb imageparticle.vert -qsb -DTABLE -DDEFORM -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_tabled.frag.qsb imageparticle.frag +qsb -DPOINT -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_coloredpoint.vert.qsb imageparticle.vert +qsb -DPOINT -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_coloredpoint.frag.qsb imageparticle.frag + +qsb -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_colored.vert.qsb imageparticle.vert +qsb -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_colored.frag.qsb imageparticle.frag qsb -DDEFORM -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_deformed.vert.qsb imageparticle.vert qsb -DDEFORM -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_deformed.frag.qsb imageparticle.frag +qsb -DTABLE -DDEFORM -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_tabled.vert.qsb imageparticle.vert +qsb -DTABLE -DDEFORM -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_tabled.frag.qsb imageparticle.frag + qsb -DSPRITE -DTABLE -DDEFORM -DCOLOR -b --zorder-loc 8 --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_sprite.vert.qsb imageparticle.vert qsb -DSPRITE -DTABLE -DDEFORM -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_sprite.frag.qsb imageparticle.frag -qsb -DCOLOR -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_colored.vert.qsb imageparticle.vert -qsb -DCOLOR --glsl "150,120,100 es" --hlsl 50 --msl 12 -O -c -o imageparticle_colored.frag.qsb imageparticle.frag + diff --git a/src/particles/shaders_ng/imageparticle.frag b/src/particles/shaders_ng/imageparticle.frag index cefb7d2d75..89cdd48257 100644 --- a/src/particles/shaders_ng/imageparticle.frag +++ b/src/particles/shaders_ng/imageparticle.frag @@ -6,7 +6,7 @@ layout(location = 0) in vec2 tt; #if defined(SPRITE) layout(location = 1) in vec4 fTexS; -#elif defined(DEFORM) +#elif !defined(POINT) layout(location = 1) in vec2 fTex; #endif @@ -45,11 +45,11 @@ void main() * fColor * texture(colortable, tt) * ubuf.opacity; -#elif defined(DEFORM) +#elif !defined(POINT) fragColor = texture(_qt_texture, fTex) * fColor * ubuf.opacity; #elif defined(COLOR) fragColor = texture(_qt_texture, gl_PointCoord) * fColor * ubuf.opacity; -#else +#else // simple point fragColor = texture(_qt_texture, gl_PointCoord) * fFade * ubuf.opacity; #endif } diff --git a/src/particles/shaders_ng/imageparticle.vert b/src/particles/shaders_ng/imageparticle.vert index 124071e48e..420b2e2210 100644 --- a/src/particles/shaders_ng/imageparticle.vert +++ b/src/particles/shaders_ng/imageparticle.vert @@ -13,6 +13,10 @@ layout(location = 0) in vec2 vPos; layout(location = 3) in vec4 vColor; #endif +#if !defined(DEFORM) && !defined(POINT) // Color-level +layout(location = 4) in vec2 vTex; // x = tx, y = ty +#endif + #if defined(DEFORM) layout(location = 4) in vec4 vDeformVec; // x,y x unit vector; z,w = y unit vector layout(location = 5) in vec3 vTex; // x = tx, y = ty, z = bool autoRotate @@ -29,7 +33,7 @@ layout(location = 0) out vec2 tt; //y is progress if Sprite mode #if defined(SPRITE) layout(location = 1) out vec4 fTexS; -#elif defined(DEFORM) +#elif !defined(POINT) layout(location = 1) out vec2 fTex; #endif @@ -56,8 +60,10 @@ void main() if (t < 0. || t > 1.) { #if defined(DEFORM) gl_Position = ubuf.matrix * vec4(vPosRot.x, vPosRot.y, 0., 1.); -#else +#elif defined(POINT) gl_PointSize = 0.; +#else + gl_Position = ubuf.matrix * vec4(vPos.x, vPos.y, 0., 1.); #endif } else { #if defined(SPRITE) @@ -69,7 +75,7 @@ void main() // Next frame is also passed, for interpolation fTexS.zw = vAnimPos.zy + vTex.xy * vAnimData.xy; -#elif defined(DEFORM) +#elif !defined(POINT) fTex = vTex.xy; #endif float currentSize = mix(vData.z, vData.w, t * t); @@ -90,9 +96,12 @@ void main() if (currentSize <= 0.) { #if defined(DEFORM) gl_Position = ubuf.matrix * vec4(vPosRot.x, vPosRot.y, 0., 1.); -#else +#elif defined(POINT) gl_PointSize = 0.; +#else + gl_Position = ubuf.matrix * vec4(vPos.x, vPos.y, 0., 1.); #endif + } else { if (currentSize < 3.) // Sizes too small look jittery as they move currentSize = 3.; @@ -124,11 +133,17 @@ void main() + rotatedDeform.zw + vVec.xy * t * vData.y // apply velocity + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration -#else - pos = vPos +#elif defined(POINT) + pos = vPos.xy + vVec.xy * t * vData.y // apply velocity vector.. + 0.5 * vVec.zw * pow(t * vData.y, 2.); gl_PointSize = currentSize; +#else // non point color + vec2 deform = currentSize * (vTex.xy - 0.5); + pos = vPos.xy + + deform.xy + + vVec.xy * t * vData.y // apply velocity + + 0.5 * vVec.zw * pow(t * vData.y, 2.); // apply acceleration #endif gl_Position = ubuf.matrix * vec4(pos.x, pos.y, 0, 1); diff --git a/src/particles/shaders_ng/imageparticle_colored.frag.qsb b/src/particles/shaders_ng/imageparticle_colored.frag.qsb Binary files differindex 84ba3262eb..0cde86cd8f 100644 --- a/src/particles/shaders_ng/imageparticle_colored.frag.qsb +++ b/src/particles/shaders_ng/imageparticle_colored.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_colored.vert.qsb b/src/particles/shaders_ng/imageparticle_colored.vert.qsb Binary files differindex 293cc7ea4e..77549dd5f0 100644 --- a/src/particles/shaders_ng/imageparticle_colored.vert.qsb +++ b/src/particles/shaders_ng/imageparticle_colored.vert.qsb diff --git a/src/particles/shaders_ng/imageparticle_coloredpoint.frag.qsb b/src/particles/shaders_ng/imageparticle_coloredpoint.frag.qsb Binary files differnew file mode 100644 index 0000000000..f30633eec9 --- /dev/null +++ b/src/particles/shaders_ng/imageparticle_coloredpoint.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_coloredpoint.vert.qsb b/src/particles/shaders_ng/imageparticle_coloredpoint.vert.qsb Binary files differnew file mode 100644 index 0000000000..3c92bc2f63 --- /dev/null +++ b/src/particles/shaders_ng/imageparticle_coloredpoint.vert.qsb diff --git a/src/particles/shaders_ng/imageparticle_deformed.frag.qsb b/src/particles/shaders_ng/imageparticle_deformed.frag.qsb Binary files differindex 02179080fa..00ebda56a9 100644 --- a/src/particles/shaders_ng/imageparticle_deformed.frag.qsb +++ b/src/particles/shaders_ng/imageparticle_deformed.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_deformed.vert.qsb b/src/particles/shaders_ng/imageparticle_deformed.vert.qsb Binary files differindex d67cb043bb..378e9ba876 100644 --- a/src/particles/shaders_ng/imageparticle_deformed.vert.qsb +++ b/src/particles/shaders_ng/imageparticle_deformed.vert.qsb diff --git a/src/particles/shaders_ng/imageparticle_simple.frag.qsb b/src/particles/shaders_ng/imageparticle_simple.frag.qsb Binary files differdeleted file mode 100644 index e781a1d7a8..0000000000 --- a/src/particles/shaders_ng/imageparticle_simple.frag.qsb +++ /dev/null diff --git a/src/particles/shaders_ng/imageparticle_simple.vert.qsb b/src/particles/shaders_ng/imageparticle_simple.vert.qsb Binary files differdeleted file mode 100644 index a2e0df027b..0000000000 --- a/src/particles/shaders_ng/imageparticle_simple.vert.qsb +++ /dev/null diff --git a/src/particles/shaders_ng/imageparticle_simplepoint.frag.qsb b/src/particles/shaders_ng/imageparticle_simplepoint.frag.qsb Binary files differnew file mode 100644 index 0000000000..738be48b91 --- /dev/null +++ b/src/particles/shaders_ng/imageparticle_simplepoint.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_simplepoint.vert.qsb b/src/particles/shaders_ng/imageparticle_simplepoint.vert.qsb Binary files differnew file mode 100644 index 0000000000..a53868d4a5 --- /dev/null +++ b/src/particles/shaders_ng/imageparticle_simplepoint.vert.qsb diff --git a/src/particles/shaders_ng/imageparticle_sprite.frag.qsb b/src/particles/shaders_ng/imageparticle_sprite.frag.qsb Binary files differindex b720360a1b..53f7592520 100644 --- a/src/particles/shaders_ng/imageparticle_sprite.frag.qsb +++ b/src/particles/shaders_ng/imageparticle_sprite.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_sprite.vert.qsb b/src/particles/shaders_ng/imageparticle_sprite.vert.qsb Binary files differindex 284f610f51..8d0efb05c3 100644 --- a/src/particles/shaders_ng/imageparticle_sprite.vert.qsb +++ b/src/particles/shaders_ng/imageparticle_sprite.vert.qsb diff --git a/src/particles/shaders_ng/imageparticle_tabled.frag.qsb b/src/particles/shaders_ng/imageparticle_tabled.frag.qsb Binary files differindex c4ca41814b..788063044e 100644 --- a/src/particles/shaders_ng/imageparticle_tabled.frag.qsb +++ b/src/particles/shaders_ng/imageparticle_tabled.frag.qsb diff --git a/src/particles/shaders_ng/imageparticle_tabled.vert.qsb b/src/particles/shaders_ng/imageparticle_tabled.vert.qsb Binary files differindex 91955cb521..2027b0ecfa 100644 --- a/src/particles/shaders_ng/imageparticle_tabled.vert.qsb +++ b/src/particles/shaders_ng/imageparticle_tabled.vert.qsb |