Add smoke particle emitters with ember sparks and enable 4x MSAA

Replace UV scroll workaround for chimney smoke with proper GL_POINTS
particle system. Smoke particles rise, expand, drift, and fade over
4-7 seconds. One in eight particles spawns as a bright orange/red
ember spark. Enable 4x multisample antialiasing for smoother edges
on player models, fences, and foliage.
This commit is contained in:
Kelsi 2026-02-04 14:37:32 -08:00
parent 11a4958e84
commit c9adcd3d96
4 changed files with 249 additions and 36 deletions

View file

@ -9,6 +9,7 @@
#include <vector>
#include <string>
#include <optional>
#include <random>
namespace wowee {
@ -93,6 +94,19 @@ struct M2Instance {
void updateModelMatrix();
};
/**
* A single smoke particle emitted from a chimney or similar M2 model
*/
struct SmokeParticle {
glm::vec3 position;
glm::vec3 velocity;
float life = 0.0f;
float maxLife = 3.0f;
float size = 1.0f;
float isSpark = 0.0f; // 0 = smoke, 1 = ember/spark
uint32_t instanceId = 0;
};
/**
* M2 Model Renderer
*
@ -144,6 +158,11 @@ public:
*/
void render(const Camera& camera, const glm::mat4& view, const glm::mat4& projection);
/**
* Render smoke particles (call after render())
*/
void renderSmokeParticles(const Camera& camera, const glm::mat4& view, const glm::mat4& projection);
/**
* Remove a specific instance by ID
* @param instanceId Instance ID returned by createInstance()
@ -258,6 +277,15 @@ private:
// Collision query profiling (per frame).
mutable double queryTimeMs = 0.0;
mutable uint32_t queryCallCount = 0;
// Smoke particle system
std::vector<SmokeParticle> smokeParticles;
GLuint smokeVAO = 0;
GLuint smokeVBO = 0;
std::unique_ptr<Shader> smokeShader;
static constexpr int MAX_SMOKE_PARTICLES = 1000;
float smokeEmitAccum = 0.0f;
std::mt19937 smokeRng{42};
};
} // namespace rendering