update particles randomizer

This commit is contained in:
MihailRis
2024-11-03 02:26:11 +03:00
parent 7abb1a88c7
commit 082a87db4e
3 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ void Emitter::update(float delta, std::vector<Particle>& particles) {
// spawn particle
Particle particle = prototype;
particle.emitter = this;
particle.random = rand();
particle.random = random.rand32();
particle.position = position;
particle.velocity += glm::ballRand(1.0f) * explosion;
particles.push_back(std::move(particle));
+3
View File
@@ -7,6 +7,7 @@
#include "typedefs.hpp"
#include "maths/UVRegion.hpp"
#include "maths/util.hpp"
class Emitter;
@@ -50,6 +51,8 @@ class Emitter {
float timer = 0.0f;
/// @brief Random velocity magnitude applying to spawned particles
glm::vec3 explosion {8.0f};
util::PseudoRandom random;
public:
ParticleBehaviour behaviour;
+1 -1
View File
@@ -71,7 +71,7 @@ void ParticlesRenderer::renderParticles(const Camera& camera, float delta) {
light = MainBatch::sampleLight(
particle.position, chunks, backlight
);
light *= 0.7f + (particle.random % 300) * 0.001f;
light *= 0.8f + (particle.random % 200) * 0.001f;
}
batch->quad(
particle.position,