Browse Source

A few fixes to support set_shader_input on attribs

Josh Yelon 20 years ago
parent
commit
28070dd33e

+ 3 - 1
direct/src/directscripts/packpanda.nsi

@@ -142,7 +142,9 @@ Section "${SMDIRECTORY}" SecCore
             SetOutPath $INSTDIR\models
             SetOutPath $INSTDIR\models
             File /r /x CVS ${PANDA}\models\*
             File /r /x CVS ${PANDA}\models\*
             SetOutPath $INSTDIR\samples
             SetOutPath $INSTDIR\samples
-            File /r /x CVS ${PSOURCE}\samples\*
+            File /r /x CVS /x GreetingCard ${PSOURCE}\samples\*
+            SetOutPath $INSTDIR\samples\GreetingCard
+            File /r /x CVS ${PANDA}\tmp\GreetingCard\*
 
 
             SetOutPath $INSTDIR
             SetOutPath $INSTDIR
             WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"
             WriteINIStr $INSTDIR\Website.url "InternetShortcut" "URL" "http://panda3d.etc.cmu.edu/"

+ 32 - 17
doc/makepanda/makepanda.py

@@ -1464,10 +1464,10 @@ def EnqueueLink(dll=0, obj=[], opts=[], xdep=[], ldef=0):
 def CompileBam(preconv, bam, egg):
 def CompileBam(preconv, bam, egg):
     if (egg[-4:] == ".flt"):
     if (egg[-4:] == ".flt"):
         ifile = os.path.basename(egg)
         ifile = os.path.basename(egg)
-        oscmd("built/bin/flt2egg -pr " + preconv + " -o built/tmp/"+ifile+".egg" + " " + egg)
+        oscmd("built/bin/flt2egg " + preconv + " -o built/tmp/"+ifile+".egg" + " " + egg)
         oscmd("built/bin/egg2bam -o " + bam + " built/tmp/"+ifile+".egg")
         oscmd("built/bin/egg2bam -o " + bam + " built/tmp/"+ifile+".egg")
     else:
     else:
-        oscmd("built/bin/egg2bam -pr " + preconv + " -o " + bam + " " + egg)
+        oscmd("built/bin/egg2bam " + preconv + " -o " + bam + " " + egg)
 
 
 def EnqueueBam(preconv, bam, egg):
 def EnqueueBam(preconv, bam, egg):
     if (sys.platform == "win32"):
     if (sys.platform == "win32"):
@@ -1578,6 +1578,9 @@ MakeDirectory("built/models/icons")
 MakeDirectory("built/models/maps")
 MakeDirectory("built/models/maps")
 MakeDirectory("built/models/misc")
 MakeDirectory("built/models/misc")
 MakeDirectory("built/models/gui")
 MakeDirectory("built/models/gui")
+MakeDirectory("built/tmp/GreetingCard")
+MakeDirectory("built/tmp/GreetingCard/models")
+MakeDirectory("built/tmp/GreetingCard/sound")
 
 
 if (OMIT.count("PYTHON")==0):
 if (OMIT.count("PYTHON")==0):
     MakeDirectory("built/direct")
     MakeDirectory("built/direct")
@@ -4447,21 +4450,21 @@ if (OMIT.count("PANDAAPP")==0):
 #
 #
 
 
 if (OMIT.count("PANDATOOL")==0):
 if (OMIT.count("PANDATOOL")==0):
-    EnqueueBam("../=", "built/models/gui/dialog_box_gui.bam",  "dmodels/src/gui/dialog_box_gui.flt")
-    EnqueueBam("../=", "built/models/misc/camera.bam",         "dmodels/src/misc/camera.flt")
-    EnqueueBam("../=", "built/models/misc/fade.bam",           "dmodels/src/misc/fade.flt")
-    EnqueueBam("../=", "built/models/misc/fade_sphere.bam",    "dmodels/src/misc/fade_sphere.flt")
-    EnqueueBam("../=", "built/models/misc/gridBack.bam",       "dmodels/src/misc/gridBack.flt")
-    EnqueueBam("../=", "built/models/misc/iris.bam",           "dmodels/src/misc/iris.flt")
-    EnqueueBam("../=", "built/models/misc/lilsmiley.bam",      "dmodels/src/misc/lilsmiley.egg")
-    EnqueueBam("../=", "built/models/misc/objectHandles.bam",  "dmodels/src/misc/objectHandles.flt")
-    EnqueueBam("../=", "built/models/misc/rgbCube.bam",        "dmodels/src/misc/rgbCube.flt")
-    EnqueueBam("../=", "built/models/misc/smiley.bam",         "dmodels/src/misc/smiley.egg")
-    EnqueueBam("../=", "built/models/misc/sphere.bam",         "dmodels/src/misc/sphere.flt")
-    EnqueueBam("../=", "built/models/misc/Pointlight.bam",     "dmodels/src/misc/Pointlight.egg")
-    EnqueueBam("../=", "built/models/misc/Dirlight.bam",       "dmodels/src/misc/Dirlight.egg")
-    EnqueueBam("../=", "built/models/misc/Spotlight.bam",      "dmodels/src/misc/Spotlight.egg")
-    #EnqueueBam("../=", "built/models/misc/xyzAxis.bam",        "dmodels/src/misc/xyzAxis.flt")
+    EnqueueBam("-pr ../=", "built/models/gui/dialog_box_gui.bam",  "dmodels/src/gui/dialog_box_gui.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/camera.bam",         "dmodels/src/misc/camera.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/fade.bam",           "dmodels/src/misc/fade.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/fade_sphere.bam",    "dmodels/src/misc/fade_sphere.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/gridBack.bam",       "dmodels/src/misc/gridBack.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/iris.bam",           "dmodels/src/misc/iris.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/lilsmiley.bam",      "dmodels/src/misc/lilsmiley.egg")
+    EnqueueBam("-pr ../=", "built/models/misc/objectHandles.bam",  "dmodels/src/misc/objectHandles.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/rgbCube.bam",        "dmodels/src/misc/rgbCube.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/smiley.bam",         "dmodels/src/misc/smiley.egg")
+    EnqueueBam("-pr ../=", "built/models/misc/sphere.bam",         "dmodels/src/misc/sphere.flt")
+    EnqueueBam("-pr ../=", "built/models/misc/Pointlight.bam",     "dmodels/src/misc/Pointlight.egg")
+    EnqueueBam("-pr ../=", "built/models/misc/Dirlight.bam",       "dmodels/src/misc/Dirlight.egg")
+    EnqueueBam("-pr ../=", "built/models/misc/Spotlight.bam",      "dmodels/src/misc/Spotlight.egg")
+    EnqueueBam("-pr ../=", "built/models/misc/xyzAxis.bam",        "dmodels/src/misc/xyzAxis.flt")
     
     
     CopyAllFiles("built/models/audio/sfx/",  "dmodels/src/audio/sfx/", ".wav")
     CopyAllFiles("built/models/audio/sfx/",  "dmodels/src/audio/sfx/", ".wav")
     CopyAllFiles("built/models/icons/",      "dmodels/src/icons/",     ".gif")
     CopyAllFiles("built/models/icons/",      "dmodels/src/icons/",     ".gif")
@@ -4479,6 +4482,18 @@ if (OMIT.count("PANDATOOL")==0):
     CopyAllFiles("built/models/maps/",       "dmodels/src/maps/",      ".rgb")
     CopyAllFiles("built/models/maps/",       "dmodels/src/maps/",      ".rgb")
     CopyAllFiles("built/models/maps/",       "dmodels/src/maps/",      ".rgba")
     CopyAllFiles("built/models/maps/",       "dmodels/src/maps/",      ".rgba")
 
 
+#
+# egg2bam on the greeting card directory
+#
+
+if (INSTALLER):
+    CopyFile("built/tmp/GreetingCard/",            "samples/GreetingCard/GreetingCard.py")
+    CopyFile("built/tmp/GreetingCard/sound/",      "samples/GreetingCard/sound/soundtrack.mp3")
+    CopyAllFiles("built/tmp/GreetingCard/models/", "samples/GreetingCard/models/", ".jpg")
+    EnqueueBam("-ps strip", "built/tmp/GreetingCard/models/thankyou_card.bam", "samples/GreetingCard/models/thankyou_card.egg")
+    EnqueueBam("-ps strip", "built/tmp/GreetingCard/models/thankyou_anim.bam", "samples/GreetingCard/models/thankyou_anim.egg")
+
+
 ##########################################################################################
 ##########################################################################################
 #
 #
 # Dependency-Based Distributed Build System.
 # Dependency-Based Distributed Build System.

+ 5 - 5
panda/src/glstuff/glShaderContext_src.cxx

@@ -335,14 +335,14 @@ issue_parameters(GSG *gsg)
     // Pass in k-float parameters.
     // Pass in k-float parameters.
     for (int i=0; i<(int)_cg_fbind.size(); i++) {
     for (int i=0; i<(int)_cg_fbind.size(); i++) {
       InternalName *id = _cg_fbind[i].name;
       InternalName *id = _cg_fbind[i].name;
-      const ShaderInput *input = gsg->_target._shader->get_input(id);
+      const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
       cgGLSetParameter4fv(_cg_fbind[i].parameter, input->get_vector().get_data());
       cgGLSetParameter4fv(_cg_fbind[i].parameter, input->get_vector().get_data());
     }
     }
     
     
     // Pass in k-float4x4 parameters.
     // Pass in k-float4x4 parameters.
     for (int i=0; i<(int)_cg_npbind.size(); i++) {
     for (int i=0; i<(int)_cg_npbind.size(); i++) {
       InternalName *id = _cg_npbind[i].name;
       InternalName *id = _cg_npbind[i].name;
-      const ShaderInput *input = gsg->_target._shader->get_input(id);
+      const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
       const float *dat;
       const float *dat;
       if (input->get_nodepath().is_empty()) {
       if (input->get_nodepath().is_empty()) {
         dat = LMatrix4f::ident_mat().get_data();
         dat = LMatrix4f::ident_mat().get_data();
@@ -515,7 +515,7 @@ update_shader_texture_bindings(CLP(ShaderContext) *prev, GSG *gsg)
       Texture *tex = 0;
       Texture *tex = 0;
       InternalName *id = _cg_texbind[i].name;
       InternalName *id = _cg_texbind[i].name;
       if (id != 0) {
       if (id != 0) {
-        const ShaderInput *input = gsg->_target._shader->get_input(id);
+        const ShaderInput *input = gsg->_target._shader->get_shader_input(id);
         tex = input->get_texture();
         tex = input->get_texture();
       } else {
       } else {
         if (_cg_texbind[i].stage >= gsg->_target._texture->get_num_on_stages()) {
         if (_cg_texbind[i].stage >= gsg->_target._texture->get_num_on_stages()) {
@@ -576,7 +576,7 @@ bind_cg_transform(const ShaderTransBind &stb, GSG *gsg)
   } else if (stb.src_name == InternalName::get_world()) {
   } else if (stb.src_name == InternalName::get_world()) {
     src = gsg->get_scene()->get_world_transform();
     src = gsg->get_scene()->get_world_transform();
   } else {
   } else {
-    const ShaderInput *input = gsg->_target._shader->get_input(stb.src_name);
+    const ShaderInput *input = gsg->_target._shader->get_shader_input(stb.src_name);
     if (input->get_nodepath().is_empty()) {
     if (input->get_nodepath().is_empty()) {
       src = gsg->get_scene()->get_world_transform();
       src = gsg->get_scene()->get_world_transform();
     } else {
     } else {
@@ -594,7 +594,7 @@ bind_cg_transform(const ShaderTransBind &stb, GSG *gsg)
   } else if (stb.rel_name == InternalName::get_world()) {
   } else if (stb.rel_name == InternalName::get_world()) {
     rel = gsg->get_scene()->get_world_transform();
     rel = gsg->get_scene()->get_world_transform();
   } else {
   } else {
-    const ShaderInput *input = gsg->_target._shader->get_input(stb.rel_name);
+    const ShaderInput *input = gsg->_target._shader->get_shader_input(stb.rel_name);
     if (input->get_nodepath().is_empty()) {
     if (input->get_nodepath().is_empty()) {
       rel = gsg->get_scene()->get_world_transform();
       rel = gsg->get_scene()->get_world_transform();
     } else {
     } else {

+ 4 - 4
panda/src/pgraph/nodePath.cxx

@@ -3141,11 +3141,11 @@ set_shader_input(const ShaderInput *inp) {
     node()->get_attrib(ShaderAttrib::get_class_type());
     node()->get_attrib(ShaderAttrib::get_class_type());
   if (attrib != (const RenderAttrib *)NULL) {
   if (attrib != (const RenderAttrib *)NULL) {
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
-    node()->set_attrib(sa->add_input(inp));
+    node()->set_attrib(sa->set_shader_input(inp));
   } else {
   } else {
     // Create a new ShaderAttrib for this node.
     // Create a new ShaderAttrib for this node.
     CPT(ShaderAttrib) sa = DCAST(ShaderAttrib, ShaderAttrib::make());
     CPT(ShaderAttrib) sa = DCAST(ShaderAttrib, ShaderAttrib::make());
-    node()->set_attrib(sa->add_input(inp));
+    node()->set_attrib(sa->set_shader_input(inp));
   }
   }
 }
 }
 
 
@@ -3162,7 +3162,7 @@ get_shader_input(InternalName *id) const {
     node()->get_attrib(ShaderAttrib::get_class_type());
     node()->get_attrib(ShaderAttrib::get_class_type());
   if (attrib != (const RenderAttrib *)NULL) {
   if (attrib != (const RenderAttrib *)NULL) {
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
-    return sa->get_input(id);
+    return sa->get_shader_input(id);
   }
   }
   return NULL;
   return NULL;
 }
 }
@@ -3180,7 +3180,7 @@ clear_shader_input(InternalName *id) {
     node()->get_attrib(ShaderAttrib::get_class_type());
     node()->get_attrib(ShaderAttrib::get_class_type());
   if (attrib != (const RenderAttrib *)NULL) {
   if (attrib != (const RenderAttrib *)NULL) {
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
     const ShaderAttrib *sa = DCAST(ShaderAttrib, attrib);
-    node()->set_attrib(sa->clear_input(id));
+    node()->set_attrib(sa->clear_shader_input(id));
   }
   }
 }
 }
 
 

+ 5 - 4
panda/src/pgraph/nodePath.h

@@ -557,10 +557,7 @@ PUBLISHED:
   void set_shader(Shader *sha, int priority = 0);
   void set_shader(Shader *sha, int priority = 0);
   void set_shader_off(int priority = 0);
   void set_shader_off(int priority = 0);
   void clear_shader();
   void clear_shader();
-  const Shader *get_shader() const;
   void set_shader_input(const ShaderInput *inp);
   void set_shader_input(const ShaderInput *inp);
-  const ShaderInput *get_shader_input(InternalName *id) const;
-  void clear_shader_input(InternalName *id);
   void set_shader_input(InternalName *id, Texture *tex,       int priority=0);
   void set_shader_input(InternalName *id, Texture *tex,       int priority=0);
   void set_shader_input(InternalName *id, const NodePath &np, int priority=0);
   void set_shader_input(InternalName *id, const NodePath &np, int priority=0);
   void set_shader_input(InternalName *id, const LVector4f &v, int priority=0);
   void set_shader_input(InternalName *id, const LVector4f &v, int priority=0);
@@ -569,8 +566,12 @@ PUBLISHED:
   void set_shader_input(const string &id, const NodePath &np, int priority=0);
   void set_shader_input(const string &id, const NodePath &np, int priority=0);
   void set_shader_input(const string &id, const LVector4f &v, int priority=0);
   void set_shader_input(const string &id, const LVector4f &v, int priority=0);
   void set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0);
   void set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1, int priority=0);
-  const ShaderInput *get_shader_input(const string &id) const;
+  void clear_shader_input(InternalName *id);
   void clear_shader_input(const string &id);
   void clear_shader_input(const string &id);
+
+  const Shader *get_shader() const;
+  const ShaderInput *get_shader_input(InternalName *id) const;
+  const ShaderInput *get_shader_input(const string &id) const;
   
   
   void set_tex_transform(TextureStage *stage, const TransformState *transform);
   void set_tex_transform(TextureStage *stage, const TransformState *transform);
   void clear_tex_transform();
   void clear_tex_transform();

+ 0 - 30
panda/src/pgraph/shaderAttrib.I

@@ -40,19 +40,6 @@ ShaderAttrib(const ShaderAttrib &copy) :
 {
 {
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: ShaderAttrib::get_shader
-//       Access: Published
-//  Description: Returns the shader object associated with the node.
-//               If get_override returns true, but get_shader 
-//               returns NULL, that means that this attribute should
-//               disable the shader.
-////////////////////////////////////////////////////////////////////
-INLINE const Shader *ShaderAttrib::
-get_shader() const {
-  return _shader;
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ShaderAttrib::has_shader
 //     Function: ShaderAttrib::has_shader
 //       Access: Published
 //       Access: Published
@@ -74,20 +61,3 @@ get_shader_priority() const {
   return _shader_priority;
   return _shader_priority;
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: ShaderAttrib::get_input
-//       Access: Published
-//  Description: Returns the ShaderInput of the given name.  If
-//               no such name is found, this function does not return
-//               NULL --- it returns the "blank" ShaderInput.
-////////////////////////////////////////////////////////////////////
-INLINE const ShaderInput *ShaderAttrib::
-get_input(const InternalName *id) const {
-  Inputs::const_iterator i = _inputs.find(id);
-  if (i == _inputs.end()) {
-    return ShaderInput::get_blank();
-  } else {
-    return (*i).second;
-  }
-}
-

+ 136 - 4
panda/src/pgraph/shaderAttrib.cxx

@@ -110,12 +110,12 @@ clear_shader() const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderAttrib::add_input
+//     Function: ShaderAttrib::set_shader_input
 //       Access: Published
 //       Access: Published
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 CPT(RenderAttrib) ShaderAttrib::
 CPT(RenderAttrib) ShaderAttrib::
-add_input(const ShaderInput *input) const {
+set_shader_input(const ShaderInput *input) const {
   ShaderAttrib *result = new ShaderAttrib(*this);
   ShaderAttrib *result = new ShaderAttrib(*this);
   Inputs::iterator i = result->_inputs.find(input->get_name());
   Inputs::iterator i = result->_inputs.find(input->get_name());
   if (i == result->_inputs.end()) {
   if (i == result->_inputs.end()) {
@@ -127,17 +127,149 @@ add_input(const ShaderInput *input) const {
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-//     Function: ShaderAttrib::clear_input
+//     Function: ShaderAttrib::set_shader_input
 //       Access: Published
 //       Access: Published
 //  Description: 
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 CPT(RenderAttrib) ShaderAttrib::
 CPT(RenderAttrib) ShaderAttrib::
-clear_input(const InternalName *id) const {
+set_shader_input(InternalName *id, Texture *tex, int priority) const {
+  return set_shader_input(new ShaderInput(id, tex, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(InternalName *id, const NodePath &np, int priority) const {
+  return set_shader_input(new ShaderInput(id, np, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(InternalName *id, const LVector4f &v, int priority) const {
+  return set_shader_input(new ShaderInput(id, v, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(InternalName *id, double n1, double n2, double n3, double n4, int priority) const {
+  return set_shader_input(new ShaderInput(id, LVector4f(n1,n2,n3,n4), priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(const string &id, Texture *tex, int priority) const {
+  return set_shader_input(new ShaderInput(InternalName::make(id), tex, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(const string &id, const NodePath &np, int priority) const {
+  return set_shader_input(new ShaderInput(InternalName::make(id), np, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(const string &id, const LVector4f &v, int priority) const {
+  return set_shader_input(new ShaderInput(InternalName::make(id), v, priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::set_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+set_shader_input(const string &id, double n1, double n2, double n3, double n4, int priority) const {
+  return set_shader_input(new ShaderInput(InternalName::make(id), LVector4f(n1,n2,n3,n4), priority));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::clear_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+clear_shader_input(InternalName *id) const {
   ShaderAttrib *result = new ShaderAttrib(*this);
   ShaderAttrib *result = new ShaderAttrib(*this);
   result->_inputs.erase(id);
   result->_inputs.erase(id);
   return return_new(result);
   return return_new(result);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::clear_shader_input
+//       Access: Published
+//  Description: 
+////////////////////////////////////////////////////////////////////
+CPT(RenderAttrib) ShaderAttrib::
+clear_shader_input(const string &id) const {
+  return clear_shader_input(InternalName::make(id));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::get_shader_input
+//       Access: Published
+//  Description: Returns the ShaderInput of the given name.  If
+//               no such name is found, this function does not return
+//               NULL --- it returns the "blank" ShaderInput.
+////////////////////////////////////////////////////////////////////
+const ShaderInput *ShaderAttrib::
+get_shader_input(InternalName *id) const {
+  Inputs::const_iterator i = _inputs.find(id);
+  if (i == _inputs.end()) {
+    return ShaderInput::get_blank();
+  } else {
+    return (*i).second;
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::get_shader_input
+//       Access: Published
+//  Description: Returns the ShaderInput of the given name.  If
+//               no such name is found, this function does not return
+//               NULL --- it returns the "blank" ShaderInput.
+////////////////////////////////////////////////////////////////////
+const ShaderInput *ShaderAttrib::
+get_shader_input(const string &id) const {
+  return get_shader_input(InternalName::make(id));
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: ShaderAttrib::get_shader
+//       Access: Published
+//  Description: Returns the shader object associated with the node.
+//               If get_override returns true, but get_shader 
+//               returns NULL, that means that this attribute should
+//               disable the shader.
+////////////////////////////////////////////////////////////////////
+const Shader *ShaderAttrib::
+get_shader() const {
+  return _shader;
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: ShaderAttrib::make_default_impl
 //     Function: ShaderAttrib::make_default_impl
 //       Access: Protected, Virtual
 //       Access: Protected, Virtual

+ 20 - 8
panda/src/pgraph/shaderAttrib.h

@@ -42,15 +42,27 @@ PUBLISHED:
 
 
   INLINE bool               has_shader() const;
   INLINE bool               has_shader() const;
   INLINE int                get_shader_priority() const;
   INLINE int                get_shader_priority() const;
-  INLINE const Shader      *get_shader() const;
-  INLINE const ShaderInput *get_input(const InternalName *id) const;
   
   
-  CPT(RenderAttrib)  clear_shader() const;
-  CPT(RenderAttrib)  set_shader(const Shader *s, int priority=0) const;
-  CPT(RenderAttrib)  set_shader_off(int priority=0) const;
-  
-  CPT(RenderAttrib)  add_input(const ShaderInput *input) const;
-  CPT(RenderAttrib)  clear_input(const InternalName *id) const;
+  CPT(RenderAttrib) set_shader(const Shader *s, int priority=0) const;
+  CPT(RenderAttrib) set_shader_off(int priority=0) const;
+  CPT(RenderAttrib) clear_shader() const;
+  CPT(RenderAttrib) set_shader_input(const ShaderInput *inp) const;
+  CPT(RenderAttrib) set_shader_input(InternalName *id, Texture *tex,       int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(InternalName *id, const NodePath &np, int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(InternalName *id, const LVector4f &v, int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(InternalName *id, double n1=0, double n2=0, double n3=0, double n4=1,
+                                     int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(const string &id, Texture *tex,       int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(const string &id, const NodePath &np, int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(const string &id, const LVector4f &v, int priority=0) const;
+  CPT(RenderAttrib) set_shader_input(const string &id, double n1=0, double n2=0, double n3=0, double n4=1,
+                                     int priority=0) const;
+  CPT(RenderAttrib) clear_shader_input(InternalName *id) const;
+  CPT(RenderAttrib) clear_shader_input(const string &id) const;
+
+  const Shader      *get_shader() const;
+  const ShaderInput *get_shader_input(InternalName *id) const;
+  const ShaderInput *get_shader_input(const string &id) const;
   
   
   static void register_with_read_factory();
   static void register_with_read_factory();