Browse Source

Fix for 1.9: fix errors when Cg-style matrix inputs are mat3

rdb 9 years ago
parent
commit
8c1f64e086

+ 1 - 0
doc/ReleaseNotes

@@ -47,6 +47,7 @@ This issue fixes several bugs that were still found in 1.9.2.
 * Fix compilation errors with Bullet 2.84
 * Fix compilation errors with Bullet 2.84
 * Fix exception when trying to pickle NodePathCollection objects
 * Fix exception when trying to pickle NodePathCollection objects
 * Fix error when trying to raise vectors to a power
 * Fix error when trying to raise vectors to a power
+* GLSL: fix error when legacy matrix generator inputs are mat3
 
 
 ------------------------  RELEASE 1.9.2  ------------------------
 ------------------------  RELEASE 1.9.2  ------------------------
 
 

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

@@ -51,7 +51,7 @@ TypeHandle CLP(ShaderContext)::_type_handle;
 //               actually picked up and the appropriate ShaderMatSpec pushed onto _mat_spec.
 //               actually picked up and the appropriate ShaderMatSpec pushed onto _mat_spec.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 bool CLP(ShaderContext)::
 bool CLP(ShaderContext)::
-parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, Shader *objShader) {
+parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, GLenum param_type, Shader *objShader) {
   Shader::ShaderArgInfo p;
   Shader::ShaderArgInfo p;
   p._id = arg_id;
   p._id = arg_id;
   p._cat = GLCAT;
   p._cat = GLCAT;
@@ -167,6 +167,14 @@ parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, Shader *objSha
     else if (pieces[0] == "col2")  bind._piece = Shader::SMP_col2;
     else if (pieces[0] == "col2")  bind._piece = Shader::SMP_col2;
     else if (pieces[0] == "col3")  bind._piece = Shader::SMP_col3;
     else if (pieces[0] == "col3")  bind._piece = Shader::SMP_col3;
 
 
+    if (param_type == GL_FLOAT_MAT3) {
+      if (bind._piece == Shader::SMP_whole) {
+        bind._piece = Shader::SMP_upper3x3;
+      } else if (bind._piece == Shader::SMP_transpose) {
+        bind._piece = Shader::SMP_transpose3x3;
+      }
+    }
+
     if (!objShader->cp_parse_coord_sys(p, pieces, next, bind, true)) {
     if (!objShader->cp_parse_coord_sys(p, pieces, next, bind, true)) {
       return false;
       return false;
     }
     }
@@ -614,7 +622,7 @@ CLP(ShaderContext)(CLP(GraphicsStateGuardian) *glgsg, Shader *s) : ShaderContext
         }
         }
 
 
         //Tries to parse shorthand notations like mspos_XXX and trans_model_to_clip_of_XXX
         //Tries to parse shorthand notations like mspos_XXX and trans_model_to_clip_of_XXX
-        if (parse_and_set_short_hand_shader_vars(arg_id, s)) {
+        if (parse_and_set_short_hand_shader_vars(arg_id, param_type, s)) {
           continue;
           continue;
         }
         }
 
 

+ 1 - 1
panda/src/glstuff/glShaderContext_src.h

@@ -87,7 +87,7 @@ private:
   void glsl_report_program_errors(GLuint program, bool fatal);
   void glsl_report_program_errors(GLuint program, bool fatal);
   bool glsl_compile_shader(Shader::ShaderType type);
   bool glsl_compile_shader(Shader::ShaderType type);
   bool glsl_compile_and_link();
   bool glsl_compile_and_link();
-  bool parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, Shader *s);
+  bool parse_and_set_short_hand_shader_vars(Shader::ShaderArgId &arg_id, GLenum param_type, Shader *s);
   void release_resources();
   void release_resources();
 
 
 public:
 public: