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

Print a warning when importing a repeating NPOT texture in a GLES2 project #48817

Merged
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
15 changes: 15 additions & 0 deletions editor/import/resource_importer_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,21 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
int tex_flags = 0;
if (repeat > 0) {
tex_flags |= Texture::FLAG_REPEAT;

const bool min_gles3 = GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3" &&
!GLOBAL_GET("rendering/quality/driver/fallback_to_gles2");
if (!min_gles3 && !image->is_size_po2()) {
// The project can be run using GLES2. GLES2 does not guarantee that
// repeating textures with a non-power-of-two size will be displayed
// without artifacts (due to upscaling to the nearest power of 2).
if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) {
WARN_PRINT(vformat("%s: Imported a repeating texture with a size of %dx%d, but the project is configured to allow falling back to GLES2.\nNon-power-of-2 repeating textures may not display correctly on some platforms such as HTML5. This is because GLES2 does not mandate support for non-power-of-2 repeating textures.",
p_source_file, image->get_width(), image->get_height()));
} else {
WARN_PRINT(vformat("%s: Imported a repeating texture with a size of %dx%d, but the project is configured to use GLES2.\nNon-power-of-2 repeating textures may not display correctly on some platforms such as HTML5. This is because GLES2 does not mandate support for non-power-of-2 repeating textures.",
p_source_file, image->get_width(), image->get_height()));
}
}
}
if (repeat == 2) {
tex_flags |= Texture::FLAG_MIRRORED_REPEAT;
Expand Down