Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParticleRenderer support bounds and frustum culling #1963

Merged
merged 113 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
e2a5cdb
feat: calculate particleRenderer boundingBox
JujieX Jan 11, 2024
b732e7a
fix: shape calculate move into each type
JujieX Jan 17, 2024
85113fe
fix: get local and world bounds
JujieX Jan 17, 2024
07f9af9
fix: use private static vector3
JujieX Jan 18, 2024
917f655
Merge branch 'dev/1.2' of github.com:galacean/runtime into feat/parti…
JujieX Jan 29, 2024
9583852
fix: opt code
JujieX Jan 30, 2024
8bc6974
fix: get bounds
JujieX Jan 30, 2024
c80b5bf
feat: add unit test
JujieX Jan 30, 2024
5b31b26
feat: simulation space world
JujieX Feb 4, 2024
05e50a7
feat: add rotation into consideration
JujieX Feb 5, 2024
5bc60d6
fix: add timeout for test
JujieX Feb 5, 2024
759123a
fix: modify test
JujieX Feb 5, 2024
2725263
fix: add timeout for test
JujieX Feb 5, 2024
c20d5ab
fix: opt test
JujieX Feb 5, 2024
4905762
fix: opt test
JujieX Feb 5, 2024
3df7be4
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
JujieX Apr 2, 2024
ed35435
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
JujieX Apr 9, 2024
05817c2
feat: separately update world space and local space
JujieX Apr 11, 2024
cd5c8d0
fix: opt code
JujieX Apr 11, 2024
1989500
fix: opt code
JujieX Apr 11, 2024
4271bd6
fix: opt code
JujieX Apr 16, 2024
4819992
feat: use dirtyflag updates bounds
JujieX Apr 16, 2024
a6af680
fix: opt code
JujieX Apr 16, 2024
4af19b2
fix: opt code
JujieX Apr 16, 2024
aeb9ea4
fix: opt code
JujieX Apr 16, 2024
df359a4
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
JujieX Apr 16, 2024
04ea065
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
JujieX Apr 16, 2024
6cde202
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
JujieX Apr 19, 2024
a0f37f1
fix: opt code
JujieX Apr 19, 2024
98d3de7
fix: opt code
JujieX Apr 19, 2024
2b6fa87
fix: opt code
JujieX Apr 19, 2024
3d75752
fix: opt code
JujieX Apr 19, 2024
7149891
fix: opt code
JujieX Apr 19, 2024
0e5e9e7
fix: onValueChanged
JujieX Apr 24, 2024
9545be9
fix: opt code
JujieX Apr 24, 2024
3109472
fix: opt code
JujieX Apr 24, 2024
865a95e
fix: opt code
JujieX Apr 24, 2024
4021680
fix: opt code
JujieX Apr 24, 2024
097100c
feat: simplify localSpace bounds update
JujieX May 11, 2024
b5350d2
fix: opt code
JujieX May 11, 2024
b10a872
fix: opt code
JujieX May 13, 2024
9d03b16
fix: opt code
JujieX May 14, 2024
7adb094
fix: opt code
JujieX May 14, 2024
5a7f351
feat: use three flags
JujieX May 17, 2024
c3e7029
fix: opt code
JujieX May 17, 2024
a9a5fa9
fix: opt code
JujieX May 23, 2024
8c1ee51
fix: opt code
JujieX May 30, 2024
a9ec0cb
feat: add e2e test
JujieX May 30, 2024
b2a6b68
feat: add e2e test
JujieX May 30, 2024
b817cb4
feat: opt code
JujieX May 31, 2024
9b6d6b5
fix: opt code
JujieX May 31, 2024
a05ad3d
fix: opt code
Jun 3, 2024
7844b75
fix: opt code
Jun 3, 2024
ca3af1b
feat: circular queue
Jun 3, 2024
b57273d
fix: minmax of composite curve
Jun 3, 2024
9f9f680
fix: opt code
Jun 3, 2024
1b183a5
fix: opt code
Jun 3, 2024
34451da
fix: opt circular queue
Jun 3, 2024
6e09011
fix: opt isNotAlive
Jun 3, 2024
a297e7c
feat: nextFreeElement for resize buffer
Jun 3, 2024
ac11fd2
fix: opt code
Jun 3, 2024
6007a62
fix: opt code
Jun 4, 2024
5e13b4c
fix: opt code
Jun 4, 2024
7938f6f
fix: opt code
Jun 4, 2024
27d3a5c
fix: opt code
Jun 4, 2024
b46fa70
fix: opt code
Jun 4, 2024
070c35e
fix: opt code
Jun 4, 2024
ffc86e8
fix: opt code
Jun 4, 2024
c7bbef2
fix: opt code
Jun 4, 2024
ad576a4
fix: opt code
Jun 4, 2024
4c71e95
fix: opt code
Jun 4, 2024
072464c
fix: opt code
Jun 4, 2024
c856783
fix: opt code
Jun 4, 2024
2e6abc4
fix: opt code
Jun 4, 2024
49539b2
fix: opt code
Jun 4, 2024
2f2bbd5
fix: opt code
Jun 4, 2024
c24c4b8
fix: opt code
Jun 4, 2024
35560e7
fix: opt code
Jun 4, 2024
bf02842
fix: opt code
Jun 5, 2024
82d6e24
feat: use flag update manager for base shape
Jun 5, 2024
68cd513
fix: opt code
Jun 5, 2024
35c3ef8
fix: opt code
Jun 5, 2024
07dd580
fix: opt code
Jun 5, 2024
c2564ad
fix: opt code
Jun 5, 2024
e5b030a
fix: opt code
Jun 5, 2024
5108c6c
fix: opt code
Jun 6, 2024
730bcfd
fix: opt cdoe
Jun 6, 2024
1f56b52
fix: opt code
Jun 6, 2024
31f068b
fix: circle random direction algo
Jun 6, 2024
e0343a9
fix: opt code
Jun 6, 2024
04b7386
fix: opt code
Jun 6, 2024
413a2c3
fix: opt code
Jun 6, 2024
1614ee8
fix: opt code
Jun 6, 2024
a5d0b7a
fix: opt code
Jun 6, 2024
9cbc519
fix: opt code
Jun 6, 2024
395df1b
fix: opt code
Jun 6, 2024
a5f7171
fix: opt code
Jun 6, 2024
ba37308
fix: opt code
Jun 6, 2024
c59bbfa
fix: hemisphere algo
Jun 6, 2024
1f14bd5
fix: opt code
Jun 6, 2024
3b2954c
fix: opt code
Jun 6, 2024
b33a9cf
fix: opt shape algo
Jun 6, 2024
52b116b
fix: opt code
Jun 6, 2024
9903a49
fix: onCurveChange bind
Jun 6, 2024
4de0d1c
fix: opt code
Jun 6, 2024
b73dba1
fix: opt code
Jun 6, 2024
787647f
fix: opt code
Jun 6, 2024
2a8efb8
fix: opt code
Jun 7, 2024
9fe522a
Merge branch 'main' of github.com:galacean/runtime into feat/particle…
Jun 7, 2024
bf5d166
fix: opt code
Jun 7, 2024
46d250e
fix: opt code
Jun 7, 2024
89d5fb7
fix: opt code
Jun 7, 2024
de600a6
fix: opt code
Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
343 changes: 343 additions & 0 deletions e2e/case/particleRenderer-dream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,343 @@
/**
* @title Particle Dream
* @category Particle
*/
import {
AssetType,
BlendMode,
BoxShape,
Camera,
Color,
Engine,
Entity,
Logger,
ParticleCurveMode,
ParticleGradientMode,
ParticleMaterial,
ParticleRenderMode,
ParticleRenderer,
Texture2D,
Vector3,
WebGLEngine,
WebGLMode
} from "@galacean/engine";
import { initScreenshot, updateForE2E } from "./.mockForE2E";

// Create engine
WebGLEngine.create({
canvas: "canvas",
graphicDeviceOptions: { webGLMode: WebGLMode.WebGL1 }
}).then((engine) => {
Logger.enable();
engine.canvas.resizeByClientSize();

const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
scene.background.solidColor = new Color(15 / 255, 38 / 255, 18 / 255, 1);

// Create camera
const cameraEntity = rootEntity.createChild("camera_entity");
cameraEntity.transform.position = new Vector3(0, 1, 3);
const camera = cameraEntity.addComponent(Camera);
camera.fieldOfView = 60;

engine.run();

engine.resourceManager
.load([
{
url: "https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*JPsCSK5LtYkAAAAAAAAAAAAADil6AQ/original",
type: AssetType.Texture2D
},
{
url: "https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*eWTFRZPqfDMAAAAAAAAAAAAADil6AQ/original",
type: AssetType.Texture2D
},
{
url: "https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*J8uhRoxJtYgAAAAAAAAAAAAADil6AQ/original",
type: AssetType.Texture2D
},
{
url: "https://mdn.alipayobjects.com/huamei_b4l2if/afts/img/A*Ea3qRb1yCQMAAAAAAAAAAAAADil6AQ/original",
type: AssetType.Texture2D
}
])
.then((textures) => {
const fireEntity = createDebrisParticle(engine, <Texture2D>textures[0]);
createGlowParticle(fireEntity, <Texture2D>textures[1]);
createSparksParticle(fireEntity, <Texture2D>textures[2]);
createHighlightsParticle(fireEntity, <Texture2D>textures[3]);

cameraEntity.addChild(fireEntity);

setTimeout(() => {
updateForE2E(engine);
initScreenshot(engine, camera);
}, 2000);
});
});

function createDebrisParticle(engine: Engine, texture: Texture2D): Entity {
const particleEntity = new Entity(engine, "Debris");
particleEntity.transform.position.set(0, -7.5, -8);

const particleRenderer = particleEntity.addComponent(ParticleRenderer);

const material = new ParticleMaterial(engine);
material.baseColor = new Color(1.0, 1.0, 1.0, 1.0);
material.blendMode = BlendMode.Additive;
material.baseTexture = texture;
particleRenderer.setMaterial(material);
particleRenderer.priority = 2;

particleRenderer.generator.useAutoRandomSeed = false;

const { main, emission, sizeOverLifetime, colorOverLifetime, velocityOverLifetime } = particleRenderer.generator;

// Main module
main.startSpeed.constant = 0;

main.startSize.constantMin = 0.1;
main.startSize.constantMax = 1;
main.startSize.mode = ParticleCurveMode.TwoConstants;

main.startRotationZ.constantMin = 0;
main.startRotationZ.constantMax = 360;
main.startRotationZ.mode = ParticleCurveMode.TwoConstants;

main.startColor.constantMin.set(255 / 255, 255 / 255, 255 / 255, 1.0);
main.startColor.constantMax.set(13 / 255, 255 / 255, 0 / 255, 1.0);
main.startColor.mode = ParticleGradientMode.TwoConstants;

// Emission module
emission.rateOverTime.constant = 5;

const boxShape = new BoxShape();
boxShape.size.set(22, 1, 0);
emission.shape = boxShape;

// Color over lifetime module
colorOverLifetime.enabled = true;
colorOverLifetime.color.mode = ParticleGradientMode.Gradient;

const gradient = colorOverLifetime.color.gradient;
gradient.alphaKeys[0].alpha = 0;
gradient.alphaKeys[1].alpha = 0;
gradient.addAlphaKey(0.2, 1.0);
gradient.addAlphaKey(0.8, 1.0);

// Size over lifetime module
sizeOverLifetime.enabled = true;
const keys = sizeOverLifetime.size.curve.keys;
keys[0].value = 1;
keys[1].value = 0;

// Velocity over lifetime module
velocityOverLifetime.enabled = true;
velocityOverLifetime.velocityX.constantMin = 2;
velocityOverLifetime.velocityX.constantMax = 1;
velocityOverLifetime.velocityX.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityY.constantMin = 4;
velocityOverLifetime.velocityY.constantMax = 2;
velocityOverLifetime.velocityY.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityZ.constantMin = 0;
velocityOverLifetime.velocityZ.constantMax = 0;
velocityOverLifetime.velocityZ.mode = ParticleCurveMode.TwoConstants;

return particleEntity;
}

function createGlowParticle(fireEntity: Entity, texture: Texture2D): void {
const particleEntity = fireEntity.createChild("Glow");
particleEntity.transform.position.set(-1.88, 0, 0);

const particleRenderer = particleEntity.addComponent(ParticleRenderer);
particleRenderer.renderMode = ParticleRenderMode.StretchBillboard;
particleRenderer.lengthScale = 2;

const material = new ParticleMaterial(fireEntity.engine);
material.blendMode = BlendMode.Additive;
material.baseTexture = texture;
particleRenderer.setMaterial(material);
particleRenderer.priority = 1;

const generator = particleRenderer.generator;
generator.useAutoRandomSeed = false;
const { main, emission, velocityOverLifetime, colorOverLifetime } = generator;

// Main module
main.startSpeed.constant = 0.0;

main.startSize.constantMin = 5;
main.startSize.constantMax = 9;
main.startSize.mode = ParticleCurveMode.TwoConstants;

main.startRotationZ.constantMin = 0;
main.startRotationZ.constantMax = 360;
main.startRotationZ.mode = ParticleCurveMode.TwoConstants;

main.startColor.constantMin = new Color(0 / 255, 157 / 255, 255 / 255, 64 / 255);
main.startColor.constantMax = new Color(13 / 255, 255 / 255, 0 / 255, 128 / 255);
main.startColor.mode = ParticleGradientMode.TwoConstants;

// Emission module
emission.rateOverTime.constant = 10;

const boxShape = new BoxShape();
boxShape.size.set(22, 1, 0);
emission.shape = boxShape;

// Velocity over lifetime module
velocityOverLifetime.enabled = true;
velocityOverLifetime.velocityX.constantMin = 2;
velocityOverLifetime.velocityX.constantMax = 1;
velocityOverLifetime.velocityX.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityY.constantMin = 4;
velocityOverLifetime.velocityY.constantMax = 2;
velocityOverLifetime.velocityY.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityZ.constantMin = 0;
velocityOverLifetime.velocityZ.constantMax = 0;
velocityOverLifetime.velocityZ.mode = ParticleCurveMode.TwoConstants;

// Color over lifetime module
colorOverLifetime.enabled = true;
colorOverLifetime.color.mode = ParticleGradientMode.Gradient;

const gradient = colorOverLifetime.color.gradient;
gradient.alphaKeys[0].alpha = 0;
gradient.alphaKeys[1].alpha = 0;
gradient.addAlphaKey(0.2, 1.0);
}

function createSparksParticle(fireEntity: Entity, texture: Texture2D): void {
const particleEntity = fireEntity.createChild("Sparks");
particleEntity.transform.position.set(-1.54, 0, 0);

const particleRenderer = particleEntity.addComponent(ParticleRenderer);
const material = new ParticleMaterial(fireEntity.engine);
material.baseTexture = texture;
particleRenderer.setMaterial(material);
particleRenderer.priority = 0;

const { main, emission, colorOverLifetime, velocityOverLifetime } = particleRenderer.generator;
particleRenderer.generator.useAutoRandomSeed = false;

// Main module
main.startLifetime.constant = 5;
main.startSpeed.constant = 0;

main.startSize.constantMin = 0.05;
main.startSize.constantMax = 0.2;
main.startSize.mode = ParticleCurveMode.TwoConstants;

main.startRotationZ.constantMin = 0;
main.startRotationZ.constantMax = 360;
main.startRotationZ.mode = ParticleCurveMode.TwoConstants;

main.startColor.constant = new Color(37 / 255, 133 / 255, 255 / 255, 255 / 255);

// Emission module
emission.rateOverTime.constant = 30;

const boxShape = new BoxShape();
boxShape.size.set(22, 1, 0);
emission.shape = boxShape;

// Velocity over lifetime module
velocityOverLifetime.enabled = true;
velocityOverLifetime.velocityX.constantMin = 2;
velocityOverLifetime.velocityX.constantMax = 1;
velocityOverLifetime.velocityX.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityY.constantMin = 4;
velocityOverLifetime.velocityY.constantMax = 2;
velocityOverLifetime.velocityY.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityZ.constantMin = 0;
velocityOverLifetime.velocityZ.constantMax = 0;
velocityOverLifetime.velocityZ.mode = ParticleCurveMode.TwoConstants;

// Color over lifetime module
colorOverLifetime.enabled = true;
colorOverLifetime.color.mode = ParticleGradientMode.Gradient;

const gradient = colorOverLifetime.color.gradient;
gradient.alphaKeys[0].alpha = 0;
gradient.alphaKeys[1].alpha = 0;
gradient.addAlphaKey(0.2, 1.0);
gradient.addAlphaKey(0.8, 1.0);
}

function createHighlightsParticle(fireEntity: Entity, texture: Texture2D): void {
const particleEntity = fireEntity.createChild("Highlights");
particleEntity.transform.position.set(-5.31, 0, 0);

const particleRenderer = particleEntity.addComponent(ParticleRenderer);

const material = new ParticleMaterial(fireEntity.engine);
material.blendMode = BlendMode.Additive;
material.baseTexture = texture;
particleRenderer.setMaterial(material);
particleRenderer.priority = 3;

const generator = particleRenderer.generator;
const { main, emission, sizeOverLifetime, colorOverLifetime, velocityOverLifetime } = generator;
generator.useAutoRandomSeed = false;

// Main module
main.startSpeed.constant = 0;

main.startSize.constantMin = 0.1;
main.startSize.constantMax = 7;
main.startSize.mode = ParticleCurveMode.TwoConstants;

main.startRotationZ.constantMin = 0;
main.startRotationZ.constantMax = 360;
main.startRotationZ.mode = ParticleCurveMode.TwoConstants;

main.startColor.constantMin.set(105 / 255, 198 / 255, 255 / 255, 64 / 255);
main.startColor.constantMax.set(13 / 255, 255 / 255, 0 / 255, 32 / 255);
main.startColor.mode = ParticleGradientMode.TwoConstants;

// Emission module
emission.rateOverTime.constant = 40;

const boxShape = new BoxShape();
boxShape.size.set(22, 1, 0);
emission.shape = boxShape;

// Velocity over lifetime module
velocityOverLifetime.enabled = true;
velocityOverLifetime.velocityX.constantMin = 3;
velocityOverLifetime.velocityX.constantMax = 2;
velocityOverLifetime.velocityX.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityY.constantMin = 4;
velocityOverLifetime.velocityY.constantMax = 2;
velocityOverLifetime.velocityY.mode = ParticleCurveMode.TwoConstants;

velocityOverLifetime.velocityZ.constantMin = 0;
velocityOverLifetime.velocityZ.constantMax = 0;
velocityOverLifetime.velocityZ.mode = ParticleCurveMode.TwoConstants;

// Color over lifetime module
colorOverLifetime.enabled = true;
colorOverLifetime.color.mode = ParticleGradientMode.Gradient;

const gradient = colorOverLifetime.color.gradient;
gradient.alphaKeys[0].alpha = 0;
gradient.alphaKeys[1].alpha = 0;
gradient.addAlphaKey(0.2, 1.0);
gradient.addAlphaKey(0.8, 1.0);

// Size over lifetime module
sizeOverLifetime.enabled = true;
const curve = sizeOverLifetime.size.curve;
sizeOverLifetime.size.mode = ParticleCurveMode.Curve;
curve.keys[0].value = 1;
curve.keys[1].value = 0;
}
7 changes: 7 additions & 0 deletions e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,12 @@ export const E2E_CONFIG = {
caseFileName: "physx-collision",
threshold: 0.1
}
},
Particle: {
meshopt: {
category: "Particle",
caseFileName: "particleRenderer-dream",
threshold: 0.3
}
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 0 additions & 14 deletions packages/core/src/2d/text/TextRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,13 @@ export class TextRenderer extends Renderer {
target._subFont = this._subFont;
}

/**
* @internal
*/
_isContainDirtyFlag(type: number): boolean {
return (this._dirtyFlag & type) != 0;
}

/**
* @internal
*/
_setDirtyFlagTrue(type: number): void {
this._dirtyFlag |= type;
}

/**
* @internal
*/
_setDirtyFlagFalse(type: number): void {
this._dirtyFlag &= ~type;
}

/**
* @internal
*/
Expand Down
Loading
Loading