Browse Source

ShaderGenerator: big overhaul, don't generate more shaders than needed

rdb 8 years ago
parent
commit
f79fbf25c3
61 changed files with 765 additions and 1020 deletions
  1. 87 4
      panda/src/display/graphicsStateGuardian.cxx
  2. 6 5
      panda/src/display/standardMunger.cxx
  3. 8 0
      panda/src/gobj/material.I
  4. 2 2
      panda/src/gobj/material.h
  5. 109 8
      panda/src/gobj/shader.cxx
  6. 11 0
      panda/src/gobj/shader.h
  7. 0 16
      panda/src/pgraph/alphaTestAttrib.cxx
  8. 0 1
      panda/src/pgraph/alphaTestAttrib.h
  9. 0 8
      panda/src/pgraph/auxBitplaneAttrib.cxx
  10. 0 1
      panda/src/pgraph/auxBitplaneAttrib.h
  11. 0 8
      panda/src/pgraph/clipPlaneAttrib.cxx
  12. 0 1
      panda/src/pgraph/clipPlaneAttrib.h
  13. 0 13
      panda/src/pgraph/colorAttrib.cxx
  14. 0 1
      panda/src/pgraph/colorAttrib.h
  15. 0 8
      panda/src/pgraph/colorBlendAttrib.cxx
  16. 0 1
      panda/src/pgraph/colorBlendAttrib.h
  17. 0 11
      panda/src/pgraph/colorScaleAttrib.cxx
  18. 0 1
      panda/src/pgraph/colorScaleAttrib.h
  19. 7 3
      panda/src/pgraph/cullableObject.cxx
  20. 1 0
      panda/src/pgraph/cullableObject.h
  21. 0 8
      panda/src/pgraph/fogAttrib.cxx
  22. 0 1
      panda/src/pgraph/fogAttrib.h
  23. 0 8
      panda/src/pgraph/lightAttrib.cxx
  24. 0 1
      panda/src/pgraph/lightAttrib.h
  25. 0 8
      panda/src/pgraph/lightRampAttrib.cxx
  26. 0 1
      panda/src/pgraph/lightRampAttrib.h
  27. 0 8
      panda/src/pgraph/logicOpAttrib.cxx
  28. 0 1
      panda/src/pgraph/logicOpAttrib.h
  29. 2 10
      panda/src/pgraph/materialAttrib.I
  30. 3 54
      panda/src/pgraph/materialAttrib.cxx
  31. 0 5
      panda/src/pgraph/materialAttrib.h
  32. 0 19
      panda/src/pgraph/renderAttrib.I
  33. 0 8
      panda/src/pgraph/renderAttrib.cxx
  34. 0 2
      panda/src/pgraph/renderAttrib.h
  35. 0 84
      panda/src/pgraph/renderState.cxx
  36. 0 6
      panda/src/pgraph/renderState.h
  37. 0 16
      panda/src/pgraph/rescaleNormalAttrib.cxx
  38. 0 1
      panda/src/pgraph/rescaleNormalAttrib.h
  39. 0 20
      panda/src/pgraph/shaderAttrib.cxx
  40. 0 1
      panda/src/pgraph/shaderAttrib.h
  41. 0 8
      panda/src/pgraph/texGenAttrib.cxx
  42. 0 1
      panda/src/pgraph/texGenAttrib.h
  43. 0 22
      panda/src/pgraph/texMatrixAttrib.cxx
  44. 0 1
      panda/src/pgraph/texMatrixAttrib.h
  45. 1 41
      panda/src/pgraph/textureAttrib.I
  46. 2 78
      panda/src/pgraph/textureAttrib.cxx
  47. 0 9
      panda/src/pgraph/textureAttrib.h
  48. 0 15
      panda/src/pgraph/transparencyAttrib.cxx
  49. 0 1
      panda/src/pgraph/transparencyAttrib.h
  50. 1 4
      panda/src/pgraphnodes/directionalLight.cxx
  51. 0 2
      panda/src/pgraphnodes/directionalLight.h
  52. 9 0
      panda/src/pgraphnodes/lightLensNode.I
  53. 2 0
      panda/src/pgraphnodes/lightLensNode.cxx
  54. 3 0
      panda/src/pgraphnodes/lightLensNode.h
  55. 1 4
      panda/src/pgraphnodes/pointLight.cxx
  56. 0 2
      panda/src/pgraphnodes/pointLight.h
  57. 436 413
      panda/src/pgraphnodes/shaderGenerator.cxx
  58. 72 58
      panda/src/pgraphnodes/shaderGenerator.h
  59. 1 4
      panda/src/pgraphnodes/spotlight.cxx
  60. 0 2
      panda/src/pgraphnodes/spotlight.h
  61. 1 1
      panda/src/pstatclient/pStatProperties.cxx

+ 87 - 4
panda/src/display/graphicsStateGuardian.cxx

@@ -44,6 +44,7 @@
 #include "ambientLight.h"
 #include "ambientLight.h"
 #include "directionalLight.h"
 #include "directionalLight.h"
 #include "pointLight.h"
 #include "pointLight.h"
+#include "sphereLight.h"
 #include "spotlight.h"
 #include "spotlight.h"
 #include "textureReloadRequest.h"
 #include "textureReloadRequest.h"
 #include "shaderAttrib.h"
 #include "shaderAttrib.h"
@@ -1122,6 +1123,28 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
       return &LMatrix4::ident_mat();
       return &LMatrix4::ident_mat();
     }
     }
   }
   }
+  case Shader::SMO_texscale_i: {
+    const TexMatrixAttrib *tma;
+    const TextureAttrib *ta;
+    if (_target_rs->get_attrib(ta) && _target_rs->get_attrib(tma) &&
+        index < ta->get_num_on_stages()) {
+      LVecBase3 scale = tma->get_transform(ta->get_on_stage(index))->get_scale();
+      t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,scale[0],scale[1],scale[2],0);
+      return &t;
+    } else {
+      return &LMatrix4::ident_mat();
+    }
+  }
+  case Shader::SMO_texcolor_i: {
+    const TextureAttrib *ta;
+    if (_target_rs->get_attrib(ta) && index < ta->get_num_on_stages()) {
+      TextureStage *ts = ta->get_on_stage(index);
+      t.set_row(3, ts->get_color());
+      return &t;
+    } else {
+      return &LMatrix4::zeros_mat();
+    }
+  }
   case Shader::SMO_tex_is_alpha_i: {
   case Shader::SMO_tex_is_alpha_i: {
     // This is a hack so we can support both F_alpha and other formats in the
     // This is a hack so we can support both F_alpha and other formats in the
     // default shader, to fix font rendering in GLES2
     // default shader, to fix font rendering in GLES2
@@ -1156,9 +1179,14 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
     nassertr(!np.is_empty(), &LMatrix4::zeros_mat());
     nassertr(!np.is_empty(), &LMatrix4::zeros_mat());
     const PlaneNode *plane_node;
     const PlaneNode *plane_node;
     DCAST_INTO_R(plane_node, np.node(), &LMatrix4::zeros_mat());
     DCAST_INTO_R(plane_node, np.node(), &LMatrix4::zeros_mat());
-    LPlane p (plane_node->get_plane());
-    p.xform(np.get_net_transform()->get_mat()); // World-space
-    t = LMatrix4(0,0,0,0,0,0,0,0,0,0,0,0,p[0],p[1],p[2],p[3]);
+
+    // Transform plane to world space
+    CPT(TransformState) transform = np.get_net_transform();
+    LPlane plane = plane_node->get_plane();
+    if (!transform->is_identity()) {
+      plane.xform(transform->get_mat());
+    }
+    t.set_row(3, plane);
     return &t;
     return &t;
   }
   }
   case Shader::SMO_apiview_clipplane_i: {
   case Shader::SMO_apiview_clipplane_i: {
@@ -1195,7 +1223,6 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
   }
   }
   case Shader::SMO_world_to_view: {
   case Shader::SMO_world_to_view: {
     return &(_scene_setup->get_world_transform()->get_mat());
     return &(_scene_setup->get_world_transform()->get_mat());
-    break;
   }
   }
   case Shader::SMO_view_to_world: {
   case Shader::SMO_view_to_world: {
     return &(_scene_setup->get_camera_transform()->get_mat());
     return &(_scene_setup->get_camera_transform()->get_mat());
@@ -1387,6 +1414,62 @@ fetch_specified_part(Shader::ShaderMatInput part, InternalName *name,
     }
     }
     return fetch_specified_member(NodePath(), name, t);
     return fetch_specified_member(NodePath(), name, t);
   }
   }
+  case Shader::SMO_light_source_i_packed: {
+    // The light matrix contains COLOR, ATTENUATION, POSITION, VIEWVECTOR
+    const LightAttrib *target_light;
+    _target_rs->get_attrib_def(target_light);
+
+    // We don't count ambient lights, which would be pretty silly to handle
+    // via this mechanism.
+    size_t num_lights = target_light->get_num_non_ambient_lights();
+    if (index >= 0 && (size_t)index < num_lights) {
+      NodePath np = target_light->get_on_light((size_t)index);
+      nassertr(!np.is_empty(), &LMatrix4::ident_mat());
+      PandaNode *node = np.node();
+      Light *light = node->as_light();
+      nassertr(light != nullptr, &LMatrix4::zeros_mat());
+      t.set_row(0, light->get_color());
+      t.set_row(1, light->get_attenuation());
+
+      LMatrix4 mat = np.get_net_transform()->get_mat() *
+        _scene_setup->get_world_transform()->get_mat();
+
+      if (node->is_of_type(DirectionalLight::get_class_type())) {
+        LVecBase3 d = mat.xform_vec(((const DirectionalLight *)node)->get_direction());
+        d.normalize();
+        t.set_row(2, LVecBase4(d, 0));
+        t.set_row(3, LVecBase4(-d, 0));
+
+      } else if (node->is_of_type(LightLensNode::get_class_type())) {
+        const Lens *lens = ((const LightLensNode *)node)->get_lens();
+
+        LPoint3 p = mat.xform_point(lens->get_nodal_point());
+        t.set_row(3, LVecBase4(p));
+
+        // For shadowed point light we need to store near/far.
+        // For spotlight we need to store cutoff angle.
+        if (node->is_of_type(Spotlight::get_class_type())) {
+          PN_stdfloat cutoff = ccos(deg_2_rad(lens->get_hfov() * 0.5f));
+          LVecBase3 d = -(mat.xform_vec(lens->get_view_vector()));
+          t.set_cell(1, 3, ((const Spotlight *)node)->get_exponent());
+          t.set_row(2, LVecBase4(d, cutoff));
+
+        } else if (node->is_of_type(PointLight::get_class_type())) {
+          t.set_cell(1, 3, lens->get_near());
+          t.set_cell(3, 3, lens->get_far());
+
+          if (node->is_of_type(SphereLight::get_class_type())) {
+            t.set_cell(2, 3, ((const SphereLight *)node)->get_radius());
+          }
+        }
+      }
+    } else if (index == 0) {
+      // Apply the default OpenGL lights otherwise.
+      // Special exception for light 0, which defaults to white.
+      t.set_row(0, _light_color_scale);
+    }
+    return &t;
+  }
   default:
   default:
     nassertr(false /*should never get here*/, &LMatrix4::ident_mat());
     nassertr(false /*should never get here*/, &LMatrix4::ident_mat());
     return &LMatrix4::ident_mat();
     return &LMatrix4::ident_mat();

+ 6 - 5
panda/src/display/standardMunger.cxx

@@ -343,28 +343,29 @@ munge_state_impl(const RenderState *state) {
 
 
 #ifdef HAVE_CG
 #ifdef HAVE_CG
   if (_auto_shader) {
   if (_auto_shader) {
-    CPT(RenderState) shader_state = munged_state->get_auto_shader_state();
     GraphicsStateGuardian *gsg = get_gsg();
     GraphicsStateGuardian *gsg = get_gsg();
     ShaderGenerator *shader_generator = gsg->get_shader_generator();
     ShaderGenerator *shader_generator = gsg->get_shader_generator();
     if (shader_generator == nullptr) {
     if (shader_generator == nullptr) {
       shader_generator = new ShaderGenerator(gsg);
       shader_generator = new ShaderGenerator(gsg);
       gsg->set_shader_generator(shader_generator);
       gsg->set_shader_generator(shader_generator);
     }
     }
-    if (shader_state->_generated_shader == NULL) {
+    if (munged_state->_generated_shader == nullptr) {
       // Cache the generated ShaderAttrib on the shader state.
       // Cache the generated ShaderAttrib on the shader state.
       GeomVertexAnimationSpec spec;
       GeomVertexAnimationSpec spec;
 
 
       // Currently we overload this flag to request vertex animation for the
       // Currently we overload this flag to request vertex animation for the
       // shader generator.
       // shader generator.
       const ShaderAttrib *sattr;
       const ShaderAttrib *sattr;
-      shader_state->get_attrib_def(sattr);
+      munged_state->get_attrib_def(sattr);
       if (sattr->get_flag(ShaderAttrib::F_hardware_skinning)) {
       if (sattr->get_flag(ShaderAttrib::F_hardware_skinning)) {
         spec.set_hardware(4, true);
         spec.set_hardware(4, true);
       }
       }
 
 
-      shader_state->_generated_shader = shader_generator->synthesize_shader(shader_state, spec);
+      munged_state->_generated_shader = shader_generator->synthesize_shader(munged_state, spec);
+    }
+    if (munged_state->_generated_shader != nullptr) {
+      munged_state = munged_state->set_attrib(munged_state->_generated_shader);
     }
     }
-    munged_state = munged_state->set_attrib(shader_state->_generated_shader);
   }
   }
 #endif
 #endif
 
 

+ 8 - 0
panda/src/gobj/material.I

@@ -327,3 +327,11 @@ INLINE void Material::
 set_attrib_lock() {
 set_attrib_lock() {
   _flags |= F_attrib_lock;
   _flags |= F_attrib_lock;
 }
 }
+
+/**
+ *
+ */
+INLINE int Material::
+get_flags() const {
+  return _flags;
+}

+ 2 - 2
panda/src/gobj/material.h

@@ -128,6 +128,8 @@ PUBLISHED:
   MAKE_PROPERTY(twoside, get_twoside, set_twoside);
   MAKE_PROPERTY(twoside, get_twoside, set_twoside);
 
 
 public:
 public:
+  INLINE int get_flags() const;
+
   enum Flags {
   enum Flags {
     F_ambient     = 0x001,
     F_ambient     = 0x001,
     F_diffuse     = 0x002,
     F_diffuse     = 0x002,
@@ -157,8 +159,6 @@ private:
 
 
   int _flags;
   int _flags;
 
 
-  friend class MaterialAttrib;
-
 public:
 public:
   static void register_with_read_factory();
   static void register_with_read_factory();
   virtual void write_datagram(BamWriter *manager, Datagram &me);
   virtual void write_datagram(BamWriter *manager, Datagram &me);

+ 109 - 8
panda/src/gobj/shader.cxx

@@ -450,9 +450,11 @@ cp_dependency(ShaderMatInput inp) {
     }
     }
   }
   }
   if ((inp == SMO_light_ambient) ||
   if ((inp == SMO_light_ambient) ||
-      (inp == SMO_light_source_i_attrib)) {
-    dep |= SSD_light;
-    if (inp == SMO_light_source_i_attrib) {
+      (inp == SMO_light_source_i_attrib) ||
+      (inp == SMO_light_source_i_packed)) {
+    dep |= SSD_light | SSD_frame;
+    if (inp == SMO_light_source_i_attrib ||
+        inp == SMO_light_source_i_packed) {
       dep |= SSD_view_transform;
       dep |= SSD_view_transform;
     }
     }
   }
   }
@@ -465,7 +467,7 @@ cp_dependency(ShaderMatInput inp) {
       (inp == SMO_apiview_clipplane_i)) {
       (inp == SMO_apiview_clipplane_i)) {
     dep |= SSD_clip_planes;
     dep |= SSD_clip_planes;
   }
   }
-  if (inp == SMO_texmat_i || inp == SMO_inv_texmat_i) {
+  if (inp == SMO_texmat_i || inp == SMO_inv_texmat_i || inp == SMO_texscale_i) {
     dep |= SSD_tex_matrix;
     dep |= SSD_tex_matrix;
   }
   }
   if ((inp == SMO_window_size) ||
   if ((inp == SMO_window_size) ||
@@ -483,7 +485,7 @@ cp_dependency(ShaderMatInput inp) {
       (inp == SMO_apiclip_to_apiview)) {
       (inp == SMO_apiclip_to_apiview)) {
     dep |= SSD_projection;
     dep |= SSD_projection;
   }
   }
-  if (inp == SMO_tex_is_alpha_i) {
+  if (inp == SMO_tex_is_alpha_i || inp == SMO_texcolor_i) {
     dep |= SSD_texture | SSD_frame;
     dep |= SSD_texture | SSD_frame;
   }
   }
 
 
@@ -734,6 +736,29 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
     return true;
     return true;
   }
   }
 
 
+  if (pieces[0] == "mat" && pieces[1] == "shadow") {
+    if ((!cp_errchk_parameter_words(p,3))||
+        (!cp_errchk_parameter_in(p)) ||
+        (!cp_errchk_parameter_uniform(p))||
+        (!cp_errchk_parameter_float(p,16,16))) {
+      return false;
+    }
+    ShaderMatSpec bind;
+    bind._id = p._id;
+    bind._piece = SMP_whole;
+    bind._func = SMF_compose;
+    bind._part[1] = SMO_light_source_i_attrib;
+    bind._arg[1] = InternalName::make("shadowViewMatrix");
+    bind._part[0] = SMO_view_to_apiview;
+    bind._arg[0] = NULL;
+    bind._index = atoi(pieces[2].c_str());
+
+    cp_optimize_mat_spec(bind);
+    _mat_spec.push_back(bind);
+    _mat_deps |= bind._dep[0] | bind._dep[1];
+    return true;
+  }
+
   // Implement some macros.  Macros work by altering the contents of the
   // Implement some macros.  Macros work by altering the contents of the
   // 'pieces' array, and then falling through.
   // 'pieces' array, and then falling through.
 
 
@@ -833,7 +858,13 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
 
 
     ShaderMatSpec bind;
     ShaderMatSpec bind;
     bind._id = p._id;
     bind._id = p._id;
+    bind._piece = SMP_whole;
     bind._func = SMF_compose;
     bind._func = SMF_compose;
+    bind._part[1] = SMO_light_source_i_attrib;
+    bind._arg[1] = InternalName::make("shadowViewMatrix");
+    bind._part[0] = SMO_view_to_apiview;
+    bind._arg[0] = NULL;
+    bind._index = atoi(pieces[2].c_str());
 
 
     int next = 1;
     int next = 1;
     pieces.push_back("");
     pieces.push_back("");
@@ -958,6 +989,30 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
       bind._arg[0] = NULL;
       bind._arg[0] = NULL;
       bind._part[1] = SMO_identity;
       bind._part[1] = SMO_identity;
       bind._arg[1] = NULL;
       bind._arg[1] = NULL;
+    } else if (pieces[1].compare(0, 5, "light") == 0) {
+      if (!cp_errchk_parameter_float(p,16,16)) {
+        return false;
+      }
+      bind._id = p._id;
+      bind._piece = SMP_transpose;
+      bind._func = SMF_first;
+      bind._part[0] = SMO_light_source_i_packed;
+      bind._arg[0] = NULL;
+      bind._part[1] = SMO_identity;
+      bind._arg[1] = NULL;
+      bind._index = atoi(pieces[1].c_str() + 5);
+    } else if (pieces[1].compare(0, 5, "lspec") == 0) {
+      if (!cp_errchk_parameter_float(p,3,4)) {
+        return false;
+      }
+      bind._id = p._id;
+      bind._piece = SMP_row3;
+      bind._func = SMF_first;
+      bind._part[0] = SMO_light_source_i_attrib;
+      bind._arg[0] = InternalName::make("specular");
+      bind._part[1] = SMO_identity;
+      bind._arg[1] = NULL;
+      bind._index = atoi(pieces[1].c_str() + 5);
     } else {
     } else {
       cp_report_error(p,"Unknown attr parameter.");
       cp_report_error(p,"Unknown attr parameter.");
       return false;
       return false;
@@ -1094,6 +1149,52 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
     return true;
     return true;
   }
   }
 
 
+  if (pieces[0] == "texscale") {
+    if ((!cp_errchk_parameter_words(p,2))||
+        (!cp_errchk_parameter_in(p)) ||
+        (!cp_errchk_parameter_uniform(p))||
+        (!cp_errchk_parameter_float(p,3,4))) {
+      return false;
+    }
+    ShaderMatSpec bind;
+    bind._id = p._id;
+    bind._piece = SMP_row3;
+    bind._func = SMF_first;
+    bind._part[0] = SMO_texscale_i;
+    bind._arg[0] = NULL;
+    bind._part[1] = SMO_identity;
+    bind._arg[1] = NULL;
+    bind._index = atoi(pieces[1].c_str());
+
+    cp_optimize_mat_spec(bind);
+    _mat_spec.push_back(bind);
+    _mat_deps |= bind._dep[0] | bind._dep[1];
+    return true;
+  }
+
+  if (pieces[0] == "texcolor") {
+    if ((!cp_errchk_parameter_words(p,2))||
+        (!cp_errchk_parameter_in(p)) ||
+        (!cp_errchk_parameter_uniform(p))||
+        (!cp_errchk_parameter_float(p,3,4))) {
+      return false;
+    }
+    ShaderMatSpec bind;
+    bind._id = p._id;
+    bind._piece = SMP_row3;
+    bind._func = SMF_first;
+    bind._part[0] = SMO_texcolor_i;
+    bind._arg[0] = NULL;
+    bind._part[1] = SMO_identity;
+    bind._arg[1] = NULL;
+    bind._index = atoi(pieces[1].c_str());
+
+    cp_optimize_mat_spec(bind);
+    _mat_spec.push_back(bind);
+    _mat_deps |= bind._dep[0] | bind._dep[1];
+    return true;
+  }
+
   if (pieces[0] == "plane") {
   if (pieces[0] == "plane") {
     if ((!cp_errchk_parameter_words(p,2))||
     if ((!cp_errchk_parameter_words(p,2))||
         (!cp_errchk_parameter_in(p)) ||
         (!cp_errchk_parameter_in(p)) ||
@@ -1233,9 +1334,9 @@ compile_parameter(ShaderArgInfo &p, int *arg_dim) {
     }
     }
     ShaderTexSpec bind;
     ShaderTexSpec bind;
     bind._id = p._id;
     bind._id = p._id;
-    bind._name = InternalName::make(pieces[1])->append("shadowMap");
-    bind._stage = -1;
-    bind._part = STO_named_input;
+    bind._name = nullptr;
+    bind._stage = atoi(pieces[1].c_str());
+    bind._part = STO_light_i_shadow_map;
     switch (p._type) {
     switch (p._type) {
     case SAT_sampler2d:      bind._desired_type = Texture::TT_2d_texture; break;
     case SAT_sampler2d:      bind._desired_type = Texture::TT_2d_texture; break;
     case SAT_sampler_cube:   bind._desired_type = Texture::TT_cube_map; break;
     case SAT_sampler_cube:   bind._desired_type = Texture::TT_cube_map; break;

+ 11 - 0
panda/src/gobj/shader.h

@@ -202,6 +202,17 @@ public:
     // Hack for text rendering.  Don't use in user shaders.
     // Hack for text rendering.  Don't use in user shaders.
     SMO_tex_is_alpha_i,
     SMO_tex_is_alpha_i,
 
 
+    SMO_transform_i,
+    SMO_slider_i,
+
+    SMO_light_source_i_packed,
+
+    // Texture scale component of texture matrix.
+    SMO_texscale_i,
+
+    // Color of an M_blend texture stage.
+    SMO_texcolor_i,
+
     SMO_INVALID
     SMO_INVALID
   };
   };
 
 

+ 0 - 16
panda/src/pgraph/alphaTestAttrib.cxx

@@ -94,22 +94,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) AlphaTestAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // This is only important if the shader subsumes the alpha test, which only
-  // happens if there is an AuxBitplaneAttrib with ABO_glow.
-  const AuxBitplaneAttrib *aux;
-  if (!state->get_attrib(aux) ||
-      (aux->get_outputs() & AuxBitplaneAttrib::ABO_glow) == 0) {
-    return nullptr;
-  } else {
-    return this;
-  }
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type AlphaTestAttrib.
  * Tells the BamReader how to create objects of type AlphaTestAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/alphaTestAttrib.h

@@ -46,7 +46,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   PandaCompareFunc _mode;
   PandaCompareFunc _mode;

+ 0 - 8
panda/src/pgraph/auxBitplaneAttrib.cxx

@@ -97,14 +97,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) AuxBitplaneAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type AuxBitplaneAttrib.
  * Tells the BamReader how to create objects of type AuxBitplaneAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/auxBitplaneAttrib.h

@@ -72,7 +72,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   int _outputs;
   int _outputs;

+ 0 - 8
panda/src/pgraph/clipPlaneAttrib.cxx

@@ -833,14 +833,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return other;
   return other;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) ClipPlaneAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * This is patterned after TextureAttrib::sort_on_stages(), but since
  * This is patterned after TextureAttrib::sort_on_stages(), but since
  * planeNodes don't actually require sorting, this only empties the _filtered
  * planeNodes don't actually require sorting, this only empties the _filtered

+ 0 - 1
panda/src/pgraph/clipPlaneAttrib.h

@@ -98,7 +98,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   INLINE void check_filtered() const;
   INLINE void check_filtered() const;

+ 0 - 13
panda/src/pgraph/colorAttrib.cxx

@@ -132,19 +132,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) ColorAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // For a ColorAttrib, the only relevant information is the type: is it flat-
-  // shaded or vertex-shaded?  The actual color value is read by the shader
-  // from the graphics state.
-
-  ColorAttrib *attrib = new ColorAttrib(_type, LColor(1.0f, 1.0f, 1.0f, 1.0f));
-  return return_new(attrib);
-}
-
 /**
 /**
  * Quantizes the color color to the nearest multiple of 1000, just to prevent
  * Quantizes the color color to the nearest multiple of 1000, just to prevent
  * runaway accumulation of only slightly-different ColorAttribs.
  * runaway accumulation of only slightly-different ColorAttribs.

+ 0 - 1
panda/src/pgraph/colorAttrib.h

@@ -52,7 +52,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   void quantize_color();
   void quantize_color();

+ 0 - 8
panda/src/pgraph/colorBlendAttrib.cxx

@@ -148,14 +148,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) ColorBlendAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type ColorBlendAttrib.
  * Tells the BamReader how to create objects of type ColorBlendAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/colorBlendAttrib.h

@@ -121,7 +121,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   Mode _mode;
   Mode _mode;

+ 0 - 11
panda/src/pgraph/colorScaleAttrib.cxx

@@ -229,17 +229,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return return_new(attrib);
   return return_new(attrib);
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) ColorScaleAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // A ColorScaleAttrib doesn't directly contribute to the auto-shader
-  // contents--instead, the shader is always written to query attr_colorscale
-  // at runtime.  So the attrib itself means nothing to the shader.
-  return NULL;
-}
-
 /**
 /**
  * Quantizes the color scale to the nearest multiple of 1000, just to prevent
  * Quantizes the color scale to the nearest multiple of 1000, just to prevent
  * runaway accumulation of only slightly-different ColorScaleAttribs.
  * runaway accumulation of only slightly-different ColorScaleAttribs.

+ 0 - 1
panda/src/pgraph/colorScaleAttrib.h

@@ -55,7 +55,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   void quantize_scale();
   void quantize_scale();

+ 7 - 3
panda/src/pgraph/cullableObject.cxx

@@ -34,6 +34,7 @@
 CullableObject::FormatMap CullableObject::_format_map;
 CullableObject::FormatMap CullableObject::_format_map;
 LightMutex CullableObject::_format_lock;
 LightMutex CullableObject::_format_lock;
 
 
+PStatCollector CullableObject::_munge_pcollector("*:Munge");
 PStatCollector CullableObject::_munge_geom_pcollector("*:Munge:Geom");
 PStatCollector CullableObject::_munge_geom_pcollector("*:Munge:Geom");
 PStatCollector CullableObject::_munge_sprites_pcollector("*:Munge:Sprites");
 PStatCollector CullableObject::_munge_sprites_pcollector("*:Munge:Sprites");
 PStatCollector CullableObject::_munge_sprites_verts_pcollector("*:Munge:Sprites:Verts");
 PStatCollector CullableObject::_munge_sprites_verts_pcollector("*:Munge:Sprites:Verts");
@@ -55,7 +56,7 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger,
   nassertr(munger != nullptr, false);
   nassertr(munger != nullptr, false);
 
 
   Thread *current_thread = traverser->get_current_thread();
   Thread *current_thread = traverser->get_current_thread();
-  PStatTimer timer(_munge_geom_pcollector, current_thread);
+  PStatTimer timer(_munge_pcollector, current_thread);
   if (_geom != nullptr) {
   if (_geom != nullptr) {
     GraphicsStateGuardianBase *gsg = traverser->get_gsg();
     GraphicsStateGuardianBase *gsg = traverser->get_gsg();
     int gsg_bits = gsg->get_supported_geom_rendering();
     int gsg_bits = gsg->get_supported_geom_rendering();
@@ -123,8 +124,11 @@ munge_geom(GraphicsStateGuardianBase *gsg, GeomMunger *munger,
 
 
     // Now invoke the munger to ensure the resulting geometry is in a GSG-
     // Now invoke the munger to ensure the resulting geometry is in a GSG-
     // friendly form.
     // friendly form.
-    if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) {
-      return false;
+    {
+      PStatTimer timer(_munge_geom_pcollector, current_thread);
+      if (!munger->munge_geom(_geom, _munged_data, force, current_thread)) {
+        return false;
+      }
     }
     }
 
 
     // If we have prepared it for skinning via the shader generator, mark a
     // If we have prepared it for skinning via the shader generator, mark a

+ 1 - 0
panda/src/pgraph/cullableObject.h

@@ -108,6 +108,7 @@ private:
   static FormatMap _format_map;
   static FormatMap _format_map;
   static LightMutex _format_lock;
   static LightMutex _format_lock;
 
 
+  static PStatCollector _munge_pcollector;
   static PStatCollector _munge_geom_pcollector;
   static PStatCollector _munge_geom_pcollector;
   static PStatCollector _munge_sprites_pcollector;
   static PStatCollector _munge_sprites_pcollector;
   static PStatCollector _munge_sprites_verts_pcollector;
   static PStatCollector _munge_sprites_verts_pcollector;

+ 0 - 8
panda/src/pgraph/fogAttrib.cxx

@@ -100,14 +100,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) FogAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type FogAttrib.
  * Tells the BamReader how to create objects of type FogAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/fogAttrib.h

@@ -43,7 +43,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   PT(Fog) _fog;
   PT(Fog) _fog;

+ 0 - 8
panda/src/pgraph/lightAttrib.cxx

@@ -850,14 +850,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return other;
   return other;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) LightAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * Makes sure the lights are sorted in order of priority.  Also counts the
  * Makes sure the lights are sorted in order of priority.  Also counts the
  * number of non-ambient lights.
  * number of non-ambient lights.

+ 0 - 1
panda/src/pgraph/lightAttrib.h

@@ -103,7 +103,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   INLINE void check_sorted() const;
   INLINE void check_sorted() const;

+ 0 - 8
panda/src/pgraph/lightRampAttrib.cxx

@@ -254,14 +254,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) LightRampAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type LightRampAttrib.
  * Tells the BamReader how to create objects of type LightRampAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/lightRampAttrib.h

@@ -61,7 +61,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   LightRampMode _mode;
   LightRampMode _mode;

+ 0 - 8
panda/src/pgraph/logicOpAttrib.cxx

@@ -88,14 +88,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) LogicOpAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return RenderAttribRegistry::quick_get_global_ptr()->get_slot_default(_attrib_slot);
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type LogicOpAttrib.
  * Tells the BamReader how to create objects of type LogicOpAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/logicOpAttrib.h

@@ -64,7 +64,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   Operation _op;
   Operation _op;

+ 2 - 10
panda/src/pgraph/materialAttrib.I

@@ -15,7 +15,7 @@
  * Use MaterialAttrib::make() to construct a new MaterialAttrib object.
  * Use MaterialAttrib::make() to construct a new MaterialAttrib object.
  */
  */
 INLINE MaterialAttrib::
 INLINE MaterialAttrib::
-MaterialAttrib() : _flags(0) {
+MaterialAttrib() {
 }
 }
 
 
 /**
 /**
@@ -24,7 +24,7 @@ MaterialAttrib() : _flags(0) {
  */
  */
 INLINE bool MaterialAttrib::
 INLINE bool MaterialAttrib::
 is_off() const {
 is_off() const {
-  return _flags == 0;
+  return _material == nullptr;
 }
 }
 
 
 /**
 /**
@@ -35,11 +35,3 @@ INLINE Material *MaterialAttrib::
 get_material() const {
 get_material() const {
   return _material;
   return _material;
 }
 }
-
-/**
- * Equivalent to get_material()->get_flags().
- */
-INLINE int MaterialAttrib::
-get_material_flags() const {
-  return _flags;
-}

+ 3 - 54
panda/src/pgraph/materialAttrib.cxx

@@ -30,8 +30,6 @@ make(Material *material) {
   MaterialAttrib *attrib = new MaterialAttrib;
   MaterialAttrib *attrib = new MaterialAttrib;
   attrib->_material = material;
   attrib->_material = material;
   material->set_attrib_lock();
   material->set_attrib_lock();
-  attrib->_flags = material->_flags;
-  nassertr(attrib->_flags & Material::F_attrib_lock, nullptr);
   return return_new(attrib);
   return return_new(attrib);
 }
 }
 
 
@@ -64,30 +62,6 @@ output(ostream &out) const {
     out << *_material;
     out << *_material;
   } else if (is_off()) {
   } else if (is_off()) {
     out << "(off)";
     out << "(off)";
-  } else {
-    // This is a state returned from get_auto_shader_attrib().
-    out << "(on";
-#ifndef NDEBUG
-    if (_flags & Material::F_ambient) {
-      out << " amb";
-    }
-    if (_flags & Material::F_diffuse) {
-      out << " diff";
-    }
-    if (_flags & Material::F_specular) {
-      out << " spec";
-    }
-    if (_flags & Material::F_emission) {
-      out << " emit";
-    }
-    if (_flags & Material::F_local) {
-      out << " local";
-    }
-    if (_flags & Material::F_twoside) {
-      out << " twoside";
-    }
-#endif
-    out << ")";
   }
   }
 }
 }
 
 
@@ -113,7 +87,7 @@ compare_to_impl(const RenderAttrib *other) const {
   if (_material != ta->_material) {
   if (_material != ta->_material) {
     return _material < ta->_material ? -1 : 1;
     return _material < ta->_material ? -1 : 1;
   }
   }
-  return _flags < ta->_flags;
+  return 0;
 }
 }
 
 
 /**
 /**
@@ -124,26 +98,7 @@ compare_to_impl(const RenderAttrib *other) const {
  */
  */
 size_t MaterialAttrib::
 size_t MaterialAttrib::
 get_hash_impl() const {
 get_hash_impl() const {
-  size_t hash = 0;
-  hash = pointer_hash::add_hash(hash, _material);
-  hash = int_hash::add_hash(hash, _flags);
-  return hash;
-}
-
-/**
- *
- */
-CPT(RenderAttrib) MaterialAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  if (_material == nullptr) {
-    return this;
-  } else {
-    // Make a copy, but only with the flags, not with the material itself.
-    MaterialAttrib *attrib = new MaterialAttrib();
-    attrib->_material = nullptr;
-    attrib->_flags = _flags;
-    return return_new(attrib);
-  }
+  return pointer_hash::add_hash(0, _material);
 }
 }
 
 
 /**
 /**
@@ -174,13 +129,7 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
   int pi = RenderAttrib::complete_pointers(p_list, manager);
   int pi = RenderAttrib::complete_pointers(p_list, manager);
 
 
   TypedWritable *material = p_list[pi++];
   TypedWritable *material = p_list[pi++];
-  if (material != nullptr) {
-    _material = DCAST(Material, material);
-    _flags = _material->_flags | Material::F_attrib_lock;
-  } else {
-    _material = nullptr;
-    _flags = 0;
-  }
+  _material = DCAST(Material, material);
 
 
   return pi;
   return pi;
 }
 }

+ 0 - 5
panda/src/pgraph/materialAttrib.h

@@ -36,9 +36,6 @@ PUBLISHED:
   INLINE bool is_off() const;
   INLINE bool is_off() const;
   INLINE Material *get_material() const;
   INLINE Material *get_material() const;
 
 
-public:
-  INLINE int get_material_flags() const;
-
 PUBLISHED:
 PUBLISHED:
   MAKE_PROPERTY(material, get_material);
   MAKE_PROPERTY(material, get_material);
 
 
@@ -48,11 +45,9 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   PT(Material) _material;
   PT(Material) _material;
-  int _flags;
 
 
 PUBLISHED:
 PUBLISHED:
   static int get_class_slot() {
   static int get_class_slot() {

+ 0 - 19
panda/src/pgraph/renderAttrib.I

@@ -82,25 +82,6 @@ get_unique() const {
   return return_unique((RenderAttrib *)this);
   return return_unique((RenderAttrib *)this);
 }
 }
 
 
-/**
- * Returns the variant of this RenderAttrib that's most relevant for
- * associating with an auto-generated shader.  This should be a new
- * RenderAttrib of the same type as this one, with any superfluous data set to
- * neutral.  Only the parts of the attrib that contribute to the shader should
- * be reflected in the returned attrib.  The idea is to associate the auto-
- * generated shader with the most neutral form of all states, to allow it to
- * be shared across as many RenderState objects as possible.
- *
- * If this RenderAttrib is completely irrelevant to the auto-shader, this
- * should return NULL to indicate that the attrib won't be assocaited with the
- * shader at all.  In this case the attrib does not contribute to the shader
- * meaningfully.
- */
-INLINE CPT(RenderAttrib) RenderAttrib::
-get_auto_shader_attrib(const RenderState *state) const {
-  return get_auto_shader_attrib_impl(state);
-}
-
 /**
 /**
  * Calculates a suitable hash value for phash_map.
  * Calculates a suitable hash value for phash_map.
  */
  */

+ 0 - 8
panda/src/pgraph/renderAttrib.cxx

@@ -112,14 +112,6 @@ cull_callback(CullTraverser *, const CullTraverserData &) const {
   return true;
   return true;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) RenderAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return NULL;
-}
-
 /**
 /**
  * This method overrides ReferenceCount::unref() to clear the pointer from the
  * This method overrides ReferenceCount::unref() to clear the pointer from the
  * global object pool when its reference count goes to zero.
  * global object pool when its reference count goes to zero.

+ 0 - 2
panda/src/pgraph/renderAttrib.h

@@ -71,7 +71,6 @@ PUBLISHED:
   INLINE int compare_to(const RenderAttrib &other) const;
   INLINE int compare_to(const RenderAttrib &other) const;
   INLINE size_t get_hash() const;
   INLINE size_t get_hash() const;
   INLINE CPT(RenderAttrib) get_unique() const;
   INLINE CPT(RenderAttrib) get_unique() const;
-  INLINE CPT(RenderAttrib) get_auto_shader_attrib(const RenderState *state) const;
 
 
   virtual bool unref() const FINAL;
   virtual bool unref() const FINAL;
 
 
@@ -170,7 +169,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
   void output_comparefunc(ostream &out, PandaCompareFunc fn) const;
   void output_comparefunc(ostream &out, PandaCompareFunc fn) const;
 
 
 public:
 public:

+ 0 - 84
panda/src/pgraph/renderState.cxx

@@ -64,7 +64,6 @@ TypeHandle RenderState::_type_handle;
 RenderState::
 RenderState::
 RenderState() :
 RenderState() :
   _flags(0),
   _flags(0),
-  _auto_shader_state(NULL),
   _lock("RenderState")
   _lock("RenderState")
 {
 {
   if (_states == (States *)NULL) {
   if (_states == (States *)NULL) {
@@ -88,7 +87,6 @@ RenderState::
 RenderState(const RenderState &copy) :
 RenderState(const RenderState &copy) :
   _filled_slots(copy._filled_slots),
   _filled_slots(copy._filled_slots),
   _flags(0),
   _flags(0),
-  _auto_shader_state(NULL),
   _lock("RenderState")
   _lock("RenderState")
 {
 {
   // Copy over the attributes.
   // Copy over the attributes.
@@ -131,14 +129,6 @@ RenderState::
   nassertv(_saved_entry == -1);
   nassertv(_saved_entry == -1);
   nassertv(_composition_cache.is_empty() && _invert_composition_cache.is_empty());
   nassertv(_composition_cache.is_empty() && _invert_composition_cache.is_empty());
 
 
-  // Make sure the _auto_shader_state cache pointer is cleared.
-  if (_auto_shader_state != (const RenderState *)NULL) {
-    if (_auto_shader_state != this) {
-      cache_unref_delete(_auto_shader_state);
-    }
-    _auto_shader_state = NULL;
-  }
-
   // If this was true at the beginning of the destructor, but is no longer
   // If this was true at the beginning of the destructor, but is no longer
   // true now, probably we've been double-deleted.
   // true now, probably we've been double-deleted.
   nassertv(get_ref_count() == 0);
   nassertv(get_ref_count() == 0);
@@ -665,24 +655,6 @@ unref() const {
   return false;
   return false;
 }
 }
 
 
-/**
- * Returns the base RenderState that should have the generated_shader stored
- * within it, for generated shader states.  The returned object might be the
- * same as this object, or it might be a different RenderState with certain
- * attributes removed, or set to their default values.
- *
- * The point is to avoid needless regeneration of the shader attrib by storing
- * the generated shader on a common RenderState object, with all irrelevant
- * attributes removed.
- */
-const RenderState *RenderState::
-get_auto_shader_state() const {
-  if (_auto_shader_state == (const RenderState *)NULL) {
-    ((RenderState *)this)->assign_auto_shader_state();
-  }
-  return _auto_shader_state;
-}
-
 /**
 /**
  *
  *
  */
  */
@@ -1259,54 +1231,6 @@ do_calc_hash() {
   _flags |= F_hash_known;
   _flags |= F_hash_known;
 }
 }
 
 
-/**
- * Sets _auto_shader_state to the appropriate RenderState object pointer,
- * either the same pointer as this object, or some other (simpler)
- * RenderState.
- */
-void RenderState::
-assign_auto_shader_state() {
-  CPT(RenderState) state = do_calc_auto_shader_state();
-
-  {
-    LightReMutexHolder holder(*_states_lock);
-    if (_auto_shader_state == (const RenderState *)NULL) {
-      _auto_shader_state = state;
-      if (_auto_shader_state != this) {
-        _auto_shader_state->cache_ref();
-      }
-    }
-  }
-}
-
-/**
- * Returns the appropriate RenderState that should be used to store the auto
- * shader pointer for nodes that shader this RenderState.
- */
-CPT(RenderState) RenderState::
-do_calc_auto_shader_state() {
-  RenderState *state = new RenderState;
-
-  SlotMask mask = _filled_slots;
-  int slot = mask.get_lowest_on_bit();
-  while (slot >= 0) {
-    const Attribute &attrib = _attributes[slot];
-    nassertr(attrib._attrib != (RenderAttrib *)NULL, this);
-    CPT(RenderAttrib) new_attrib = attrib._attrib->get_auto_shader_attrib(this);
-    if (new_attrib != NULL) {
-      nassertr(new_attrib->get_slot() == slot, this);
-      state->_attributes[slot].set(new_attrib, 0);
-      state->_filled_slots.set_bit(slot);
-    }
-
-    mask.clear_bit(slot);
-    slot = mask.get_lowest_on_bit();
-  }
-
-  return return_new(state);
-}
-
-
 /**
 /**
  * This function is used to share a common RenderState pointer for all
  * This function is used to share a common RenderState pointer for all
  * equivalent RenderState objects.
  * equivalent RenderState objects.
@@ -1705,14 +1629,6 @@ void RenderState::
 remove_cache_pointers() {
 remove_cache_pointers() {
   nassertv(_states_lock->debug_is_locked());
   nassertv(_states_lock->debug_is_locked());
 
 
-  // First, make sure the _auto_shader_state cache pointer is cleared.
-  if (_auto_shader_state != (const RenderState *)NULL) {
-    if (_auto_shader_state != this) {
-      cache_unref_delete(_auto_shader_state);
-    }
-    _auto_shader_state = NULL;
-  }
-
   // Fortunately, since we added CompositionCache records in pairs, we know
   // Fortunately, since we added CompositionCache records in pairs, we know
   // exactly the set of RenderState objects that have us in their cache: it's
   // exactly the set of RenderState objects that have us in their cache: it's
   // the same set of RenderState objects that we have in our own cache.
   // the same set of RenderState objects that we have in our own cache.

+ 0 - 6
panda/src/pgraph/renderState.h

@@ -130,8 +130,6 @@ PUBLISHED:
   EXTENSION(PyObject *get_composition_cache() const);
   EXTENSION(PyObject *get_composition_cache() const);
   EXTENSION(PyObject *get_invert_composition_cache() const);
   EXTENSION(PyObject *get_invert_composition_cache() const);
 
 
-  const RenderState *get_auto_shader_state() const;
-
   void output(ostream &out) const;
   void output(ostream &out) const;
   void write(ostream &out, int indent_level) const;
   void write(ostream &out, int indent_level) const;
 
 
@@ -173,8 +171,6 @@ private:
   INLINE bool do_node_unref() const;
   INLINE bool do_node_unref() const;
   INLINE void calc_hash();
   INLINE void calc_hash();
   void do_calc_hash();
   void do_calc_hash();
-  void assign_auto_shader_state();
-  CPT(RenderState) do_calc_auto_shader_state();
 
 
   class CompositionCycleDescEntry {
   class CompositionCycleDescEntry {
   public:
   public:
@@ -317,8 +313,6 @@ private:
   int _draw_order;
   int _draw_order;
   size_t _hash;
   size_t _hash;
 
 
-  const RenderState *_auto_shader_state;
-
   enum Flags {
   enum Flags {
     F_checked_bin_index       = 0x000001,
     F_checked_bin_index       = 0x000001,
     F_checked_cull_callback   = 0x000002,
     F_checked_cull_callback   = 0x000002,

+ 0 - 16
panda/src/pgraph/rescaleNormalAttrib.cxx

@@ -80,22 +80,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) RescaleNormalAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // We currently only support M_normalize in the ShaderGenerator.
-  /*if (_mode == M_none || _mode == M_normalize) {
-    return this;
-  } else {
-    return RescaleNormalAttrib::make(M_normalize);
-  }*/
-  // Actually, we currently ignore this attribute in the shader generator,
-  // and always normalize the normals.  It's too much of a bother.
-  return nullptr;
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type RescaleNormalAttrib.
  * Tells the BamReader how to create objects of type RescaleNormalAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/rescaleNormalAttrib.h

@@ -57,7 +57,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   Mode _mode;
   Mode _mode;

+ 0 - 20
panda/src/pgraph/shaderAttrib.cxx

@@ -695,26 +695,6 @@ compose_impl(const RenderAttrib *other) const {
   return return_new(attr);
   return return_new(attr);
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) ShaderAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // For a ShaderAttrib, we only need to preserve the auto-shader flags.
-  // Custom shaders, and custom shader inputs, aren't relevant to the shader
-  // generator.
-  ShaderAttrib *attrib = new ShaderAttrib;
-  attrib->_auto_shader = _auto_shader;
-  attrib->_has_shader = _has_shader;
-  attrib->_auto_normal_on = _auto_normal_on;
-  attrib->_auto_glow_on = _auto_glow_on;
-  attrib->_auto_gloss_on = _auto_gloss_on;
-  attrib->_auto_ramp_on = _auto_ramp_on;
-  attrib->_auto_shadow_on = _auto_shadow_on;
-  attrib->_flags = _flags;
-  return return_new(attrib);
-}
-
 /**
 /**
  * Factory method to generate a Shader object
  * Factory method to generate a Shader object
  */
  */

+ 0 - 1
panda/src/pgraph/shaderAttrib.h

@@ -127,7 +127,6 @@ protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
 
 

+ 0 - 8
panda/src/pgraph/texGenAttrib.cxx

@@ -432,14 +432,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return return_new(attrib);
   return return_new(attrib);
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) TexGenAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  return this;
-}
-
 /**
 /**
  * This method is to be called after the _stages map has been built up
  * This method is to be called after the _stages map has been built up
  * internally through some artificial means; it copies the appropriate
  * internally through some artificial means; it copies the appropriate

+ 0 - 1
panda/src/pgraph/texGenAttrib.h

@@ -68,7 +68,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   class ModeDef;
   class ModeDef;

+ 0 - 22
panda/src/pgraph/texMatrixAttrib.cxx

@@ -415,28 +415,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return return_new(attrib);
   return return_new(attrib);
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) TexMatrixAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  // For a TexMatrixAttrib, the particular matrix per TextureStage isn't
-  // important, just whether there is a matrix at all.  So we create a new
-  // state with an identity matrix everywhere there is a matrix at all in the
-  // original.
-
-  TexMatrixAttrib *attrib = new TexMatrixAttrib;
-
-  Stages::const_iterator ai;
-  for (ai = _stages.begin(); ai != _stages.end(); ++ai) {
-    StageNode sn((*ai)._stage);
-    sn._transform = TransformState::make_identity();
-    attrib->_stages.insert(attrib->_stages.end(), sn);
-  }
-
-  return return_new(attrib);
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type TexMatrixAttrib.
  * Tells the BamReader how to create objects of type TexMatrixAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/texMatrixAttrib.h

@@ -67,7 +67,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   INLINE void check_stage_list() const;
   INLINE void check_stage_list() const;

+ 1 - 41
panda/src/pgraph/textureAttrib.I

@@ -140,26 +140,6 @@ get_on_texture(TextureStage *stage) const {
   return NULL;
   return NULL;
 }
 }
 
 
-/**
- * Returns the type of the texture associated with the indicated stage.  It is
- * an error to call this if has_on_stage(stage) returns false.
- *
- * This method is no different than get_on_texture(stage)->get_texture_type();
- * it merely exists to address a corner case for the shader generator.
- */
-INLINE Texture::TextureType TextureAttrib::
-get_on_texture_type(TextureStage *stage) const {
-  Stages::const_iterator si;
-  si = _on_stages.find(StageNode(stage));
-  nassertr(si != _on_stages.end(), Texture::TT_2d_texture);
-
-  if ((*si)._texture == nullptr) {
-    return (*si)._texture_type;
-  } else {
-    return (*si)._texture->get_texture_type();
-  }
-}
-
 /**
 /**
  * Returns the sampler associated with the indicated stage, or the one
  * Returns the sampler associated with the indicated stage, or the one
  * associated with its texture if no custom stage has been specified.  It is
  * associated with its texture if no custom stage has been specified.  It is
@@ -235,26 +215,6 @@ is_identity() const {
   return _on_stages.empty() && _off_stages.empty() && !_off_all_stages;
   return _on_stages.empty() && _off_stages.empty() && !_off_all_stages;
 }
 }
 
 
-/**
- * Call only on a state returned by get_auto_shader_attrib.
- */
-bool TextureAttrib::
-on_stage_affects_rgb(size_t n) const {
-  nassertr(n < _render_stages.size(), false);
-  StageNode *stage = _render_stages[n];
-  return stage->_texture_affects_rgb;
-}
-
-/**
- * Call only on a state returned by get_auto_shader_attrib.
- */
-bool TextureAttrib::
-on_stage_affects_alpha(size_t n) const {
-  nassertr(n < _render_stages.size(), false);
-  StageNode *stage = _render_stages[n];
-  return stage->_texture_affects_alpha;
-}
-
 /**
 /**
  * Confirms whether the _on_stages list is still sorted.  It will become
  * Confirms whether the _on_stages list is still sorted.  It will become
  * unsorted if someone calls TextureStage::set_sort().
  * unsorted if someone calls TextureStage::set_sort().
@@ -263,7 +223,7 @@ on_stage_affects_alpha(size_t n) const {
  */
  */
 INLINE void TextureAttrib::
 INLINE void TextureAttrib::
 check_sorted() const {
 check_sorted() const {
-  if (_sort_seq != TextureStage::get_sort_seq() && !_sort_seq.is_fresh()) {
+  if (_sort_seq != TextureStage::get_sort_seq()) {
     ((TextureAttrib *)this)->sort_on_stages();
     ((TextureAttrib *)this)->sort_on_stages();
   }
   }
 }
 }

+ 2 - 78
panda/src/pgraph/textureAttrib.cxx

@@ -385,19 +385,9 @@ output(ostream &out) const {
     const StageNode &sn = *(*ri);
     const StageNode &sn = *(*ri);
     TextureStage *stage = sn._stage;
     TextureStage *stage = sn._stage;
     Texture *tex = sn._texture;
     Texture *tex = sn._texture;
+    out << " " << stage->get_name();
     if (tex != nullptr) {
     if (tex != nullptr) {
-      out << " " << stage->get_name() << ":" << tex->get_name();
-    } else {
-      out << " " << stage->get_name() << ":(" << sn._texture_type;
-      if (sn._texture_affects_rgb) {
-        out << " rgb";
-        if (sn._texture_affects_alpha) {
-          out << "a";
-        }
-      } else if (sn._texture_affects_alpha) {
-        out << " alpha";
-      }
-      out << ")";
+      out << ":" << tex->get_name();
     }
     }
     if (sn._override != 0) {
     if (sn._override != 0) {
       out << "^" << sn._override;
       out << "^" << sn._override;
@@ -513,19 +503,6 @@ compare_to_impl(const RenderAttrib *other) const {
       }
       }
     }
     }
 
 
-    if (texture == nullptr) {
-      // This is an attribute returned by get_auto_shader_attrib_impl.
-      if ((*si)._texture_type != (*osi)._texture_type) {
-        return (*si)._texture_type < (*osi)._texture_type ? -1 : 1;
-      }
-      if ((*si)._texture_affects_rgb != (*osi)._texture_affects_rgb) {
-        return (*si)._texture_affects_rgb < (*osi)._texture_affects_rgb ? -1 : 1;
-      }
-      if ((*si)._texture_affects_alpha != (*osi)._texture_affects_alpha) {
-        return (*si)._texture_affects_alpha < (*osi)._texture_affects_alpha ? -1 : 1;
-      }
-    }
-
     ++si;
     ++si;
     ++osi;
     ++osi;
   }
   }
@@ -589,13 +566,6 @@ get_hash_impl() const {
     hash = pointer_hash::add_hash(hash, sn._texture);
     hash = pointer_hash::add_hash(hash, sn._texture);
     hash = int_hash::add_hash(hash, (int)sn._implicit_sort);
     hash = int_hash::add_hash(hash, (int)sn._implicit_sort);
     hash = int_hash::add_hash(hash, sn._override);
     hash = int_hash::add_hash(hash, sn._override);
-
-    if (sn._texture == nullptr) {
-      // This is an attribute returned by get_auto_shader_attrib_impl.
-      hash = int_hash::add_hash(hash, (int)sn._texture_type);
-      hash = int_hash::add_hash(hash, (int)sn._texture_affects_rgb);
-      hash = int_hash::add_hash(hash, (int)sn._texture_affects_alpha);
-    }
   }
   }
 
 
   // This bool value goes here, between the two lists, to differentiate
   // This bool value goes here, between the two lists, to differentiate
@@ -767,52 +737,6 @@ invert_compose_impl(const RenderAttrib *other) const {
   return other;
   return other;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) TextureAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  if (_on_stages.empty()) {
-    // Having no stages is the same as not applying a texture attribute.
-    return nullptr;
-  }
-
-  // We make a texture attribute that does not store the texture and sampler,
-  // so that we don't have to generate a shader for every possible texture.
-  // We do have to store the few texture properties that do affect the
-  // generated shader.
-  PT(TextureAttrib) attrib = new TextureAttrib;
-  attrib->_on_stages = _on_stages;
-  attrib->sort_on_stages();
-
-  Stages::iterator si;
-  for (si = attrib->_on_stages.begin(); si != attrib->_on_stages.end(); ++si) {
-    Texture::Format format = (*si)._texture->get_format();
-    (*si)._texture_type = (*si)._texture->get_texture_type();
-    (*si)._texture_affects_rgb = (format != Texture::F_alpha);
-    (*si)._texture_affects_alpha = Texture::has_alpha(format);
-    (*si)._texture = nullptr;
-    (*si)._has_sampler = false;
-
-    // We will no longer be composing or sorting this state so we can get rid
-    // of these values.
-    (*si)._override = 0;
-    (*si)._implicit_sort = 0;
-
-    // Exception to optimize a common case: if the first texture is an RGB
-    // texture, we don't care about whether it affects the alpha channel.
-    if (attrib->_render_stages[0] == &(*si) &&
-        (*si)._texture_affects_rgb && !(*si)._texture_affects_alpha) {
-      (*si)._texture_affects_alpha = true;
-    }
-  }
-
-  // Prevent check_sorted() from being called on this state.
-  attrib->_sort_seq = UpdateSeq::fresh();
-
-  return return_new(attrib);
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type TextureAttrib.
  * Tells the BamReader how to create objects of type TextureAttrib.
  */
  */

+ 0 - 9
panda/src/pgraph/textureAttrib.h

@@ -59,7 +59,6 @@ PUBLISHED:
   INLINE int get_ff_tc_index(int n) const;
   INLINE int get_ff_tc_index(int n) const;
   INLINE bool has_on_stage(TextureStage *stage) const;
   INLINE bool has_on_stage(TextureStage *stage) const;
   INLINE Texture *get_on_texture(TextureStage *stage) const;
   INLINE Texture *get_on_texture(TextureStage *stage) const;
-  INLINE Texture::TextureType get_on_texture_type(TextureStage *stage) const;
   INLINE const SamplerState &get_on_sampler(TextureStage *stage) const;
   INLINE const SamplerState &get_on_sampler(TextureStage *stage) const;
   INLINE int get_on_stage_override(TextureStage *stage) const;
   INLINE int get_on_stage_override(TextureStage *stage) const;
 
 
@@ -82,8 +81,6 @@ PUBLISHED:
   CPT(RenderAttrib) unify_texture_stages(TextureStage *stage) const;
   CPT(RenderAttrib) unify_texture_stages(TextureStage *stage) const;
 
 
 public:
 public:
-  INLINE bool on_stage_affects_rgb(size_t n) const;
-  INLINE bool on_stage_affects_alpha(size_t n) const;
   CPT(TextureAttrib) filter_to_max(int max_texture_stages) const;
   CPT(TextureAttrib) filter_to_max(int max_texture_stages) const;
 
 
   virtual bool lower_attrib_can_override() const;
   virtual bool lower_attrib_can_override() const;
@@ -97,7 +94,6 @@ protected:
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
   virtual CPT(RenderAttrib) invert_compose_impl(const RenderAttrib *other) const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   INLINE void check_sorted() const;
   INLINE void check_sorted() const;
@@ -117,11 +113,6 @@ private:
     int _ff_tc_index;
     int _ff_tc_index;
     unsigned int _implicit_sort;
     unsigned int _implicit_sort;
     int _override;
     int _override;
-
-    // These fields are used by the shader generator.
-    Texture::TextureType _texture_type : 16;
-    bool _texture_affects_rgb : 8;
-    bool _texture_affects_alpha : 8;
   };
   };
 
 
   class CompareTextureStagePriorities {
   class CompareTextureStagePriorities {

+ 0 - 15
panda/src/pgraph/transparencyAttrib.cxx

@@ -109,21 +109,6 @@ get_hash_impl() const {
   return hash;
   return hash;
 }
 }
 
 
-/**
- *
- */
-CPT(RenderAttrib) TransparencyAttrib::
-get_auto_shader_attrib_impl(const RenderState *state) const {
-  if (_mode == TransparencyAttrib::M_alpha) {
-    return this;
-  } else if (_mode == TransparencyAttrib::M_premultiplied_alpha ||
-             _mode == TransparencyAttrib::M_dual) {
-    return return_new(new TransparencyAttrib(M_alpha));
-  } else {
-    return nullptr;
-  }
-}
-
 /**
 /**
  * Tells the BamReader how to create objects of type TransparencyAttrib.
  * Tells the BamReader how to create objects of type TransparencyAttrib.
  */
  */

+ 0 - 1
panda/src/pgraph/transparencyAttrib.h

@@ -59,7 +59,6 @@ public:
 protected:
 protected:
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual int compare_to_impl(const RenderAttrib *other) const;
   virtual size_t get_hash_impl() const;
   virtual size_t get_hash_impl() const;
-  virtual CPT(RenderAttrib) get_auto_shader_attrib_impl(const RenderState *state) const;
 
 
 private:
 private:
   Mode _mode;
   Mode _mode;

+ 1 - 4
panda/src/pgraphnodes/directionalLight.cxx

@@ -56,9 +56,7 @@ fillin(DatagramIterator &scan, BamReader *) {
  */
  */
 DirectionalLight::
 DirectionalLight::
 DirectionalLight(const string &name) :
 DirectionalLight(const string &name) :
-  LightLensNode(name, new OrthographicLens()),
-  _has_specular_color(false)
-{
+  LightLensNode(name, new OrthographicLens()) {
   _lenses[0]._lens->set_interocular_distance(0);
   _lenses[0]._lens->set_interocular_distance(0);
 }
 }
 
 
@@ -69,7 +67,6 @@ DirectionalLight(const string &name) :
 DirectionalLight::
 DirectionalLight::
 DirectionalLight(const DirectionalLight &copy) :
 DirectionalLight(const DirectionalLight &copy) :
   LightLensNode(copy),
   LightLensNode(copy),
-  _has_specular_color(copy._has_specular_color),
   _cycler(copy._cycler)
   _cycler(copy._cycler)
 {
 {
 }
 }

+ 0 - 2
panda/src/pgraphnodes/directionalLight.h

@@ -59,8 +59,6 @@ public:
                     int light_id);
                     int light_id);
 
 
 private:
 private:
-  bool _has_specular_color;
-
   // This is the data that must be cycled between pipeline stages.
   // This is the data that must be cycled between pipeline stages.
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   public:
   public:

+ 9 - 0
panda/src/pgraphnodes/lightLensNode.I

@@ -11,6 +11,15 @@
  * @date 2002-03-26
  * @date 2002-03-26
  */
  */
 
 
+/**
+ * Returns true if this light defines a specular color, false if the specular
+ * color is derived automatically from the light color.
+ */
+INLINE bool LightLensNode::
+has_specular_color() const {
+  return _has_specular_color;
+}
+
 /**
 /**
  * Returns whether this light is configured to cast shadows or not.
  * Returns whether this light is configured to cast shadows or not.
  */
  */

+ 2 - 0
panda/src/pgraphnodes/lightLensNode.cxx

@@ -28,6 +28,7 @@ TypeHandle LightLensNode::_type_handle;
 LightLensNode::
 LightLensNode::
 LightLensNode(const string &name, Lens *lens) :
 LightLensNode(const string &name, Lens *lens) :
   Camera(name, lens),
   Camera(name, lens),
+  _has_specular_color(false),
   _attrib_count(0)
   _attrib_count(0)
 {
 {
   set_active(false);
   set_active(false);
@@ -63,6 +64,7 @@ LightLensNode(const LightLensNode &copy) :
   _shadow_caster(copy._shadow_caster),
   _shadow_caster(copy._shadow_caster),
   _sb_size(copy._sb_size),
   _sb_size(copy._sb_size),
   _sb_sort(-10),
   _sb_sort(-10),
+  _has_specular_color(copy._has_specular_color),
   _attrib_count(0)
   _attrib_count(0)
 {
 {
 }
 }

+ 3 - 0
panda/src/pgraphnodes/lightLensNode.h

@@ -35,6 +35,8 @@ PUBLISHED:
   LightLensNode(const string &name, Lens *lens = new PerspectiveLens());
   LightLensNode(const string &name, Lens *lens = new PerspectiveLens());
   virtual ~LightLensNode();
   virtual ~LightLensNode();
 
 
+  INLINE bool has_specular_color() const;
+
   INLINE bool is_shadow_caster() const;
   INLINE bool is_shadow_caster() const;
   INLINE void set_shadow_caster(bool caster);
   INLINE void set_shadow_caster(bool caster);
   INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
   INLINE void set_shadow_caster(bool caster, int buffer_xsize, int buffer_ysize, int sort = -10);
@@ -54,6 +56,7 @@ protected:
 
 
   LVecBase2i _sb_size;
   LVecBase2i _sb_size;
   bool _shadow_caster;
   bool _shadow_caster;
+  bool _has_specular_color;
   int _sb_sort;
   int _sb_sort;
 
 
   // This is really a map of GSG -> GraphicsOutput.
   // This is really a map of GSG -> GraphicsOutput.

+ 1 - 4
panda/src/pgraphnodes/pointLight.cxx

@@ -61,9 +61,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
  */
  */
 PointLight::
 PointLight::
 PointLight(const string &name) :
 PointLight(const string &name) :
-  LightLensNode(name),
-  _has_specular_color(false)
-{
+  LightLensNode(name) {
   PT(Lens) lens;
   PT(Lens) lens;
   lens = new PerspectiveLens(90, 90);
   lens = new PerspectiveLens(90, 90);
   lens->set_interocular_distance(0);
   lens->set_interocular_distance(0);
@@ -98,7 +96,6 @@ PointLight(const string &name) :
 PointLight::
 PointLight::
 PointLight(const PointLight &copy) :
 PointLight(const PointLight &copy) :
   LightLensNode(copy),
   LightLensNode(copy),
-  _has_specular_color(copy._has_specular_color),
   _cycler(copy._cycler)
   _cycler(copy._cycler)
 {
 {
 }
 }

+ 0 - 2
panda/src/pgraphnodes/pointLight.h

@@ -63,8 +63,6 @@ public:
                     int light_id);
                     int light_id);
 
 
 private:
 private:
-  bool _has_specular_color;
-
   // This is the data that must be cycled between pipeline stages.
   // This is the data that must be cycled between pipeline stages.
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   public:
   public:

File diff suppressed because it is too large
+ 436 - 413
panda/src/pgraphnodes/shaderGenerator.cxx


+ 72 - 58
panda/src/pgraphnodes/shaderGenerator.h

@@ -28,6 +28,11 @@
 #include "renderState.h"
 #include "renderState.h"
 #include "renderAttrib.h"
 #include "renderAttrib.h"
 
 
+#include "colorAttrib.h"
+#include "lightRampAttrib.h"
+#include "texGenAttrib.h"
+#include "textureAttrib.h"
+
 class AmbientLight;
 class AmbientLight;
 class DirectionalLight;
 class DirectionalLight;
 class PointLight;
 class PointLight;
@@ -66,7 +71,6 @@ PUBLISHED:
                                               const GeomVertexAnimationSpec &anim);
                                               const GeomVertexAnimationSpec &anim);
 
 
 protected:
 protected:
-  CPT(RenderAttrib) create_shader_attrib(const string &txt);
   static const string combine_mode_as_string(CPT(TextureStage) stage,
   static const string combine_mode_as_string(CPT(TextureStage) stage,
                       TextureStage::CombineMode c_mode, bool alpha, short texindex);
                       TextureStage::CombineMode c_mode, bool alpha, short texindex);
   static const string combine_source_as_string(CPT(TextureStage) stage,
   static const string combine_source_as_string(CPT(TextureStage) stage,
@@ -84,66 +88,76 @@ protected:
   const char *alloc_vreg();
   const char *alloc_vreg();
   const char *alloc_freg();
   const char *alloc_freg();
 
 
+  bool _use_shadow_filter;
+
   // RenderState analysis information.  Created by analyze_renderstate:
   // RenderState analysis information.  Created by analyze_renderstate:
 
 
   CPT(RenderState) _state;
   CPT(RenderState) _state;
-  int _material_flags;
-  int _num_textures;
-
-  pvector<LightLensNode *> _lights;
-  pvector<NodePath> _lights_np;
-
-  bool _vertex_colors;
-  bool _flat_colors;
-
-  bool _lighting;
-  bool _shadows;
-  bool _fog;
-
-  bool _have_ambient;
-  bool _have_diffuse;
-  bool _have_emission;
-  bool _have_specular;
-
-  bool _separate_ambient_diffuse;
-
-  int _map_index_normal;
-  int _map_index_height;
-  int _map_index_glow;
-  int _map_index_gloss;
-  bool _map_height_in_alpha;
-
-  bool _out_primary_glow;
-  bool _out_aux_normal;
-  bool _out_aux_glow;
-  bool _out_aux_any;
-
-  bool _have_alpha_test;
-  bool _have_alpha_blend;
-  bool _calc_primary_alpha;
-  bool _subsume_alpha_test;
-  bool _disable_alpha_write;
-
-  int _num_clip_planes;
-  bool _use_shadow_filter;
-
-  bool _need_material_props;
-  bool _need_world_position;
-  bool _need_world_normal;
-  bool _need_eye_position;
-  bool _need_eye_normal;
-  bool _normalize_normals;
-  bool _auto_normal_on;
-  bool _auto_glow_on;
-  bool _auto_gloss_on;
-  bool _auto_ramp_on;
-  bool _auto_shadow_on;
-
-  void analyze_renderstate(const RenderState *rs);
-  void clear_analysis();
-
-  // This is not a PT() to prevent a circular reference.
-  GraphicsStateGuardianBase *_gsg;
+  struct ShaderKey {
+    ShaderKey();
+    bool operator < (const ShaderKey &other) const;
+    bool operator == (const ShaderKey &other) const;
+    bool operator != (const ShaderKey &other) const { return !operator ==(other); }
+
+    GeomVertexAnimationSpec _anim_spec;
+    enum TextureFlags {
+      TF_has_rgb = 1,
+      TF_has_alpha = 2,
+      TF_has_texscale = 4,
+      TF_has_texmat = 8,
+      TF_saved_result = 16,
+      TF_map_normal = 32,
+      TF_map_height = 64,
+      TF_map_glow = 128,
+      TF_map_gloss = 256,
+    };
+
+    ColorAttrib::Type _color_type;
+    int _material_flags;
+    int _texture_flags;
+
+    struct TextureInfo {
+      CPT_InternalName _texcoord_name;
+      Texture::TextureType _type;
+      TextureStage::Mode _mode;
+      TexGenAttrib::Mode _gen_mode;
+      int _flags;
+
+      // Stored only if combine modes / blend color is used
+      CPT(TextureStage) _stage;
+    };
+    pvector<TextureInfo> _textures;
+
+    enum LightFlags {
+      LF_has_shadows = 1,
+      LF_has_specular_color = 2,
+    };
+
+    struct LightInfo {
+      TypeHandle _type;
+      int _flags;
+    };
+    pvector<LightInfo> _lights;
+    bool _lighting;
+    bool _have_separate_ambient;
+
+    int _fog_mode;
+
+    int _outputs;
+    bool _calc_primary_alpha;
+    bool _disable_alpha_write;
+    RenderAttrib::PandaCompareFunc _alpha_test_mode;
+    PN_stdfloat _alpha_test_ref;
+
+    int _num_clip_planes;
+
+    CPT(LightRampAttrib) _light_ramp;
+  };
+
+  typedef phash_map<ShaderKey, CPT(ShaderAttrib)> GeneratedShaders;
+  GeneratedShaders _generated_shaders;
+
+  void analyze_renderstate(ShaderKey &key, const RenderState *rs);
 
 
 public:
 public:
   static TypeHandle get_class_type() {
   static TypeHandle get_class_type() {

+ 1 - 4
panda/src/pgraphnodes/spotlight.cxx

@@ -65,9 +65,7 @@ fillin(DatagramIterator &scan, BamReader *manager) {
  */
  */
 Spotlight::
 Spotlight::
 Spotlight(const string &name) :
 Spotlight(const string &name) :
-  LightLensNode(name),
-  _has_specular_color(false)
-{
+  LightLensNode(name) {
   _lenses[0]._lens->set_interocular_distance(0);
   _lenses[0]._lens->set_interocular_distance(0);
 }
 }
 
 
@@ -78,7 +76,6 @@ Spotlight(const string &name) :
 Spotlight::
 Spotlight::
 Spotlight(const Spotlight &copy) :
 Spotlight(const Spotlight &copy) :
   LightLensNode(copy),
   LightLensNode(copy),
-  _has_specular_color(copy._has_specular_color),
   _cycler(copy._cycler)
   _cycler(copy._cycler)
 {
 {
 }
 }

+ 0 - 2
panda/src/pgraphnodes/spotlight.h

@@ -79,8 +79,6 @@ private:
   CPT(RenderState) get_viz_state();
   CPT(RenderState) get_viz_state();
 
 
 private:
 private:
-  bool _has_specular_color;
-
   // This is the data that must be cycled between pipeline stages.
   // This is the data that must be cycled between pipeline stages.
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   class EXPCL_PANDA_PGRAPHNODES CData : public CycleData {
   public:
   public:

+ 1 - 1
panda/src/pstatclient/pStatProperties.cxx

@@ -119,7 +119,7 @@ static TimeCollectorProperties time_properties[] = {
   { 1, "Cull:Sort",                        { 0.3, 0.3, 0.6 } },
   { 1, "Cull:Sort",                        { 0.3, 0.3, 0.6 } },
   { 1, "*",                                { 0.1, 0.1, 0.5 } },
   { 1, "*",                                { 0.1, 0.1, 0.5 } },
   { 1, "*:Show fps",                       { 0.5, 0.8, 1.0 } },
   { 1, "*:Show fps",                       { 0.5, 0.8, 1.0 } },
-  { 0, "*:Munge",                          { 0.3, 0.3, 0.9 } },
+  { 1, "*:Munge",                          { 0.3, 0.3, 0.9 } },
   { 1, "*:Munge:Geom",                     { 0.4, 0.2, 0.8 } },
   { 1, "*:Munge:Geom",                     { 0.4, 0.2, 0.8 } },
   { 1, "*:Munge:Sprites",                  { 0.2, 0.8, 0.4 } },
   { 1, "*:Munge:Sprites",                  { 0.2, 0.8, 0.4 } },
   { 0, "*:Munge:Data",                     { 0.7, 0.5, 0.2 } },
   { 0, "*:Munge:Data",                     { 0.7, 0.5, 0.2 } },

Some files were not shown because too many files changed in this diff