浏览代码

pgraphnodes: Support missing texture types in shader generator:

- Cube arrays
- 1D texture arrays
- Buffer textures

Not to say that they are displayed meaningfully, but better than a cryptic error message.
rdb 2 年之前
父节点
当前提交
a20996d2aa
共有 1 个文件被更改,包括 37 次插入18 次删除
  1. 37 18
      panda/src/pgraphnodes/shaderGenerator.cxx

+ 37 - 18
panda/src/pgraphnodes/shaderGenerator.cxx

@@ -1293,15 +1293,20 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
     text << "\t float4 tex" << i << " = tex" << texture_type_as_string(tex._type);
     text << "(tex_" << i << ", texcoord" << i << ".";
     switch (tex._type) {
+    case Texture::TT_cube_map_array:
+      text << "xyzw";
+      break;
     case Texture::TT_cube_map:
     case Texture::TT_3d_texture:
     case Texture::TT_2d_texture_array:
       text << "xyz";
       break;
     case Texture::TT_2d_texture:
+    case Texture::TT_1d_texture_array:
       text << "xy";
       break;
     case Texture::TT_1d_texture:
+    case Texture::TT_buffer_texture:
       text << "x";
       break;
     default:
@@ -1342,15 +1347,20 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
       text << "\t float4 tex" << i << " = tex" << texture_type_as_string(tex._type);
       text << "(tex_" << i << ", texcoord" << i << ".";
       switch (tex._type) {
+      case Texture::TT_cube_map_array:
+        text << "xyzw";
+        break;
       case Texture::TT_cube_map:
       case Texture::TT_3d_texture:
       case Texture::TT_2d_texture_array:
         text << "xyz";
         break;
       case Texture::TT_2d_texture:
+      case Texture::TT_1d_texture_array:
         text << "xy";
         break;
       case Texture::TT_1d_texture:
+      case Texture::TT_buffer_texture:
         text << "x";
         break;
       default:
@@ -1970,24 +1980,33 @@ combine_source_as_string(const ShaderKey::TextureInfo &info, short num, bool alp
 const char *ShaderGenerator::
 texture_type_as_string(Texture::TextureType ttype) {
   switch (ttype) {
-    case Texture::TT_1d_texture:
-      return "1D";
-      break;
-    case Texture::TT_2d_texture:
-      return "2D";
-      break;
-    case Texture::TT_3d_texture:
-      return "3D";
-      break;
-    case Texture::TT_cube_map:
-      return "CUBE";
-      break;
-    case Texture::TT_2d_texture_array:
-      return "2DARRAY";
-      break;
-    default:
-      pgraphnodes_cat.error() << "Unsupported texture type!\n";
-      return "2D";
+  case Texture::TT_1d_texture:
+    return "1D";
+
+  case Texture::TT_2d_texture:
+    return "2D";
+
+  case Texture::TT_3d_texture:
+    return "3D";
+
+  case Texture::TT_2d_texture_array:
+    return "2DARRAY";
+
+  case Texture::TT_cube_map:
+    return "CUBE";
+
+  case Texture::TT_buffer_texture:
+    return "BUF";
+
+  case Texture::TT_cube_map_array:
+    return "CUBEARRAY";
+
+  case Texture::TT_1d_texture_array:
+    return "1DARRAY";
+
+  default:
+    pgraphnodes_cat.error() << "Unsupported texture type!\n";
+    return "2D";
   }
 }