Allow nearest neighbor lookup when using mipmaps

This commit is contained in:
clayjohn 2020-07-19 14:44:42 -07:00
parent 89f57ae122
commit e5cc4d4f87
2 changed files with 20 additions and 4 deletions

View file

@ -711,7 +711,11 @@ void RasterizerStorageGLES2::texture_set_data(RID p_texture, const Ref<Image> &p
texture->ignore_mipmaps = compressed && !img->has_mipmaps(); texture->ignore_mipmaps = compressed && !img->has_mipmaps();
if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_LINEAR);
}
else { else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) { if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -957,7 +961,11 @@ void RasterizerStorageGLES2::texture_set_flags(RID p_texture, uint32_t p_flags)
if (!had_mipmaps && texture->mipmaps == 1) { if (!had_mipmaps && texture->mipmaps == 1) {
glGenerateMipmap(texture->target); glGenerateMipmap(texture->target);
} }
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_LINEAR);
}
} else { } else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) { if (texture->flags & VS::TEXTURE_FLAG_FILTER) {

View file

@ -841,7 +841,11 @@ void RasterizerStorageGLES3::texture_set_data(RID p_texture, const Ref<Image> &p
texture->ignore_mipmaps = compressed && !img->has_mipmaps(); texture->ignore_mipmaps = compressed && !img->has_mipmaps();
if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps) if ((texture->flags & VS::TEXTURE_FLAG_MIPMAPS) && !texture->ignore_mipmaps)
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_LINEAR);
}
else { else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) { if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -1420,7 +1424,11 @@ void RasterizerStorageGLES3::texture_set_flags(RID p_texture, uint32_t p_flags)
if (!had_mipmaps && texture->mipmaps == 1) { if (!had_mipmaps && texture->mipmaps == 1) {
glGenerateMipmap(texture->target); glGenerateMipmap(texture->target);
} }
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR); if (texture->flags & VS::TEXTURE_FLAG_FILTER) {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR);
} else {
glTexParameteri(texture->target, GL_TEXTURE_MIN_FILTER, config.use_fast_texture_filter ? GL_NEAREST_MIPMAP_NEAREST : GL_NEAREST_MIPMAP_LINEAR);
}
} else { } else {
if (texture->flags & VS::TEXTURE_FLAG_FILTER) { if (texture->flags & VS::TEXTURE_FLAG_FILTER) {