diff --git a/src/Components/ParticleEmitter.h b/src/Components/ParticleEmitter.h index f7cb678..edd92b5 100755 --- a/src/Components/ParticleEmitter.h +++ b/src/Components/ParticleEmitter.h @@ -20,6 +20,7 @@ struct ParticleEmitter : Component , SpreadAngle(0) , LifeTime(0) , TimeSinceLastSpawn(100) + , Emitting(false) , Color(glm::vec4(0)) { } EntityID ParticleTemplate; @@ -32,6 +33,7 @@ struct ParticleEmitter : Component double LifeTime; bool UseGoalVelocity; bool Fade; + bool Emitting; glm::vec3 GoalVelocity; std::vector AngularVelocitySpectrum; std::vector OrientationSpectrum; //Keep? noo.. diff --git a/src/Events/CreateExplosion.h b/src/Events/CreateExplosion.h index 0fb6310..3766c6b 100644 --- a/src/Events/CreateExplosion.h +++ b/src/Events/CreateExplosion.h @@ -9,8 +9,10 @@ namespace Events { struct CreateExplosion : Event { - CreateExplosion() - : Color(glm::vec4(0)) {} + CreateExplosion() : + Color(glm::vec4(0)), + UseGoalVector(false) {} + glm::vec3 Position; glm::vec4 Color; double LifeTime; @@ -20,6 +22,10 @@ namespace Events float Speed; float SpreadAngle; std::vector ParticleScale; + bool UseGoalVector; + glm::vec3 GoalVelocity; + bool Emitting; + float SpawnFrequency; }; } diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index 9e25c5e..c324f3d 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -271,15 +271,6 @@ void GameWorld::Initialize() } #pragma endregion Region for wall debris -#pragma region Wall_Regin - - for(int i = 10; i < 0; i++) - { - EntityID Wall = CreateWall(glm::vec3(i*10.f, -15.f, 0.f), glm::quat()); - } - -#pragma endregion Region for all wall creations - /*EntityID tank1 = CreateTank(1); { auto transform = GetComponent(tank1); @@ -640,9 +631,9 @@ void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orient } } -EntityID GameWorld::CreateWall(glm::vec3 pos, glm::quat orientation) +EntityID GameWorld::CreateWall(EntityID parent, glm::vec3 pos, glm::quat orientation) { - auto wall = CreateEntity(); + auto wall = CreateEntity(parent); auto transform = AddComponent(wall); transform->Position = pos; transform->Orientation = orientation; @@ -1211,6 +1202,14 @@ void GameWorld::CreateBase(glm::quat orientation, int playerID) CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -55.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -45.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -35.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, -15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, 15.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateWall(base, glm::vec3(273.f, 40.3f, 25.f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0))); + CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi() / 2.f, 0)), playerID); } EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID) diff --git a/src/GameWorld.h b/src/GameWorld.h index 420a328..e8decde 100755 --- a/src/GameWorld.h +++ b/src/GameWorld.h @@ -82,7 +82,7 @@ private: void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation); void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering); EntityID CreateJeep(int playerID); - EntityID CreateWall(glm::vec3 pos, glm::quat orientation); + EntityID CreateWall(EntityID parent, glm::vec3 pos, glm::quat orientation); EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID); void CreateTerrain(); void CreateBase(glm::quat orientation, int playerID); diff --git a/src/Model.cpp b/src/Model.cpp index 1186671..352c7f6 100755 --- a/src/Model.cpp +++ b/src/Model.cpp @@ -93,7 +93,7 @@ Model::Model(std::shared_ptr rm, OBJ &obj) if (Vertices.size() > 0) { CreateTangents(); - //getSimilarVertexIndex(); + getSimilarVertexIndex(); CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords); } else @@ -105,7 +105,7 @@ Model::Model(std::shared_ptr rm, OBJ &obj) void Model::CreateBuffers( std::vector vertices, std::vector normals, std::vector tangents, std::vector biTangents, std::vectortextureCoords) { - LOG_INFO("Generating VertexBuffer"); + //LOG_INFO("Generating VertexBuffer"); glGenBuffers(1, &VertexBuffer); if (vertices.size() > 0) { @@ -118,7 +118,7 @@ void Model::CreateBuffers( std::vector vertices, std::vector 0) { @@ -131,7 +131,7 @@ void Model::CreateBuffers( std::vector vertices, std::vector 0) { @@ -144,7 +144,7 @@ void Model::CreateBuffers( std::vector vertices, std::vector 0) { @@ -158,7 +158,7 @@ void Model::CreateBuffers( std::vector vertices, std::vector 0) { @@ -223,6 +223,8 @@ void Model::getSimilarVertexIndex() { glm::vec3 tempNormal, tempTangent, tempBiTangent; + if(glm::dot(Normals[i], Normals[t]) > 0) + { tempNormal = Normals[i] + Normals[t]; tempTangent = TangentNormals[i] + TangentNormals[t]; tempBiTangent = BiTangentNormals[i] + BiTangentNormals[t]; @@ -235,6 +237,7 @@ void Model::getSimilarVertexIndex() BiTangentNormals[i] = tempBiTangent; BiTangentNormals[t] = tempBiTangent; + } } } } diff --git a/src/OBJ.cpp b/src/OBJ.cpp index 71ec109..a5f9973 100755 --- a/src/OBJ.cpp +++ b/src/OBJ.cpp @@ -13,7 +13,7 @@ bool OBJ::LoadFromFile(std::string filename) return false; } - LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str()); + //LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str()); std::string line; while (std::getline(file, line)) @@ -121,7 +121,7 @@ void OBJ::ParseMaterial() return; } - LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str()); + //LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str()); std::string currentMaterialName; MaterialInfo* currentMaterial = nullptr; @@ -144,7 +144,7 @@ void OBJ::ParseMaterial() { MaterialInfo mat; ss >> currentMaterialName; - LOG_INFO("Parsing material %s", currentMaterialName.c_str()); + //LOG_INFO("Parsing material %s", currentMaterialName.c_str()); Materials[currentMaterialName] = mat; currentMaterial = &Materials[currentMaterialName]; continue; diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 958fd1b..ef8e67b 100755 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -22,7 +22,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager) LAtt = 0.0f; QAtt = 3.0f; m_ShadowMapRes = 1; - m_SunPosition = glm::vec3(0.f, 1.0f, 0.5f); + m_SunPosition = glm::vec3(0.f, 1.0f, 0.7f); m_SunTarget = glm::vec3(0, 0, 0); m_SunProjection_height = glm::vec2(-40.f, 40.f); m_SunProjection_width = glm::vec2(-40.f, 40.f); @@ -126,6 +126,7 @@ void Renderer::LoadContent() m_SunPassProgram.AddShader(std::shared_ptr(new VertexShader("Shaders/SunPass.vert.glsl"))); m_SunPassProgram.AddShader(std::shared_ptr(new FragmentShader("Shaders/SunPass.frag.glsl"))); m_SunPassProgram.Compile(); + glBindFragDataLocation(m_SunPassProgram.GetHandle(), 0, "frag_Light"); m_SunPassProgram.Link(); m_ForwardRendering.AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardRendering.vert.glsl"))); @@ -142,7 +143,6 @@ void Renderer::LoadContent() m_FirstPassProgram.AddShader(std::shared_ptr(new VertexShader("Shaders/Vertex.glsl"))); m_FirstPassProgram.AddShader(std::shared_ptr(new FragmentShader("Shaders/Fragment.glsl"))); m_FirstPassProgram.Compile(); - glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "frag_Diffuse"); glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "frag_Position"); glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal"); @@ -151,6 +151,7 @@ void Renderer::LoadContent() m_SecondPassProgram.AddShader(std::shared_ptr(new VertexShader("Shaders/Vertex2.glsl"))); m_SecondPassProgram.AddShader(std::shared_ptr(new FragmentShader("Shaders/Fragment2.glsl"))); m_SecondPassProgram.Compile(); + glBindFragDataLocation(m_SecondPassProgram.GetHandle(), 0, "frag_Light"); m_SecondPassProgram.Link(); m_SecondPassProgram_Debug.AddShader(std::shared_ptr(new VertexShader("Shaders/Vertex2.glsl"))); @@ -161,6 +162,7 @@ void Renderer::LoadContent() m_FinalPassProgram.AddShader(std::shared_ptr(new VertexShader("Shaders/FinalPass.vert.glsl"))); m_FinalPassProgram.AddShader(std::shared_ptr(new FragmentShader("Shaders/FinalPass.frag.glsl"))); m_FinalPassProgram.Compile(); + glBindFragDataLocation(m_FinalPassProgram.GetHandle(), 0, "frag_Diffuse"); m_FinalPassProgram.Link(); m_ScreenQuad = CreateQuad(); CreateShadowMap(m_ShadowMapRes); @@ -269,6 +271,7 @@ void Renderer::Draw(double dt) void Renderer::DrawFrame(RenderQueuePair &rq) { + glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height); @@ -386,81 +389,78 @@ void Renderer::DrawWorld(RenderQueuePair &rq) rq.Forward.Jobs.sort(Renderer::DepthSort); //DrawShadowMap(rq.Deferred); - /* - Base pass + Base pass */ - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass); + glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass); glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height); //glViewport(0, 0, m_Width, m_Height); // Clear G-buffer - GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; - glDrawBuffers(4, windowBuffClear); glClearColor(115.f / 255, 192.f / 255, 255.f / 255, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Execute the first render stage which will fill out the internal buffers with data(??) m_FirstPassProgram.Bind(); - GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; - glDrawBuffers(4, windowBuffOpaque); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); - DrawSkybox(); + //DrawSkybox(); + DrawFBOScene(rq.Deferred); /* - Lighting pass + Lighting pass */ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbLightingPass); + //glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass); glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 }; - glDrawBuffers(1, lightingPassAttachments); + glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height); + + + glCullFace(GL_FRONT); + glEnable(GL_BLEND); + glBlendEquation(GL_FUNC_ADD); + glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT); - m_SecondPassProgram.Bind(); - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_fPositionTexture); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture); - - glCullFace(GL_FRONT); DrawLightScene(rq.Deferred); + glCullFace(GL_BACK); DrawSunLightScene(); /* - Final pass + Final pass */ - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - //glViewport(m_Viewport.X, m_Viewport.Y, m_Viewport.Width, m_Viewport.Height); - glViewport(0, 0, m_Width, m_Height); - //glScissor(0, 0, m_Width, m_Height); - glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - glClear(GL_DEPTH_BUFFER_BIT); + glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass); + glViewport(0, 0, m_Width, m_Height); + glScissor(0, 0, m_Width, m_Height); + //glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); + glClear(GL_COLOR_BUFFER_BIT); + glClearColor(0.f, 0.f, 0.f, 0.f); + + + m_FinalPassProgram.Bind(); - - // Ambient light - glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.7f))); - glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, m_fLightingTexture); - - glCullFace(GL_BACK); - glBindVertexArray(m_ScreenQuad); - glEnableVertexAttribArray(0); - glDrawArrays(GL_TRIANGLES, 0, 6); + // Ambient light + glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(1.0f))); + //glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_fLightingTexture); + + glCullFace(GL_BACK); + glBindVertexArray(m_ScreenQuad); + glEnableVertexAttribArray(0); + glDrawArrays(GL_TRIANGLES, 0, 6); /* Transparency @@ -470,25 +470,23 @@ void Renderer::DrawWorld(RenderQueuePair &rq) void Renderer::ForwardRendering(RenderQueue &rq) { - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass); - - glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); - - // Clear G-buffer - GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE }; - glDrawBuffers(4, attachments); - //glClearColor(0.f, 0.f, 0.f, 1.f); - //glClear(GL_COLOR_BUFFER_BIT); - glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEPTH_TEST); glDepthMask(GL_FALSE); - glEnable(GL_CULL_FACE); glCullFace(GL_BACK); + //glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass); + glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); + glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); + + // Clear G-buffer + //GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE, GL_NONE }; + //glDrawBuffers(4, attachments); + //glClear(GL_COLOR_BUFFER_BIT); + //glClearColor(0.f, 0.f, 0.f, 0.f); + glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height); glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix(); glm::mat4 MVP; @@ -497,7 +495,7 @@ void Renderer::ForwardRendering(RenderQueue &rq) GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle(); for (auto &job : rq) { - auto modelJob = std::dynamic_pointer_cast(job); + auto modelJob = std::dynamic_pointer_cast(job); if (modelJob) { glm::mat4 modelMatrix = modelJob->ModelMatrix; @@ -508,12 +506,14 @@ void Renderer::ForwardRendering(RenderQueue &rq) glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection)); glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color)); + glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "La"), 1, glm::value_ptr(glm::vec3(1.0f))); + glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "directionToSun"), 1, glm::value_ptr(glm::normalize(m_SunPosition))); glBindVertexArray(modelJob->VAO); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture); - /*if (modelJob->NormalTexture != 0) + if (modelJob->NormalTexture != 0) { glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture); @@ -522,7 +522,7 @@ void Renderer::ForwardRendering(RenderQueue &rq) { glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture); - }*/ + } glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1); continue; @@ -555,7 +555,8 @@ void Renderer::ForwardRendering(RenderQueue &rq) /* Final pass */ - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); glViewport(0, 0, m_Width, m_Height); glScissor(0, 0, m_Width, m_Height); @@ -571,7 +572,9 @@ void Renderer::ForwardRendering(RenderQueue &rq) //glUniform1f(glGetUniformLocation(ShaderProgramHandle, "Gamma"), Gamma); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture); + glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture); +// glActiveTexture(GL_TEXTURE1); +// glBindTexture(GL_TEXTURE_2D, m_fLightingTexture); glCullFace(GL_BACK); glBindVertexArray(m_ScreenQuad); @@ -947,7 +950,7 @@ void Renderer::FrameBufferTextures() //Generate and bind diffuse texture glGenTextures(1, &m_fDiffuseTexture); glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -999,19 +1002,47 @@ void Renderer::FrameBufferTextures() glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fSpecularTexture, 0); //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fShadowTexture, 0); + GLenum FirstPass[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; + glDrawBuffers(4, FirstPass); + GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(fbStatus != GL_FRAMEBUFFER_COMPLETE) { LOG_ERROR("DeferredLighting:Init: m_fbBasePass incomplete: 0x%x\n", fbStatus); //exit(1); } + + m_fbFinalPass = 0; + glGenFramebuffers(1, &m_fbFinalPass); + glGenTextures(1, &m_fFinalDiffuseTexture); + glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + + glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fFinalDiffuseTexture, 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer); + + GLenum FinalPassAttachments[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, FinalPassAttachments); + + fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if(fbStatus != GL_FRAMEBUFFER_COMPLETE) + { + LOG_ERROR("DeferredLighting:Init: m_fbLightingPass incomplete: 0x%x\n", fbStatus); + //exit(1); + } + m_fbLightingPass = 0; glGenFramebuffers(1, &m_fbLightingPass); glGenTextures(1, &m_fLightingTexture); glBindTexture(GL_TEXTURE_2D, m_fLightingTexture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -1020,6 +1051,9 @@ void Renderer::FrameBufferTextures() glBindFramebuffer(GL_FRAMEBUFFER, m_fbLightingPass); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fLightingTexture, 0); + GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 }; + glDrawBuffers(1, lightingPassAttachments); + fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); if(fbStatus != GL_FRAMEBUFFER_COMPLETE) { @@ -1268,12 +1302,7 @@ void Renderer::DrawFBOScene(RenderQueue &rq) void Renderer::DrawLightScene(RenderQueue &rq) { - glEnable(GL_BLEND); - glBlendEquation (GL_FUNC_ADD); - glBlendFunc(GL_ONE,GL_ONE); - - glDisable (GL_DEPTH_TEST); - glDepthMask (GL_FALSE); + glBindVertexArray(m_sphereModel->VAO); glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height); @@ -1284,6 +1313,13 @@ void Renderer::DrawLightScene(RenderQueue &rq) m_SecondPassProgram.Bind(); GLuint ShaderProgramHandle = m_SecondPassProgram.GetHandle(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_fPositionTexture); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture); + for (auto &light : Lights) { MVP = cameraMatrix * light.SphereModelMatrix; @@ -1306,21 +1342,10 @@ void Renderer::DrawLightScene(RenderQueue &rq) glDrawArrays(GL_TRIANGLES, 0, m_sphereModel->Vertices.size()); }; - glEnable(GL_DEPTH_TEST); - glDepthMask(GL_TRUE); - glDisable(GL_BLEND); } void Renderer::DrawSunLightScene() { - glCullFace(GL_BACK); - - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_ONE,GL_ONE); - - glDisable (GL_DEPTH_TEST); - glDepthMask (GL_FALSE); //glBindVertexArray(m_sphereModel->VAO); glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height); @@ -1329,7 +1354,13 @@ void Renderer::DrawSunLightScene() m_SunPassProgram.Bind(); GLuint ShaderProgramHandle = m_SunPassProgram.GetHandle(); - + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_fPositionTexture); + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture); + glActiveTexture(GL_TEXTURE2); + glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture); glUniform2fv(glGetUniformLocation(ShaderProgramHandle, "ViewportSize"), 1, glm::value_ptr(glm::vec2(m_Width, m_Height))); glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); @@ -1341,10 +1372,6 @@ void Renderer::DrawSunLightScene() glBindVertexArray(m_ScreenQuad); glEnableVertexAttribArray(0); glDrawArrays(GL_TRIANGLES, 0, 6); - - glEnable (GL_DEPTH_TEST); - glDepthMask (GL_TRUE); - glDisable (GL_BLEND); } void Renderer::SetSphereModel( Model* _model ) diff --git a/src/Renderer.h b/src/Renderer.h index 2efdb57..faedb8f 100755 --- a/src/Renderer.h +++ b/src/Renderer.h @@ -167,6 +167,10 @@ private: GLuint m_ShadowFrameBuffer; GLuint m_ShadowDepthTexture; + + GLuint m_fbFinalPass; + GLuint m_fFinalDiffuseTexture; + GLuint m_fbBasePass; GLuint m_fDiffuseTexture; GLuint m_fPositionTexture; diff --git a/src/Shaders/FinalForwardPass.frag.glsl b/src/Shaders/FinalForwardPass.frag.glsl index 022efde..ac977ea 100644 --- a/src/Shaders/FinalForwardPass.frag.glsl +++ b/src/Shaders/FinalForwardPass.frag.glsl @@ -1,6 +1,5 @@ #version 430 -//uniform vec3 La; layout (binding=0) uniform sampler2D DiffuseTexture; @@ -15,11 +14,11 @@ out vec4 FragmentColor; void main() { vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord); - //vec4 LightingTexel = texture(LightingTexture, Input.TextureCoord); //FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0); //FragmentColor = DiffuseTexel; FragmentColor = DiffuseTexel; + //FragmentColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightingTexel.rgb, 0.0)) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0); //FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a); } \ No newline at end of file diff --git a/src/Shaders/FinalPass.frag.glsl b/src/Shaders/FinalPass.frag.glsl index 5a4faf0..4b05b38 100644 --- a/src/Shaders/FinalPass.frag.glsl +++ b/src/Shaders/FinalPass.frag.glsl @@ -1,7 +1,7 @@ #version 430 +//Dicksdickdickdickssssss uniform vec3 La; -uniform float Gamma; layout (binding=0) uniform sampler2D DiffuseTexture; layout (binding=1) uniform sampler2D LightingTexture; @@ -12,7 +12,7 @@ in VertexData vec2 TextureCoord; } Input; -out vec4 FragmentColor; +out vec4 frag_Diffuse; void main() { @@ -21,7 +21,12 @@ void main() //FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0); //FragmentColor = DiffuseTexel; + //FragmentColor = DiffuseTexel; + //frag_Diffuse = vec4(LightingTexel.rgb, 0.0); + + //frag_Diffuse = DiffuseTexel * ((vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0))); + frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0))); + //frag_Diffuse = LightingTexel; - FragmentColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightingTexel.rgb, 0.0)) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0); //FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a); } \ No newline at end of file diff --git a/src/Shaders/ForwardRendering.frag.glsl b/src/Shaders/ForwardRendering.frag.glsl index 0d3a7c8..5dd2b2d 100644 --- a/src/Shaders/ForwardRendering.frag.glsl +++ b/src/Shaders/ForwardRendering.frag.glsl @@ -1,8 +1,23 @@ #version 430 uniform vec4 Color; +uniform vec3 La; +uniform vec3 directionToSun; +uniform mat4 V; layout(binding=0) uniform sampler2D texture0; +layout(binding=1) uniform sampler2D PositionTexture; +layout(binding=2) uniform sampler2D NormalsTexture; +layout(binding=3) uniform sampler2D SpecularTexture; + +const vec3 ks = vec3(1.0, 1.0, 1.0); +const vec3 kd = vec3(1.0, 1.0, 1.0); +const vec3 ka = vec3(1.0, 1.0, 1.0); +const float kshine = 1.0; +const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0); +const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0); +const vec3 SunPos = directionToSun*vec3(100); +const float specularExponent = 100; in VertexData { vec3 Position; @@ -12,9 +27,34 @@ in VertexData { out vec4 frag_Diffuse; +vec4 phong(vec3 position, vec3 normal, vec3 specular) +{ + + //Diffuse Sunlight + vec3 directionToLight = normalize(vec3(V * vec4(directionToSun, 0.0))); + float dotProdLight = dot(directionToLight, normal); + dotProdLight = max(dotProdLight, 0.0); + vec3 sId = kd * SunDiffuseLight * dotProdLight; + + //Specular Sunlight + vec3 surfaceToViewer = normalize(-position); + vec3 halfWay = normalize(surfaceToViewer + directionToLight); + float dotSpecular = max(dot(halfWay, normal), 0.0); + float specularFactorSun = pow(dotSpecular, specularExponent); + vec3 sIs = specular.r * SunSpecularLight * specularFactorSun; + + return vec4((sId), sIs.r); +} + void main() { - // Texture vec4 texel = texture(texture0, Input.TextureCoord); + vec4 PositionTexel = texture(PositionTexture, Input.TextureCoord); + vec4 NormalTexel = texture(NormalsTexture, Input.TextureCoord); + vec4 SpecularTexel = texture(SpecularTexture, Input.TextureCoord); + frag_Diffuse = texel * Color; + //frag_Diffuse = texel * Color * (vec4(La, 0.0) * phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel))); + //frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0))); + } \ No newline at end of file diff --git a/src/Shaders/Fragment2.glsl b/src/Shaders/Fragment2.glsl index 27dcb76..6be4778 100644 --- a/src/Shaders/Fragment2.glsl +++ b/src/Shaders/Fragment2.glsl @@ -24,6 +24,7 @@ const vec3 ks = vec3(1.0, 1.0, 1.0); const vec3 kd = vec3(1.0, 1.0, 1.0); const vec3 ka = vec3(1.0, 1.0, 1.0); const float kshine = 1.0; +const vec3 La = vec3(0.3, 0.3, 0.3); in VertexData @@ -32,7 +33,7 @@ in VertexData vec2 TextureCoord; } Input; -out vec4 FragColor; +out vec4 frag_Light; vec4 phong(vec3 position, vec3 normal, vec3 specular) { @@ -67,6 +68,8 @@ void main() vec4 NormalTexel = texture(NormalsTexture, TextureCoord); vec4 SpecularTexel = texture(SpecularTexture, TextureCoord); - FragColor = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel)); + frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel)); + //FragColor = DiffuseTexel * vec4(1.0/La, 0.0) * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0)); + //FragColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0)) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0); //FragColor = NormalTexel; } \ No newline at end of file diff --git a/src/Shaders/SunPass.frag.glsl b/src/Shaders/SunPass.frag.glsl index 6f80c40..3604e1f 100644 --- a/src/Shaders/SunPass.frag.glsl +++ b/src/Shaders/SunPass.frag.glsl @@ -4,6 +4,7 @@ layout (binding=0) uniform sampler2D PositionTexture; layout (binding=1) uniform sampler2D NormalsTexture; layout (binding=2) uniform sampler2D SpecularTexture; + uniform vec2 ViewportSize; uniform mat4 MVP; uniform mat4 M; @@ -16,10 +17,12 @@ const vec3 ks = vec3(1.0, 1.0, 1.0); const vec3 kd = vec3(1.0, 1.0, 1.0); const vec3 ka = vec3(1.0, 1.0, 1.0); const float kshine = 1.0; -const vec3 SunDiffuseLight = vec3(0.3, 0.3, 0.3); +const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0); const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0); const vec3 SunPos = directionToSun*vec3(100); -const float specularExponent = 5; +const float specularExponent = 100; +const vec3 La = vec3(0.3, 0.3, 0.3); + in VertexData @@ -28,7 +31,7 @@ in VertexData vec2 TextureCoord; } Input; -out vec4 FragColor; +out vec4 frag_Light; vec4 phong(vec3 position, vec3 normal, vec3 specular) { @@ -46,7 +49,7 @@ vec4 phong(vec3 position, vec3 normal, vec3 specular) float specularFactorSun = pow(dotSpecular, specularExponent); vec3 sIs = specular.r * SunSpecularLight * specularFactorSun; - return vec4((sId), sIs.r); + return vec4((sId + La), sIs.r); } void main() @@ -56,6 +59,8 @@ void main() vec4 NormalTexel = texture(NormalsTexture, TextureCoord); vec4 SpecularTexel = texture(SpecularTexture, TextureCoord); - FragColor = phong(vec3(PositionTexel), vec3(normalize(NormalTexel)), vec3(SpecularTexel)); + + frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel)); + //FragColor = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0))); //FragColor = NormalTexel; } \ No newline at end of file diff --git a/src/Systems/ParticleSystem.cpp b/src/Systems/ParticleSystem.cpp index 45c3646..e9e6c56 100644 --- a/src/Systems/ParticleSystem.cpp +++ b/src/Systems/ParticleSystem.cpp @@ -49,11 +49,15 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID { emitterComponent->TimeSinceLastSpawn += dt; auto emitterTransformComponent = m_World->GetComponent(entity); -// if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency) -// { -// SpawnParticles(entity); -// emitterComponent->TimeSinceLastSpawn = 0; -// } + if(emitterComponent->Emitting) + { + if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency) + { + SpawnParticles(entity); + emitterComponent->TimeSinceLastSpawn = 0; + } + } + } auto particleComponent = m_World->GetComponent(entity); @@ -242,10 +246,17 @@ bool Systems::ParticleSystem::CreateExplosion(const Events::CreateExplosion &e) emitter->SpawnCount = e.ParticlesToSpawn; emitter->Speed = e.Speed; emitter->SpreadAngle = e.SpreadAngle; + emitter->Emitting = e.Emitting; + emitter->SpawnFrequency = e.SpawnFrequency; //emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale)); emitter->SpawnFrequency = e.LifeTime + 20; //temp emitter->Fade = true; emitter->Color = e.Color; + if(e.UseGoalVector) + { + emitter->UseGoalVelocity = e.UseGoalVector; + emitter->GoalVelocity = e.GoalVelocity; + } std::vector scale; scale.push_back(glm::vec3(e.ParticleScale[0])); if(e.ParticleScale.size() >= 2) diff --git a/src/Systems/SoundSystem.cpp b/src/Systems/SoundSystem.cpp index 5dd446b..1617078 100755 --- a/src/Systems/SoundSystem.cpp +++ b/src/Systems/SoundSystem.cpp @@ -11,7 +11,7 @@ void Systems::SoundSystem::Initialize() m_TransformSystem = m_World->GetSystem(); FMOD_System_Create(&m_System); - FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED, 0); + FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_ENABLE_PROFILE, 0); if(result != FMOD_OK) { LOG_ERROR("Did initialized load FMOD correctly"); @@ -59,16 +59,20 @@ void Systems::SoundSystem::Update(double dt) } //LOG_INFO("Antal emitters i listan: %i", m_Channels.size()); - for (auto channel : m_Channels) + + for(it = m_Channels.begin(); it != m_Channels.end();) { FMOD_BOOL isPlaying = false; - FMOD_Channel_IsPlaying(channel.second, &isPlaying); + FMOD_Channel_IsPlaying(it->second, &isPlaying); if(!isPlaying) { - m_Channels.erase(channel.first); + it = m_Channels.erase(it); + } + else + { + it++; } } - } void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent) diff --git a/src/Systems/TankSteeringSystem.cpp b/src/Systems/TankSteeringSystem.cpp index f1c9caa..d886550 100644 --- a/src/Systems/TankSteeringSystem.cpp +++ b/src/Systems/TankSteeringSystem.cpp @@ -102,12 +102,14 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit e.LifeTime = 1.5; e.ParticleScale.push_back(0.6); e.ParticleScale.push_back(1.8); - e.ParticlesToSpawn = 5; + e.ParticlesToSpawn = 1; e.Position = cloneTransform->Position; e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); e.Speed = 1.7; - e.SpreadAngle = glm::pi()/10; + e.SpreadAngle = glm::pi()/100; e.spritePath = "Textures/Sprites/Smoke1.png"; + e.Emitting = true; + e.SpawnFrequency = 0.2; e.Color = glm::vec4(0.6,0.6,0.6,1); EventBroker->Publish(e); } @@ -192,36 +194,65 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e) //auto otherTransform = m_World->GetComponent(otherEntity); { +// Events::CreateExplosion e; +// e.LifeTime = 3; +// e.ParticleScale.push_back(8); +// e.ParticlesToSpawn = 20; +// e.Position = shellTransform->Position; +// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); +// e.Speed = 3; +// e.SpreadAngle = glm::pi(); +// e.spritePath = "Textures/Sprites/Smoke1.png"; +// e.Color = glm::vec4(0.6,0.6,0.6,1); +// EventBroker->Publish(e); +// e.LifeTime = 0.7; +// e.ParticleScale.push_back(12); +// e.ParticlesToSpawn = 10; +// e.Position = shellTransform->Position; +// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); +// e.Speed = 17; +// e.SpreadAngle = glm::pi(); +// e.spritePath = "Textures/Sprites/Fire.png"; +// EventBroker->Publish(e); +// e.LifeTime = 0.2; +// e.ParticleScale.push_back(1); +// e.ParticleScale.push_back(15); +// e.ParticlesToSpawn = 5; +// e.Position = shellTransform->Position; +// e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); +// e.Speed = 6; +// e.SpreadAngle = glm::pi(); +// e.spritePath = "Textures/Sprites/Blast1.png"; +// e.Color = glm::vec4(2, 2, 2, 0.2); +// EventBroker->Publish(e); + Events::CreateExplosion e; - e.LifeTime = 3; - e.ParticleScale.push_back(8); + e.LifeTime = 1.5; + e.ParticleScale.push_back(1); + e.ParticleScale.push_back(6); e.ParticlesToSpawn = 20; e.Position = shellTransform->Position; - e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); - e.Speed = 3; - e.SpreadAngle = glm::pi(); - e.spritePath = "Textures/Sprites/Smoke1.png"; - e.Color = glm::vec4(0.6,0.6,0.6,1); + e.SpreadAngle = glm::radians(180) / 4; + e.RelativeUpOrientation = glm::angleAxis(glm::radians(90), glm::vec3(1,0,0)); + e.UseGoalVector = true; + e.GoalVelocity = glm::vec3(0,-12,0); + e.Speed = 12; + e.spritePath = "Textures/Sprites/Splash.png"; + e.Color = glm::vec4(5.f,5.f,5.f,1); + EventBroker->Publish(e); - e.LifeTime = 0.7; - e.ParticleScale.push_back(12); - e.ParticlesToSpawn = 10; - e.Position = shellTransform->Position; - e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); - e.Speed = 17; - e.SpreadAngle = glm::pi(); - e.spritePath = "Textures/Sprites/Fire.png"; - EventBroker->Publish(e); - e.LifeTime = 0.2; + e.LifeTime = 1.5; e.ParticleScale.push_back(1); - e.ParticleScale.push_back(15); - e.ParticlesToSpawn = 5; + e.ParticleScale.push_back(6); + e.ParticlesToSpawn = 20; e.Position = shellTransform->Position; - e.RelativeUpOrientation = glm::angleAxis(glm::pi() / 2, glm::vec3(1,0,0)); - e.Speed = 6; - e.SpreadAngle = glm::pi(); - e.spritePath = "Textures/Sprites/Blast1.png"; - e.Color = glm::vec4(2, 2, 2, 0.2); + e.SpreadAngle = glm::radians(180)/ 4; + e.RelativeUpOrientation = glm::angleAxis(glm::radians(90), glm::vec3(1,0,0)); + e.UseGoalVector = true; + e.GoalVelocity = glm::vec3(0,-12,0); + e.Speed = 12; + e.spritePath = "Textures/Sprites/Splash.png"; + e.Color = glm::vec4(1.f,1.f,1.f,1); EventBroker->Publish(e); } {