MCPcopy Create free account
hub / github.com/Kitware/VTK / GetNeedToRebuildShaders

Method GetNeedToRebuildShaders

Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx:2543–2658  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2541
2542//------------------------------------------------------------------------------
2543bool vtkOpenGLPolyDataMapper::GetNeedToRebuildShaders(
2544 vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* actor)
2545{
2546 primitiveInfo::LightingTypeEnum lightComplexity = primitiveInfo::NoLighting;
2547 int numberOfLights = 0;
2548
2549 // wacky backwards compatibility with old VTK lighting
2550 // soooo there are many factors that determine if a primitive is lit or not.
2551 // three that mix in a complex way are representation POINT, Interpolation FLAT
2552 // and having normals or not.
2553 bool needLighting = false;
2554 bool haveNormals = (this->CurrentInput->GetPointData()->GetNormals() != nullptr);
2555 if (actor->GetProperty()->GetRepresentation() == VTK_POINTS)
2556 {
2557 needLighting = (actor->GetProperty()->GetInterpolation() != VTK_FLAT && haveNormals);
2558 }
2559 else // wireframe or surface rep
2560 {
2561 bool isTrisOrStrips = (cellBO.PrimitiveType == PrimitiveTris ||
2562 cellBO.PrimitiveType == vtkOpenGLPolyDataMapper::PrimitiveTriStrips);
2563 needLighting = (isTrisOrStrips ||
2564 (!isTrisOrStrips && actor->GetProperty()->GetInterpolation() != VTK_FLAT && haveNormals));
2565 }
2566
2567 // we sphering or tubing? Yes I made sphere into a verb
2568 if (this->DrawingTubesOrSpheres(cellBO, actor))
2569 {
2570 needLighting = true;
2571 }
2572
2573 // do we need lighting?
2574 if (actor->GetProperty()->GetLighting() && needLighting)
2575 {
2576 vtkOpenGLRenderer* oren = static_cast<vtkOpenGLRenderer*>(ren);
2577 lightComplexity = static_cast<primitiveInfo::LightingTypeEnum>(oren->GetLightingComplexity());
2578 numberOfLights = oren->GetLightingCount();
2579 }
2580
2581 auto& primInfo = this->PrimitiveInfo[&cellBO];
2582 if (primInfo.LastLightComplexity != lightComplexity || primInfo.LastLightCount != numberOfLights)
2583 {
2584 primInfo.LightComplexityChanged.Modified();
2585 primInfo.LastLightComplexity = lightComplexity;
2586 primInfo.LastLightCount = numberOfLights;
2587 }
2588
2589 // has something changed that would require us to recreate the shader?
2590 // candidates are
2591 // -- property modified (representation interpolation and lighting)
2592 // -- input modified if it changes the presence of normals/tcoords
2593 // -- light complexity changed
2594 // -- any render pass that requires it
2595 // -- some selection state changes
2596 // we do some quick simple tests first
2597
2598 // Have the renderpasses changed?
2599 vtkMTimeType renderPassMTime = this->GetRenderPassStageMTime(actor, &cellBO);
2600

Callers 1

UpdateShadersMethod · 0.95

Calls 15

DrawingTubesOrSpheresMethod · 0.95
GetTexturesMethod · 0.95
GetRepresentationMethod · 0.80
GetActiveCameraMethod · 0.80
GetShaderMTimeMethod · 0.80
GetShaderPropertyMethod · 0.80
GetNormalsMethod · 0.45
GetPointDataMethod · 0.45
GetPropertyMethod · 0.45
GetInterpolationMethod · 0.45

Tested by

no test coverage detected