mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Do not use textureLod for fetching normal textures. It kills anisotropic filtering:
https://www.opengl.org/wiki/Sampler_(GLSL) Also need to keep in mind issue #232 and not allow mip-mapping for combiners, which do not use it. Fixed anisotropic filtering not working #505
This commit is contained in:
parent
49efba0ce6
commit
7f9a3973eb
|
@ -453,14 +453,10 @@ static const char* fragment_shader_readtex =
|
||||||
SHADER_VERSION
|
SHADER_VERSION
|
||||||
#endif
|
#endif
|
||||||
"uniform lowp int uTextureFilterMode; \n"
|
"uniform lowp int uTextureFilterMode; \n"
|
||||||
"lowp vec4 filterNearest(in sampler2D tex, in mediump vec2 texCoord)\n"
|
|
||||||
"{ \n"
|
|
||||||
" return textureLod(tex, texCoord, 0.0); \n"
|
|
||||||
"} \n"
|
|
||||||
// 3 point texture filtering.
|
// 3 point texture filtering.
|
||||||
// Original author: ArthurCarvalho
|
// Original author: ArthurCarvalho
|
||||||
// GLSL implementation: twinaphex, mupen64plus-libretro project.
|
// GLSL implementation: twinaphex, mupen64plus-libretro project.
|
||||||
"#define TEX_OFFSET(off) textureLod(tex, texCoord - (off)/texSize, 0.0) \n"
|
"#define TEX_OFFSET(off) texture(tex, texCoord - (off)/texSize) \n"
|
||||||
"lowp vec4 filter3point(in sampler2D tex, in mediump vec2 texCoord) \n"
|
"lowp vec4 filter3point(in sampler2D tex, in mediump vec2 texCoord) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" mediump vec2 texSize = vec2(textureSize(tex,0)); \n"
|
" mediump vec2 texSize = vec2(textureSize(tex,0)); \n"
|
||||||
|
@ -473,7 +469,7 @@ SHADER_VERSION
|
||||||
"} \n"
|
"} \n"
|
||||||
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
"lowp vec4 readTex(in sampler2D tex, in mediump vec2 texCoord, in bool fb8bit, in bool fbFixedAlpha) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" lowp vec4 texColor = uTextureFilterMode == 0 ? filterNearest(tex, texCoord) : filter3point(tex, texCoord); \n"
|
" lowp vec4 texColor = uTextureFilterMode == 0 ? texture(tex, texCoord) : filter3point(tex, texCoord); \n"
|
||||||
" if (fb8bit) texColor = vec4(texColor.r); \n"
|
" if (fb8bit) texColor = vec4(texColor.r); \n"
|
||||||
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
" if (fbFixedAlpha) texColor.a = 0.825; \n"
|
||||||
" return texColor; \n"
|
" return texColor; \n"
|
||||||
|
|
|
@ -1086,24 +1086,26 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
|
const bool bUseBilinear = (gDP.otherMode.textureFilter | (gSP.objRendermode&G_OBJRM_BILERP)) != 0;
|
||||||
|
const bool bUseLOD = currentCombiner()->usesLOD();
|
||||||
|
const GLint texLevel = bUseLOD ? _pTexture->max_level : 0;
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, _pTexture->max_level);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, texLevel);
|
||||||
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
|
if (config.texture.bilinearMode == BILINEAR_STANDARD) {
|
||||||
if (bUseBilinear) {
|
if (bUseBilinear) {
|
||||||
if (_pTexture->max_level > 0)
|
if (texLevel > 0)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
else
|
else
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
} else {
|
} else {
|
||||||
if (_pTexture->max_level > 0)
|
if (texLevel > 0)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
else
|
else
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
} else { // 3 point filter
|
} else { // 3 point filter
|
||||||
if (_pTexture->max_level > 0) { // Apply standard bilinear to mipmap textures
|
if (texLevel > 0) { // Apply standard bilinear to mipmap textures
|
||||||
if (bUseBilinear) {
|
if (bUseBilinear) {
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
@ -1111,7 +1113,7 @@ void TextureCache::activateTexture(u32 _t, CachedTexture *_pTexture)
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
} else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && currentCombiner()->usesLOD()) { // Apply standard bilinear to first tile of mipmap texture
|
} else if (bUseBilinear && config.generalEmulation.enableLOD != 0 && bUseLOD) { // Apply standard bilinear to first tile of mipmap texture
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
} else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
|
} else { // Don't use texture filter. Texture will be filtered by 3 point filter shader
|
||||||
|
|
Loading…
Reference in New Issue
Block a user