From 90d60a0e480fb7d766c6b1dfa19854d45d0661a6 Mon Sep 17 00:00:00 2001 From: Szymon Szczubkowski Date: Thu, 8 Feb 2024 08:44:24 +0100 Subject: [PATCH] add: flame colour change on engine upgrade --- README.md | 15 +++++++++++---- cw_8/shaders/part.frag | 7 +++++-- cw_8/src/Particle.cpp | 9 +++++++-- cw_8/src/Particle.h | 2 +- cw_8/src/projekt.hpp | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7c284dd..0f1a17f 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ Szymon Szczubkowski, Agnieszka Wyrosławska ## Zaimplementowane technologie ### Physically based rendering -W projekcie zaimplementowane jest oświetlenie PBR. Wspiera ono albedo, roughness, metallic, ambient occlusion oraz **normal** mapy. +W projekcie zaimplementowane jest oświetlenie **PBR**. Wspiera ono albedo, roughness, metallic, ambient occlusion oraz **normal** mapy. ### Normal mapping -Razem z PBR zaimplementowane zostało wsparcie dla normal maps. +Razem z **PBR** zaimplementowane zostało wsparcie dla **normal maps**. ![picture](https://i.imgur.com/VJP72bY.png) @@ -19,7 +19,7 @@ W tle widoczny jest skybox kosmosu. ### Billboarding -Na potrzeby wyświetlania cząsteczek ognia zaimplementowany został billboarding. +Na potrzeby wyświetlania cząsteczek ognia zaimplementowany został **billboarding**. Aby osiągnąć bardziej realistyczny efekt płonącego ognia wykorzystana została technika **blending**u. ![picture](https://i.gyazo.com/d00aba38d49f6179861f68ec464b4753.gif) @@ -33,4 +33,11 @@ FUNKCJA | PRZYCISK LOT W PRZÓD | PRAWY TRIGGER LOT W TYŁ | LEWY TRIGGER OBRÓT LEWO-PRAWO | LEWA GAŁKA -NACHYLENIE GÓRA-DÓŁ | PRAWA GAŁKA \ No newline at end of file +NACHYLENIE GÓRA-DÓŁ | PRAWA GAŁKA +MONOTWANIE ULEPSZENIA | A / X + +### Interaktywność + +W związku z brakami kadrowymi, "gra" stanowi bardziej demo typu "Proof of concept". +Możliwe jest zebranie ulepszenia które poprawia prędkość statku oraz zmienia kolor płomieni. +![picture](https://i.gyazo.com/35f28bdc6ef12186f38395b3f967cdb7.gif) \ No newline at end of file diff --git a/cw_8/shaders/part.frag b/cw_8/shaders/part.frag index 291ec4c..28f48e4 100644 --- a/cw_8/shaders/part.frag +++ b/cw_8/shaders/part.frag @@ -7,6 +7,9 @@ uniform sampler2D sprite; void main() { - FragColor = (texture(sprite, TexCoords) * ParticleColor); - FragColor = texture(sprite, TexCoords); + if(ParticleColor.w > 0){ + FragColor = (texture(sprite, TexCoords) * ParticleColor); + }else{ + FragColor = texture(sprite, TexCoords); + } } \ No newline at end of file diff --git a/cw_8/src/Particle.cpp b/cw_8/src/Particle.cpp index 3f5e3ec..bc31a1b 100644 --- a/cw_8/src/Particle.cpp +++ b/cw_8/src/Particle.cpp @@ -4,7 +4,7 @@ ParticleGenerator::ParticleGenerator() { this->init(); } -void ParticleGenerator::Draw(glm::mat4 modelMatrix, GLuint programParticle, GLuint texture, glm::vec3 cameraDir) { +void ParticleGenerator::Draw(glm::mat4 modelMatrix, GLuint programParticle, GLuint texture, glm::vec3 cameraDir, bool isColour) { glEnable(GL_BLEND); glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -18,7 +18,12 @@ void ParticleGenerator::Draw(glm::mat4 modelMatrix, GLuint programParticle, GLui glUniformMatrix4fv(glGetUniformLocation(programParticle, "transformation"), 1, GL_FALSE, (float*)&(modelMatrix)); glUniform3f(glGetUniformLocation(programParticle, "position"), particle.position.x, particle.position.y + (rand() % 10 - 5) / 500.f, particle.position.z + (rand() % 10 - 5) / 500.f); - glUniform4f(glGetUniformLocation(programParticle, "color"), particle.color.x, particle.color.y, particle.color.z, particle.color.w); + if (isColour) { + glUniform4f(glGetUniformLocation(programParticle, "color"), 0.f, 0.9f, 0.f, 1.f); + } + else { + glUniform4f(glGetUniformLocation(programParticle, "color"), 0.f, 0.f, 0.f, 0.f); + } glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f))); glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir)); diff --git a/cw_8/src/Particle.h b/cw_8/src/Particle.h index 2a1f4fd..176bbc6 100644 --- a/cw_8/src/Particle.h +++ b/cw_8/src/Particle.h @@ -15,7 +15,7 @@ struct Particle { class ParticleGenerator { public: - void Draw(glm::mat4 modelMatrix, GLuint programParticle, GLuint texture, glm::vec3 cameraDir); + void Draw(glm::mat4 modelMatrix, GLuint programParticle, GLuint texture, glm::vec3 cameraDir, bool isColour); ParticleGenerator(); private: std::vector particles; diff --git a/cw_8/src/projekt.hpp b/cw_8/src/projekt.hpp index c2e3c6f..2bfe2f5 100644 --- a/cw_8/src/projekt.hpp +++ b/cw_8/src/projekt.hpp @@ -407,7 +407,7 @@ void renderScene(GLFWwindow* window) { drawObjectPBR(planetContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(0, 0, -3.f)) * glm::eulerAngleY(-1.5f * time) * glm::scale(glm::vec3(0.1f)), texture::earth_albedo, texture::earth_normal, texture::earth_ao, texture::earth_roughness, texture::earth_metallic); drawObjectPBR(planetContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(0, 0, -3.f)) * glm::eulerAngleY( 2.f * time) * glm::translate(glm::vec3(0.4f, 0, 0.4f)) * glm::eulerAngleY(-0.5f * time) * glm::scale(glm::vec3(0.04f)), texture::moon_albedo, texture::moon_normal, texture::moon_ao, texture::moon_roughness, texture::moon_metallic); - mainEngine->Draw(createPerspectiveMatrix() * createCameraMatrix() * glm::translate(glm::vec3(0.f, -0.22f, 0.0f)) * glm::translate(cameraPos + 0.2 * cameraDir + glm::vec3(0, 1, 0) * 0.05f), programParticle, texture::particle_fire, cameraDir); + mainEngine->Draw(createPerspectiveMatrix() * createCameraMatrix() * glm::translate(glm::vec3(0.f, -0.22f, 0.0f)) * glm::translate(cameraPos + 0.2 * cameraDir + glm::vec3(0, 1, 0) * 0.05f), programParticle, texture::particle_fire, cameraDir, engineIs == 2); std::cout << glm::to_string(spaceshipPos) << std::endl; //desired objects end here glUseProgram(0);