Skip to content

Commit

Permalink
fix: Particle Alpha bug (pixijs#11078)
Browse files Browse the repository at this point in the history
* fix particles shaders to handle alpha and tint correctly. update test

* update test
  • Loading branch information
GoodBoyDigital authored Nov 21, 2024
1 parent decb807 commit 7236953
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/scene/particle-container/shared/shader/particles.vert
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ void main(void){
}

vUV = aUV;
vColor = aColor * uColor;
vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
}
5 changes: 4 additions & 1 deletion src/scene/particle-container/shared/shader/particles.wgsl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

struct ParticleUniforms {
uProjectionMatrix:mat3x3<f32>,
uColor:vec4<f32>,
uResolution:vec2<f32>,
uRoundPixels:f32,
};
Expand Down Expand Up @@ -31,10 +32,12 @@ fn mainVertex(

let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);

let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;

return VSOutput(
position,
aUV,
aColor,
vColor,
);
}

Expand Down
7 changes: 7 additions & 0 deletions tests/visual/scenes/particle/particle.scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ export const scene: TestScene = {
particle.rotation = i * 0.01;

particleContainer.addParticle(particle);

particle.alpha = i / 100;

if (i % 2 === 0)
{
particle.tint = 'red';
}
}

scene.addChild(particleContainer);
Expand Down
Binary file modified tests/visual/snapshots/particle-scene-ts-webgl1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/visual/snapshots/particle-scene-ts-webgl2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/visual/snapshots/particle-scene-ts-webgpu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7236953

Please sign in to comment.