egg: Add limited forward compatibility for ORM textures

Mainly intended to be able to passthrough 1.11 egg files safely
This commit is contained in:
rdb 2025-12-22 12:41:34 +01:00
parent e319be1fcb
commit 975a9fb484
4 changed files with 35 additions and 0 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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,

View File

@ -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;