Skip to content

Commit 2dff253

Browse files
committed
Particles look better
1 parent 37d918e commit 2dff253

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

ParticleGen.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
ParticleGen::ParticleGen(int amount, GLuint texture, GLuint shader)
1212
: amount(amount), texture(texture), shaderProgram(shader) {
1313

14+
e1 = std::default_random_engine(r());
15+
uniform_real = std::uniform_real_distribution<float>(-100.0f,100.0f);
16+
1417
GLfloat particle_quad[] = {
1518
0.0f, 1.0f, 0.0f, 1.0f,
1619
1.0f, 0.0f, 1.0f, 0.0f,
@@ -66,8 +69,12 @@ GLuint ParticleGen::firstUnusedParticle(){
6669
// Respawns particle
6770
void ParticleGen::respawnParticle(Particle &particle){
6871
// srand((unsigned int)time(NULL));
69-
GLfloat randomX = ((rand() % 200) - 100);
70-
GLfloat randomZ = ((rand() & 200) - 100);
72+
73+
float randomX = uniform_real(e1);
74+
float randomZ = uniform_real(e1);
75+
76+
// GLfloat randomX = ((rand() % 200) - 100);
77+
// GLfloat randomZ = ((rand() & 200) - 100);
7178
GLfloat rColor = 0.5 + ((rand() % 100) / 100.0f);
7279
particle.Position = glm::vec3(randomX, CLOUD_HEIGHT, randomZ);//Randomize positions on the xy-plane, z should be same
7380
particle.Color = glm::vec4(rColor, rColor, rColor, 1.0f); //randomize the color

ParticleGen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class ParticleGen : public Geode{
3939
GLuint texture, shaderProgram;
4040
std::vector<Particle> particles;
4141

42+
std::random_device r;
43+
std::default_random_engine e1;
44+
std::uniform_real_distribution<float> uniform_real;
4245

4346
GLuint uModel, uProjection, uModelview;
4447

Window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ void Window::drawSkybox(){
408408
void Window::drawObjects(){
409409
drawSkybox();
410410

411-
// generator->draw(glm::mat4(1.0f));
411+
generator->draw(glm::mat4(1.0f));
412412

413413
//Toggle showing particles drawn
414414
if(parts)

particleShader.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ void main()
1919
// TexCoords = vertex.zw;
2020
ParticleColor = color;
2121
// gl_Position = projection * modelview * vec4(position.xyz / scale + partPos, 1.0f);
22-
gl_Position = projection * modelview * vec4(position.x/scale+partPos.x,
23-
position.y*scale+partPos.y, position.z/scale+partPos.z, 1.0f);
22+
gl_Position = projection * modelview * vec4(position.x/(scale*3.0f)+partPos.x,
23+
position.y*scale+partPos.y, position.z/(scale*3.0f)+partPos.z, 1.0f);
2424
}

waterShader.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in vec3 fromLightVector;
2020

2121
uniform float moveFactor;
2222

23-
const float waveStrength = 0.00375f;
23+
const float waveStrength = 0.00375f*2.0f*2.0f;
2424
const float shineDamper = 20.0f; //shinedamper
2525
const float reflectivity = 1.0f; //reflectivity
2626

0 commit comments

Comments
 (0)