From 975a9fb484f56db32ba13ca4770939cee0388fd2 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 22 Dec 2025 12:41:34 +0100 Subject: [PATCH] egg: Add limited forward compatibility for ORM textures Mainly intended to be able to passthrough 1.11 egg files safely --- doc/ReleaseNotes | 1 + panda/src/egg/eggTexture.cxx | 23 +++++++++++++++++++++++ panda/src/egg/eggTexture.h | 5 +++++ panda/src/egg2pg/eggLoader.cxx | 6 ++++++ 4 files changed, 35 insertions(+) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 6374795a59..a9322f8518 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -10,6 +10,7 @@ This maintenance release fixes some minor defects and stability issues. * Fix linecache error when distributing for newer Python versions * Fix `await AsyncFuture.gather()` returning first item instead of tuple (#1738) * Fix use-after-free in collision system with transform cache disabled (#1733) +* Egg: Add limited forward compatibility for metallic-roughness textures * OpenGL: fix error blitting depth texture on macOS (#1719) * OpenGL: fix SSBO support not being detected in certain situations * X11: Add config variable to enable detection of autorepeat key events (#1735) diff --git a/panda/src/egg/eggTexture.cxx b/panda/src/egg/eggTexture.cxx index 899438276e..4fb9ba1c3e 100644 --- a/panda/src/egg/eggTexture.cxx +++ b/panda/src/egg/eggTexture.cxx @@ -564,6 +564,11 @@ affects_polygon_alpha() const { case ET_selector: return true; + case ET___occlusion: + case ET___occlusion_metallic_roughness: + case ET___metallic_roughness: + return false; + case ET_unspecified: break; } @@ -886,6 +891,15 @@ string_env_type(const string &string) { } else if (cmp_nocase_uh(string, "emission") == 0) { return ET_emission; + } else if (cmp_nocase_uh(string, "occlusion") == 0) { + return ET___occlusion; + + } else if (cmp_nocase_uh(string, "occlusion_metallic_roughness") == 0) { + return ET___occlusion_metallic_roughness; + + } else if (cmp_nocase_uh(string, "metallic_roughness") == 0) { + return ET___metallic_roughness; + } else { return ET_unspecified; } @@ -1319,6 +1333,15 @@ ostream &operator << (ostream &out, EggTexture::EnvType type) { case EggTexture::ET_emission: return out << "emission"; + + case EggTexture::ET___occlusion: + return out << "occlusion"; + + case EggTexture::ET___occlusion_metallic_roughness: + return out << "occlusion_metallic_roughness"; + + case EggTexture::ET___metallic_roughness: + return out << "metallic_roughness"; } nassertr(false, out); diff --git a/panda/src/egg/eggTexture.h b/panda/src/egg/eggTexture.h index 5d602e26f8..6e1b7017fb 100644 --- a/panda/src/egg/eggTexture.h +++ b/panda/src/egg/eggTexture.h @@ -108,6 +108,11 @@ PUBLISHED: ET_selector, ET_normal_gloss, ET_emission, + + // Forward compatibility with Panda 1.11 + ET___occlusion, + ET___occlusion_metallic_roughness, + ET___metallic_roughness, }; enum CombineMode { CM_unspecified, diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index b1beac16d9..c0d9a7fa55 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -876,6 +876,10 @@ load_textures() { */ bool EggLoader:: load_texture(TextureDef &def, EggTexture *egg_tex) { + if (egg_tex->get_env_type() == EggTexture::ET___occlusion) { + return false; + } + // Check to see if we should reduce the number of channels in the texture. int wanted_channels = 0; bool wanted_alpha = false; @@ -1533,6 +1537,8 @@ make_texture_stage(const EggTexture *egg_tex) { break; case EggTexture::ET_selector: + case EggTexture::ET___metallic_roughness: + case EggTexture::ET___occlusion_metallic_roughness: stage->set_mode(TextureStage::M_selector); break;