Browse Source

pgraphnodes: Disable lighting when rendering shadow cam

This prevents accessing a texture (the shadow map) that we're currently rendering into.  Hopefully a reasonable driver was already optimizing out the access properly due to the color write being off, but it could cause unnecessary work in the driver

This will have the effect of the shader generator generating a different shader for the shadow pass than for the main pass, ideally we optimize the shader generator a bit more so that there are fewer shaders generated for the shadow pass.
rdb 1 year ago
parent
commit
22381c94d4
1 changed files with 8 additions and 3 deletions
  1. 8 3
      panda/src/pgraphnodes/lightLensNode.cxx

+ 8 - 3
panda/src/pgraphnodes/lightLensNode.cxx

@@ -19,6 +19,7 @@
 #include "renderState.h"
 #include "cullFaceAttrib.h"
 #include "colorWriteAttrib.h"
+#include "lightAttrib.h"
 #include "graphicsStateGuardianBase.h"
 
 TypeHandle LightLensNode::_type_handle;
@@ -37,10 +38,14 @@ LightLensNode(const std::string &name, Lens *lens) :
   _shadow_caster = false;
   _sb_size.set(512, 512);
   _sb_sort = -10;
-  // set_initial_state(RenderState::make(ShaderAttrib::make_off(), 1000));
+
   // Backface culling helps eliminating artifacts.
-  set_initial_state(RenderState::make(CullFaceAttrib::make_reverse(),
-                    ColorWriteAttrib::make(ColorWriteAttrib::C_off)));
+  static CPT(RenderState) default_initial_state =
+    RenderState::make(
+      CullFaceAttrib::make_reverse(),
+      ColorWriteAttrib::make(ColorWriteAttrib::C_off)
+    )->set_attrib(LightAttrib::make_all_off(), RenderState::get_max_priority());
+  set_initial_state(default_initial_state);
 }
 
 /**