Fixed DDS after merge
This commit is contained in:
+1
-1
Submodule assets updated: 1944662a1c...a4e3b0b60a
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Binary file not shown.
@@ -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<PNG>(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<DDS>(m_CubeMapTextures[i]);
|
||||
std::size_t bpe = 16;
|
||||
std::size_t numBlocksWide = std::max<std::size_t>(1, (img->Width + 3) / 4);
|
||||
std::size_t numBlocksHigh = std::max<std::size_t>(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);
|
||||
|
||||
@@ -1537,10 +1537,12 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
if (job->NormalTexture.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_ptr<E
|
||||
if (job->NormalTexture.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++;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ Texture::Texture(std::string path)
|
||||
Image* img;
|
||||
if (ext == ".png") {
|
||||
img = ResourceManager::Load<PNG, true>(path);
|
||||
m_Type = TextureType::PNG;
|
||||
m_Type = TextureType::cPNG;
|
||||
} else if (ext == ".dds") {
|
||||
img = ResourceManager::Load<DDS, true>(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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user