Ver código fonte

egg: Add limited forward compatibility for ORM textures

Mainly intended to be able to passthrough 1.11 egg files safely
rdb 2 dias atrás
pai
commit
975a9fb484

+ 1 - 0
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 linecache error when distributing for newer Python versions
 * Fix `await AsyncFuture.gather()` returning first item instead of tuple (#1738)
 * Fix `await AsyncFuture.gather()` returning first item instead of tuple (#1738)
 * Fix use-after-free in collision system with transform cache disabled (#1733)
 * 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 error blitting depth texture on macOS (#1719)
 * OpenGL: fix SSBO support not being detected in certain situations
 * OpenGL: fix SSBO support not being detected in certain situations
 * X11: Add config variable to enable detection of autorepeat key events (#1735)
 * X11: Add config variable to enable detection of autorepeat key events (#1735)

+ 23 - 0
panda/src/egg/eggTexture.cxx

@@ -564,6 +564,11 @@ affects_polygon_alpha() const {
   case ET_selector:
   case ET_selector:
     return true;
     return true;
 
 
+  case ET___occlusion:
+  case ET___occlusion_metallic_roughness:
+  case ET___metallic_roughness:
+    return false;
+
   case ET_unspecified:
   case ET_unspecified:
     break;
     break;
   }
   }
@@ -886,6 +891,15 @@ string_env_type(const string &string) {
   } else if (cmp_nocase_uh(string, "emission") == 0) {
   } else if (cmp_nocase_uh(string, "emission") == 0) {
     return ET_emission;
     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 {
   } else {
     return ET_unspecified;
     return ET_unspecified;
   }
   }
@@ -1319,6 +1333,15 @@ ostream &operator << (ostream &out, EggTexture::EnvType type) {
 
 
   case EggTexture::ET_emission:
   case EggTexture::ET_emission:
     return out << "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);
   nassertr(false, out);

+ 5 - 0
panda/src/egg/eggTexture.h

@@ -108,6 +108,11 @@ PUBLISHED:
     ET_selector,
     ET_selector,
     ET_normal_gloss,
     ET_normal_gloss,
     ET_emission,
     ET_emission,
+
+    // Forward compatibility with Panda 1.11
+    ET___occlusion,
+    ET___occlusion_metallic_roughness,
+    ET___metallic_roughness,
   };
   };
   enum CombineMode {
   enum CombineMode {
     CM_unspecified,
     CM_unspecified,

+ 6 - 0
panda/src/egg2pg/eggLoader.cxx

@@ -876,6 +876,10 @@ load_textures() {
  */
  */
 bool EggLoader::
 bool EggLoader::
 load_texture(TextureDef &def, EggTexture *egg_tex) {
 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.
   // Check to see if we should reduce the number of channels in the texture.
   int wanted_channels = 0;
   int wanted_channels = 0;
   bool wanted_alpha = false;
   bool wanted_alpha = false;
@@ -1533,6 +1537,8 @@ make_texture_stage(const EggTexture *egg_tex) {
     break;
     break;
 
 
   case EggTexture::ET_selector:
   case EggTexture::ET_selector:
+  case EggTexture::ET___metallic_roughness:
+  case EggTexture::ET___occlusion_metallic_roughness:
     stage->set_mode(TextureStage::M_selector);
     stage->set_mode(TextureStage::M_selector);
     break;
     break;