diff --git a/hrt/prefab/fx/gpuemitter/BaseSimulation.hx b/hrt/prefab/fx/gpuemitter/BaseSimulation.hx index 7e5bff2f..0f950762 100644 --- a/hrt/prefab/fx/gpuemitter/BaseSimulation.hx +++ b/hrt/prefab/fx/gpuemitter/BaseSimulation.hx @@ -7,8 +7,7 @@ class BaseSimulation extends ComputeUtils { }>; @param var particleBuffer : RWPartialBuffer<{ speed : Vec3, - lifeTime : Float, - lifeRatio : Float, + life : Float, random : Float, }>; @@ -24,7 +23,7 @@ class BaseSimulation extends ComputeUtils { var dt : Float; var speed : Vec3; - var lifeTime : Float; + var life : Float; var particleRandom : Float; var modelView : Mat4; var instanceID : Int; @@ -34,7 +33,7 @@ class BaseSimulation extends ComputeUtils { function __init__() { dt = dtParam; speed = particleBuffer[computeVar.globalInvocation.x].speed; - lifeTime = particleBuffer[computeVar.globalInvocation.x].lifeTime; + life = particleBuffer[computeVar.globalInvocation.x].life; prevModelView = batchBuffer[computeVar.globalInvocation.x].modelView; particleRandom = particleBuffer[computeVar.globalInvocation.x].random; relativeTransform = scaleMatrix(vec3(particleRandom * (maxSize - minSize) + minSize)); @@ -53,7 +52,7 @@ class BaseSimulation extends ComputeUtils { newPos = ((newPos - boundsPos) % boundsSize) + boundsPos; modelView = relativeTransform * align * translationMatrix(newPos); var idx = computeVar.globalInvocation.x; - particleBuffer[idx].lifeTime = lifeTime - dt; + particleBuffer[idx].life = life - dt; particleBuffer[idx].speed = speed; batchBuffer[idx].modelView = modelView; } diff --git a/hrt/prefab/fx/gpuemitter/BaseSpawn.hx b/hrt/prefab/fx/gpuemitter/BaseSpawn.hx index 3b320855..c387fe81 100644 --- a/hrt/prefab/fx/gpuemitter/BaseSpawn.hx +++ b/hrt/prefab/fx/gpuemitter/BaseSpawn.hx @@ -7,8 +7,8 @@ class BaseSpawn extends ComputeUtils { }>; @param var particleBuffer : RWPartialBuffer<{ speed : Vec3, + life : Float, lifeTime : Float, - lifeRatio : Float, random : Float, }>; @param var atomic : RWBuffer; @@ -23,7 +23,7 @@ class BaseSpawn extends ComputeUtils { @param var rate : Int; @param var absPos : Mat4; - var lifeTime : Float; + var life : Float; var particleRandom : Float; var modelView : Mat4; var relativeTransform : Mat4; @@ -31,14 +31,14 @@ class BaseSpawn extends ComputeUtils { function __init__() { emitNormal = vec3(0.0, 0.0, 1.0); particleRandom = particleBuffer[computeVar.globalInvocation.x].random; - lifeTime = mix(minLifeTime, maxLifeTime, (global.time + particleRandom) % 1.0); + life = mix(minLifeTime, maxLifeTime, (global.time + particleRandom) % 1.0); relativeTransform = translationMatrix(vec3(0.0)); modelView = relativeTransform * absPos; } function main() { var idx = computeVar.globalInvocation.x; - if ( FORCED || (!INFINITE && particleBuffer[idx].lifeTime < 0.0) ) { + if ( FORCED || (!INFINITE && particleBuffer[idx].life < 0.0) ) { var c = atomicAdd(atomic, 0, 1); if ( FORCED || (!INFINITE && c < rate) ) { batchBuffer[idx].modelView = modelView; @@ -46,9 +46,9 @@ class BaseSpawn extends ComputeUtils { if ( SPEED_NORMAL ) s = emitNormal; particleBuffer[idx].speed = s * maxStartSpeed; - particleBuffer[idx].lifeTime = lifeTime; + particleBuffer[idx].life = life; // Keep in memory duration of particle to normalize curve update. - particleBuffer[idx].lifeRatio = 1.0 / lifeTime; + particleBuffer[idx].lifeTime = life; } } } diff --git a/hrt/prefab/fx/gpuemitter/GPUEmitter.hx b/hrt/prefab/fx/gpuemitter/GPUEmitter.hx index ceb6b17d..169d27c8 100644 --- a/hrt/prefab/fx/gpuemitter/GPUEmitter.hx +++ b/hrt/prefab/fx/gpuemitter/GPUEmitter.hx @@ -116,8 +116,8 @@ class GPUEmitterObject extends h3d.scene.MeshBatch { var p = dataPasses; var particleBufferFormat = hxd.BufferFormat.make([ { name : "speed", type : DVec3 }, + { name : "life", type : DFloat }, { name : "lifeTime", type : DFloat }, - { name : "lifeRatio", type : DFloat }, { name : "random", type : DFloat }, { name : "padding", type : DVec2 }, ]); @@ -130,9 +130,9 @@ class GPUEmitterObject extends h3d.scene.MeshBatch { // floats[i * stride] = 0.0; // floats[i * stride + 1] = 0.0; // floats[i * stride + 2] = 0.0; - floats[i * stride + 3] = -1000.0; // lifeTime warmup + floats[i * stride + 3] = -1000.0; // life warmup var l = hxd.Math.random() * (data.maxLifeTime - data.minLifeTime) + data.minLifeTime; - floats[i * stride + 4] = 1.0 / l; // lifeRatio + floats[i * stride + 4] = l; // lifeTime floats[i * stride + 5] = hxd.Math.random(); // random // padding // floats[i * stride + 6] = 0.0; diff --git a/hrt/prefab/fx/gpuemitter/LocalRotation.hx b/hrt/prefab/fx/gpuemitter/LocalRotation.hx index e7dd24a3..2b74eeb6 100644 --- a/hrt/prefab/fx/gpuemitter/LocalRotation.hx +++ b/hrt/prefab/fx/gpuemitter/LocalRotation.hx @@ -7,13 +7,13 @@ class LocalRotationShader extends ComputeUtils { var relativeTransform : Mat4; var dt : Float; - var lifeTime : Float; + var life : Float; var particleRandom : Float; function main() { var r = 2.0 * random3d(vec2(particleRandom)) - 1.0; - relativeTransform = rotateMatrixX(speedRotation * lifeTime * r.x) * - rotateMatrixY(speedRotation * lifeTime * r.y) * - rotateMatrixZ(speedRotation * lifeTime * r.z) * + relativeTransform = rotateMatrixX(speedRotation * life * r.x) * + rotateMatrixY(speedRotation * life * r.y) * + rotateMatrixZ(speedRotation * life * r.z) * relativeTransform; } } diff --git a/hrt/prefab/fx/gpuemitter/UpdateParamShader.hx b/hrt/prefab/fx/gpuemitter/UpdateParamShader.hx index 0b8c52f9..ed38cb69 100644 --- a/hrt/prefab/fx/gpuemitter/UpdateParamShader.hx +++ b/hrt/prefab/fx/gpuemitter/UpdateParamShader.hx @@ -5,7 +5,7 @@ class UpdateParamShader extends hxsl.Shader { @param var batchBuffer : RWBuffer; - @param var particleBuffer : RWPartialBuffer<{ lifeTime : Float, lifeRatio : Float }>; + @param var particleBuffer : RWPartialBuffer<{ life : Float, lifeTime : Float }>; @param var paramTexture : Sampler2D; @param var stride : Int; @@ -15,7 +15,7 @@ class UpdateParamShader extends hxsl.Shader { function main() { var idx = computeVar.globalInvocation.x; - batchBuffer[idx * stride + pos] = paramTexture.get(vec2(1.0 - particleBuffer[idx].lifeTime * particleBuffer[idx].lifeRatio, row)).x; + batchBuffer[idx * stride + pos] = paramTexture.get(vec2(1.0 - particleBuffer[idx].life / particleBuffer[idx].lifeTime, row)).x; } } } \ No newline at end of file