Fix particles direction,

This commit is contained in:
xkamikoo 2021-02-09 22:51:41 +01:00
parent e2146bc5a1
commit 032c080f33
8 changed files with 18 additions and 11 deletions

View File

@ -12,8 +12,8 @@ newmtl SF_Corvette_F3
Kd 1.000000 1.000000 1.000000 Kd 1.000000 1.000000 1.000000
Ks 1.260000 1.260000 1.260000 Ks 1.260000 1.260000 1.260000
Ke 0.000000 0.000000 0.000000 Ke 0.000000 0.000000 0.000000
map_Ka SF_Corvette-F3_diffuse.jpg map_Ka textures\\SF_Corvette-F3_diffuse.jpg
map_Kd SF_Corvette-F3_diffuse.jpg map_Kd textures\\SF_Corvette-F3_specular.jpg
map_Ke SF_Corvette-F3_glow.jpg map_Ke textures\\SF_Corvette-F3_glow.jpg
map_bump SF_Corvette-F3_bump.jpg map_bump textures\\SF_Corvette-F3_normals.jpg
bump SF_Corvette-F3_bump.jpg bump textures\\SF_Corvette-F3_bump.jpg

View File

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 423 KiB

After

Width:  |  Height:  |  Size: 423 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 MiB

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -322,8 +322,10 @@ void drawParticles(int ParticlesCount, glm::mat4 &transformation)
glBindBuffer(GL_ARRAY_BUFFER, particles_color_buffer); glBindBuffer(GL_ARRAY_BUFFER, particles_color_buffer);
glBufferData(GL_ARRAY_BUFFER, MaxParticles * 4 * sizeof(GLubyte), NULL, GL_STREAM_DRAW); // Buffer orphaning, a common way to improve streaming perf. See above link for details. glBufferData(GL_ARRAY_BUFFER, MaxParticles * 4 * sizeof(GLubyte), NULL, GL_STREAM_DRAW); // Buffer orphaning, a common way to improve streaming perf. See above link for details.
glBufferSubData(GL_ARRAY_BUFFER, 0, ParticlesCount * sizeof(GLubyte) * 4, g_particule_color_data); glBufferSubData(GL_ARRAY_BUFFER, 0, ParticlesCount * sizeof(GLubyte) * 4, g_particule_color_data);
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, particleTexture); glBindTexture(GL_TEXTURE_2D, particleTexture);
glUniform1i(glGetUniformLocation(programParticle, "sprite"), 0); glUniform1i(glGetUniformLocation(programParticle, "sprite"), 0);
glUniform3f(glGetUniformLocation(programParticle, "CameraRight_worldspace"), cameraSide.x, cameraSide.y, cameraSide.z); glUniform3f(glGetUniformLocation(programParticle, "CameraRight_worldspace"), cameraSide.x, cameraSide.y, cameraSide.z);
glUniform3f(glGetUniformLocation(programParticle, "CameraUp_worldspace"), 0, 1, 0); glUniform3f(glGetUniformLocation(programParticle, "CameraUp_worldspace"), 0, 1, 0);
@ -489,7 +491,9 @@ void renderScene()
int newparticles = 0; int newparticles = 0;
if (engineLightTimer < 40)
if (engineLightTimer < 30)
{ {
engineLightTimer++; engineLightTimer++;
newparticles = (int)(delta * 10000.0); newparticles = (int)(delta * 10000.0);
@ -501,6 +505,7 @@ void renderScene()
lights[2].intensity = 0.00001; lights[2].intensity = 0.00001;
lights[3].intensity = 0.00001; lights[3].intensity = 0.00001;
} }
/*
if (cameraPos[0] < partX) if (cameraPos[0] < partX)
{ {
partXdir = 1; partXdir = 1;
@ -529,9 +534,10 @@ void renderScene()
{ {
partAdir = cameraDir[0] * -1; partAdir = cameraDir[0] * -1;
} }
*/
for (int i = 0; i < newparticles; i++) { for (int i = 0; i < newparticles; i++) {
int particleIndex = FindUnusedParticle(); int particleIndex = FindUnusedParticle();
ParticlesContainer[particleIndex].life = 5.0f; ParticlesContainer[particleIndex].life = 2.0f;
if (lights[2].intensity > 0.001 && lights[3].intensity > 0.001) if (lights[2].intensity > 0.001 && lights[3].intensity > 0.001)
{ {
if (rand() % 2) if (rand() % 2)
@ -547,8 +553,8 @@ void renderScene()
ParticlesContainer[particleIndex].pos = lights[3].position; ParticlesContainer[particleIndex].pos = lights[3].position;
float spread = 0.2f; float spread = 0.8;
glm::vec3 maindir = glm::vec3(partXdir*partAdir, -0.3f, partYdir*partAdir); glm::vec3 maindir = -1 * cameraDir; //glm::vec3(partXdir*partAdir, -0.3f, partYdir*partAdir);
glm::vec3 randomdir = glm::vec3( glm::vec3 randomdir = glm::vec3(
(rand() % 2000 - 1000.0f) / 5000.0f, (rand() % 2000 - 1000.0f) / 5000.0f,
(rand() % 2000 - 1000.0f) / 5000.0f, (rand() % 2000 - 1000.0f) / 5000.0f,
@ -646,7 +652,7 @@ void init_particles()
g_particule_position_size_data = new GLfloat[MaxParticles * 4]; g_particule_position_size_data = new GLfloat[MaxParticles * 4];
g_particule_color_data = new GLubyte[MaxParticles * 4]; g_particule_color_data = new GLubyte[MaxParticles * 4];
for (int i = 0; i < MaxParticles; i++) { for (int i = 0; i < MaxParticles; i++) {
ParticlesContainer[i].life = 5.0f; ParticlesContainer[i].life = 1.0f;
ParticlesContainer[i].cameradistance = -1.0f; ParticlesContainer[i].cameradistance = -1.0f;
} }
static const GLfloat g_vertex_buffer_data[] = { static const GLfloat g_vertex_buffer_data[] = {

View File

@ -78,7 +78,8 @@ public:
number = std::to_string(heightNr++); // transfer unsigned int to stream number = std::to_string(heightNr++); // transfer unsigned int to stream
// now set the sampler to the correct texture unit // now set the sampler to the correct texture unit
glUniform1i(glGetUniformLocation(program, (name + number).c_str()), i); //glUniform1i(glGetUniformLocation(program, (name + number).c_str()), i);
glUniform1i(glGetUniformLocation(program, "colorTexture"), i);
// and finally bind the texture // and finally bind the texture
glBindTexture(GL_TEXTURE_2D, textures[i].id); glBindTexture(GL_TEXTURE_2D, textures[i].id);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 MiB