From 8c1f64e086e3dd12be80a97b2e35ce3cffbff6d2 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 14 Nov 2016 19:40:46 +0100 Subject: [PATCH] Fix for 1.9: fix errors when Cg-style matrix inputs are mat3 --- doc/ReleaseNotes | 1 + panda/src/glstuff/glShaderContext_src.cxx | 12 ++++++++++-- panda/src/glstuff/glShaderContext_src.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 157a20b2bf..b7462a97d6 100644 --- a/doc/ReleaseNotes +++ b/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 exception when trying to pickle NodePathCollection objects * Fix error when trying to raise vectors to a power +* GLSL: fix error when legacy matrix generator inputs are mat3 ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index df8ea97655..5ce322bfac 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/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. //////////////////////////////////////////////////////////////////// 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; p._id = arg_id; 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] == "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)) { 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 - 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; } diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 62d54ed675..51376e44f4 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -87,7 +87,7 @@ private: void glsl_report_program_errors(GLuint program, bool fatal); bool glsl_compile_shader(Shader::ShaderType type); 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(); public: