Browse Source

Add shininess shader input

rdb 11 years ago
parent
commit
4856804938

+ 3 - 0
panda/src/glstuff/glCgShaderContext_src.cxx

@@ -370,6 +370,9 @@ issue_parameters(int altered) {
           GLfr(cgGLSetMatrixParameter)(p, upper3.get_data());
           GLfr(cgGLSetMatrixParameter)(p, upper3.get_data());
           continue;
           continue;
         }
         }
+      case Shader::SMP_cell15:
+        GLf(cgGLSetParameter1)(p, data[15]);
+        continue;
       }
       }
     }
     }
   }
   }

+ 12 - 2
panda/src/glstuff/glShaderContext_src.cxx

@@ -374,6 +374,10 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
               bind._piece = Shader::SMP_row3x3;
               bind._piece = Shader::SMP_row3x3;
               s->_mat_spec.push_back(bind);
               s->_mat_spec.push_back(bind);
               continue;
               continue;
+            } else if (noprefix == "Material.shininess") {
+              bind._piece = Shader::SMP_cell15;
+              s->_mat_spec.push_back(bind);
+              continue;
             }
             }
           }
           }
           if (noprefix == "ColorScale") {
           if (noprefix == "ColorScale") {
@@ -938,6 +942,9 @@ issue_parameters(int altered) {
           _glgsg->_glUniformMatrix3fv(p, 1, true, upper3.get_data());
           _glgsg->_glUniformMatrix3fv(p, 1, true, upper3.get_data());
           continue;
           continue;
         }
         }
+      case Shader::SMP_cell15:
+        _glgsg->_glUniform1fv(p, 1, data+15);
+        continue;
       }
       }
     }
     }
   }
   }
@@ -993,6 +1000,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
     Geom::NumericType numeric_type;
     Geom::NumericType numeric_type;
     int start, stride, num_values;
     int start, stride, num_values;
     int nvarying = _shader->_var_spec.size();
     int nvarying = _shader->_var_spec.size();
+
     for (int i = 0; i < nvarying; ++i) {
     for (int i = 0; i < nvarying; ++i) {
       InternalName *name = _shader->_var_spec[i]._name;
       InternalName *name = _shader->_var_spec[i]._name;
       int texslot = _shader->_var_spec[i]._append_uv;
       int texslot = _shader->_var_spec[i]._append_uv;
@@ -1007,8 +1015,8 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
         }
         }
       }
       }
       if (_glgsg->_data_reader->get_array_info(name,
       if (_glgsg->_data_reader->get_array_info(name,
-                                            array_reader, num_values, numeric_type,
-                                            start, stride)) {
+                                               array_reader, num_values, numeric_type,
+                                               start, stride)) {
         const unsigned char *client_pointer;
         const unsigned char *client_pointer;
         if (!_glgsg->setup_array_data(client_pointer, array_reader, force)) {
         if (!_glgsg->setup_array_data(client_pointer, array_reader, force)) {
           return false;
           return false;
@@ -1024,6 +1032,8 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
           _glgsg->_glVertexAttribPointer(p, num_values, _glgsg->get_numeric_type(numeric_type),
           _glgsg->_glVertexAttribPointer(p, num_values, _glgsg->get_numeric_type(numeric_type),
                                          GL_TRUE, stride, client_pointer + start);
                                          GL_TRUE, stride, client_pointer + start);
         }
         }
+      } else {
+        _glgsg->_glDisableVertexAttribArray(p);
       }
       }
     }
     }
   }
   }

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

@@ -234,6 +234,7 @@ public:
     SMP_row3x3,
     SMP_row3x3,
     SMP_upper3x3,
     SMP_upper3x3,
     SMP_transpose3x3,
     SMP_transpose3x3,
+    SMP_cell15,
   };
   };
 
 
   enum ShaderStateDep {
   enum ShaderStateDep {
@@ -362,6 +363,7 @@ public:
     int               _dep[2];
     int               _dep[2];
     PT(InternalName)  _arg;
     PT(InternalName)  _arg;
     ShaderArgInfo     _info;
     ShaderArgInfo     _info;
+    ShaderPtrType     _type;
   };
   };
 
 
   class ShaderCaps {
   class ShaderCaps {