Uploading MCWCMatrix to the Shader in vtkOpenGLPolyDataMapper.cxx
In the changes allowing the mapper to read vtkShaderProperties from the actor, it seems like the invokeEvent:
this->InvokeEvent(vtkCommand::UpdateShaderEvent, cellBO.Program);
call was not updated does not pass the actor to the callback. In the case of instancing this makes it very difficult to pass the mcwcmatrix manually using the callback. In our particular case we just want to color something when part of the transformed poly data is below a value. (in addition, there is the complexity of the shift scale transform on the vertex model coordinates).
To circumvent these issues, I propose allowing the mapper to also upload the MCWC matrix I attached a small diff below
index 49da15d714..100bffab12 100644
--- a/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
+++ b/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx
@@ -2749,6 +2749,10 @@ void vtkOpenGLPolyDataMapper::SetCameraShaderParameters(
vtkMatrix3x3* anorms;
static_cast<vtkOpenGLActor*>(actor)->GetKeyMatrices(mcwc, anorms);
vtkMatrix4x4::Multiply4x4(this->VBOShiftScale, mcwc, this->TempMatrix4);
+ if (program->IsUniformUsed("MCWCMatrix"))
+ {
+ program->SetUniformMatrix("MCWCMatrix", this->TempMatrix4);
+ }
vtkMatrix4x4::Multiply4x4(this->TempMatrix4, wcdc, this->TempMatrix4);
program->SetUniformMatrix("MCDCMatrix", this->TempMatrix4);
if (program->IsUniformUsed("MCVCMatrix"))
@@ -2785,6 +2789,10 @@ void vtkOpenGLPolyDataMapper::SetCameraShaderParameters(
vtkMatrix4x4* mcwc;
vtkMatrix3x3* anorms;
((vtkOpenGLActor*)actor)->GetKeyMatrices(mcwc, anorms);
+ if (program->IsUniformUsed("MCWCMatrix"))
+ {
+ program->SetUniformMatrix("MCWCMatrix", mcwc);
+ }
vtkMatrix4x4::Multiply4x4(mcwc, wcdc, this->TempMatrix4);
program->SetUniformMatrix("MCDCMatrix", this->TempMatrix4);
if (program->IsUniformUsed("MCVCMatrix"))```