particles are even nicer now.

This commit is contained in:
Andreas Ortmann 2016-09-30 22:04:14 +02:00
parent 3a30a20043
commit c950d6a54d
5 changed files with 13 additions and 15 deletions

View file

@ -15,7 +15,6 @@ vec3 hsv2rgb(vec3 c)
void main() void main()
{ {
gl_FragColor = vec4(0.5+0.5*vertex.x, 0.5+0.5*vertex.y, 0.0, 1.0);
float r = length(vertex); float r = length(vertex);
if (r > 1.0) { if (r > 1.0) {
discard; discard;
@ -26,8 +25,6 @@ void main()
float v = max(0.0, (1.0-log(d))); float v = max(0.0, (1.0-log(d)));
float s = max(0.0, min(30.0 * sqrt(decay) * explCenterDist, 1.0)); float s = max(0.0, min(30.0 * sqrt(decay) * explCenterDist, 1.0));
//v /= decay * 10.0*length(vertex-explCenter);
//v /= 1.0+2.0*length(vertex-explCenter);
//v /= 1.0 + max(0.0, min(35.0*(decay-0.2), 1.0)) + 10.0 * explCenterDist; //v /= 1.0 + max(0.0, min(35.0*(decay-0.2), 1.0)) + 10.0 * explCenterDist;
v /= 1.0 + 10.0 * explCenterDist; v /= 1.0 + 10.0 * explCenterDist;

View file

@ -22,11 +22,11 @@ void main()
decay = age / halfAge; decay = age / halfAge;
// faster particles are smaller // faster particles are smaller
//float s = size * (1.0-length(in_velocity)/maxVelocity); float speedScale = (1.0 - 0.8*length(in_velocity)/maxVelocity);
float s = size; float finalSize = size * speedScale;
vec2 base = in_vertex; vec2 base = in_vertex;
vec3 p = s*vec3(base, 0.0); vec3 p = finalSize*vec3(base, 0.0);
vec3 offset = (0.1*age + log(1.0+age*5.0)) * in_velocity + in_position; vec3 offset = (0.2*age + log(1.0+age*5.0)) * in_velocity + in_position;
p += offset; p += offset;
gl_Position = vec4(p, 1.0); gl_Position = vec4(p, 1.0);

View file

@ -77,7 +77,8 @@ int main(int argc, char *argv[])
asio::io_service io_service; asio::io_service io_service;
Server s(io_service, game.state(), atoi(port) ); Server s(io_service, game.state(), atoi(port) );
GameWindow window(500, 500, &game); //GameWindow window(500, 500, &game);
GameWindow window(750, 750, &game);
window.set_maxfps(60.0); window.set_maxfps(60.0);
window.open(); window.open();

View file

@ -139,7 +139,7 @@ namespace endofthejedi {
glUniform1f(m_shader.location("maxVelocity"), m_maxVelocity); glUniform1f(m_shader.location("maxVelocity"), m_maxVelocity);
glUniform1f(m_shader.location("halfAge"), m_halfAge); glUniform1f(m_shader.location("halfAge"), m_halfAge);
glUniform1f(m_shader.location("size"), m_particleRadius); glUniform1f(m_shader.location("size"), m_particleRadius);
glUniform3f(m_shader.location("center"), m_center.x, m_center.y, m_center.z); glUniform3f(m_shader.location("explCenter"), m_center.x, m_center.y, m_center.z);
bind(); bind();

View file

@ -95,7 +95,7 @@ namespace endofthejedi {
{ {
//float particleRadius = 0.005; //float particleRadius = 0.005;
//float particleRadius = 0.003; //float particleRadius = 0.003;
float particleRadius = 0.01; float particleRadius = 0.007;
// TODO: use this as shader input too and make the area 2x around this // 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 // so that it stays hot/yellow for 2/3 of the time
@ -119,7 +119,7 @@ namespace endofthejedi {
//glm::vec3 v = 0.5f*glm::vec3(sin(t), cos(t), util::randf_m1_1()); //glm::vec3 v = 0.5f*glm::vec3(sin(t), cos(t), util::randf_m1_1());
glm::vec3 v = glm::ballRand(maxVelocity); glm::vec3 v = glm::ballRand(maxVelocity);
v *= util::randf_0_1() * util::randf_0_1(); 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(explSize), v);
} }
@ -141,12 +141,12 @@ namespace endofthejedi {
} }
if (!gotIt) { if (!gotIt) {
addExplosionEffect(expl->id, expl->position, 500, 5.0); addExplosionEffect(expl->id, expl->position, 1000, 2.0);
} }
} }
if (m_particles.size() == 0) { if (m_particles.size() == 0) {
addExplosionEffect(0, glm::vec2(0.0, 0.0), 1000, 5.0); addExplosionEffect(0, glm::vec2(0.0, 0.0), 1000, 2.0);
} }
std::vector<ParticleBatch*> rm; std::vector<ParticleBatch*> rm;
@ -284,7 +284,7 @@ namespace endofthejedi {
fade_out = 1.0 - (trace->age / trace->maxAge); fade_out = 1.0 - (trace->age / trace->maxAge);
} }
glColor3f(0.0, 0.0, 1.0*fade_out); glColor3f(0.0, 0.5*fade_out, 0.5*fade_out);
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
for (const game::Trace::TracePoint &tp : trace->points) { for (const game::Trace::TracePoint &tp : trace->points) {
glVertex2f(tp.position.x, tp.position.y); glVertex2f(tp.position.x, tp.position.y);