Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a filter with mipmaps when initializing textures with mipmaps in GL Compatibility renderer #78720

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions drivers/gles3/storage/texture_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,10 +1249,6 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image,
glActiveTexture(GL_TEXTURE0);
glBindTexture(texture->target, texture->tex_id);

// set filtering and repeat state to default
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);

#ifndef WEB_ENABLED
switch (texture->format) {
#ifdef GLES_OVER_GL
Expand Down Expand Up @@ -1294,6 +1290,15 @@ void TextureStorage::_texture_set_data(RID p_texture, const Ref<Image> &p_image,

int mipmaps = img->has_mipmaps() ? img->get_mipmap_count() + 1 : 1;

// Set filtering and repeat state to default.
if (mipmaps > 1) {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST_WITH_MIPMAPS);
} else {
texture->gl_set_filter(RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST);
}

texture->gl_set_repeat(RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED);

int w = img->get_width();
int h = img->get_height();

Expand Down