From a3f215831d9441314af462238c7ad72c6258b78c Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 14 Mar 2016 06:09:06 +0100 Subject: [PATCH] Fixed DDS after merge --- assets | 2 +- include/Engine/Rendering/Texture.h | 2 +- .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 2 +- ...ForwardPlusSplatMapRGBShieldCheck.frag.glsl | 2 +- resources/Shaders/Util/CommonNormalFunc.glsl | Bin 813 -> 814 bytes src/Engine/Rendering/CubeMapPass.cpp | 17 ++++++++++++----- src/Engine/Rendering/DrawFinalPass.cpp | 4 ++++ src/Engine/Rendering/Texture.cpp | 6 +++--- 8 files changed, 23 insertions(+), 12 deletions(-) diff --git a/assets b/assets index 1944662a..a4e3b0b6 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1944662a1ca7db56610bb3215fe1ea6e15285fe1 +Subproject commit a4e3b0b60aa615cf0de9b63456e4687cb65a81c5 diff --git a/include/Engine/Rendering/Texture.h b/include/Engine/Rendering/Texture.h index 78f3cfc2..4053e8da 100644 --- a/include/Engine/Rendering/Texture.h +++ b/include/Engine/Rendering/Texture.h @@ -21,7 +21,7 @@ public: GLuint m_Texture = 0; - enum TextureType : GLint { Invalid = 0, DDS = 1, PNG = 2}; + enum TextureType : GLint { cInvalid = 0, cDDS = 1, cPNG = 2}; TextureType m_Type; }; diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index 1a865a01..7b1d9e08 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -187,7 +187,7 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, } vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, - vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues + vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, int R_TextureType, int G_TextureType, int B_TextureType) { mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal); vec3 R_Channel = NormalMapValue(Input.TextureCoordinate * R_TileValues, R, R_TextureType); diff --git a/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl index eefadb81..e18bf0ad 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl @@ -166,7 +166,7 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, } vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, - vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues + vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, int R_TextureType, int G_TextureType, int B_TextureType) { mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal); vec3 R_Channel = NormalMapValue(Input.TextureCoordinate * R_TileValues, R, R_TextureType); diff --git a/resources/Shaders/Util/CommonNormalFunc.glsl b/resources/Shaders/Util/CommonNormalFunc.glsl index aa748acc2abd29e7ad85072789ca052460876be4..ea6cc3f1a7174a5c584c560ae44cc801956e416c 100644 GIT binary patch delta 9 QcmZ3>wvKIsE;Azo01smVNdN!< delta 7 OcmZ3-ww7&!E;9fM(*j5U diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index 8d133579..c567789b 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -11,7 +11,7 @@ void CubeMapPass::LoadTextures(std::string cubemapName) if (m_PreviusCubeMapTexture != cubemapName) { m_CubeMapTextures.clear(); for (int i = 0; i < 6; i++) { - std::string path = "Textures/Test/CubeMap/" + cubemapName + "/CubeMapTest0" + std::to_string(i) + ".png"; + std::string path = "Textures/Test/CubeMap/" + cubemapName + "/CubeMapTest0" + std::to_string(i) + ".dds"; m_CubeMapTextures.push_back(path); } GenerateCubeMapTexture(); @@ -21,15 +21,22 @@ void CubeMapPass::LoadTextures(std::string cubemapName) void CubeMapPass::GenerateCubeMapTexture() { - if (m_CubeMapTexture == -1) { + if (m_CubeMapTexture == 0) { glGenTextures(1, &m_CubeMapTexture); } glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - PNG* img = ResourceManager::Load(m_CubeMapTextures[i]); - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, img->Width, img->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->Data); - ResourceManager::Release("PNG", m_CubeMapTextures[i]); + DDS* img = ResourceManager::Load(m_CubeMapTextures[i]); + std::size_t bpe = 16; + std::size_t numBlocksWide = std::max(1, (img->Width + 3) / 4); + std::size_t numBlocksHigh = std::max(1, (img->Height + 3) / 4); + std::size_t rowBytes = numBlocksWide * bpe; + std::size_t numRows = numBlocksHigh; + std::size_t numBytes = rowBytes * numBlocksHigh; + glCompressedTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, img->Width, img->Height, 0, numBytes, img->Data); + //glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, img->Width, img->Height, 0, GL_COMPRESSED_RGBA, GL_UNSIGNED_BYTE, img->Data); + ResourceManager::Release("DDS", m_CubeMapTextures[i]); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 8c6f7885..9a771b42 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1537,10 +1537,12 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrNormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat)); + glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), job->NormalTexture[0]->Texture->m_Type); } else { glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), m_NeutralNormalTexture->m_Type); } glActiveTexture(GL_TEXTURE3); @@ -1593,10 +1595,12 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrNormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->NormalTexture[i]->UVRepeat)); + glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), job->NormalTexture[0]->Texture->m_Type); } else { glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + glUniform1i(glGetUniformLocation(shaderHandle, "NormalTextureType"), m_NeutralNormalTexture->m_Type); } texturePosition++; } diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index 8e072582..3d2de0db 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -6,12 +6,12 @@ Texture::Texture(std::string path) Image* img; if (ext == ".png") { img = ResourceManager::Load(path); - m_Type = TextureType::PNG; + m_Type = TextureType::cPNG; } else if (ext == ".dds") { img = ResourceManager::Load(path); - m_Type = TextureType::DDS; + m_Type = TextureType::cDDS; } else { - m_Type = TextureType::Invalid; + m_Type = TextureType::cInvalid; throw Resource::FailedLoadingException("Texture extension is not .png nor .dds"); }