Selaa lähdekoodia

pgraph: Fix prepare_scene() not properly invoking the shader generator

rdb 4 vuotta sitten
vanhempi
sitoutus
32584f0a68
1 muutettua tiedostoa jossa 18 lisäystä ja 10 poistoa
  1. 18 10
      panda/src/pgraph/geomNode.cxx

+ 18 - 10
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);