From feeff5b164a86f88346046b2d84ac45af15b867b Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:47:47 +0100 Subject: [PATCH] Debug tool for different CubeMap changed cubemap influence. --- include/Engine/Rendering/CubeMapPass.h | 2 +- include/Engine/Rendering/Renderer.h | 1 + resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/CubeMapPass.cpp | 6 ++++-- src/Engine/Rendering/Renderer.cpp | 6 ++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 0840e2c8..3cda8cad 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -15,7 +15,7 @@ public: void GenerateCubeMapTexture(); //GLuint CubeMapTexture() const { return m_CubeMapTexture; } - GLuint m_CubeMapTexture; + GLuint m_CubeMapTexture = -1; private: IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 720336aa..f3a6bf31 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -59,6 +59,7 @@ private: Model* m_UnitSphere; int m_DebugTextureToDraw = 0; + int m_CubeMapTexture = 0; bool m_ResizeWindow = false; float m_SSAO_Radius = 1.0f; float m_SSAO_Bias = 0.05f; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index cddd6d6b..6fbc9c27 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -170,7 +170,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index b64b77f1..75f5e1c9 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -4,7 +4,6 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) :m_Renderer(renderer) { LoadTextures("Nevada"); - GenerateCubeMapTexture(); } void CubeMapPass::LoadTextures(std::string input) @@ -17,12 +16,15 @@ void CubeMapPass::LoadTextures(std::string input) Texture* img = ResourceManager::Load(str); m_CubeMapTextures.push_back(img); } + GenerateCubeMapTexture(); } } void CubeMapPass::GenerateCubeMapTexture() { - glGenTextures(1, &m_CubeMapTexture); + if (m_CubeMapTexture == -1) { + glGenTextures(1, &m_CubeMapTexture); + } glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 8391599c..a3a53591 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -108,6 +108,12 @@ void Renderer::Draw(RenderFrame& frame) { GLERROR("PRE"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); + ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); + if(m_CubeMapTexture == 0) { + m_CubeMapPass->LoadTextures("Nevada"); + } else if (m_CubeMapTexture == 1) { + m_CubeMapPass->LoadTextures("Sky"); + } ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f);