@galacean/engine-core 2.0.0-alpha.16 → 2.0.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1028 -53
- package/dist/main.js.map +1 -1
- package/dist/module.js +1028 -54
- package/dist/module.js.map +1 -1
- package/package.json +3 -3
- package/types/graphic/Buffer.d.ts +8 -1
- package/types/graphic/TransformFeedback.d.ts +1 -0
- package/types/graphic/TransformFeedbackPrimitive.d.ts +1 -0
- package/types/graphic/TransformFeedbackShader.d.ts +1 -0
- package/types/graphic/TransformFeedbackSimulator.d.ts +1 -0
- package/types/graphic/enums/BufferBindFlag.d.ts +2 -2
- package/types/particle/ParticleGenerator.d.ts +7 -0
- package/types/particle/ParticleTransformFeedbackSimulator.d.ts +1 -0
- package/types/particle/enums/attributes/ParticleFeedbackVertexAttribute.d.ts +1 -0
- package/types/particle/index.d.ts +1 -0
- package/types/particle/modules/LimitVelocityOverLifetimeModule.d.ts +119 -0
- package/types/renderingHardwareInterface/IPlatformBuffer.d.ts +1 -0
- package/types/renderingHardwareInterface/IPlatformTransformFeedback.d.ts +1 -0
- package/types/renderingHardwareInterface/IPlatformTransformFeedbackPrimitive.d.ts +1 -0
- package/types/renderingHardwareInterface/index.d.ts +2 -0
- package/types/shader/ShaderPass.d.ts +1 -1
- package/types/shaderlib/ShaderLib.d.ts +2 -0
- package/types/shaderlib/particle/index.d.ts +2 -0
package/dist/module.js
CHANGED
|
@@ -4898,7 +4898,7 @@ var ShadowLib = {
|
|
|
4898
4898
|
ShadowVertex: ShadowVertex
|
|
4899
4899
|
};
|
|
4900
4900
|
|
|
4901
|
-
var particle_common = "vec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nvec3 rotationByEuler(in vec3 vector, in vec3 rot) {\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float cosYawPitch = cosYaw * cosPitch;\n float sinYawPitch = sinYaw * sinPitch;\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYawPitch * sinRoll) - (sinYawPitch * cosRoll);\n float quaW = (cosYawPitch * cosRoll) + (sinYawPitch * sinRoll);\n\n return rotationByQuaternions(vector, vec4(quaX, quaY, quaZ, quaW));\n}\n\n// Assume axis is normalized\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float s = sin(halfAngle);\n\n return rotationByQuaternions(vector, vec4(axis * s, cos(halfAngle)));\n}\n\n\nfloat evaluateParticleCurve(in vec2 keys[4], in float normalizedAge) {\n float value;\n for (int i = 1; i < 4; i++) {\n vec2 key = keys[i];\n float time = key.x;\n if (time >= normalizedAge) {\n vec2 lastKey = keys[i - 1];\n float lastTime = lastKey.x;\n float age = (normalizedAge - lastTime) / (time - lastTime);\n value = mix(lastKey.y, key.y, age);\n break;\n }\n }\n return value;\n}\n\nfloat evaluateParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float currentValue){\n float cumulativeValue = 0.0;\n for (int i = 1; i < 4; i++){\n\t vec2 key = keys[i];\n\t float time = key.x;\n\t vec2 lastKey = keys[i - 1];\n\t float lastValue = lastKey.y;\n\n\t if (time >= normalizedAge){\n\t\t float lastTime = lastKey.x;\n float offsetTime = normalizedAge - lastTime;\n\t\t float age = offsetTime / (time - lastTime);\n currentValue = mix(lastValue, key.y, age);\n\t\t cumulativeValue += (lastValue + currentValue) * 0.5 * offsetTime;\n\t\t break;\n\t\t}\n\t else{\n\t\t cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n\t\t}\n\t}\n return cumulativeValue;\n}\n\nvec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorMaxTime, in vec2 alphaKeys[4], in float alphaMaxTime, in float t) {\n vec4 value;\n\n float alphaT = min(t, alphaMaxTime);\n for (int i = 0; i < 4; i++) {\n vec2 key = alphaKeys[i];\n if (alphaT <= key.x) {\n if (i == 0) {\n value.a = alphaKeys[0].y;\n } else {\n vec2 lastKey = alphaKeys[i - 1];\n float age = (alphaT - lastKey.x) / (key.x - lastKey.x);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n\n float colorT = min(t, colorMaxTime);\n for (int i = 0; i < 4; i++) {\n vec4 key = colorKeys[i];\n if (colorT <= key.x) {\n if (i == 0) {\n value.rgb = colorKeys[0].yzw;\n } else {\n vec4 lastKey = colorKeys[i - 1];\n float age = (colorT - lastKey.x) / (key.x - lastKey.x);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n\n return value;\n}"; // eslint-disable-line
|
|
4901
|
+
var particle_common = "vec3 rotationByQuaternions(in vec3 v, in vec4 q) {\n return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nvec4 quaternionConjugate(in vec4 q) {\n return vec4(-q.xyz, q.w);\n}\n\nvec3 rotationByEuler(in vec3 vector, in vec3 rot) {\n float halfRoll = rot.z * 0.5;\n float halfPitch = rot.x * 0.5;\n float halfYaw = rot.y * 0.5;\n\n float sinRoll = sin(halfRoll);\n float cosRoll = cos(halfRoll);\n float sinPitch = sin(halfPitch);\n float cosPitch = cos(halfPitch);\n float sinYaw = sin(halfYaw);\n float cosYaw = cos(halfYaw);\n\n float cosYawPitch = cosYaw * cosPitch;\n float sinYawPitch = sinYaw * sinPitch;\n\n float quaX = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);\n float quaY = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);\n float quaZ = (cosYawPitch * sinRoll) - (sinYawPitch * cosRoll);\n float quaW = (cosYawPitch * cosRoll) + (sinYawPitch * sinRoll);\n\n return rotationByQuaternions(vector, vec4(quaX, quaY, quaZ, quaW));\n}\n\n// Assume axis is normalized\nvec3 rotationByAxis(in vec3 vector, in vec3 axis, in float angle) {\n float halfAngle = angle * 0.5;\n float s = sin(halfAngle);\n\n return rotationByQuaternions(vector, vec4(axis * s, cos(halfAngle)));\n}\n\n\nfloat evaluateParticleCurve(in vec2 keys[4], in float normalizedAge) {\n float value;\n for (int i = 1; i < 4; i++) {\n vec2 key = keys[i];\n float time = key.x;\n if (time >= normalizedAge) {\n vec2 lastKey = keys[i - 1];\n float lastTime = lastKey.x;\n float age = (normalizedAge - lastTime) / (time - lastTime);\n value = mix(lastKey.y, key.y, age);\n break;\n }\n }\n return value;\n}\n\nfloat evaluateParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float currentValue){\n float cumulativeValue = 0.0;\n for (int i = 1; i < 4; i++){\n\t vec2 key = keys[i];\n\t float time = key.x;\n\t vec2 lastKey = keys[i - 1];\n\t float lastValue = lastKey.y;\n\n\t if (time >= normalizedAge){\n\t\t float lastTime = lastKey.x;\n float offsetTime = normalizedAge - lastTime;\n\t\t float age = offsetTime / (time - lastTime);\n currentValue = mix(lastValue, key.y, age);\n\t\t cumulativeValue += (lastValue + currentValue) * 0.5 * offsetTime;\n\t\t break;\n\t\t}\n\t else{\n\t\t cumulativeValue += (lastValue + key.y) * 0.5 * (time - lastKey.x);\n\t\t}\n\t}\n return cumulativeValue;\n}\n\nvec4 evaluateParticleGradient(in vec4 colorKeys[4], in float colorMaxTime, in vec2 alphaKeys[4], in float alphaMaxTime, in float t) {\n vec4 value;\n\n float alphaT = min(t, alphaMaxTime);\n for (int i = 0; i < 4; i++) {\n vec2 key = alphaKeys[i];\n if (alphaT <= key.x) {\n if (i == 0) {\n value.a = alphaKeys[0].y;\n } else {\n vec2 lastKey = alphaKeys[i - 1];\n float age = (alphaT - lastKey.x) / (key.x - lastKey.x);\n value.a = mix(lastKey.y, key.y, age);\n }\n break;\n }\n }\n\n float colorT = min(t, colorMaxTime);\n for (int i = 0; i < 4; i++) {\n vec4 key = colorKeys[i];\n if (colorT <= key.x) {\n if (i == 0) {\n value.rgb = colorKeys[0].yzw;\n } else {\n vec4 lastKey = colorKeys[i - 1];\n float age = (colorT - lastKey.x) / (key.x - lastKey.x);\n value.rgb = mix(lastKey.yzw, key.yzw, age);\n }\n break;\n }\n }\n\n return value;\n}"; // eslint-disable-line
|
|
4902
4902
|
|
|
4903
4903
|
var velocity_over_lifetime_module = "#if defined(RENDERER_VOL_CONSTANT_MODE) || defined(RENDERER_VOL_CURVE_MODE)\n #define _VOL_MODULE_ENABLED\n#endif\n\n#ifdef _VOL_MODULE_ENABLED\n uniform int renderer_VOLSpace;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n uniform vec3 renderer_VOLMaxConst;\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n uniform vec3 renderer_VOLMinConst;\n #endif\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\n uniform vec2 renderer_VOLMaxGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMaxGradientZ[4]; // x:time y:value\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n uniform vec2 renderer_VOLMinGradientX[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientY[4]; // x:time y:value\n uniform vec2 renderer_VOLMinGradientZ[4]; // x:time y:value\n #endif\n #endif\n\n\n vec3 computeVelocityPositionOffset(in float normalizedAge, in float age, out vec3 currentVelocity) {\n vec3 velocityPosition;\n\n #ifdef RENDERER_VOL_CONSTANT_MODE\n currentVelocity = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n currentVelocity = mix(renderer_VOLMinConst, currentVelocity, a_Random1.yzw);\n #endif\n\n velocityPosition = currentVelocity * age;\n #endif\n\n #ifdef RENDERER_VOL_CURVE_MODE\n velocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientX, normalizedAge, currentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientY, normalizedAge, currentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ, normalizedAge, currentVelocity.z));\n\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minCurrentVelocity;\n vec3 minVelocityPosition = vec3(\n evaluateParticleCurveCumulative(renderer_VOLMinGradientX, normalizedAge, minCurrentVelocity.x),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientY, normalizedAge, minCurrentVelocity.y),\n evaluateParticleCurveCumulative(renderer_VOLMinGradientZ, normalizedAge, minCurrentVelocity.z));\n\n currentVelocity = mix(minCurrentVelocity, currentVelocity, a_Random1.yzw);\n velocityPosition = mix(minVelocityPosition, velocityPosition, a_Random1.yzw);\n #endif\n\n velocityPosition *= vec3(a_ShapePositionStartLifeTime.w);\n #endif\n return velocityPosition;\n }\n#endif\n"; // eslint-disable-line
|
|
4904
4904
|
|
|
@@ -4910,7 +4910,11 @@ var color_over_lifetime_module = "#if defined(RENDERER_COL_GRADIENT) || defined(
|
|
|
4910
4910
|
|
|
4911
4911
|
var texture_sheet_animation_module = "#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n uniform float renderer_TSACycles;\n uniform vec3 renderer_TSATillingParams; // x:subU y:subV z:tileCount\n uniform vec2 renderer_TSAFrameMaxCurve[4]; // x:time y:value\n\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n uniform vec2 renderer_TSAFrameMinCurve[4]; // x:time y:value\n #endif\n#endif\n\nvec2 computeParticleUV(in vec2 uv, in float normalizedAge) {\n #if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\n float scaledNormalizedAge = normalizedAge * renderer_TSACycles;\n float cycleNormalizedAge = scaledNormalizedAge - floor(scaledNormalizedAge);\n float normalizedFrame = evaluateParticleCurve(renderer_TSAFrameMaxCurve, cycleNormalizedAge);\n #ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\n normalizedFrame = mix(evaluateParticleCurve(renderer_TSAFrameMinCurve, cycleNormalizedAge), normalizedFrame, a_Random1.x);\n #endif\n\n float frame = floor(normalizedFrame * renderer_TSATillingParams.z);\n\n float tileRow = frame * renderer_TSATillingParams.x;\n float tileRowIndex = floor(tileRow);\n uv.x += tileRow - tileRowIndex;\n uv.y += tileRowIndex * renderer_TSATillingParams.y;\n #endif\n \n return uv;\n}\n"; // eslint-disable-line
|
|
4912
4912
|
|
|
4913
|
-
var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE)\n #define _FOL_MODULE_ENABLED\n#endif\n\n#ifdef _FOL_MODULE_ENABLED\n
|
|
4913
|
+
var force_over_lifetime_module = "#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE)\n #define _FOL_MODULE_ENABLED\n#endif\n\n#ifdef _FOL_MODULE_ENABLED\n uniform int renderer_FOLSpace;\n\n #ifdef RENDERER_FOL_CONSTANT_MODE\n uniform vec3 renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec3 renderer_FOLMinConst;\n #endif\n\n #endif\n\n #ifdef RENDERER_FOL_CURVE_MODE\n uniform vec2 renderer_FOLMaxGradientX[4];\n uniform vec2 renderer_FOLMaxGradientY[4];\n uniform vec2 renderer_FOLMaxGradientZ[4];\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n uniform vec2 renderer_FOLMinGradientX[4];\n uniform vec2 renderer_FOLMinGradientY[4];\n uniform vec2 renderer_FOLMinGradientZ[4];\n #endif\n #endif\n\n // (tHat - t1) * (tHat - t1) * (tHat - t1) * (a2 - a1) / ((t2 - t1) * 6.0) + a1 * (tHat - t1) * (tHat - t1) * 0.5 + v1 * (tHat - t1);\n // to = tHat - t1; tr = t2 - t1\n float computeDisplacementIntegral(in float to, in float tr, in float a1, in float a2, in float v1) {\n return to * to * to * (a2 - a1) / (tr * 6.0) + a1 * to * to * 0.5 + v1 * to;\n }\n\n float evaluateForceParticleCurveCumulative(in vec2 keys[4], in float normalizedAge, out float velocityCumulative) {\n float cumulativeValue = 0.0;\n velocityCumulative = 0.0;\n\n for (int i = 1; i < 4; i++){\n vec2 key = keys[i];\n vec2 lastKey = keys[i - 1];\n float timeRange = (key.x - lastKey.x) * a_ShapePositionStartLifeTime.w;\n\n if (key.x >= normalizedAge){\n float timeOffset = (normalizedAge - lastKey.x) * a_ShapePositionStartLifeTime.w;\n cumulativeValue += computeDisplacementIntegral(timeOffset, timeRange, lastKey.y, key.y, velocityCumulative);\n\n float finalAcceleration = mix(lastKey.y, key.y, timeOffset / timeRange);\n velocityCumulative += 0.5 * timeOffset * (finalAcceleration + lastKey.y);\n break;\n } else { \n cumulativeValue += computeDisplacementIntegral(timeRange, timeRange, lastKey.y, key.y, velocityCumulative);\n velocityCumulative += 0.5 * timeRange * (lastKey.y + key.y);\n }\n }\n return cumulativeValue;\n }\n\n vec3 computeForcePositionOffset(in float normalizedAge, in float age, out vec3 velocityOffset) {\n vec3 forcePosition;\n\n #if defined(RENDERER_FOL_CONSTANT_MODE)\n vec3 forceAcceleration = renderer_FOLMaxConst;\n\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n forceAcceleration = mix(renderer_FOLMinConst, forceAcceleration, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n\n velocityOffset = forceAcceleration * age;\n\n forcePosition = 0.5 * forceAcceleration * age * age;\n #elif defined(RENDERER_FOL_CURVE_MODE)\n forcePosition = vec3(\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientX, normalizedAge, velocityOffset.x),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientY, normalizedAge, velocityOffset.y),\n evaluateForceParticleCurveCumulative(renderer_FOLMaxGradientZ, normalizedAge, velocityOffset.z)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minVelocityOffset;\n\n forcePosition = vec3(\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientX, normalizedAge, minVelocityOffset.x), forcePosition.x, a_Random2.x),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientY, normalizedAge, minVelocityOffset.y), forcePosition.y, a_Random2.y),\n mix(evaluateForceParticleCurveCumulative(renderer_FOLMinGradientZ, normalizedAge, minVelocityOffset.z), forcePosition.z, a_Random2.z)\n );\n\n velocityOffset = mix(minVelocityOffset, velocityOffset, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n return forcePosition;\n }\n#endif"; // eslint-disable-line
|
|
4914
|
+
|
|
4915
|
+
var limit_velocity_over_lifetime_module = "#ifdef RENDERER_LVL_MODULE_ENABLED\n uniform int renderer_LVLSpace;\n uniform float renderer_LVLDampen;\n\n // Scalar limit\n #ifndef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform float renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform float renderer_LVLSpeedMinConst;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedMinCurve[4];\n #endif\n #endif\n #endif\n\n // Per-axis limit\n #ifdef RENDERER_LVL_SEPARATE_AXES\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n uniform vec3 renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec3 renderer_LVLSpeedMinConstVector;\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n uniform vec2 renderer_LVLSpeedXMaxCurve[4];\n uniform vec2 renderer_LVLSpeedYMaxCurve[4];\n uniform vec2 renderer_LVLSpeedZMaxCurve[4];\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n uniform vec2 renderer_LVLSpeedXMinCurve[4];\n uniform vec2 renderer_LVLSpeedYMinCurve[4];\n uniform vec2 renderer_LVLSpeedZMinCurve[4];\n #endif\n #endif\n #endif\n\n // Drag curve\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n uniform vec2 renderer_LVLDragMaxCurve[4];\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n uniform vec2 renderer_LVLDragMinCurve[4];\n #endif\n #endif\n\n float evaluateLVLDrag(float normalizedAge, float dragRand) {\n #ifdef RENDERER_LVL_DRAG_CURVE_MODE\n float dragMax = evaluateParticleCurve(renderer_LVLDragMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_DRAG_IS_RANDOM_TWO\n float dragMin = evaluateParticleCurve(renderer_LVLDragMinCurve, normalizedAge);\n return mix(dragMin, dragMax, dragRand);\n #else\n return dragMax;\n #endif\n #else\n return mix(renderer_LVLDragConstant.x, renderer_LVLDragConstant.y, dragRand);\n #endif\n }\n\n vec3 applyLVLSpeedLimitTF(vec3 velocity, float normalizedAge, float limitRand, float effectiveDampen) {\n #ifdef RENDERER_LVL_SEPARATE_AXES\n vec3 limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConstVector;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConstVector, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMaxCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMaxCurve, normalizedAge)\n );\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n vec3 minLimitSpeed = vec3(\n evaluateParticleCurve(renderer_LVLSpeedXMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedYMinCurve, normalizedAge),\n evaluateParticleCurve(renderer_LVLSpeedZMinCurve, normalizedAge)\n );\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n vec3 absVel = abs(velocity);\n vec3 excess = max(absVel - limitSpeed, vec3(0.0));\n velocity = sign(velocity) * (absVel - excess * effectiveDampen);\n #else\n float limitSpeed;\n #ifdef RENDERER_LVL_SPEED_CONSTANT_MODE\n limitSpeed = renderer_LVLSpeedMaxConst;\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n limitSpeed = mix(renderer_LVLSpeedMinConst, limitSpeed, limitRand);\n #endif\n #endif\n #ifdef RENDERER_LVL_SPEED_CURVE_MODE\n limitSpeed = evaluateParticleCurve(renderer_LVLSpeedMaxCurve, normalizedAge);\n #ifdef RENDERER_LVL_SPEED_IS_RANDOM_TWO\n float minLimitSpeed = evaluateParticleCurve(renderer_LVLSpeedMinCurve, normalizedAge);\n limitSpeed = mix(minLimitSpeed, limitSpeed, limitRand);\n #endif\n #endif\n\n float speed = length(velocity);\n if (speed > limitSpeed && speed > 0.0) {\n float excess = speed - limitSpeed;\n velocity = velocity * ((speed - excess * effectiveDampen) / speed);\n }\n #endif\n return velocity;\n }\n\n#endif\n"; // eslint-disable-line
|
|
4916
|
+
|
|
4917
|
+
var particle_feedback_simulation = "// Transform Feedback update shader for particle simulation.\n// Update order: VOL/FOL → Dampen → Drag → Position.\n// Runs once per particle per frame (no rasterization).\n\n// Previous frame TF data\nattribute vec3 a_FeedbackPosition;\nattribute vec3 a_FeedbackVelocity;\n\n// Per-particle instance data\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec3 a_StartSize;\nattribute float a_StartSpeed;\nattribute vec4 a_Random0;\nattribute vec4 a_Random1;\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\nattribute vec4 a_Random2;\n\n// Uniforms\nuniform float renderer_CurrentTime;\nuniform float renderer_DeltaTime;\nuniform vec3 renderer_Gravity;\nuniform vec2 renderer_LVLDragConstant;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform int renderer_SimulationSpace;\n\n// TF outputs\nvarying vec3 v_FeedbackPosition;\nvarying vec3 v_FeedbackVelocity;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <limit_velocity_over_lifetime_module>\n\n// Get VOL instantaneous velocity at normalizedAge\nvec3 getVOLVelocity(float normalizedAge) {\n vec3 vel = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n #ifdef RENDERER_VOL_CONSTANT_MODE\n vel = renderer_VOLMaxConst;\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vel = mix(renderer_VOLMinConst, vel, a_Random1.yzw);\n #endif\n #endif\n #ifdef RENDERER_VOL_CURVE_MODE\n vel = vec3(\n evaluateParticleCurve(renderer_VOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_VOL_IS_RANDOM_TWO\n vec3 minVel = vec3(\n evaluateParticleCurve(renderer_VOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_VOLMinGradientZ, normalizedAge)\n );\n vel = mix(minVel, vel, a_Random1.yzw);\n #endif\n #endif\n #endif\n return vel;\n}\n\n// Get FOL instantaneous acceleration at normalizedAge\nvec3 getFOLAcceleration(float normalizedAge) {\n vec3 acc = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n #ifdef RENDERER_FOL_CONSTANT_MODE\n acc = renderer_FOLMaxConst;\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n acc = mix(renderer_FOLMinConst, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #ifdef RENDERER_FOL_CURVE_MODE\n acc = vec3(\n evaluateParticleCurve(renderer_FOLMaxGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMaxGradientZ, normalizedAge)\n );\n #ifdef RENDERER_FOL_IS_RANDOM_TWO\n vec3 minAcc = vec3(\n evaluateParticleCurve(renderer_FOLMinGradientX, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientY, normalizedAge),\n evaluateParticleCurve(renderer_FOLMinGradientZ, normalizedAge)\n );\n acc = mix(minAcc, acc, vec3(a_Random2.x, a_Random2.y, a_Random2.z));\n #endif\n #endif\n #endif\n return acc;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float lifetime = a_ShapePositionStartLifeTime.w;\n float normalizedAge = age / lifetime;\n // Clamp to age on the first TF pass: particles emitted mid-frame have age < dt,\n // so using the full dt would over-integrate. Subsequent passes are unaffected (age >= dt).\n float dt = min(renderer_DeltaTime, age);\n\n // normalizedAge < 0.0: stale TF slot whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 1.0 || normalizedAge < 0.0) {\n v_FeedbackPosition = a_FeedbackPosition;\n v_FeedbackVelocity = a_FeedbackVelocity;\n gl_Position = vec4(0.0);\n return;\n }\n\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n vec4 invWorldRotation = quaternionConjugate(worldRotation);\n\n // Read previous frame state (initialized by CPU on particle birth)\n vec3 localVelocity = a_FeedbackVelocity;\n\n // =====================================================\n // Step 1: Apply velocity module deltas (VOL + FOL + Gravity)\n // =====================================================\n\n // Gravity (world space)\n vec3 gravityDelta = renderer_Gravity * a_Random0.x * dt;\n\n // VOL instantaneous velocity (animated velocity, not persisted)\n vec3 volLocal = vec3(0.0);\n vec3 volWorld = vec3(0.0);\n #ifdef _VOL_MODULE_ENABLED\n vec3 vol = getVOLVelocity(normalizedAge);\n if (renderer_VOLSpace == 0) {\n volLocal = vol;\n } else {\n volWorld = vol;\n }\n #endif\n\n // FOL acceleration → velocity delta (always persisted, like gravity)\n vec3 folDeltaLocal = vec3(0.0);\n #ifdef _FOL_MODULE_ENABLED\n vec3 folAcc = getFOLAcceleration(normalizedAge);\n vec3 folVelDelta = folAcc * dt;\n if (renderer_FOLSpace == 0) {\n folDeltaLocal = folVelDelta;\n } else {\n // World FOL: convert to local and persist, same as gravity\n folDeltaLocal = rotationByQuaternions(folVelDelta, invWorldRotation);\n }\n #endif\n\n // Gravity and FOL contribute to base velocity (persisted, subject to dampen/drag).\n vec3 gravityLocal = rotationByQuaternions(gravityDelta, invWorldRotation);\n localVelocity += folDeltaLocal + gravityLocal;\n\n // =====================================================\n // Step 2 & 3: Dampen (Limit Velocity) + Drag\n // VOL must be projected into the LVL target space so that\n // limit/drag see the full velocity regardless of VOL.space vs LVL.space.\n // =====================================================\n #ifdef RENDERER_LVL_MODULE_ENABLED\n // Precompute VOL in both spaces\n vec3 volAsLocal = volLocal + rotationByQuaternions(volWorld, invWorldRotation);\n vec3 volAsWorld = rotationByQuaternions(volLocal, worldRotation) + volWorld;\n\n float limitRand = a_Random2.w;\n float dampen = renderer_LVLDampen;\n // Frame-rate independent dampen (30fps as reference)\n float effectiveDampen = 1.0 - pow(1.0 - dampen, dt * 30.0);\n\n if (renderer_LVLSpace == 0) {\n // Local space: total = base + all VOL projected to local\n vec3 totalLocal = localVelocity + volAsLocal;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalLocal, normalizedAge, limitRand, effectiveDampen);\n localVelocity = dampenedTotal - volAsLocal;\n } else {\n // World space: total = rotated base + all VOL projected to world\n vec3 totalWorld = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n vec3 dampenedTotal = applyLVLSpeedLimitTF(totalWorld, normalizedAge, limitRand, effectiveDampen);\n localVelocity = rotationByQuaternions(dampenedTotal - volAsWorld, invWorldRotation);\n }\n\n // Drag: same space as dampen\n {\n float dragCoeff = evaluateLVLDrag(normalizedAge, a_Random2.w);\n if (dragCoeff > 0.0) {\n vec3 totalVel;\n if (renderer_LVLSpace == 0) {\n totalVel = localVelocity + volAsLocal;\n } else {\n totalVel = rotationByQuaternions(localVelocity, worldRotation) + volAsWorld;\n }\n float velMagSqr = dot(totalVel, totalVel);\n float velMag = sqrt(velMagSqr);\n\n float drag = dragCoeff;\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_SIZE\n float maxDim = max(a_StartSize.x, max(a_StartSize.y, a_StartSize.z));\n float radius = maxDim * 0.5;\n drag *= 3.14159265 * radius * radius;\n #endif\n\n #ifdef RENDERER_LVL_DRAG_MULTIPLY_VELOCITY\n drag *= velMagSqr;\n #endif\n\n if (velMag > 0.0) {\n float newVelMag = max(0.0, velMag - drag * dt);\n vec3 draggedTotal = totalVel * (newVelMag / velMag);\n if (renderer_LVLSpace == 0) {\n localVelocity = draggedTotal - volAsLocal;\n } else {\n localVelocity = rotationByQuaternions(draggedTotal - volAsWorld, invWorldRotation);\n }\n }\n }\n }\n #endif\n\n // =====================================================\n // Step 4: Integrate position in simulation space\n // Local mode: position in local space, velocity rotated to local\n // World mode: position in world space, velocity rotated to world\n // =====================================================\n // FOL is now fully in localVelocity (both local and world-space FOL).\n // Only VOL overlay needs to be added here.\n vec3 totalVelocity;\n if (renderer_SimulationSpace == 0) {\n // Local: integrate in local space\n totalVelocity = localVelocity + volLocal\n + rotationByQuaternions(volWorld, invWorldRotation);\n } else {\n // World: integrate in world space\n totalVelocity = rotationByQuaternions(localVelocity + volLocal, worldRotation) + volWorld;\n }\n vec3 position = a_FeedbackPosition + totalVelocity * dt;\n\n v_FeedbackPosition = position;\n v_FeedbackVelocity = localVelocity;\n gl_Position = vec4(0.0);\n}\n"; // eslint-disable-line
|
|
4914
4918
|
|
|
4915
4919
|
var sphere_billboard = "#ifdef RENDERER_MODE_SPHERE_BILLBOARD\n\tvec2 corner = a_CornerTextureCoordinate.xy + renderer_PivotOffset.xy;\n\tvec3 sideVector = normalize(cross(camera_Forward, camera_Up));\n\tvec3 upVector = normalize(cross(sideVector, camera_Forward));\n\tcorner *= computeParticleSizeBillboard(a_StartSize.xy, normalizedAge);\n #if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n if (renderer_ThreeDStartRotation) {\n vec3 rotation = radians(vec3(a_StartRotation0.xy, computeParticleRotationFloat(a_StartRotation0.z, age, normalizedAge)));\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, rotation);\n } else {\n float rot = radians(computeParticleRotationFloat(a_StartRotation0.x, age, normalizedAge));\n float c = cos(rot);\n float s = sin(rot);\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #else\n if (renderer_ThreeDStartRotation) {\n center += renderer_SizeScale.xzy * rotationByEuler(corner.x * sideVector + corner.y * upVector, radians(a_StartRotation0));\n } else {\n float c = cos(radians(a_StartRotation0.x));\n float s = sin(radians(a_StartRotation0.x));\n mat2 rotation = mat2(c, -s, s, c);\n corner = rotation * corner;\n center += renderer_SizeScale.xzy * (corner.x * sideVector + corner.y * upVector);\n }\n #endif\n#endif"; // eslint-disable-line
|
|
4916
4920
|
|
|
@@ -4930,6 +4934,8 @@ var ParticleShaderLib = {
|
|
|
4930
4934
|
color_over_lifetime_module: color_over_lifetime_module,
|
|
4931
4935
|
texture_sheet_animation_module: texture_sheet_animation_module,
|
|
4932
4936
|
force_over_lifetime_module: force_over_lifetime_module,
|
|
4937
|
+
limit_velocity_over_lifetime_module: limit_velocity_over_lifetime_module,
|
|
4938
|
+
particle_feedback_simulation: particle_feedback_simulation,
|
|
4933
4939
|
sphere_billboard: sphere_billboard,
|
|
4934
4940
|
stretched_billboard: stretched_billboard,
|
|
4935
4941
|
vertical_billboard: vertical_billboard,
|
|
@@ -4996,6 +5002,41 @@ var ShaderFactory = /*#__PURE__*/ function() {
|
|
|
4996
5002
|
return "#define " + (m.value ? m.name + " " + m.value : m.name) + "\n";
|
|
4997
5003
|
}).join("");
|
|
4998
5004
|
};
|
|
5005
|
+
/**
|
|
5006
|
+
* @internal
|
|
5007
|
+
* Compile vertex and fragment source with standard macros, includes, and version header.
|
|
5008
|
+
* @param engine - Engine instance
|
|
5009
|
+
* @param macroCollection - Current macro collection
|
|
5010
|
+
* @param vertexSource - Raw vertex shader source (may contain #include)
|
|
5011
|
+
* @param fragmentSource - Raw fragment shader source
|
|
5012
|
+
* @returns Compiled { vertexSource, fragmentSource } ready for ShaderProgram
|
|
5013
|
+
*/ ShaderFactory.compilePlatformSource = function compilePlatformSource(engine, macroCollection, vertexSource, fragmentSource) {
|
|
5014
|
+
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
5015
|
+
var shaderMacroList = new Array();
|
|
5016
|
+
ShaderMacro._getMacrosElements(macroCollection, shaderMacroList);
|
|
5017
|
+
shaderMacroList.push(ShaderMacro.getByName(isWebGL2 ? "GRAPHICS_API_WEBGL2" : "GRAPHICS_API_WEBGL1"));
|
|
5018
|
+
if (engine._hardwareRenderer.canIUse(GLCapabilityType.shaderTextureLod)) {
|
|
5019
|
+
shaderMacroList.push(ShaderMacro.getByName("HAS_TEX_LOD"));
|
|
5020
|
+
}
|
|
5021
|
+
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
5022
|
+
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
5023
|
+
}
|
|
5024
|
+
var noIncludeVertex = ShaderFactory.parseIncludes(vertexSource);
|
|
5025
|
+
var noIncludeFrag = ShaderFactory.parseIncludes(fragmentSource);
|
|
5026
|
+
var macroStr = ShaderFactory.parseCustomMacros(shaderMacroList);
|
|
5027
|
+
noIncludeVertex = macroStr + noIncludeVertex;
|
|
5028
|
+
noIncludeFrag = macroStr + noIncludeFrag;
|
|
5029
|
+
if (isWebGL2) {
|
|
5030
|
+
noIncludeVertex = ShaderFactory.convertTo300(noIncludeVertex);
|
|
5031
|
+
noIncludeFrag = ShaderFactory.convertTo300(noIncludeFrag, true);
|
|
5032
|
+
}
|
|
5033
|
+
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
5034
|
+
var precisionStr = "\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n#else\n precision mediump float;\n precision mediump int;\n#endif\n";
|
|
5035
|
+
return {
|
|
5036
|
+
vertexSource: versionStr + "\nprecision highp float;\n" + noIncludeVertex,
|
|
5037
|
+
fragmentSource: versionStr + "\n" + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + precisionStr + noIncludeFrag
|
|
5038
|
+
};
|
|
5039
|
+
};
|
|
4999
5040
|
ShaderFactory.registerInclude = function registerInclude(includeName, includeSource) {
|
|
5000
5041
|
if (ShaderLib[includeName]) {
|
|
5001
5042
|
throw 'The "' + includeName + '" shader include already exist';
|
|
@@ -5328,7 +5369,7 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5328
5369
|
* Shader program, corresponding to the GPU shader program.
|
|
5329
5370
|
* @internal
|
|
5330
5371
|
*/ var ShaderProgram = /*#__PURE__*/ function() {
|
|
5331
|
-
function ShaderProgram(engine, vertexSource, fragmentSource) {
|
|
5372
|
+
function ShaderProgram(engine, vertexSource, fragmentSource, transformFeedbackVaryings) {
|
|
5332
5373
|
this.sceneUniformBlock = new ShaderUniformBlock();
|
|
5333
5374
|
this.cameraUniformBlock = new ShaderUniformBlock();
|
|
5334
5375
|
this.rendererUniformBlock = new ShaderUniformBlock();
|
|
@@ -5344,7 +5385,7 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5344
5385
|
this._activeTextureUint = 0;
|
|
5345
5386
|
this._engine = engine;
|
|
5346
5387
|
this._gl = engine._hardwareRenderer.gl;
|
|
5347
|
-
this._glProgram = this._createProgram(vertexSource, fragmentSource);
|
|
5388
|
+
this._glProgram = this._createProgram(vertexSource, fragmentSource, transformFeedbackVaryings);
|
|
5348
5389
|
if (this._glProgram) {
|
|
5349
5390
|
this._isValid = true;
|
|
5350
5391
|
this._recordLocation();
|
|
@@ -5490,7 +5531,7 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5490
5531
|
};
|
|
5491
5532
|
/**
|
|
5492
5533
|
* Init and link program with shader.
|
|
5493
|
-
*/ _proto._createProgram = function _createProgram(vertexSource, fragmentSource) {
|
|
5534
|
+
*/ _proto._createProgram = function _createProgram(vertexSource, fragmentSource, transformFeedbackVaryings) {
|
|
5494
5535
|
var gl = this._gl;
|
|
5495
5536
|
// Create and compile shader
|
|
5496
5537
|
var vertexShader = this._createShader(gl.VERTEX_SHADER, vertexSource);
|
|
@@ -5508,6 +5549,10 @@ ShaderTagKey._nameMap = Object.create(null);
|
|
|
5508
5549
|
}
|
|
5509
5550
|
gl.attachShader(program, vertexShader);
|
|
5510
5551
|
gl.attachShader(program, fragmentShader);
|
|
5552
|
+
// Set Transform Feedback varyings before linking (WebGL2 only)
|
|
5553
|
+
if (transformFeedbackVaryings == null ? void 0 : transformFeedbackVaryings.length) {
|
|
5554
|
+
gl.transformFeedbackVaryings(program, transformFeedbackVaryings, gl.INTERLEAVED_ATTRIBS);
|
|
5555
|
+
}
|
|
5511
5556
|
gl.linkProgram(program);
|
|
5512
5557
|
gl.validateProgram(program);
|
|
5513
5558
|
gl.deleteShader(vertexShader);
|
|
@@ -5771,7 +5816,7 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
5771
5816
|
/**
|
|
5772
5817
|
* @internal
|
|
5773
5818
|
*/ _proto._getShaderProgram = function _getShaderProgram(engine, macroCollection) {
|
|
5774
|
-
var shaderProgramPool = engine._getShaderProgramPool(this);
|
|
5819
|
+
var shaderProgramPool = engine._getShaderProgramPool(this._shaderPassId, this._shaderProgramPools);
|
|
5775
5820
|
var shaderProgram = shaderProgramPool.get(macroCollection);
|
|
5776
5821
|
if (shaderProgram) {
|
|
5777
5822
|
return shaderProgram;
|
|
@@ -5793,6 +5838,13 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
5793
5838
|
shaderProgramPools.length = 0;
|
|
5794
5839
|
};
|
|
5795
5840
|
_proto._getCanonicalShaderProgram = function _getCanonicalShaderProgram(engine, macroCollection) {
|
|
5841
|
+
if (this._platformTarget != undefined) {
|
|
5842
|
+
return this._getShaderLabProgram(engine, macroCollection);
|
|
5843
|
+
}
|
|
5844
|
+
var _ShaderFactory_compilePlatformSource = ShaderFactory.compilePlatformSource(engine, macroCollection, this._vertexSource, this._fragmentSource), vertexSource = _ShaderFactory_compilePlatformSource.vertexSource, fragmentSource = _ShaderFactory_compilePlatformSource.fragmentSource;
|
|
5845
|
+
return new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
5846
|
+
};
|
|
5847
|
+
_proto._getShaderLabProgram = function _getShaderLabProgram(engine, macroCollection) {
|
|
5796
5848
|
var isWebGL2 = engine._hardwareRenderer.isWebGL2;
|
|
5797
5849
|
var shaderMacroList = new Array();
|
|
5798
5850
|
ShaderMacro._getMacrosElements(macroCollection, shaderMacroList);
|
|
@@ -5803,32 +5855,22 @@ var precisionStr = "\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision hig
|
|
|
5803
5855
|
if (engine._hardwareRenderer.canIUse(GLCapabilityType.standardDerivatives)) {
|
|
5804
5856
|
shaderMacroList.push(ShaderMacro.getByName("HAS_DERIVATIVES"));
|
|
5805
5857
|
}
|
|
5806
|
-
// Compatible with non-shaderlab syntax
|
|
5807
5858
|
var noIncludeVertex = ShaderFactory.parseIncludes(this._vertexSource);
|
|
5808
5859
|
var noIncludeFrag = ShaderFactory.parseIncludes(this._fragmentSource);
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
noIncludeFrag = Shader._shaderLab._parseMacros(noIncludeFrag, shaderMacroList);
|
|
5813
|
-
} else {
|
|
5814
|
-
var macroNameStr = ShaderFactory.parseCustomMacros(shaderMacroList);
|
|
5815
|
-
noIncludeVertex = macroNameStr + noIncludeVertex;
|
|
5816
|
-
noIncludeFrag = macroNameStr + noIncludeFrag;
|
|
5817
|
-
}
|
|
5818
|
-
// Need to convert to 300 es when the target is GLSL ES 100 or unkdown
|
|
5819
|
-
if (isWebGL2 && (this._platformTarget == undefined || this._platformTarget === ShaderLanguage.GLSLES100)) {
|
|
5860
|
+
noIncludeVertex = Shader._shaderLab._parseMacros(noIncludeVertex, shaderMacroList);
|
|
5861
|
+
noIncludeFrag = Shader._shaderLab._parseMacros(noIncludeFrag, shaderMacroList);
|
|
5862
|
+
if (isWebGL2 && this._platformTarget === ShaderLanguage.GLSLES100) {
|
|
5820
5863
|
noIncludeVertex = ShaderFactory.convertTo300(noIncludeVertex);
|
|
5821
5864
|
noIncludeFrag = ShaderFactory.convertTo300(noIncludeFrag, true);
|
|
5822
5865
|
}
|
|
5823
5866
|
var versionStr = isWebGL2 ? "#version 300 es" : "#version 100";
|
|
5824
|
-
var vertexSource = " " + versionStr + "
|
|
5867
|
+
var vertexSource = " " + versionStr + "\n " + noIncludeVertex + "\n ";
|
|
5825
5868
|
var fragmentSource = " " + versionStr + "\n " + (isWebGL2 ? "" : ShaderFactory._shaderExtension) + "\n " + precisionStr + "\n " + noIncludeFrag + "\n ";
|
|
5826
|
-
|
|
5827
|
-
return shaderProgram;
|
|
5869
|
+
return new ShaderProgram(engine, vertexSource, fragmentSource);
|
|
5828
5870
|
};
|
|
5829
5871
|
return ShaderPass;
|
|
5830
5872
|
}(ShaderPart);
|
|
5831
|
-
ShaderPass._shaderPassCounter = 0;
|
|
5873
|
+
/** @internal */ ShaderPass._shaderPassCounter = 0;
|
|
5832
5874
|
/** @internal */ ShaderPass._shaderRootPath = "shaders://root/";
|
|
5833
5875
|
|
|
5834
5876
|
/**
|
|
@@ -18467,6 +18509,15 @@ var TextChunk = function TextChunk() {
|
|
|
18467
18509
|
this._platformBuffer.getData(data, bufferByteOffset, dataOffset, dataLength);
|
|
18468
18510
|
};
|
|
18469
18511
|
/**
|
|
18512
|
+
* Copy data from another buffer on the GPU.
|
|
18513
|
+
* @param srcBuffer - Source buffer
|
|
18514
|
+
* @param srcByteOffset - Byte offset in the source buffer
|
|
18515
|
+
* @param dstByteOffset - Byte offset in this buffer
|
|
18516
|
+
* @param byteLength - Number of bytes to copy
|
|
18517
|
+
*/ _proto.copyFromBuffer = function copyFromBuffer(srcBuffer, srcByteOffset, dstByteOffset, byteLength) {
|
|
18518
|
+
this._platformBuffer.copyFromBuffer(srcBuffer._platformBuffer, srcByteOffset, dstByteOffset, byteLength);
|
|
18519
|
+
};
|
|
18520
|
+
/**
|
|
18470
18521
|
* Mark buffer as readable, the `data` property will be not accessible anymore.
|
|
18471
18522
|
*/ _proto.markAsUnreadable = function markAsUnreadable() {
|
|
18472
18523
|
this._data = null;
|
|
@@ -18761,8 +18812,8 @@ var BufferUtil = /*#__PURE__*/ function() {
|
|
|
18761
18812
|
/**
|
|
18762
18813
|
* Buffer binding flag.
|
|
18763
18814
|
*/ var BufferBindFlag = /*#__PURE__*/ function(BufferBindFlag) {
|
|
18764
|
-
/** Vertex buffer binding flag */ BufferBindFlag[BufferBindFlag["VertexBuffer"] = 0] = "VertexBuffer";
|
|
18765
|
-
/** Index buffer binding flag */ BufferBindFlag[BufferBindFlag["IndexBuffer"] = 1] = "IndexBuffer";
|
|
18815
|
+
/** Vertex buffer binding flag. */ BufferBindFlag[BufferBindFlag["VertexBuffer"] = 0] = "VertexBuffer";
|
|
18816
|
+
/** Index buffer binding flag. */ BufferBindFlag[BufferBindFlag["IndexBuffer"] = 1] = "IndexBuffer";
|
|
18766
18817
|
return BufferBindFlag;
|
|
18767
18818
|
}({});
|
|
18768
18819
|
|
|
@@ -26198,6 +26249,15 @@ PointerEventEmitter._tempRay = new Ray();
|
|
|
26198
26249
|
return ParticleBillboardVertexAttribute;
|
|
26199
26250
|
}({});
|
|
26200
26251
|
|
|
26252
|
+
/**
|
|
26253
|
+
* @internal
|
|
26254
|
+
* Vertex attributes for the Transform Feedback buffer.
|
|
26255
|
+
*/ var ParticleFeedbackVertexAttribute = /*#__PURE__*/ function(ParticleFeedbackVertexAttribute) {
|
|
26256
|
+
ParticleFeedbackVertexAttribute["Position"] = "a_FeedbackPosition";
|
|
26257
|
+
ParticleFeedbackVertexAttribute["Velocity"] = "a_FeedbackVelocity";
|
|
26258
|
+
return ParticleFeedbackVertexAttribute;
|
|
26259
|
+
}({});
|
|
26260
|
+
|
|
26201
26261
|
/**
|
|
26202
26262
|
* @internal
|
|
26203
26263
|
*/ var ParticleInstanceVertexAttribute = /*#__PURE__*/ function(ParticleInstanceVertexAttribute) {
|
|
@@ -26292,6 +26352,22 @@ PointerEventEmitter._tempRay = new Ray();
|
|
|
26292
26352
|
return _class;
|
|
26293
26353
|
}(ContentRestorer))());
|
|
26294
26354
|
};
|
|
26355
|
+
ParticleBufferUtils.feedbackVertexStride = 24;
|
|
26356
|
+
ParticleBufferUtils.feedbackVertexElements = [
|
|
26357
|
+
new VertexElement(ParticleFeedbackVertexAttribute.Position, 0, VertexElementFormat.Vector3, 0),
|
|
26358
|
+
new VertexElement(ParticleFeedbackVertexAttribute.Velocity, 12, VertexElementFormat.Vector3, 0)
|
|
26359
|
+
];
|
|
26360
|
+
ParticleBufferUtils.feedbackInstanceElements = [
|
|
26361
|
+
new VertexElement(ParticleInstanceVertexAttribute.ShapePositionStartLifeTime, 0, VertexElementFormat.Vector4, 0),
|
|
26362
|
+
new VertexElement(ParticleInstanceVertexAttribute.DirectionTime, 16, VertexElementFormat.Vector4, 0),
|
|
26363
|
+
new VertexElement(ParticleInstanceVertexAttribute.StartSize, 48, VertexElementFormat.Vector3, 0),
|
|
26364
|
+
new VertexElement(ParticleInstanceVertexAttribute.StartSpeed, 72, VertexElementFormat.Float, 0),
|
|
26365
|
+
new VertexElement(ParticleInstanceVertexAttribute.Random0, 76, VertexElementFormat.Vector4, 0),
|
|
26366
|
+
new VertexElement(ParticleInstanceVertexAttribute.Random1, 92, VertexElementFormat.Vector4, 0),
|
|
26367
|
+
new VertexElement(ParticleInstanceVertexAttribute.SimulationWorldPosition, 108, VertexElementFormat.Vector3, 0),
|
|
26368
|
+
new VertexElement(ParticleInstanceVertexAttribute.SimulationWorldRotation, 120, VertexElementFormat.Vector4, 0),
|
|
26369
|
+
new VertexElement(ParticleInstanceVertexAttribute.Random2, 152, VertexElementFormat.Vector4, 0)
|
|
26370
|
+
];
|
|
26295
26371
|
ParticleBufferUtils.instanceVertexStride = 168;
|
|
26296
26372
|
ParticleBufferUtils.instanceVertexFloatStride = ParticleBufferUtils.instanceVertexStride / 4;
|
|
26297
26373
|
ParticleBufferUtils.startLifeTimeOffset = 3;
|
|
@@ -26324,7 +26400,7 @@ var depthOnlyVs = "#define MATERIAL_OMIT_NORMAL\n#include <common>\n#include <co
|
|
|
26324
26400
|
|
|
26325
26401
|
var particleFs = "#include <common>\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D material_BaseTexture;\nuniform vec4 material_BaseColor;\n \nuniform mediump vec3 material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n uniform sampler2D material_EmissiveTexture;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n\tvarying vec4 v_MeshColor;\n#endif\n\nvoid main() {\n\tvec4 color = material_BaseColor * v_Color;\n\n\t#if defined(RENDERER_MODE_MESH) && defined(RENDERER_ENABLE_VERTEXCOLOR)\n\t\tcolor *= v_MeshColor;\n\t#endif\n\n\t#ifdef MATERIAL_HAS_BASETEXTURE\n\t\tcolor *= texture2DSRGB(material_BaseTexture, v_TextureCoordinate);\n\t#endif\n\t\n\t// Emissive\n\tvec3 emissiveRadiance = material_EmissiveColor;\n\t#ifdef MATERIAL_HAS_EMISSIVETEXTURE\n\t\temissiveRadiance *= texture2DSRGB(material_EmissiveTexture, v_TextureCoordinate).rgb;\n\t#endif\n\n\tcolor.rgb += emissiveRadiance;\n\n\tgl_FragColor = color;\n}"; // eslint-disable-line
|
|
26326
26402
|
|
|
26327
|
-
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform
|
|
26403
|
+
var particleVs = "#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n attribute vec4 a_CornerTextureCoordinate;\n#endif\n\n#ifdef RENDERER_MODE_MESH\n attribute vec3 POSITION;\n #ifdef RENDERER_ENABLE_VERTEXCOLOR\n attribute vec4 COLOR_0;\n #endif\n attribute vec2 TEXCOORD_0;\n varying vec4 v_MeshColor;\n#endif\n\nattribute vec4 a_ShapePositionStartLifeTime;\nattribute vec4 a_DirectionTime;\nattribute vec4 a_StartColor;\nattribute vec3 a_StartSize;\nattribute vec3 a_StartRotation0;\nattribute float a_StartSpeed;\n\n//#if defined(COLOR_OVER_LIFETIME) || defined(RENDERER_COL_RANDOM_GRADIENTS) || defined(RENDERER_SOL_RANDOM_CURVES) || defined(RENDERER_SOL_RANDOM_CURVES_SEPARATE) || defined(ROTATION_OVER_LIFE_TIME_RANDOM_CONSTANTS) || defined(ROTATION_OVER_LIFETIME_RANDOM_CURVES)\n attribute vec4 a_Random0;\n//#endif\n\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_IS_RANDOM_TWO)\n attribute vec4 a_Random1; // x:texture sheet animation random\n#endif\n\n#if defined(RENDERER_FOL_CONSTANT_MODE) || defined(RENDERER_FOL_CURVE_MODE) || defined(RENDERER_LVL_MODULE_ENABLED)\n attribute vec4 a_Random2;\n#endif\n\nattribute vec3 a_SimulationWorldPosition;\nattribute vec4 a_SimulationWorldRotation;\n\n#ifdef RENDERER_TRANSFORM_FEEDBACK\n attribute vec3 a_FeedbackPosition;\n attribute vec3 a_FeedbackVelocity;\n#endif\n\nvarying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\n attribute vec4 a_SimulationUV;\n varying vec2 v_TextureCoordinate;\n#endif\n\nuniform float renderer_CurrentTime;\nuniform vec3 renderer_Gravity;\nuniform vec3 renderer_WorldPosition;\nuniform vec4 renderer_WorldRotation;\nuniform bool renderer_ThreeDStartRotation;\nuniform int renderer_ScalingMode;\nuniform vec3 renderer_PositionScale;\nuniform vec3 renderer_SizeScale;\nuniform vec3 renderer_PivotOffset;\n\nuniform mat4 camera_ViewMat;\nuniform mat4 camera_ProjMat;\n\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\n uniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward; // TODO:只有几种广告牌模式需要用\nuniform vec3 camera_Up;\n\nuniform float renderer_StretchedBillboardLengthScale;\nuniform float renderer_StretchedBillboardSpeedScale;\nuniform int renderer_SimulationSpace;\n\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <force_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\n\nvec3 computeParticlePosition(in vec3 startVelocity, in float age, in float normalizedAge, vec3 gravityVelocity, vec4 worldRotation, inout vec3 localVelocity, inout vec3 worldVelocity) {\n vec3 startPosition = startVelocity * age;\n\n vec3 finalPosition;\n vec3 localPositionOffset = startPosition;\n vec3 worldPositionOffset;\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 lifeVelocity; \n vec3 velocityPositionOffset = computeVelocityPositionOffset(normalizedAge, age, lifeVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += lifeVelocity;\n localPositionOffset += velocityPositionOffset;\n } else {\n worldVelocity += lifeVelocity;\n worldPositionOffset += velocityPositionOffset;\n }\n #endif\n\n #ifdef _FOL_MODULE_ENABLED\n vec3 forceVelocity;\n vec3 forcePositionOffset = computeForcePositionOffset(normalizedAge, age, forceVelocity);\n if (renderer_FOLSpace == 0) {\n localVelocity += forceVelocity;\n localPositionOffset += forcePositionOffset;\n } else {\n worldVelocity += forceVelocity;\n worldPositionOffset += forcePositionOffset;\n }\n #endif\n\n finalPosition = rotationByQuaternions(a_ShapePositionStartLifeTime.xyz + localPositionOffset, worldRotation) + worldPositionOffset;\n\n if (renderer_SimulationSpace == 0) {\n finalPosition = finalPosition + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n\t finalPosition = finalPosition + a_SimulationWorldPosition;\n\t}\n\n finalPosition += 0.5 * gravityVelocity * age;\n\n return finalPosition;\n}\n\nvoid main() {\n float age = renderer_CurrentTime - a_DirectionTime.w;\n float normalizedAge = age / a_ShapePositionStartLifeTime.w;\n // normalizedAge >= 0.0: skip stale TF slots whose startTime is from a previous playback (e.g. after StopEmittingAndClear).\n if (normalizedAge >= 0.0 && normalizedAge < 1.0) {\n vec4 worldRotation;\n if (renderer_SimulationSpace == 0) {\n worldRotation = renderer_WorldRotation;\n } else {\n worldRotation = a_SimulationWorldRotation;\n }\n\n vec3 localVelocity;\n vec3 worldVelocity;\n\n #ifdef RENDERER_TRANSFORM_FEEDBACK\n // Transform Feedback mode: position in simulation space (local or world).\n // Local: transform to world; World: use directly.\n vec3 center;\n if (renderer_SimulationSpace == 0) {\n center = rotationByQuaternions(a_FeedbackPosition, worldRotation) + renderer_WorldPosition;\n } else if (renderer_SimulationSpace == 1) {\n center = a_FeedbackPosition;\n }\n localVelocity = a_FeedbackVelocity;\n worldVelocity = vec3(0.0);\n\n #ifdef _VOL_MODULE_ENABLED\n vec3 instantVOLVelocity;\n computeVelocityPositionOffset(normalizedAge, age, instantVOLVelocity);\n if (renderer_VOLSpace == 0) {\n localVelocity += instantVOLVelocity;\n } else {\n worldVelocity += instantVOLVelocity;\n }\n #endif\n #else\n // Original analytical path\n vec3 startVelocity = a_DirectionTime.xyz * a_StartSpeed;\n vec3 gravityVelocity = renderer_Gravity * a_Random0.x * age;\n localVelocity = startVelocity;\n worldVelocity = gravityVelocity;\n vec3 center = computeParticlePosition(startVelocity, age, normalizedAge, gravityVelocity, worldRotation, localVelocity, worldVelocity);\n #endif\n\n #include <sphere_billboard>\n #include <stretched_billboard>\n #include <horizontal_billboard>\n #include <vertical_billboard>\n #include <particle_mesh>\n\n gl_Position = camera_ProjMat * camera_ViewMat * vec4(center, 1.0);\n v_Color = computeParticleColor(a_StartColor, normalizedAge);\n\n #ifdef MATERIAL_HAS_BASETEXTURE\n vec2 simulateUV;\n #if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\n simulateUV = a_CornerTextureCoordinate.zw * a_SimulationUV.xy + a_SimulationUV.zw;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #ifdef RENDERER_MODE_MESH\n simulateUV = a_SimulationUV.zw + TEXCOORD_0 * a_SimulationUV.xy;\n v_TextureCoordinate = computeParticleUV(simulateUV, normalizedAge);\n #endif\n #endif\n } else {\n\t gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // Discard use out of X(-1,1),Y(-1,1),Z(0,1)\n }\n}"; // eslint-disable-line
|
|
26328
26404
|
|
|
26329
26405
|
var pbrSpecularFs = "#include <common>\n#include <camera_declare>\n\n#include <FogFragmentDeclaration>\n\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n\n#include <light_frag_define>\n\n\n#include <pbr_frag_define>\n#include <pbr_helper>\n\nvoid main() {\n #include <pbr_frag>\n #include <FogFragment>\n}\n"; // eslint-disable-line
|
|
26330
26406
|
|
|
@@ -26360,12 +26436,46 @@ var unlitFs = "#include <common>\n#include <uv_share>\n#include <FogFragmentDecl
|
|
|
26360
26436
|
|
|
26361
26437
|
var unlitVs = "#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\n\nvoid main() {\n\n #include <begin_position_vert>\n #include <blendShape_vert>\n #include <skinning_vert>\n #include <uv_vert>\n #include <position_vert>\n\n #include <FogVertex>\n}\n"; // eslint-disable-line
|
|
26362
26438
|
|
|
26439
|
+
/**
|
|
26440
|
+
* @internal
|
|
26441
|
+
* Shared shader definition for Transform Feedback simulation.
|
|
26442
|
+
* Multiple simulators using the same shader share a single program pool per engine.
|
|
26443
|
+
*/ var TransformFeedbackShader = /*#__PURE__*/ function() {
|
|
26444
|
+
function TransformFeedbackShader(vertexSource, fragmentSource, feedbackVaryings) {
|
|
26445
|
+
this._id = ShaderPass._shaderPassCounter++;
|
|
26446
|
+
this.vertexSource = vertexSource;
|
|
26447
|
+
this.fragmentSource = fragmentSource;
|
|
26448
|
+
this.feedbackVaryings = feedbackVaryings;
|
|
26449
|
+
}
|
|
26450
|
+
var _proto = TransformFeedbackShader.prototype;
|
|
26451
|
+
/**
|
|
26452
|
+
* Get or compile a shader program for the given engine and macro combination.
|
|
26453
|
+
*/ _proto.getProgram = function getProgram(engine, macroCollection) {
|
|
26454
|
+
var pool = engine._getShaderProgramPool(this._id);
|
|
26455
|
+
var program = pool.get(macroCollection);
|
|
26456
|
+
if (program) return program;
|
|
26457
|
+
var _ShaderFactory_compilePlatformSource = ShaderFactory.compilePlatformSource(engine, macroCollection, this.vertexSource, this.fragmentSource), vertexSource = _ShaderFactory_compilePlatformSource.vertexSource, fragmentSource = _ShaderFactory_compilePlatformSource.fragmentSource;
|
|
26458
|
+
program = new ShaderProgram(engine, vertexSource, fragmentSource, this.feedbackVaryings);
|
|
26459
|
+
if (!program.isValid) {
|
|
26460
|
+
Logger.error("TransformFeedbackShader: Failed to compile shader program.");
|
|
26461
|
+
return null;
|
|
26462
|
+
}
|
|
26463
|
+
pool.cache(program);
|
|
26464
|
+
return program;
|
|
26465
|
+
};
|
|
26466
|
+
return TransformFeedbackShader;
|
|
26467
|
+
}();
|
|
26468
|
+
|
|
26363
26469
|
/**
|
|
26364
26470
|
* Internal shader pool.
|
|
26365
26471
|
* @internal
|
|
26366
26472
|
*/ var ShaderPool = /*#__PURE__*/ function() {
|
|
26367
26473
|
function ShaderPool() {}
|
|
26368
26474
|
ShaderPool.init = function init() {
|
|
26475
|
+
ShaderPool.particleFeedbackShader = new TransformFeedbackShader("#include <particle_feedback_simulation>", "void main() { discard; }", [
|
|
26476
|
+
"v_FeedbackPosition",
|
|
26477
|
+
"v_FeedbackVelocity"
|
|
26478
|
+
]);
|
|
26369
26479
|
var shadowCasterPass = new ShaderPass("ShadowCaster", shadowMapVs, shadowMapFs, {
|
|
26370
26480
|
pipelineStage: PipelineStage.ShadowCaster
|
|
26371
26481
|
});
|
|
@@ -26858,8 +26968,7 @@ ShaderPool.init();
|
|
|
26858
26968
|
};
|
|
26859
26969
|
/**
|
|
26860
26970
|
* @internal
|
|
26861
|
-
*/ _proto._getShaderProgramPool = function _getShaderProgramPool(
|
|
26862
|
-
var index = shaderPass._shaderPassId;
|
|
26971
|
+
*/ _proto._getShaderProgramPool = function _getShaderProgramPool(index, trackPools) {
|
|
26863
26972
|
var shaderProgramPools = this._shaderProgramPools;
|
|
26864
26973
|
var pool = shaderProgramPools[index];
|
|
26865
26974
|
if (!pool) {
|
|
@@ -26868,7 +26977,7 @@ ShaderPool.init();
|
|
|
26868
26977
|
shaderProgramPools.length = length;
|
|
26869
26978
|
}
|
|
26870
26979
|
shaderProgramPools[index] = pool = new ShaderProgramPool(this);
|
|
26871
|
-
|
|
26980
|
+
trackPools == null ? void 0 : trackPools.push(pool);
|
|
26872
26981
|
}
|
|
26873
26982
|
return pool;
|
|
26874
26983
|
};
|
|
@@ -33259,6 +33368,10 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
33259
33368
|
shaderData.setFloat(ParticleRenderer._currentTime, this.generator._playTime);
|
|
33260
33369
|
shaderData.setVector3(ParticleRenderer._pivotOffsetProperty, this.pivot);
|
|
33261
33370
|
this.generator._updateShaderData(shaderData);
|
|
33371
|
+
// Run Transform Feedback simulation after shader data is up to date
|
|
33372
|
+
if (generator._useTransformFeedback) {
|
|
33373
|
+
generator._updateFeedback(shaderData, this.engine.time.deltaTime * generator.main.simulationSpeed);
|
|
33374
|
+
}
|
|
33262
33375
|
};
|
|
33263
33376
|
_proto._render = function _render(context) {
|
|
33264
33377
|
var generator = this.generator;
|
|
@@ -33267,7 +33380,9 @@ var ParticleStopMode = /*#__PURE__*/ function(ParticleStopMode) {
|
|
|
33267
33380
|
if (!aliveParticleCount) {
|
|
33268
33381
|
return;
|
|
33269
33382
|
}
|
|
33270
|
-
|
|
33383
|
+
// Transform Feedback: render all slots (instance buffer not compacted, dead particles discarded in shader)
|
|
33384
|
+
// Non-Transform Feedback: render only alive particles (instance buffer compacted)
|
|
33385
|
+
generator._primitive.instanceCount = generator._useTransformFeedback ? generator._firstActiveElement <= generator._firstFreeElement ? generator._firstFreeElement : generator._currentParticleCount : aliveParticleCount;
|
|
33271
33386
|
var material = this.getMaterial();
|
|
33272
33387
|
if (!material || this._renderMode === ParticleRenderMode.Mesh && !this._mesh) {
|
|
33273
33388
|
return;
|
|
@@ -33423,6 +33538,331 @@ __decorate([
|
|
|
33423
33538
|
return ParticleUpdateFlags;
|
|
33424
33539
|
}({});
|
|
33425
33540
|
|
|
33541
|
+
/**
|
|
33542
|
+
* Transform Feedback object for GPU-based data capture.
|
|
33543
|
+
* @internal
|
|
33544
|
+
*/ var TransformFeedback = /*#__PURE__*/ function(GraphicsResource) {
|
|
33545
|
+
_inherits(TransformFeedback, GraphicsResource);
|
|
33546
|
+
function TransformFeedback(engine) {
|
|
33547
|
+
var _this;
|
|
33548
|
+
_this = GraphicsResource.call(this, engine) || this;
|
|
33549
|
+
_this._platformTransformFeedback = engine._hardwareRenderer.createPlatformTransformFeedback();
|
|
33550
|
+
return _this;
|
|
33551
|
+
}
|
|
33552
|
+
var _proto = TransformFeedback.prototype;
|
|
33553
|
+
/**
|
|
33554
|
+
* Bind this Transform Feedback object as active.
|
|
33555
|
+
*/ _proto.bind = function bind() {
|
|
33556
|
+
this._platformTransformFeedback.bind();
|
|
33557
|
+
};
|
|
33558
|
+
/**
|
|
33559
|
+
* Bind a buffer range as output at the given index.
|
|
33560
|
+
* @param index - Output binding point index (corresponds to varying index in shader)
|
|
33561
|
+
* @param buffer - Output buffer to capture data into
|
|
33562
|
+
* @param byteOffset - Starting byte offset in the buffer
|
|
33563
|
+
* @param byteSize - Size in bytes of the capture range
|
|
33564
|
+
*/ _proto.bindBufferRange = function bindBufferRange(index, buffer, byteOffset, byteSize) {
|
|
33565
|
+
this._platformTransformFeedback.bindBufferRange(index, buffer._platformBuffer, byteOffset, byteSize);
|
|
33566
|
+
};
|
|
33567
|
+
/**
|
|
33568
|
+
* Begin a Transform Feedback pass.
|
|
33569
|
+
* @param primitiveMode - Primitive topology mode
|
|
33570
|
+
*/ _proto.begin = function begin(primitiveMode) {
|
|
33571
|
+
this._platformTransformFeedback.begin(primitiveMode);
|
|
33572
|
+
};
|
|
33573
|
+
/**
|
|
33574
|
+
* End the current Transform Feedback pass.
|
|
33575
|
+
*/ _proto.end = function end() {
|
|
33576
|
+
this._platformTransformFeedback.end();
|
|
33577
|
+
};
|
|
33578
|
+
/**
|
|
33579
|
+
* Unbind the output buffer at the given index from the Transform Feedback target.
|
|
33580
|
+
* @param index - Output binding point index
|
|
33581
|
+
*/ _proto.unbindBuffer = function unbindBuffer(index) {
|
|
33582
|
+
this._platformTransformFeedback.unbindBuffer(index);
|
|
33583
|
+
};
|
|
33584
|
+
/**
|
|
33585
|
+
* Unbind this Transform Feedback object.
|
|
33586
|
+
*/ _proto.unbind = function unbind() {
|
|
33587
|
+
this._platformTransformFeedback.unbind();
|
|
33588
|
+
};
|
|
33589
|
+
_proto._rebuild = function _rebuild() {
|
|
33590
|
+
this._platformTransformFeedback = this._engine._hardwareRenderer.createPlatformTransformFeedback();
|
|
33591
|
+
};
|
|
33592
|
+
_proto._onDestroy = function _onDestroy() {
|
|
33593
|
+
GraphicsResource.prototype._onDestroy.call(this);
|
|
33594
|
+
this._platformTransformFeedback.destroy();
|
|
33595
|
+
};
|
|
33596
|
+
return TransformFeedback;
|
|
33597
|
+
}(GraphicsResource);
|
|
33598
|
+
|
|
33599
|
+
/**
|
|
33600
|
+
* @internal
|
|
33601
|
+
* Primitive for Transform Feedback simulation with read/write buffer swapping.
|
|
33602
|
+
*/ var TransformFeedbackPrimitive = /*#__PURE__*/ function(GraphicsResource) {
|
|
33603
|
+
_inherits(TransformFeedbackPrimitive, GraphicsResource);
|
|
33604
|
+
function TransformFeedbackPrimitive(engine, byteStride) {
|
|
33605
|
+
var _this;
|
|
33606
|
+
_this = GraphicsResource.call(this, engine) || this, _this._readIsA = true;
|
|
33607
|
+
_this._byteStride = byteStride;
|
|
33608
|
+
_this._transformFeedback = new TransformFeedback(engine);
|
|
33609
|
+
_this._transformFeedback.isGCIgnored = true;
|
|
33610
|
+
_this._platformPrimitive = engine._hardwareRenderer.createPlatformTransformFeedbackPrimitive();
|
|
33611
|
+
_this.isGCIgnored = true;
|
|
33612
|
+
return _this;
|
|
33613
|
+
}
|
|
33614
|
+
var _proto = TransformFeedbackPrimitive.prototype;
|
|
33615
|
+
/**
|
|
33616
|
+
* Resize read and write buffers.
|
|
33617
|
+
* @param vertexCount - Number of vertices to allocate
|
|
33618
|
+
*/ _proto.resize = function resize(vertexCount) {
|
|
33619
|
+
var byteLength = this._byteStride * vertexCount;
|
|
33620
|
+
var bufferA = new Buffer(this._engine, BufferBindFlag.VertexBuffer, byteLength, BufferUsage.Dynamic, false);
|
|
33621
|
+
bufferA.isGCIgnored = true;
|
|
33622
|
+
var bufferB = new Buffer(this._engine, BufferBindFlag.VertexBuffer, byteLength, BufferUsage.Dynamic, false);
|
|
33623
|
+
bufferB.isGCIgnored = true;
|
|
33624
|
+
this._bindingA = new VertexBufferBinding(bufferA, this._byteStride);
|
|
33625
|
+
this._bindingB = new VertexBufferBinding(bufferB, this._byteStride);
|
|
33626
|
+
this._readIsA = true;
|
|
33627
|
+
this._platformPrimitive.invalidate();
|
|
33628
|
+
};
|
|
33629
|
+
/**
|
|
33630
|
+
* Update vertex layout, only rebuilds when program changes.
|
|
33631
|
+
* @param program - Shader program for attribute locations
|
|
33632
|
+
* @param feedbackElements - Vertex elements describing the read/write buffer
|
|
33633
|
+
* @param inputBinding - Additional input buffer binding
|
|
33634
|
+
* @param inputElements - Vertex elements describing the input buffer
|
|
33635
|
+
*/ _proto.updateVertexLayout = function updateVertexLayout(program, feedbackElements, inputBinding, inputElements) {
|
|
33636
|
+
this._platformPrimitive.updateVertexLayout(program, this._bindingA, this._bindingB, feedbackElements, inputBinding, inputElements);
|
|
33637
|
+
};
|
|
33638
|
+
/**
|
|
33639
|
+
* Bind state before issuing draw calls.
|
|
33640
|
+
*/ _proto.beginDraw = function beginDraw() {
|
|
33641
|
+
this._engine._hardwareRenderer.enableRasterizerDiscard();
|
|
33642
|
+
this._transformFeedback.bind();
|
|
33643
|
+
this._platformPrimitive.bind(this._readIsA);
|
|
33644
|
+
};
|
|
33645
|
+
/**
|
|
33646
|
+
* Issue a draw call for a vertex range, capturing output to the write buffer.
|
|
33647
|
+
* @param mode - Primitive topology
|
|
33648
|
+
* @param first - First vertex index
|
|
33649
|
+
* @param count - Number of vertices
|
|
33650
|
+
*/ _proto.draw = function draw(mode, first, count) {
|
|
33651
|
+
var transformFeedback = this._transformFeedback;
|
|
33652
|
+
transformFeedback.bindBufferRange(0, this.writeBinding.buffer, first * this._byteStride, count * this._byteStride);
|
|
33653
|
+
transformFeedback.begin(mode);
|
|
33654
|
+
this._platformPrimitive.draw(mode, first, count);
|
|
33655
|
+
transformFeedback.end();
|
|
33656
|
+
};
|
|
33657
|
+
/**
|
|
33658
|
+
* Unbind state after draw calls.
|
|
33659
|
+
*/ _proto.endDraw = function endDraw() {
|
|
33660
|
+
this._platformPrimitive.unbind();
|
|
33661
|
+
this._transformFeedback.unbindBuffer(0);
|
|
33662
|
+
this._transformFeedback.unbind();
|
|
33663
|
+
this._engine._hardwareRenderer.disableRasterizerDiscard();
|
|
33664
|
+
this._engine._hardwareRenderer.invalidateShaderProgramState();
|
|
33665
|
+
};
|
|
33666
|
+
/**
|
|
33667
|
+
* Swap read and write buffers.
|
|
33668
|
+
*/ _proto.swap = function swap() {
|
|
33669
|
+
this._readIsA = !this._readIsA;
|
|
33670
|
+
};
|
|
33671
|
+
_proto._rebuild = function _rebuild() {
|
|
33672
|
+
this._platformPrimitive = this._engine._hardwareRenderer.createPlatformTransformFeedbackPrimitive();
|
|
33673
|
+
};
|
|
33674
|
+
_proto._onDestroy = function _onDestroy() {
|
|
33675
|
+
var _this__platformPrimitive, _this__bindingA, _this__bindingB, _this__transformFeedback;
|
|
33676
|
+
GraphicsResource.prototype._onDestroy.call(this);
|
|
33677
|
+
(_this__platformPrimitive = this._platformPrimitive) == null ? void 0 : _this__platformPrimitive.destroy();
|
|
33678
|
+
(_this__bindingA = this._bindingA) == null ? void 0 : _this__bindingA.buffer.destroy();
|
|
33679
|
+
(_this__bindingB = this._bindingB) == null ? void 0 : _this__bindingB.buffer.destroy();
|
|
33680
|
+
(_this__transformFeedback = this._transformFeedback) == null ? void 0 : _this__transformFeedback.destroy();
|
|
33681
|
+
};
|
|
33682
|
+
_create_class(TransformFeedbackPrimitive, [
|
|
33683
|
+
{
|
|
33684
|
+
key: "readBinding",
|
|
33685
|
+
get: /**
|
|
33686
|
+
* The current read buffer binding.
|
|
33687
|
+
*/ function get() {
|
|
33688
|
+
return this._readIsA ? this._bindingA : this._bindingB;
|
|
33689
|
+
}
|
|
33690
|
+
},
|
|
33691
|
+
{
|
|
33692
|
+
key: "writeBinding",
|
|
33693
|
+
get: /**
|
|
33694
|
+
* The current write buffer binding.
|
|
33695
|
+
*/ function get() {
|
|
33696
|
+
return this._readIsA ? this._bindingB : this._bindingA;
|
|
33697
|
+
}
|
|
33698
|
+
}
|
|
33699
|
+
]);
|
|
33700
|
+
return TransformFeedbackPrimitive;
|
|
33701
|
+
}(GraphicsResource);
|
|
33702
|
+
|
|
33703
|
+
/**
|
|
33704
|
+
* @internal
|
|
33705
|
+
* General-purpose Transform Feedback simulator.
|
|
33706
|
+
* Manages per-frame simulation with shared shader program caching.
|
|
33707
|
+
*/ var TransformFeedbackSimulator = /*#__PURE__*/ function() {
|
|
33708
|
+
function TransformFeedbackSimulator(engine, byteStride, shader) {
|
|
33709
|
+
this._engine = engine;
|
|
33710
|
+
this._primitive = new TransformFeedbackPrimitive(engine, byteStride);
|
|
33711
|
+
this._shader = shader;
|
|
33712
|
+
}
|
|
33713
|
+
var _proto = TransformFeedbackSimulator.prototype;
|
|
33714
|
+
/**
|
|
33715
|
+
* Resize feedback buffers.
|
|
33716
|
+
* @param vertexCount - Number of vertices to allocate
|
|
33717
|
+
*/ _proto.resize = function resize(vertexCount) {
|
|
33718
|
+
this._primitive.resize(vertexCount);
|
|
33719
|
+
};
|
|
33720
|
+
/**
|
|
33721
|
+
* Begin a simulation step: get/compile program, bind, upload uniforms, update layout.
|
|
33722
|
+
* @param shaderData - Shader data with current macros and uniforms
|
|
33723
|
+
* @param feedbackElements - Vertex elements for the feedback buffer
|
|
33724
|
+
* @param inputBinding - Input buffer binding
|
|
33725
|
+
* @param inputElements - Vertex elements for the input buffer
|
|
33726
|
+
*/ _proto.beginUpdate = function beginUpdate(shaderData, feedbackElements, inputBinding, inputElements) {
|
|
33727
|
+
var program = this._shader.getProgram(this._engine, shaderData._macroCollection);
|
|
33728
|
+
if (!program) return false;
|
|
33729
|
+
program.bind();
|
|
33730
|
+
program.uploadUniforms(program.rendererUniformBlock, shaderData);
|
|
33731
|
+
program.uploadUniforms(program.otherUniformBlock, shaderData);
|
|
33732
|
+
this._primitive.updateVertexLayout(program, feedbackElements, inputBinding, inputElements);
|
|
33733
|
+
this._primitive.beginDraw();
|
|
33734
|
+
return true;
|
|
33735
|
+
};
|
|
33736
|
+
/**
|
|
33737
|
+
* Issue a draw call for a vertex range.
|
|
33738
|
+
* @param mode - Primitive topology
|
|
33739
|
+
* @param first - First vertex index
|
|
33740
|
+
* @param count - Number of vertices
|
|
33741
|
+
*/ _proto.draw = function draw(mode, first, count) {
|
|
33742
|
+
this._primitive.draw(mode, first, count);
|
|
33743
|
+
};
|
|
33744
|
+
/**
|
|
33745
|
+
* End the simulation step: unbind state and swap buffers.
|
|
33746
|
+
*/ _proto.endUpdate = function endUpdate() {
|
|
33747
|
+
this._primitive.endDraw();
|
|
33748
|
+
this._primitive.swap();
|
|
33749
|
+
};
|
|
33750
|
+
_proto.destroy = function destroy() {
|
|
33751
|
+
var _this__primitive;
|
|
33752
|
+
(_this__primitive = this._primitive) == null ? void 0 : _this__primitive.destroy();
|
|
33753
|
+
};
|
|
33754
|
+
_create_class(TransformFeedbackSimulator, [
|
|
33755
|
+
{
|
|
33756
|
+
key: "readBinding",
|
|
33757
|
+
get: /**
|
|
33758
|
+
* The current read buffer binding.
|
|
33759
|
+
*/ function get() {
|
|
33760
|
+
return this._primitive.readBinding;
|
|
33761
|
+
}
|
|
33762
|
+
},
|
|
33763
|
+
{
|
|
33764
|
+
key: "writeBinding",
|
|
33765
|
+
get: /**
|
|
33766
|
+
* The current write buffer binding.
|
|
33767
|
+
*/ function get() {
|
|
33768
|
+
return this._primitive.writeBinding;
|
|
33769
|
+
}
|
|
33770
|
+
}
|
|
33771
|
+
]);
|
|
33772
|
+
return TransformFeedbackSimulator;
|
|
33773
|
+
}();
|
|
33774
|
+
|
|
33775
|
+
/**
|
|
33776
|
+
* @internal
|
|
33777
|
+
* Particle-specific Transform Feedback simulation.
|
|
33778
|
+
*/ var ParticleTransformFeedbackSimulator = /*#__PURE__*/ function() {
|
|
33779
|
+
function ParticleTransformFeedbackSimulator(engine) {
|
|
33780
|
+
this._particleInitData = new Float32Array(6);
|
|
33781
|
+
this._simulator = new TransformFeedbackSimulator(engine, ParticleBufferUtils.feedbackVertexStride, ShaderPool.particleFeedbackShader);
|
|
33782
|
+
}
|
|
33783
|
+
var _proto = ParticleTransformFeedbackSimulator.prototype;
|
|
33784
|
+
/**
|
|
33785
|
+
* Resize feedback buffers.
|
|
33786
|
+
* Saves pre-resize buffers internally for subsequent `copyOldBufferData` / `destroyOldBuffers` calls.
|
|
33787
|
+
* @param particleCount - Number of particles to allocate
|
|
33788
|
+
* @param instanceBinding - New instance vertex buffer binding
|
|
33789
|
+
*/ _proto.resize = function resize(particleCount, instanceBinding) {
|
|
33790
|
+
var _this__simulator_readBinding, _this__simulator_writeBinding;
|
|
33791
|
+
this._oldReadBuffer = (_this__simulator_readBinding = this._simulator.readBinding) == null ? void 0 : _this__simulator_readBinding.buffer;
|
|
33792
|
+
this._oldWriteBuffer = (_this__simulator_writeBinding = this._simulator.writeBinding) == null ? void 0 : _this__simulator_writeBinding.buffer;
|
|
33793
|
+
this._simulator.resize(particleCount);
|
|
33794
|
+
this._instanceBinding = instanceBinding;
|
|
33795
|
+
};
|
|
33796
|
+
/**
|
|
33797
|
+
* Write initial position and velocity for a newly emitted particle.
|
|
33798
|
+
*/ _proto.writeParticleData = function writeParticleData(index, position, vx, vy, vz) {
|
|
33799
|
+
var data = this._particleInitData;
|
|
33800
|
+
data[0] = position.x;
|
|
33801
|
+
data[1] = position.y;
|
|
33802
|
+
data[2] = position.z;
|
|
33803
|
+
data[3] = vx;
|
|
33804
|
+
data[4] = vy;
|
|
33805
|
+
data[5] = vz;
|
|
33806
|
+
var simulator = this._simulator;
|
|
33807
|
+
var byteOffset = index * ParticleBufferUtils.feedbackVertexStride;
|
|
33808
|
+
simulator.readBinding.buffer.setData(data, byteOffset);
|
|
33809
|
+
simulator.writeBinding.buffer.setData(data, byteOffset);
|
|
33810
|
+
};
|
|
33811
|
+
/**
|
|
33812
|
+
* Copy data from pre-resize buffers to current buffers.
|
|
33813
|
+
* Must be called after `resize` which saves the old buffers.
|
|
33814
|
+
*/ _proto.copyOldBufferData = function copyOldBufferData(srcByteOffset, dstByteOffset, byteLength) {
|
|
33815
|
+
this._simulator.readBinding.buffer.copyFromBuffer(this._oldReadBuffer, srcByteOffset, dstByteOffset, byteLength);
|
|
33816
|
+
this._simulator.writeBinding.buffer.copyFromBuffer(this._oldWriteBuffer, srcByteOffset, dstByteOffset, byteLength);
|
|
33817
|
+
};
|
|
33818
|
+
/**
|
|
33819
|
+
* Destroy pre-resize buffers saved during `resize`.
|
|
33820
|
+
*/ _proto.destroyOldBuffers = function destroyOldBuffers() {
|
|
33821
|
+
var _this__oldReadBuffer, _this__oldWriteBuffer;
|
|
33822
|
+
(_this__oldReadBuffer = this._oldReadBuffer) == null ? void 0 : _this__oldReadBuffer.destroy();
|
|
33823
|
+
(_this__oldWriteBuffer = this._oldWriteBuffer) == null ? void 0 : _this__oldWriteBuffer.destroy();
|
|
33824
|
+
this._oldReadBuffer = null;
|
|
33825
|
+
this._oldWriteBuffer = null;
|
|
33826
|
+
};
|
|
33827
|
+
/**
|
|
33828
|
+
* Run one simulation step.
|
|
33829
|
+
* @param shaderData - Shader data with current macros and uniforms
|
|
33830
|
+
* @param particleCount - Total particle slot count
|
|
33831
|
+
* @param firstActive - First active particle index in ring buffer
|
|
33832
|
+
* @param firstFree - First free particle index in ring buffer
|
|
33833
|
+
* @param deltaTime - Frame delta time
|
|
33834
|
+
*/ _proto.update = function update(shaderData, particleCount, firstActive, firstFree, deltaTime) {
|
|
33835
|
+
if (firstActive === firstFree) return;
|
|
33836
|
+
shaderData.setFloat(ParticleTransformFeedbackSimulator._deltaTimeProperty, deltaTime);
|
|
33837
|
+
if (!this._simulator.beginUpdate(shaderData, ParticleBufferUtils.feedbackVertexElements, this._instanceBinding, ParticleBufferUtils.feedbackInstanceElements)) return;
|
|
33838
|
+
if (firstActive < firstFree) {
|
|
33839
|
+
this._simulator.draw(MeshTopology.Points, firstActive, firstFree - firstActive);
|
|
33840
|
+
} else {
|
|
33841
|
+
this._simulator.draw(MeshTopology.Points, firstActive, particleCount - firstActive);
|
|
33842
|
+
if (firstFree > 0) {
|
|
33843
|
+
this._simulator.draw(MeshTopology.Points, 0, firstFree);
|
|
33844
|
+
}
|
|
33845
|
+
}
|
|
33846
|
+
this._simulator.endUpdate();
|
|
33847
|
+
};
|
|
33848
|
+
_proto.destroy = function destroy() {
|
|
33849
|
+
var _this__simulator;
|
|
33850
|
+
(_this__simulator = this._simulator) == null ? void 0 : _this__simulator.destroy();
|
|
33851
|
+
};
|
|
33852
|
+
_create_class(ParticleTransformFeedbackSimulator, [
|
|
33853
|
+
{
|
|
33854
|
+
key: "readBinding",
|
|
33855
|
+
get: /**
|
|
33856
|
+
* The current read buffer binding for the render pass.
|
|
33857
|
+
*/ function get() {
|
|
33858
|
+
return this._simulator.readBinding;
|
|
33859
|
+
}
|
|
33860
|
+
}
|
|
33861
|
+
]);
|
|
33862
|
+
return ParticleTransformFeedbackSimulator;
|
|
33863
|
+
}();
|
|
33864
|
+
ParticleTransformFeedbackSimulator._deltaTimeProperty = ShaderProperty.getByName("renderer_DeltaTime");
|
|
33865
|
+
|
|
33426
33866
|
/**
|
|
33427
33867
|
* Particle curve mode.
|
|
33428
33868
|
*/ var ParticleCurveMode = /*#__PURE__*/ function(ParticleCurveMode) {
|
|
@@ -33462,6 +33902,7 @@ __decorate([
|
|
|
33462
33902
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["Shape"] = 2941263940] = "Shape";
|
|
33463
33903
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["GravityModifier"] = 2759560269] = "GravityModifier";
|
|
33464
33904
|
ParticleRandomSubSeeds[ParticleRandomSubSeeds["ForceOverLifetime"] = 3875246972] = "ForceOverLifetime";
|
|
33905
|
+
ParticleRandomSubSeeds[ParticleRandomSubSeeds["LimitVelocityOverLifetime"] = 3047300990] = "LimitVelocityOverLifetime";
|
|
33465
33906
|
return ParticleRandomSubSeeds;
|
|
33466
33907
|
}({});
|
|
33467
33908
|
|
|
@@ -34519,6 +34960,415 @@ __decorate([
|
|
|
34519
34960
|
deepClone
|
|
34520
34961
|
], ForceOverLifetimeModule.prototype, "_forceZ", void 0);
|
|
34521
34962
|
|
|
34963
|
+
/**
|
|
34964
|
+
* Limit velocity over lifetime module.
|
|
34965
|
+
*/ var LimitVelocityOverLifetimeModule = /*#__PURE__*/ function(ParticleGeneratorModule) {
|
|
34966
|
+
_inherits(LimitVelocityOverLifetimeModule, ParticleGeneratorModule);
|
|
34967
|
+
function LimitVelocityOverLifetimeModule(generator) {
|
|
34968
|
+
var _this;
|
|
34969
|
+
_this = ParticleGeneratorModule.call(this, generator) || this, /** @internal */ _this._speedRand = new Rand(0, ParticleRandomSubSeeds.LimitVelocityOverLifetime), _this._speedMinConstantVec = new Vector3(), _this._speedMaxConstantVec = new Vector3(), _this._dragConstantVec = new Vector2(), _this._separateAxes = false, _this._dampen = 0, _this._multiplyDragByParticleSize = false, _this._multiplyDragByParticleVelocity = false, _this._space = ParticleSimulationSpace.Local;
|
|
34970
|
+
_this.speedX = new ParticleCompositeCurve(1);
|
|
34971
|
+
_this.speedY = new ParticleCompositeCurve(1);
|
|
34972
|
+
_this.speedZ = new ParticleCompositeCurve(1);
|
|
34973
|
+
_this.drag = new ParticleCompositeCurve(0);
|
|
34974
|
+
return _this;
|
|
34975
|
+
}
|
|
34976
|
+
var _proto = LimitVelocityOverLifetimeModule.prototype;
|
|
34977
|
+
/**
|
|
34978
|
+
* @internal
|
|
34979
|
+
*/ _proto._isDragRandomMode = function _isDragRandomMode() {
|
|
34980
|
+
return this._drag.mode === ParticleCurveMode.TwoConstants || this._drag.mode === ParticleCurveMode.TwoCurves;
|
|
34981
|
+
};
|
|
34982
|
+
/**
|
|
34983
|
+
* @internal
|
|
34984
|
+
*/ _proto._isSpeedRandomMode = function _isSpeedRandomMode() {
|
|
34985
|
+
if (this._separateAxes) {
|
|
34986
|
+
return (this._speedX.mode === ParticleCurveMode.TwoConstants || this._speedX.mode === ParticleCurveMode.TwoCurves) && (this._speedY.mode === ParticleCurveMode.TwoConstants || this._speedY.mode === ParticleCurveMode.TwoCurves) && (this._speedZ.mode === ParticleCurveMode.TwoConstants || this._speedZ.mode === ParticleCurveMode.TwoCurves);
|
|
34987
|
+
}
|
|
34988
|
+
return this._speedX.mode === ParticleCurveMode.TwoConstants || this._speedX.mode === ParticleCurveMode.TwoCurves;
|
|
34989
|
+
};
|
|
34990
|
+
/**
|
|
34991
|
+
* @internal
|
|
34992
|
+
*/ _proto._updateShaderData = function _updateShaderData(shaderData) {
|
|
34993
|
+
var enabledModuleMacro = null;
|
|
34994
|
+
var separateAxesMacro = null;
|
|
34995
|
+
var speedModeMacro = null;
|
|
34996
|
+
var speedRandomMacro = null;
|
|
34997
|
+
var dragCurveMacro = null;
|
|
34998
|
+
var dragRandomMacro = null;
|
|
34999
|
+
var dragSizeMacro = null;
|
|
35000
|
+
var dragVelocityMacro = null;
|
|
35001
|
+
if (this.enabled) {
|
|
35002
|
+
enabledModuleMacro = LimitVelocityOverLifetimeModule._enabledMacro;
|
|
35003
|
+
// Dampen
|
|
35004
|
+
shaderData.setFloat(LimitVelocityOverLifetimeModule._dampenProperty, this._dampen);
|
|
35005
|
+
// Space
|
|
35006
|
+
shaderData.setInt(LimitVelocityOverLifetimeModule._spaceProperty, this._space);
|
|
35007
|
+
// Limit speed
|
|
35008
|
+
if (this._separateAxes) {
|
|
35009
|
+
separateAxesMacro = LimitVelocityOverLifetimeModule._separateAxesMacro;
|
|
35010
|
+
var result = this._uploadSeparateAxisSpeeds(shaderData);
|
|
35011
|
+
speedModeMacro = result.modeMacro;
|
|
35012
|
+
speedRandomMacro = result.randomMacro;
|
|
35013
|
+
} else {
|
|
35014
|
+
var result1 = this._uploadScalarSpeed(shaderData);
|
|
35015
|
+
speedModeMacro = result1.modeMacro;
|
|
35016
|
+
speedRandomMacro = result1.randomMacro;
|
|
35017
|
+
}
|
|
35018
|
+
// Drag
|
|
35019
|
+
var dragResult = this._uploadDrag(shaderData);
|
|
35020
|
+
dragCurveMacro = dragResult.curveMacro;
|
|
35021
|
+
dragRandomMacro = dragResult.randomMacro;
|
|
35022
|
+
// Drag modifiers
|
|
35023
|
+
if (this._multiplyDragByParticleSize) {
|
|
35024
|
+
dragSizeMacro = LimitVelocityOverLifetimeModule._multiplyDragBySizeMacro;
|
|
35025
|
+
}
|
|
35026
|
+
if (this._multiplyDragByParticleVelocity) {
|
|
35027
|
+
dragVelocityMacro = LimitVelocityOverLifetimeModule._multiplyDragByVelocityMacro;
|
|
35028
|
+
}
|
|
35029
|
+
}
|
|
35030
|
+
this._enabledModuleMacro = this._enableMacro(shaderData, this._enabledModuleMacro, enabledModuleMacro);
|
|
35031
|
+
this._separateAxesCachedMacro = this._enableMacro(shaderData, this._separateAxesCachedMacro, separateAxesMacro);
|
|
35032
|
+
this._speedModeMacro = this._enableMacro(shaderData, this._speedModeMacro, speedModeMacro);
|
|
35033
|
+
this._speedRandomMacro = this._enableMacro(shaderData, this._speedRandomMacro, speedRandomMacro);
|
|
35034
|
+
this._dragCurveCachedMacro = this._enableMacro(shaderData, this._dragCurveCachedMacro, dragCurveMacro);
|
|
35035
|
+
this._dragRandomCachedMacro = this._enableMacro(shaderData, this._dragRandomCachedMacro, dragRandomMacro);
|
|
35036
|
+
this._dragSizeMacro = this._enableMacro(shaderData, this._dragSizeMacro, dragSizeMacro);
|
|
35037
|
+
this._dragVelocityMacro = this._enableMacro(shaderData, this._dragVelocityMacro, dragVelocityMacro);
|
|
35038
|
+
};
|
|
35039
|
+
/**
|
|
35040
|
+
* @internal
|
|
35041
|
+
*/ _proto._resetRandomSeed = function _resetRandomSeed(seed) {
|
|
35042
|
+
this._speedRand.reset(seed, ParticleRandomSubSeeds.LimitVelocityOverLifetime);
|
|
35043
|
+
};
|
|
35044
|
+
_proto._uploadScalarSpeed = function _uploadScalarSpeed(shaderData) {
|
|
35045
|
+
var speedX = this._speedX;
|
|
35046
|
+
var modeMacro = null;
|
|
35047
|
+
var randomMacro = null;
|
|
35048
|
+
var isRandomCurveMode = speedX.mode === ParticleCurveMode.TwoCurves;
|
|
35049
|
+
if (isRandomCurveMode || speedX.mode === ParticleCurveMode.Curve) {
|
|
35050
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedMaxCurveProperty, speedX.curveMax._getTypeArray());
|
|
35051
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedCurveModeMacro;
|
|
35052
|
+
if (isRandomCurveMode) {
|
|
35053
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedMinCurveProperty, speedX.curveMin._getTypeArray());
|
|
35054
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35055
|
+
}
|
|
35056
|
+
} else {
|
|
35057
|
+
shaderData.setFloat(LimitVelocityOverLifetimeModule._speedMaxConstProperty, speedX.constantMax);
|
|
35058
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedConstantModeMacro;
|
|
35059
|
+
if (speedX.mode === ParticleCurveMode.TwoConstants) {
|
|
35060
|
+
shaderData.setFloat(LimitVelocityOverLifetimeModule._speedMinConstProperty, speedX.constantMin);
|
|
35061
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35062
|
+
}
|
|
35063
|
+
}
|
|
35064
|
+
return {
|
|
35065
|
+
modeMacro: modeMacro,
|
|
35066
|
+
randomMacro: randomMacro
|
|
35067
|
+
};
|
|
35068
|
+
};
|
|
35069
|
+
_proto._uploadSeparateAxisSpeeds = function _uploadSeparateAxisSpeeds(shaderData) {
|
|
35070
|
+
var speedX = this._speedX;
|
|
35071
|
+
var speedY = this._speedY;
|
|
35072
|
+
var speedZ = this._speedZ;
|
|
35073
|
+
var modeMacro = null;
|
|
35074
|
+
var randomMacro = null;
|
|
35075
|
+
var isRandomCurveMode = speedX.mode === ParticleCurveMode.TwoCurves && speedY.mode === ParticleCurveMode.TwoCurves && speedZ.mode === ParticleCurveMode.TwoCurves;
|
|
35076
|
+
if (isRandomCurveMode || speedX.mode === ParticleCurveMode.Curve && speedY.mode === ParticleCurveMode.Curve && speedZ.mode === ParticleCurveMode.Curve) {
|
|
35077
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedXMaxCurveProperty, speedX.curveMax._getTypeArray());
|
|
35078
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedYMaxCurveProperty, speedY.curveMax._getTypeArray());
|
|
35079
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedZMaxCurveProperty, speedZ.curveMax._getTypeArray());
|
|
35080
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedCurveModeMacro;
|
|
35081
|
+
if (isRandomCurveMode) {
|
|
35082
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedXMinCurveProperty, speedX.curveMin._getTypeArray());
|
|
35083
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedYMinCurveProperty, speedY.curveMin._getTypeArray());
|
|
35084
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._speedZMinCurveProperty, speedZ.curveMin._getTypeArray());
|
|
35085
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35086
|
+
}
|
|
35087
|
+
} else {
|
|
35088
|
+
var constantMax = this._speedMaxConstantVec;
|
|
35089
|
+
constantMax.set(speedX.constantMax, speedY.constantMax, speedZ.constantMax);
|
|
35090
|
+
shaderData.setVector3(LimitVelocityOverLifetimeModule._speedMaxConstVecProperty, constantMax);
|
|
35091
|
+
modeMacro = LimitVelocityOverLifetimeModule._speedConstantModeMacro;
|
|
35092
|
+
if (speedX.mode === ParticleCurveMode.TwoConstants && speedY.mode === ParticleCurveMode.TwoConstants && speedZ.mode === ParticleCurveMode.TwoConstants) {
|
|
35093
|
+
var constantMin = this._speedMinConstantVec;
|
|
35094
|
+
constantMin.set(speedX.constantMin, speedY.constantMin, speedZ.constantMin);
|
|
35095
|
+
shaderData.setVector3(LimitVelocityOverLifetimeModule._speedMinConstVecProperty, constantMin);
|
|
35096
|
+
randomMacro = LimitVelocityOverLifetimeModule._speedIsRandomMacro;
|
|
35097
|
+
}
|
|
35098
|
+
}
|
|
35099
|
+
return {
|
|
35100
|
+
modeMacro: modeMacro,
|
|
35101
|
+
randomMacro: randomMacro
|
|
35102
|
+
};
|
|
35103
|
+
};
|
|
35104
|
+
_proto._uploadDrag = function _uploadDrag(shaderData) {
|
|
35105
|
+
var drag = this._drag;
|
|
35106
|
+
var curveMacro = null;
|
|
35107
|
+
var randomMacro = null;
|
|
35108
|
+
var isRandomCurveMode = drag.mode === ParticleCurveMode.TwoCurves;
|
|
35109
|
+
if (isRandomCurveMode || drag.mode === ParticleCurveMode.Curve) {
|
|
35110
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._dragMaxCurveProperty, drag.curveMax._getTypeArray());
|
|
35111
|
+
curveMacro = LimitVelocityOverLifetimeModule._dragCurveModeMacro;
|
|
35112
|
+
if (isRandomCurveMode) {
|
|
35113
|
+
shaderData.setFloatArray(LimitVelocityOverLifetimeModule._dragMinCurveProperty, drag.curveMin._getTypeArray());
|
|
35114
|
+
randomMacro = LimitVelocityOverLifetimeModule._dragIsRandomMacro;
|
|
35115
|
+
}
|
|
35116
|
+
} else {
|
|
35117
|
+
var dragVec = this._dragConstantVec;
|
|
35118
|
+
if (drag.mode === ParticleCurveMode.TwoConstants) {
|
|
35119
|
+
dragVec.set(drag.constantMin, drag.constantMax);
|
|
35120
|
+
} else {
|
|
35121
|
+
dragVec.set(drag.constantMax, drag.constantMax);
|
|
35122
|
+
}
|
|
35123
|
+
shaderData.setVector2(LimitVelocityOverLifetimeModule._dragConstantProperty, dragVec);
|
|
35124
|
+
}
|
|
35125
|
+
return {
|
|
35126
|
+
curveMacro: curveMacro,
|
|
35127
|
+
randomMacro: randomMacro
|
|
35128
|
+
};
|
|
35129
|
+
};
|
|
35130
|
+
_create_class(LimitVelocityOverLifetimeModule, [
|
|
35131
|
+
{
|
|
35132
|
+
key: "separateAxes",
|
|
35133
|
+
get: /**
|
|
35134
|
+
* Whether to limit velocity on each axis separately.
|
|
35135
|
+
*/ function get() {
|
|
35136
|
+
return this._separateAxes;
|
|
35137
|
+
},
|
|
35138
|
+
set: function set(value) {
|
|
35139
|
+
if (value !== this._separateAxes) {
|
|
35140
|
+
this._separateAxes = value;
|
|
35141
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35142
|
+
}
|
|
35143
|
+
}
|
|
35144
|
+
},
|
|
35145
|
+
{
|
|
35146
|
+
key: "speed",
|
|
35147
|
+
get: /**
|
|
35148
|
+
* Speed limit when separateAxes is false.
|
|
35149
|
+
*/ function get() {
|
|
35150
|
+
return this._speedX;
|
|
35151
|
+
},
|
|
35152
|
+
set: function set(value) {
|
|
35153
|
+
this.speedX = value;
|
|
35154
|
+
}
|
|
35155
|
+
},
|
|
35156
|
+
{
|
|
35157
|
+
key: "speedX",
|
|
35158
|
+
get: /**
|
|
35159
|
+
* Speed limit for the x-axis (or overall limit when separateAxes is false).
|
|
35160
|
+
*/ function get() {
|
|
35161
|
+
return this._speedX;
|
|
35162
|
+
},
|
|
35163
|
+
set: function set(value) {
|
|
35164
|
+
var lastValue = this._speedX;
|
|
35165
|
+
if (value !== lastValue) {
|
|
35166
|
+
this._speedX = value;
|
|
35167
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
35168
|
+
}
|
|
35169
|
+
}
|
|
35170
|
+
},
|
|
35171
|
+
{
|
|
35172
|
+
key: "speedY",
|
|
35173
|
+
get: /**
|
|
35174
|
+
* Speed limit for the y-axis.
|
|
35175
|
+
*/ function get() {
|
|
35176
|
+
return this._speedY;
|
|
35177
|
+
},
|
|
35178
|
+
set: function set(value) {
|
|
35179
|
+
var lastValue = this._speedY;
|
|
35180
|
+
if (value !== lastValue) {
|
|
35181
|
+
this._speedY = value;
|
|
35182
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
35183
|
+
}
|
|
35184
|
+
}
|
|
35185
|
+
},
|
|
35186
|
+
{
|
|
35187
|
+
key: "speedZ",
|
|
35188
|
+
get: /**
|
|
35189
|
+
* Speed limit for the z-axis.
|
|
35190
|
+
*/ function get() {
|
|
35191
|
+
return this._speedZ;
|
|
35192
|
+
},
|
|
35193
|
+
set: function set(value) {
|
|
35194
|
+
var lastValue = this._speedZ;
|
|
35195
|
+
if (value !== lastValue) {
|
|
35196
|
+
this._speedZ = value;
|
|
35197
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
35198
|
+
}
|
|
35199
|
+
}
|
|
35200
|
+
},
|
|
35201
|
+
{
|
|
35202
|
+
key: "dampen",
|
|
35203
|
+
get: /**
|
|
35204
|
+
* Controls how much the velocity is dampened when it exceeds the limit.
|
|
35205
|
+
* @remarks Value is clamped to [0, 1]. 0 means no damping, 1 means full damping.
|
|
35206
|
+
*/ function get() {
|
|
35207
|
+
return this._dampen;
|
|
35208
|
+
},
|
|
35209
|
+
set: function set(value) {
|
|
35210
|
+
value = Math.max(0, Math.min(1, value));
|
|
35211
|
+
if (value !== this._dampen) {
|
|
35212
|
+
this._dampen = value;
|
|
35213
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35214
|
+
}
|
|
35215
|
+
}
|
|
35216
|
+
},
|
|
35217
|
+
{
|
|
35218
|
+
key: "drag",
|
|
35219
|
+
get: /**
|
|
35220
|
+
* Controls the amount of drag applied to particle velocities.
|
|
35221
|
+
*/ function get() {
|
|
35222
|
+
return this._drag;
|
|
35223
|
+
},
|
|
35224
|
+
set: function set(value) {
|
|
35225
|
+
var lastValue = this._drag;
|
|
35226
|
+
if (value !== lastValue) {
|
|
35227
|
+
this._drag = value;
|
|
35228
|
+
this._onCompositeCurveChange(lastValue, value);
|
|
35229
|
+
}
|
|
35230
|
+
}
|
|
35231
|
+
},
|
|
35232
|
+
{
|
|
35233
|
+
key: "multiplyDragByParticleSize",
|
|
35234
|
+
get: /**
|
|
35235
|
+
* Adjust the amount of drag based on particle sizes.
|
|
35236
|
+
*/ function get() {
|
|
35237
|
+
return this._multiplyDragByParticleSize;
|
|
35238
|
+
},
|
|
35239
|
+
set: function set(value) {
|
|
35240
|
+
if (value !== this._multiplyDragByParticleSize) {
|
|
35241
|
+
this._multiplyDragByParticleSize = value;
|
|
35242
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35243
|
+
}
|
|
35244
|
+
}
|
|
35245
|
+
},
|
|
35246
|
+
{
|
|
35247
|
+
key: "multiplyDragByParticleVelocity",
|
|
35248
|
+
get: /**
|
|
35249
|
+
* Adjust the amount of drag based on particle speeds.
|
|
35250
|
+
*/ function get() {
|
|
35251
|
+
return this._multiplyDragByParticleVelocity;
|
|
35252
|
+
},
|
|
35253
|
+
set: function set(value) {
|
|
35254
|
+
if (value !== this._multiplyDragByParticleVelocity) {
|
|
35255
|
+
this._multiplyDragByParticleVelocity = value;
|
|
35256
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35257
|
+
}
|
|
35258
|
+
}
|
|
35259
|
+
},
|
|
35260
|
+
{
|
|
35261
|
+
key: "space",
|
|
35262
|
+
get: /**
|
|
35263
|
+
* Specifies if the velocity limits are in local space or world space.
|
|
35264
|
+
* @remarks Only takes effect when 'separateAxes' is enabled.
|
|
35265
|
+
*/ function get() {
|
|
35266
|
+
return this._space;
|
|
35267
|
+
},
|
|
35268
|
+
set: function set(value) {
|
|
35269
|
+
if (value !== this._space) {
|
|
35270
|
+
this._space = value;
|
|
35271
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35272
|
+
}
|
|
35273
|
+
}
|
|
35274
|
+
},
|
|
35275
|
+
{
|
|
35276
|
+
key: "enabled",
|
|
35277
|
+
get: /**
|
|
35278
|
+
* Specifies whether the module is enabled.
|
|
35279
|
+
* @remarks This module requires WebGL2, On WebGL1, enabling will be silently ignored.
|
|
35280
|
+
*/ function get() {
|
|
35281
|
+
return this._enabled;
|
|
35282
|
+
},
|
|
35283
|
+
set: function set(value) {
|
|
35284
|
+
if (value !== this._enabled) {
|
|
35285
|
+
if (value && !this._generator._renderer.engine._hardwareRenderer.isWebGL2) {
|
|
35286
|
+
return;
|
|
35287
|
+
}
|
|
35288
|
+
this._enabled = value;
|
|
35289
|
+
this._generator._setTransformFeedback(value);
|
|
35290
|
+
this._generator._renderer._onGeneratorParamsChanged();
|
|
35291
|
+
}
|
|
35292
|
+
}
|
|
35293
|
+
}
|
|
35294
|
+
]);
|
|
35295
|
+
return LimitVelocityOverLifetimeModule;
|
|
35296
|
+
}(ParticleGeneratorModule);
|
|
35297
|
+
LimitVelocityOverLifetimeModule._enabledMacro = ShaderMacro.getByName("RENDERER_LVL_MODULE_ENABLED");
|
|
35298
|
+
LimitVelocityOverLifetimeModule._separateAxesMacro = ShaderMacro.getByName("RENDERER_LVL_SEPARATE_AXES");
|
|
35299
|
+
LimitVelocityOverLifetimeModule._speedConstantModeMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_CONSTANT_MODE");
|
|
35300
|
+
LimitVelocityOverLifetimeModule._speedCurveModeMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_CURVE_MODE");
|
|
35301
|
+
LimitVelocityOverLifetimeModule._speedIsRandomMacro = ShaderMacro.getByName("RENDERER_LVL_SPEED_IS_RANDOM_TWO");
|
|
35302
|
+
LimitVelocityOverLifetimeModule._dragCurveModeMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_CURVE_MODE");
|
|
35303
|
+
LimitVelocityOverLifetimeModule._dragIsRandomMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_IS_RANDOM_TWO");
|
|
35304
|
+
LimitVelocityOverLifetimeModule._multiplyDragBySizeMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_MULTIPLY_SIZE");
|
|
35305
|
+
LimitVelocityOverLifetimeModule._multiplyDragByVelocityMacro = ShaderMacro.getByName("RENDERER_LVL_DRAG_MULTIPLY_VELOCITY");
|
|
35306
|
+
LimitVelocityOverLifetimeModule._speedMaxConstProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxConst");
|
|
35307
|
+
LimitVelocityOverLifetimeModule._speedMinConstProperty = ShaderProperty.getByName("renderer_LVLSpeedMinConst");
|
|
35308
|
+
LimitVelocityOverLifetimeModule._speedMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxCurve");
|
|
35309
|
+
LimitVelocityOverLifetimeModule._speedMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedMinCurve");
|
|
35310
|
+
LimitVelocityOverLifetimeModule._speedMaxConstVecProperty = ShaderProperty.getByName("renderer_LVLSpeedMaxConstVector");
|
|
35311
|
+
LimitVelocityOverLifetimeModule._speedMinConstVecProperty = ShaderProperty.getByName("renderer_LVLSpeedMinConstVector");
|
|
35312
|
+
LimitVelocityOverLifetimeModule._speedXMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedXMaxCurve");
|
|
35313
|
+
LimitVelocityOverLifetimeModule._speedXMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedXMinCurve");
|
|
35314
|
+
LimitVelocityOverLifetimeModule._speedYMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedYMaxCurve");
|
|
35315
|
+
LimitVelocityOverLifetimeModule._speedYMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedYMinCurve");
|
|
35316
|
+
LimitVelocityOverLifetimeModule._speedZMaxCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedZMaxCurve");
|
|
35317
|
+
LimitVelocityOverLifetimeModule._speedZMinCurveProperty = ShaderProperty.getByName("renderer_LVLSpeedZMinCurve");
|
|
35318
|
+
LimitVelocityOverLifetimeModule._dampenProperty = ShaderProperty.getByName("renderer_LVLDampen");
|
|
35319
|
+
LimitVelocityOverLifetimeModule._dragConstantProperty = ShaderProperty.getByName("renderer_LVLDragConstant");
|
|
35320
|
+
LimitVelocityOverLifetimeModule._dragMaxCurveProperty = ShaderProperty.getByName("renderer_LVLDragMaxCurve");
|
|
35321
|
+
LimitVelocityOverLifetimeModule._dragMinCurveProperty = ShaderProperty.getByName("renderer_LVLDragMinCurve");
|
|
35322
|
+
LimitVelocityOverLifetimeModule._spaceProperty = ShaderProperty.getByName("renderer_LVLSpace");
|
|
35323
|
+
__decorate([
|
|
35324
|
+
ignoreClone
|
|
35325
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedRand", void 0);
|
|
35326
|
+
__decorate([
|
|
35327
|
+
ignoreClone
|
|
35328
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedMinConstantVec", void 0);
|
|
35329
|
+
__decorate([
|
|
35330
|
+
ignoreClone
|
|
35331
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedMaxConstantVec", void 0);
|
|
35332
|
+
__decorate([
|
|
35333
|
+
ignoreClone
|
|
35334
|
+
], LimitVelocityOverLifetimeModule.prototype, "_dragConstantVec", void 0);
|
|
35335
|
+
__decorate([
|
|
35336
|
+
ignoreClone
|
|
35337
|
+
], LimitVelocityOverLifetimeModule.prototype, "_enabledModuleMacro", void 0);
|
|
35338
|
+
__decorate([
|
|
35339
|
+
ignoreClone
|
|
35340
|
+
], LimitVelocityOverLifetimeModule.prototype, "_separateAxesCachedMacro", void 0);
|
|
35341
|
+
__decorate([
|
|
35342
|
+
ignoreClone
|
|
35343
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedModeMacro", void 0);
|
|
35344
|
+
__decorate([
|
|
35345
|
+
ignoreClone
|
|
35346
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedRandomMacro", void 0);
|
|
35347
|
+
__decorate([
|
|
35348
|
+
ignoreClone
|
|
35349
|
+
], LimitVelocityOverLifetimeModule.prototype, "_dragCurveCachedMacro", void 0);
|
|
35350
|
+
__decorate([
|
|
35351
|
+
ignoreClone
|
|
35352
|
+
], LimitVelocityOverLifetimeModule.prototype, "_dragRandomCachedMacro", void 0);
|
|
35353
|
+
__decorate([
|
|
35354
|
+
ignoreClone
|
|
35355
|
+
], LimitVelocityOverLifetimeModule.prototype, "_dragSizeMacro", void 0);
|
|
35356
|
+
__decorate([
|
|
35357
|
+
ignoreClone
|
|
35358
|
+
], LimitVelocityOverLifetimeModule.prototype, "_dragVelocityMacro", void 0);
|
|
35359
|
+
__decorate([
|
|
35360
|
+
deepClone
|
|
35361
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedX", void 0);
|
|
35362
|
+
__decorate([
|
|
35363
|
+
deepClone
|
|
35364
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedY", void 0);
|
|
35365
|
+
__decorate([
|
|
35366
|
+
deepClone
|
|
35367
|
+
], LimitVelocityOverLifetimeModule.prototype, "_speedZ", void 0);
|
|
35368
|
+
__decorate([
|
|
35369
|
+
deepClone
|
|
35370
|
+
], LimitVelocityOverLifetimeModule.prototype, "_drag", void 0);
|
|
35371
|
+
|
|
34522
35372
|
/**
|
|
34523
35373
|
* Control how Particle Generator apply transform scale.
|
|
34524
35374
|
*/ var ParticleScaleMode = /*#__PURE__*/ function(ParticleScaleMode) {
|
|
@@ -35567,6 +36417,8 @@ __decorate([
|
|
|
35567
36417
|
/** @internal */ this._firstRetiredElement = 0;
|
|
35568
36418
|
/** @internal */ this._vertexBufferBindings = new Array();
|
|
35569
36419
|
/** @internal */ this._subPrimitive = new SubMesh(0, 0, MeshTopology.Triangles);
|
|
36420
|
+
/** @internal */ this._useTransformFeedback = false;
|
|
36421
|
+
/** @internal */ this._feedbackBindingIndex = -1;
|
|
35570
36422
|
this._isPlaying = false;
|
|
35571
36423
|
this._instanceBufferResized = false;
|
|
35572
36424
|
this._waitProcessRetiredElementCount = 0;
|
|
@@ -35585,6 +36437,7 @@ __decorate([
|
|
|
35585
36437
|
this.velocityOverLifetime = new VelocityOverLifetimeModule(this);
|
|
35586
36438
|
this.forceOverLifetime = new ForceOverLifetimeModule(this);
|
|
35587
36439
|
this.sizeOverLifetime = new SizeOverLifetimeModule(this);
|
|
36440
|
+
this.limitVelocityOverLifetime = new LimitVelocityOverLifetimeModule(this);
|
|
35588
36441
|
this.emission.enabled = true;
|
|
35589
36442
|
}
|
|
35590
36443
|
var _proto = ParticleGenerator.prototype;
|
|
@@ -35623,11 +36476,7 @@ __decorate([
|
|
|
35623
36476
|
} else {
|
|
35624
36477
|
this._isPlaying = false;
|
|
35625
36478
|
if (stopMode === ParticleStopMode.StopEmittingAndClear) {
|
|
35626
|
-
|
|
35627
|
-
var firstFreeElement = this._firstFreeElement;
|
|
35628
|
-
this._firstRetiredElement = firstFreeElement;
|
|
35629
|
-
this._firstActiveElement = firstFreeElement;
|
|
35630
|
-
this._firstNewElement = firstFreeElement;
|
|
36479
|
+
this._clearActiveParticles();
|
|
35631
36480
|
this._playTime = 0;
|
|
35632
36481
|
this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
|
|
35633
36482
|
this.emission._reset();
|
|
@@ -35711,6 +36560,16 @@ __decorate([
|
|
|
35711
36560
|
this._isPlaying = false;
|
|
35712
36561
|
}
|
|
35713
36562
|
}
|
|
36563
|
+
// Retire all particles on device restore before bounds/volume bookkeeping
|
|
36564
|
+
var isContentLost = this._instanceVertexBufferBinding._buffer.isContentLost;
|
|
36565
|
+
if (isContentLost) {
|
|
36566
|
+
this._firstActiveElement = 0;
|
|
36567
|
+
this._firstNewElement = 0;
|
|
36568
|
+
this._firstFreeElement = 0;
|
|
36569
|
+
this._firstRetiredElement = 0;
|
|
36570
|
+
this._waitProcessRetiredElementCount = 0;
|
|
36571
|
+
this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
|
|
36572
|
+
}
|
|
35714
36573
|
if (this.isAlive) {
|
|
35715
36574
|
if (main.simulationSpace === ParticleSimulationSpace.World) {
|
|
35716
36575
|
this._generateTransformedBounds();
|
|
@@ -35724,16 +36583,21 @@ __decorate([
|
|
|
35724
36583
|
if (this.isAlive !== lastAlive) {
|
|
35725
36584
|
this._renderer._onWorldVolumeChanged();
|
|
35726
36585
|
}
|
|
35727
|
-
|
|
35728
|
-
//
|
|
35729
|
-
// Another choice is just add new particles to vertex buffer and render all particles ignore the retired particle in shader, especially billboards
|
|
35730
|
-
// But webgl don't support map buffer range, so this choice don't have performance advantage even less set data to GPU
|
|
35731
|
-
if (this._firstNewElement != this._firstFreeElement || this._waitProcessRetiredElementCount > 0 || this._instanceBufferResized || this._instanceVertexBufferBinding._buffer.isContentLost) {
|
|
36586
|
+
if (this._firstNewElement != this._firstFreeElement || this._waitProcessRetiredElementCount > 0 || this._instanceBufferResized) {
|
|
35732
36587
|
this._addActiveParticlesToVertexBuffer();
|
|
35733
36588
|
}
|
|
35734
36589
|
};
|
|
35735
36590
|
/**
|
|
35736
36591
|
* @internal
|
|
36592
|
+
* Run Transform Feedback simulation pass.
|
|
36593
|
+
*/ _proto._updateFeedback = function _updateFeedback(shaderData, deltaTime) {
|
|
36594
|
+
this._feedbackSimulator.update(shaderData, this._currentParticleCount, this._firstActiveElement, this._firstFreeElement, deltaTime);
|
|
36595
|
+
// After swap, update the render pass buffer binding to point to the latest output.
|
|
36596
|
+
// VAO is disabled in TF mode so direct assignment is safe (no stale VAO issue).
|
|
36597
|
+
this._primitive.vertexBufferBindings[this._feedbackBindingIndex] = this._feedbackSimulator.readBinding;
|
|
36598
|
+
};
|
|
36599
|
+
/**
|
|
36600
|
+
* @internal
|
|
35737
36601
|
*/ _proto._reorganizeGeometryBuffers = function _reorganizeGeometryBuffers() {
|
|
35738
36602
|
var _this = this, renderer = _this._renderer, primitive = _this._primitive, vertexBufferBindings = _this._vertexBufferBindings;
|
|
35739
36603
|
var _renderer_engine = renderer.engine, particleUtils = _renderer_engine._particleBufferUtils;
|
|
@@ -35785,6 +36649,15 @@ __decorate([
|
|
|
35785
36649
|
if (this._instanceVertexBufferBinding) {
|
|
35786
36650
|
vertexBufferBindings.push(this._instanceVertexBufferBinding);
|
|
35787
36651
|
}
|
|
36652
|
+
// Add feedback buffer binding for render pass
|
|
36653
|
+
if (this._useTransformFeedback) {
|
|
36654
|
+
this._feedbackBindingIndex = vertexBufferBindings.length;
|
|
36655
|
+
primitive.addVertexElement(new VertexElement(ParticleFeedbackVertexAttribute.Position, 0, VertexElementFormat.Vector3, this._feedbackBindingIndex, 1));
|
|
36656
|
+
primitive.addVertexElement(new VertexElement(ParticleFeedbackVertexAttribute.Velocity, 12, VertexElementFormat.Vector3, this._feedbackBindingIndex, 1));
|
|
36657
|
+
vertexBufferBindings.push(this._feedbackSimulator.readBinding);
|
|
36658
|
+
} else {
|
|
36659
|
+
this._feedbackBindingIndex = -1;
|
|
36660
|
+
}
|
|
35788
36661
|
primitive.setVertexBufferBindings(vertexBufferBindings);
|
|
35789
36662
|
};
|
|
35790
36663
|
/**
|
|
@@ -35800,18 +36673,28 @@ __decorate([
|
|
|
35800
36673
|
vertexInstanceBuffer.isGCIgnored = true;
|
|
35801
36674
|
var vertexBufferBindings = this._primitive.vertexBufferBindings;
|
|
35802
36675
|
var vertexBufferBinding = new VertexBufferBinding(vertexInstanceBuffer, stride);
|
|
35803
|
-
var instanceVertices = new Float32Array(newByteLength / 4);
|
|
35804
36676
|
var lastInstanceVertices = this._instanceVertices;
|
|
36677
|
+
var useFeedback = this._useTransformFeedback;
|
|
36678
|
+
var instanceVertices = new Float32Array(newByteLength / 4);
|
|
36679
|
+
if (useFeedback) {
|
|
36680
|
+
this._feedbackSimulator.resize(newParticleCount, vertexBufferBinding);
|
|
36681
|
+
}
|
|
35805
36682
|
if (lastInstanceVertices) {
|
|
35806
|
-
var floatStride = ParticleBufferUtils.instanceVertexFloatStride;
|
|
36683
|
+
var floatStride = ParticleBufferUtils.instanceVertexFloatStride, feedbackVertexStride = ParticleBufferUtils.feedbackVertexStride;
|
|
35807
36684
|
var firstFreeElement = this._firstFreeElement;
|
|
35808
36685
|
var firstRetiredElement = this._firstRetiredElement;
|
|
35809
36686
|
if (isIncrease) {
|
|
36687
|
+
// Copy front segment [0, firstFreeElement)
|
|
35810
36688
|
instanceVertices.set(new Float32Array(lastInstanceVertices.buffer, 0, firstFreeElement * floatStride));
|
|
36689
|
+
// Copy tail segment shifted by increaseCount
|
|
35811
36690
|
var nextFreeElement = firstFreeElement + 1;
|
|
35812
|
-
var
|
|
35813
|
-
|
|
35814
|
-
|
|
36691
|
+
var tailCount = this._currentParticleCount - nextFreeElement;
|
|
36692
|
+
var tailDstElement = nextFreeElement + increaseCount;
|
|
36693
|
+
instanceVertices.set(new Float32Array(lastInstanceVertices.buffer, nextFreeElement * floatStride * 4), tailDstElement * floatStride);
|
|
36694
|
+
if (useFeedback) {
|
|
36695
|
+
this._feedbackSimulator.copyOldBufferData(0, 0, firstFreeElement * feedbackVertexStride);
|
|
36696
|
+
this._feedbackSimulator.copyOldBufferData(nextFreeElement * feedbackVertexStride, tailDstElement * feedbackVertexStride, tailCount * feedbackVertexStride);
|
|
36697
|
+
}
|
|
35815
36698
|
this._firstNewElement > firstFreeElement && (this._firstNewElement += increaseCount);
|
|
35816
36699
|
this._firstActiveElement > firstFreeElement && (this._firstActiveElement += increaseCount);
|
|
35817
36700
|
firstRetiredElement > firstFreeElement && (this._firstRetiredElement += increaseCount);
|
|
@@ -35820,7 +36703,6 @@ __decorate([
|
|
|
35820
36703
|
if (firstRetiredElement <= firstFreeElement) {
|
|
35821
36704
|
migrateCount = firstFreeElement - firstRetiredElement;
|
|
35822
36705
|
bufferOffset = 0;
|
|
35823
|
-
// Maintain expanded pointers
|
|
35824
36706
|
this._firstFreeElement -= firstRetiredElement;
|
|
35825
36707
|
this._firstNewElement -= firstRetiredElement;
|
|
35826
36708
|
this._firstActiveElement -= firstRetiredElement;
|
|
@@ -35828,20 +36710,29 @@ __decorate([
|
|
|
35828
36710
|
} else {
|
|
35829
36711
|
migrateCount = this._currentParticleCount - firstRetiredElement;
|
|
35830
36712
|
bufferOffset = firstFreeElement;
|
|
35831
|
-
// Maintain expanded pointers
|
|
35832
36713
|
this._firstNewElement > firstFreeElement && (this._firstNewElement -= firstFreeElement);
|
|
35833
36714
|
this._firstActiveElement > firstFreeElement && (this._firstActiveElement -= firstFreeElement);
|
|
35834
36715
|
firstRetiredElement > firstFreeElement && (this._firstRetiredElement -= firstFreeElement);
|
|
35835
36716
|
}
|
|
35836
36717
|
instanceVertices.set(new Float32Array(lastInstanceVertices.buffer, firstRetiredElement * floatStride * 4, migrateCount * floatStride), bufferOffset * floatStride);
|
|
36718
|
+
if (useFeedback) {
|
|
36719
|
+
this._feedbackSimulator.copyOldBufferData(firstRetiredElement * feedbackVertexStride, bufferOffset * feedbackVertexStride, migrateCount * feedbackVertexStride);
|
|
36720
|
+
}
|
|
36721
|
+
}
|
|
36722
|
+
if (useFeedback) {
|
|
36723
|
+
this._feedbackSimulator.destroyOldBuffers();
|
|
35837
36724
|
}
|
|
35838
36725
|
this._instanceBufferResized = true;
|
|
35839
36726
|
}
|
|
35840
|
-
//
|
|
35841
|
-
|
|
36727
|
+
// Update instance buffer binding
|
|
36728
|
+
var instanceBindingIndex = lastInstanceVertices ? vertexBufferBindings.length - 1 - (useFeedback ? 1 : 0) : vertexBufferBindings.length;
|
|
36729
|
+
this._primitive.setVertexBufferBinding(instanceBindingIndex, vertexBufferBinding);
|
|
35842
36730
|
this._instanceVertices = instanceVertices;
|
|
35843
36731
|
this._instanceVertexBufferBinding = vertexBufferBinding;
|
|
35844
36732
|
this._currentParticleCount = newParticleCount;
|
|
36733
|
+
if (useFeedback) {
|
|
36734
|
+
this._primitive.setVertexBufferBinding(this._feedbackBindingIndex, this._feedbackSimulator.readBinding);
|
|
36735
|
+
}
|
|
35845
36736
|
};
|
|
35846
36737
|
/**
|
|
35847
36738
|
* @internal
|
|
@@ -35849,6 +36740,7 @@ __decorate([
|
|
|
35849
36740
|
this.main._updateShaderData(shaderData);
|
|
35850
36741
|
this.velocityOverLifetime._updateShaderData(shaderData);
|
|
35851
36742
|
this.forceOverLifetime._updateShaderData(shaderData);
|
|
36743
|
+
this.limitVelocityOverLifetime._updateShaderData(shaderData);
|
|
35852
36744
|
this.textureSheetAnimation._updateShaderData(shaderData);
|
|
35853
36745
|
this.sizeOverLifetime._updateShaderData(shaderData);
|
|
35854
36746
|
this.rotationOverLifetime._updateShaderData(shaderData);
|
|
@@ -35863,11 +36755,41 @@ __decorate([
|
|
|
35863
36755
|
this.textureSheetAnimation._resetRandomSeed(seed);
|
|
35864
36756
|
this.velocityOverLifetime._resetRandomSeed(seed);
|
|
35865
36757
|
this.forceOverLifetime._resetRandomSeed(seed);
|
|
36758
|
+
this.limitVelocityOverLifetime._resetRandomSeed(seed);
|
|
35866
36759
|
this.rotationOverLifetime._resetRandomSeed(seed);
|
|
35867
36760
|
this.colorOverLifetime._resetRandomSeed(seed);
|
|
35868
36761
|
};
|
|
35869
36762
|
/**
|
|
35870
36763
|
* @internal
|
|
36764
|
+
*/ _proto._setTransformFeedback = function _setTransformFeedback(enabled) {
|
|
36765
|
+
this._useTransformFeedback = enabled;
|
|
36766
|
+
// Switching TF mode invalidates all active particle state: feedback buffers and instance
|
|
36767
|
+
// buffer layout are incompatible between the two paths. Clear rather than show a one-frame
|
|
36768
|
+
// jump; new particles will fill in naturally from the next emit cycle.
|
|
36769
|
+
this._clearActiveParticles();
|
|
36770
|
+
if (enabled) {
|
|
36771
|
+
if (!this._feedbackSimulator) {
|
|
36772
|
+
this._feedbackSimulator = new ParticleTransformFeedbackSimulator(this._renderer.engine);
|
|
36773
|
+
}
|
|
36774
|
+
var simulator = this._feedbackSimulator;
|
|
36775
|
+
var readBinding = simulator.readBinding;
|
|
36776
|
+
if (!readBinding || readBinding.buffer.byteLength !== this._currentParticleCount * ParticleBufferUtils.feedbackVertexStride) {
|
|
36777
|
+
simulator.resize(this._currentParticleCount, this._instanceVertexBufferBinding);
|
|
36778
|
+
simulator.destroyOldBuffers();
|
|
36779
|
+
} else {
|
|
36780
|
+
simulator._instanceBinding = this._instanceVertexBufferBinding;
|
|
36781
|
+
}
|
|
36782
|
+
this._renderer.shaderData.enableMacro(ParticleGenerator._transformFeedbackMacro);
|
|
36783
|
+
// Feedback buffer swaps every frame; VAO caching would bake stale buffer handles.
|
|
36784
|
+
this._primitive.enableVAO = false;
|
|
36785
|
+
} else {
|
|
36786
|
+
this._renderer.shaderData.disableMacro(ParticleGenerator._transformFeedbackMacro);
|
|
36787
|
+
this._primitive.enableVAO = true;
|
|
36788
|
+
}
|
|
36789
|
+
this._reorganizeGeometryBuffers();
|
|
36790
|
+
};
|
|
36791
|
+
/**
|
|
36792
|
+
* @internal
|
|
35871
36793
|
*/ _proto._getAliveParticleCount = function _getAliveParticleCount() {
|
|
35872
36794
|
if (this._firstActiveElement <= this._firstFreeElement) {
|
|
35873
36795
|
return this._firstFreeElement - this._firstActiveElement;
|
|
@@ -35894,10 +36816,19 @@ __decorate([
|
|
|
35894
36816
|
};
|
|
35895
36817
|
/**
|
|
35896
36818
|
* @internal
|
|
36819
|
+
*/ _proto._cloneTo = function _cloneTo(target) {
|
|
36820
|
+
if (target.limitVelocityOverLifetime.enabled) {
|
|
36821
|
+
target._setTransformFeedback(true);
|
|
36822
|
+
}
|
|
36823
|
+
};
|
|
36824
|
+
/**
|
|
36825
|
+
* @internal
|
|
35897
36826
|
*/ _proto._destroy = function _destroy() {
|
|
36827
|
+
var _this__feedbackSimulator;
|
|
35898
36828
|
this._instanceVertexBufferBinding.buffer.destroy();
|
|
35899
36829
|
this._primitive.destroy();
|
|
35900
36830
|
this.emission._destroy();
|
|
36831
|
+
(_this__feedbackSimulator = this._feedbackSimulator) == null ? void 0 : _this__feedbackSimulator.destroy();
|
|
35901
36832
|
};
|
|
35902
36833
|
/**
|
|
35903
36834
|
* @internal
|
|
@@ -36129,8 +37060,34 @@ __decorate([
|
|
|
36129
37060
|
instanceVertices[offset + 39] = rand1.random();
|
|
36130
37061
|
instanceVertices[offset + 40] = rand1.random();
|
|
36131
37062
|
}
|
|
37063
|
+
var limitVelocityOverLifetime = this.limitVelocityOverLifetime;
|
|
37064
|
+
if (limitVelocityOverLifetime.enabled && (limitVelocityOverLifetime._isSpeedRandomMode() || limitVelocityOverLifetime._isDragRandomMode())) {
|
|
37065
|
+
instanceVertices[offset + 41] = limitVelocityOverLifetime._speedRand.random();
|
|
37066
|
+
}
|
|
37067
|
+
// Initialize feedback buffer for this particle
|
|
37068
|
+
if (this._useTransformFeedback) {
|
|
37069
|
+
this._addFeedbackParticle(firstFreeElement, position, direction, startSpeed, transform);
|
|
37070
|
+
}
|
|
36132
37071
|
this._firstFreeElement = nextFreeElement;
|
|
36133
37072
|
};
|
|
37073
|
+
_proto._addFeedbackParticle = function _addFeedbackParticle(index, shapePosition, direction, startSpeed, transform) {
|
|
37074
|
+
var position;
|
|
37075
|
+
if (this.main.simulationSpace === ParticleSimulationSpace.Local) {
|
|
37076
|
+
position = shapePosition;
|
|
37077
|
+
} else {
|
|
37078
|
+
position = ParticleGenerator._tempVector32;
|
|
37079
|
+
Vector3.transformByQuat(shapePosition, transform.worldRotationQuaternion, position);
|
|
37080
|
+
position.add(transform.worldPosition);
|
|
37081
|
+
}
|
|
37082
|
+
this._feedbackSimulator.writeParticleData(index, position, direction.x * startSpeed, direction.y * startSpeed, direction.z * startSpeed);
|
|
37083
|
+
};
|
|
37084
|
+
_proto._clearActiveParticles = function _clearActiveParticles() {
|
|
37085
|
+
var firstFreeElement = this._firstFreeElement;
|
|
37086
|
+
this._firstRetiredElement = firstFreeElement;
|
|
37087
|
+
this._firstActiveElement = firstFreeElement;
|
|
37088
|
+
this._firstNewElement = firstFreeElement;
|
|
37089
|
+
this._firstActiveTransformedBoundingBox = this._firstFreeTransformedBoundingBox;
|
|
37090
|
+
};
|
|
36134
37091
|
_proto._retireActiveParticles = function _retireActiveParticles() {
|
|
36135
37092
|
var engine = this._renderer.engine;
|
|
36136
37093
|
var frameCount = engine.time.frameCount;
|
|
@@ -36174,16 +37131,19 @@ __decorate([
|
|
|
36174
37131
|
return;
|
|
36175
37132
|
}
|
|
36176
37133
|
var byteStride = ParticleBufferUtils.instanceVertexStride;
|
|
36177
|
-
var start = firstActiveElement * byteStride;
|
|
36178
37134
|
var instanceBuffer = this._instanceVertexBufferBinding.buffer;
|
|
36179
37135
|
var dataBuffer = this._instanceVertices.buffer;
|
|
37136
|
+
// Feedback mode: upload in-place (indices match feedback buffer slots)
|
|
37137
|
+
// Non-feedback mode: compact to GPU offset 0
|
|
37138
|
+
var compact = !this._useTransformFeedback;
|
|
37139
|
+
var start = firstActiveElement * byteStride;
|
|
36180
37140
|
if (firstActiveElement < firstFreeElement) {
|
|
36181
|
-
instanceBuffer.setData(dataBuffer, 0, start, (firstFreeElement - firstActiveElement) * byteStride, SetDataOptions.Discard);
|
|
37141
|
+
instanceBuffer.setData(dataBuffer, compact ? 0 : start, start, (firstFreeElement - firstActiveElement) * byteStride, SetDataOptions.Discard);
|
|
36182
37142
|
} else {
|
|
36183
|
-
var
|
|
36184
|
-
instanceBuffer.setData(dataBuffer, 0, start,
|
|
37143
|
+
var firstSegmentSize = (this._currentParticleCount - firstActiveElement) * byteStride;
|
|
37144
|
+
instanceBuffer.setData(dataBuffer, compact ? 0 : start, start, firstSegmentSize, SetDataOptions.Discard);
|
|
36185
37145
|
if (firstFreeElement > 0) {
|
|
36186
|
-
instanceBuffer.setData(dataBuffer,
|
|
37146
|
+
instanceBuffer.setData(dataBuffer, compact ? firstSegmentSize : 0, 0, firstFreeElement * byteStride);
|
|
36187
37147
|
}
|
|
36188
37148
|
}
|
|
36189
37149
|
this._firstNewElement = firstFreeElement;
|
|
@@ -36401,11 +37361,13 @@ ParticleGenerator._tempVector21 = new Vector2();
|
|
|
36401
37361
|
ParticleGenerator._tempVector22 = new Vector2();
|
|
36402
37362
|
ParticleGenerator._tempVector30 = new Vector3();
|
|
36403
37363
|
ParticleGenerator._tempVector31 = new Vector3();
|
|
37364
|
+
ParticleGenerator._tempVector32 = new Vector3();
|
|
36404
37365
|
ParticleGenerator._tempMat = new Matrix();
|
|
36405
37366
|
ParticleGenerator._tempColor0 = new Color();
|
|
36406
37367
|
ParticleGenerator._tempParticleRenderers = new Array();
|
|
36407
37368
|
ParticleGenerator._particleIncreaseCount = 128;
|
|
36408
37369
|
ParticleGenerator._transformedBoundsIncreaseCount = 16;
|
|
37370
|
+
ParticleGenerator._transformFeedbackMacro = ShaderMacro.getByName("RENDERER_TRANSFORM_FEEDBACK");
|
|
36409
37371
|
__decorate([
|
|
36410
37372
|
deepClone
|
|
36411
37373
|
], ParticleGenerator.prototype, "main", void 0);
|
|
@@ -36418,6 +37380,9 @@ __decorate([
|
|
|
36418
37380
|
__decorate([
|
|
36419
37381
|
deepClone
|
|
36420
37382
|
], ParticleGenerator.prototype, "forceOverLifetime", void 0);
|
|
37383
|
+
__decorate([
|
|
37384
|
+
deepClone
|
|
37385
|
+
], ParticleGenerator.prototype, "limitVelocityOverLifetime", void 0);
|
|
36421
37386
|
__decorate([
|
|
36422
37387
|
deepClone
|
|
36423
37388
|
], ParticleGenerator.prototype, "sizeOverLifetime", void 0);
|
|
@@ -36454,6 +37419,15 @@ __decorate([
|
|
|
36454
37419
|
__decorate([
|
|
36455
37420
|
ignoreClone
|
|
36456
37421
|
], ParticleGenerator.prototype, "_subPrimitive", void 0);
|
|
37422
|
+
__decorate([
|
|
37423
|
+
ignoreClone
|
|
37424
|
+
], ParticleGenerator.prototype, "_feedbackSimulator", void 0);
|
|
37425
|
+
__decorate([
|
|
37426
|
+
ignoreClone
|
|
37427
|
+
], ParticleGenerator.prototype, "_useTransformFeedback", void 0);
|
|
37428
|
+
__decorate([
|
|
37429
|
+
ignoreClone
|
|
37430
|
+
], ParticleGenerator.prototype, "_feedbackBindingIndex", void 0);
|
|
36457
37431
|
__decorate([
|
|
36458
37432
|
ignoreClone
|
|
36459
37433
|
], ParticleGenerator.prototype, "_isPlaying", void 0);
|
|
@@ -38493,5 +39467,5 @@ __decorate([
|
|
|
38493
39467
|
|
|
38494
39468
|
Polyfill.registerPolyfill();
|
|
38495
39469
|
|
|
38496
|
-
export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader, shallowClone };
|
|
39470
|
+
export { AmbientLight, AmbientOcclusion, AmbientOcclusionQuality, AnimationArrayCurve, AnimationBoolCurve, AnimationClip, AnimationClipCurveBinding, AnimationColorCurve, AnimationCurve, AnimationEvent, AnimationFloatArrayCurve, AnimationFloatCurve, AnimationQuaternionCurve, AnimationRectCurve, AnimationRefCurve, AnimationStringCurve, AnimationVector2Curve, AnimationVector3Curve, AnimationVector4Curve, Animator, AnimatorCondition, AnimatorConditionMode, AnimatorController, AnimatorControllerLayer, AnimatorControllerParameter, AnimatorCullingMode, AnimatorLayerBlendingMode, AnimatorLayerMask, AnimatorState, AnimatorStateMachine, AnimatorStateTransition, AntiAliasing, AssetPromise, AssetType, AudioClip, AudioManager, AudioSource, Background, BackgroundMode, BackgroundTextureFillMode, BaseMaterial, BasicRenderPipeline, BatchUtils, BlendFactor, BlendMode, BlendOperation, BlendShape, BlendShapeFrame, BlendState, BlinnPhongMaterial, Blitter, BloomDownScaleMode, BloomEffect, BoolUpdateFlag, BoxColliderShape, BoxShape, Buffer, BufferAsset, BufferBindFlag, BufferMesh, BufferUsage, BufferUtil, Burst, Camera, CameraClearFlags, CameraModifyFlags, CameraType, Canvas, CapsuleColliderShape, CharRenderInfo, CharacterController, CircleShape, ClearableObjectPool, CloneManager, CloneUtils, Collider, ColliderShape, ColliderShapeUpAxis, Collision, CollisionDetectionMode, ColorOverLifetimeModule, ColorWriteMask, CompareFunction, Component, ConeEmitType, ConeShape, ContactPoint, ContentRestorer, ControllerCollisionFlag, ControllerNonWalkableMode, CubeProbe, CullMode, CurveKey, DataType, DependentMode, DepthState, DepthTextureMode, DiffuseMode, DirectLight, DisorderedArray, Downsampling, DynamicCollider, DynamicColliderConstraints, EmissionModule, Engine, EngineObject, Entity, EntityModifyFlags, EventDispatcher, FinalPass, FixedJoint, FogMode, Font, FontStyle, GLCapabilityType, GradientAlphaKey, GradientColorKey, HemisphereShape, HingeJoint, HitResult, IndexBufferBinding, IndexFormat, InputManager, InterpolationType, JSONAsset, Joint, JointLimits, JointMotor, Keyframe, Keys, Layer, LayerPathMask, Light, LimitVelocityOverLifetimeModule, Loader, Logger, MSAASamples, MainModule, Material, Mesh, MeshColliderShape, MeshColliderShapeCookingFlag, MeshRenderer, MeshShape, MeshTopology, ModelMesh, OverflowMode, PBRMaterial, ParticleCompositeCurve, ParticleCompositeGradient, ParticleCurve, ParticleCurveMode, ParticleGenerator, ParticleGradient, ParticleGradientMode, ParticleMaterial, ParticleRenderMode, ParticleRenderer, ParticleScaleMode, ParticleShapeArcMode, ParticleShapeType, ParticleSimulationSpace, ParticleStopMode, PhysicsMaterial, PhysicsMaterialCombineMode, PhysicsScene, PipelineStage, PlaneColliderShape, Platform, PointLight, Pointer, PointerButton, PointerEventData, PointerEventEmitter, PointerPhase, PostProcess, PostProcessEffect, PostProcessEffectBoolParameter, PostProcessEffectColorParameter, PostProcessEffectEnumParameter, PostProcessEffectFloatParameter, PostProcessEffectParameter, PostProcessEffectTextureParameter, PostProcessEffectVector2Parameter, PostProcessEffectVector3Parameter, PostProcessEffectVector4Parameter, PostProcessManager, PostProcessPass, PostProcessPassEvent, PostProcessUberPass, Primitive, PrimitiveMesh, Probe, RasterState, ReferResource, RefractionMode, RenderBufferDepthFormat, RenderFace, RenderQueue, RenderQueueFlags, RenderQueueType, RenderState, RenderStateElementKey, RenderTarget, RenderTargetBlendState, Renderer, RendererUpdateFlags, RenderingStatistics, ReplacementFailureStrategy, ResourceManager, ReturnableObjectPool, RotationOverLifetimeModule, SafeLoopArray, Scene, SceneManager, Script, SetDataOptions, Shader, ShaderData, ShaderDataGroup, ShaderFactory, ShaderLanguage, ShaderLib, ShaderMacro, ShaderMacroCollection, ShaderPass, ShaderProperty, ShaderPropertyType, ShaderTagKey, ShadowCascadesMode, ShadowResolution, ShadowType, Signal, SimpleSpriteAssembler, SizeOverLifetimeModule, Skin, SkinnedMeshRenderer, Sky, SkyBoxMaterial, SkyProceduralMaterial, SlicedSpriteAssembler, SphereColliderShape, SphereShape, SpotLight, SpringJoint, Sprite, SpriteAtlas, SpriteDrawMode, SpriteMask, SpriteMaskInteraction, SpriteMaskLayer, SpriteModifyFlags, SpriteRenderer, SpriteTileMode, StateMachineScript, StaticCollider, StencilOperation, StencilState, SubFont, SubMesh, SubPrimitive, SubShader, SunMode, SystemInfo, TextAsset, TextHorizontalAlignment, TextRenderer, TextUtils, TextVerticalAlignment, Texture, Texture2D, Texture2DArray, TextureCoordinate, TextureCube, TextureCubeFace, TextureDepthCompareFunction, TextureFilterMode, TextureFormat, TextureSheetAnimationModule, TextureUsage, TextureUtils, TextureWrapMode, TiledSpriteAssembler, Time, TonemappingEffect, TonemappingMode, TrailMaterial, TrailRenderer, TrailTextureMode, Transform, TransformModifyFlags, UnlitMaterial, Utils, VelocityOverLifetimeModule, VertexAttribute, VertexBufferBinding, VertexElement, VertexElementFormat, WrapMode, XRManager, assignmentClone, deepClone, dependentComponents, ignoreClone, registerPointerEventEmitter, request, resourceLoader, shallowClone };
|
|
38497
39471
|
//# sourceMappingURL=module.js.map
|