Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • VTK VTK
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 830
    • Issues 830
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 232
    • Merge requests 232
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • VTKVTK
  • VTKVTK
  • Issues
  • #17949
Closed
Open
Issue created Jun 24, 2020 by Thomas@CoolContributor

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"))```
Edited Jun 24, 2020 by Thomas
Assignee
Assign to
Time tracking