From 03998dc74aee9cfcbf89414be9affbda82e066be Mon Sep 17 00:00:00 2001 From: Andreas Ortmann Date: Fri, 30 Sep 2016 22:25:37 +0200 Subject: [PATCH] fine tuned explosion parameters. --- data/shader/particle.vert | 6 ++++- .../renderer_polygon_3d.cpp | 25 +++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/data/shader/particle.vert b/data/shader/particle.vert index aecc600..5356692 100644 --- a/data/shader/particle.vert +++ b/data/shader/particle.vert @@ -17,9 +17,13 @@ varying float explCenterDist; // TODO: rotate to face the user! void main() { + // add a bit variation to the decay compution by adding part of the initial + // position to the age + float ageMod = age + mod(20.0*in_position.z + 10.0*in_position.x + in_position.y, 0.5); + //decay = min(1.0, age+5.0*length(velocity)) / halfAge; //decay = max(decay*decay, sqrt(decay)); - decay = age / halfAge; + decay = ageMod / halfAge; // faster particles are smaller float speedScale = (1.0 - 0.8*length(in_velocity)/maxVelocity); diff --git a/game/renderer_polygon_3d/renderer_polygon_3d.cpp b/game/renderer_polygon_3d/renderer_polygon_3d.cpp index 25b996b..1dcb7a1 100644 --- a/game/renderer_polygon_3d/renderer_polygon_3d.cpp +++ b/game/renderer_polygon_3d/renderer_polygon_3d.cpp @@ -51,7 +51,9 @@ namespace endofthejedi { // TODO: add dust particles // TODO: add little rocks flying around - glClearColor(0.0, 0.0, 0.0, 1.0); + //glClearColor(0.0, 0.0, 0.0, 1.0); + float s = 0.1; + glClearColor(s, s, s, 1.0); m_shader.bind(); @@ -70,7 +72,7 @@ namespace endofthejedi { renderParticles(); - renderTraces(); + //renderTraces(); //glColor3f(1.0, 0.0, 0.0); //glBegin(GL_QUADS); @@ -99,9 +101,8 @@ namespace endofthejedi { // TODO: use this as shader input too and make the area 2x around this // so that it stays hot/yellow for 2/3 of the time - float explSize = 0.01f; - - float maxVelocity = 0.2f; + float explCoreSize = 0.02f; + float maxVelocity = 0.4f; ParticleBatch *batch = new ParticleBatch(id, n, particleRadius, duration); batch->setCenter(glm::vec3(pos, 0.0)); @@ -121,7 +122,7 @@ namespace endofthejedi { glm::vec3 v = glm::ballRand(maxVelocity); v *= util::randf_0_1() * util::randf_0_1() * util::randf_0_1(); - batch->setParticle(i, glm::vec3(pos, 0.0) + glm::ballRand(explSize), v); + batch->setParticle(i, glm::vec3(pos, 0.0) + glm::ballRand(explCoreSize), v); } batch->upload(); @@ -141,13 +142,13 @@ namespace endofthejedi { } if (!gotIt) { - addExplosionEffect(expl->id, expl->position, 1000, 2.0); + addExplosionEffect(expl->id, expl->position, 500, 0.5); } } - if (m_particles.size() == 0) { - addExplosionEffect(0, glm::vec2(0.0, 0.0), 1000, 2.0); - } + //if (m_particles.size() == 0) { + // addExplosionEffect(0, glm::vec2(0.0, 0.0), 1000, 2.0); + //} std::vector rm; @@ -246,7 +247,9 @@ namespace endofthejedi { glm::mat4 RendererPolygon3d::computeModelMatrix(const game::Ship *ship) { // TODO: rotate them before shooting, that looks better - glm::mat4 mat = computeModelMatrix(ship->position, m_state->shipRadius()); + //glm::mat4 mat = computeModelMatrix(ship->position, m_state->shipRadius()); + glm::mat4 mat = computeModelMatrix(ship->position, 5.0*m_state->shipRadius()); + // XXX model is flipped //glm::mat4 mat = computeModelMatrix(ship->position, 0.3); mat = glm::rotate(mat, (float) M_PI, glm::vec3(0.0f, 1.0f, 0.0f));