From 783dff41b6a3f88e53f18b65c2e3ccceb8098d5c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 31 May 2020 23:08:56 +0200 Subject: [PATCH] - fixed clamp mode setup. --- source/common/textures/hw_material.cpp | 9 +++++---- source/glbackend/gl_texture.cpp | 14 +++++--------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/common/textures/hw_material.cpp b/source/common/textures/hw_material.cpp index 8df0b6298..c4a1ba9d3 100644 --- a/source/common/textures/hw_material.cpp +++ b/source/common/textures/hw_material.cpp @@ -40,7 +40,7 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags) mShaderIndex = SHADER_Default; sourcetex = tx; auto imgtex = tx->GetTexture(); - mTextureLayers.Push({ imgtex, scaleflags }); + mTextureLayers.Push({ imgtex, scaleflags, -1 }); if (tx->GetUseType() == ETextureType::SWCanvas && static_cast(imgtex)->GetColorFormat() == 0) { @@ -52,7 +52,8 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags) { mShaderIndex = tx->GetShaderIndex(); } - // no brightmap for cameratexture + mTextureLayers.Last().clampflags = CLAMP_CAMTEX; + // no additional layers for cameratexture } else { @@ -65,7 +66,7 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags) { for (auto &texture : { tx->Normal.get(), tx->Specular.get() }) { - mTextureLayers.Push({ texture, 0 }); + mTextureLayers.Push({ texture, 0, -1 }); } mShaderIndex = SHADER_Specular; } @@ -73,7 +74,7 @@ FMaterial::FMaterial(FGameTexture * tx, int scaleflags) { for (auto &texture : { tx->Normal.get(), tx->Metallic.get(), tx->Roughness.get(), tx->AmbientOcclusion.get() }) { - mTextureLayers.Push({ texture, 0 }); + mTextureLayers.Push({ texture, 0, -1 }); } mShaderIndex = SHADER_PBR; } diff --git a/source/glbackend/gl_texture.cpp b/source/glbackend/gl_texture.cpp index a54ae4e05..cc4b7b7b8 100644 --- a/source/glbackend/gl_texture.cpp +++ b/source/glbackend/gl_texture.cpp @@ -67,15 +67,11 @@ bool GLInstance::SetTexture(int picnum, FGameTexture* tex, int paletteid, int me if (!PickTexture(picnum, tex, paletteid, texpick)) return false; int TextureType = (texpick.translation & 0x80000000) ? TT_INDEXED : TT_TRUECOLOR; - auto sampler = (method & DAMETH_CLAMPED) ? (sampleroverride != -1 ? sampleroverride : SamplerClampXY) : SamplerRepeat; - if (TextureType == TT_INDEXED) - { - sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat; - } - else if (tex->isHardwareCanvas()) - { - sampler = CLAMP_CAMTEX; - } + auto sampler = (method & DAMETH_CLAMPED) ? (sampleroverride != -1 ? sampleroverride : SamplerClampXY) : SamplerRepeat; + if (TextureType == TT_INDEXED) + { + sampler = sampler + SamplerNoFilterRepeat - SamplerRepeat; + } // This is intentionally the same value for both parameters. The shader does not use the same uniform for modulation and overlay colors.