From 32584f0a68fd1043321d8d9dfe5863cc35c1c83f Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 9 Nov 2021 15:46:14 +0100 Subject: [PATCH] pgraph: Fix prepare_scene() not properly invoking the shader generator --- panda/src/pgraph/geomNode.cxx | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index eb1148b126..a485851448 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -396,6 +396,24 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, geom_state = state_munger->munge_state(geom_state); } + // As well as the shaders. + const ShaderAttrib *sa; + if (geom_state->get_attrib(sa)) { + Shader *shader = (Shader *)sa->get_shader(); + if (shader != nullptr) { + prepared_objects->enqueue_shader(shader); + } + else if (sa->auto_shader()) { + gsg->ensure_generated_shader(geom_state); + } + else if (munger->is_of_type(StateMunger::get_class_type())) { + // Premunge the state for the fixed-function pipeline. + StateMunger *state_munger = (StateMunger *)munger.p(); + geom_state = state_munger->munge_state(geom_state); + } + // TODO: prepare the shader inputs. + } + // And now prepare each of the textures. const TextureAttrib *ta; if (geom_state->get_attrib(ta)) { @@ -408,16 +426,6 @@ r_prepare_scene(GraphicsStateGuardianBase *gsg, const RenderState *node_state, } } } - - // As well as the shaders. - const ShaderAttrib *sa; - if (geom_state->get_attrib(sa)) { - Shader *shader = (Shader *)sa->get_shader(); - if (shader != nullptr) { - prepared_objects->enqueue_shader(shader); - } - // TODO: prepare the shader inputs. - } } PandaNode::r_prepare_scene(gsg, node_state, transformer, current_thread);