------------------------------------------------------------------------------
| 2448 | |
| 2449 | //------------------------------------------------------------------------------ |
| 2450 | void vtkOpenGLLowMemoryPolyDataMapper::SetShaderParameters(vtkRenderer* renderer, vtkActor* actor) |
| 2451 | { |
| 2452 | if (!this->ShaderProgram) |
| 2453 | { |
| 2454 | return; |
| 2455 | } |
| 2456 | |
| 2457 | // set uniform values |
| 2458 | int vp[4] = {}; |
| 2459 | auto renWin = vtkOpenGLRenderWindow::SafeDownCast(renderer->GetRenderWindow()); |
| 2460 | vtkOpenGLState* ostate = renWin->GetState(); |
| 2461 | ostate->vtkglGetIntegerv(GL_VIEWPORT, vp); |
| 2462 | float vpDims[4]; |
| 2463 | for (int i = 0; i < 4; ++i) |
| 2464 | { |
| 2465 | vpDims[i] = vp[i]; |
| 2466 | } |
| 2467 | const float lineWidth = actor->GetProperty()->GetLineWidth(); |
| 2468 | const float edgeWidth = actor->GetProperty()->GetEdgeWidth(); |
| 2469 | |
| 2470 | this->ShaderProgram->SetUniform4f("viewportDimensions", vpDims); |
| 2471 | this->ShaderProgram->SetUniformf("lineWidth", lineWidth); |
| 2472 | if (this->ShaderProgram->IsUniformUsed("renderPointsAsSpheres")) |
| 2473 | { |
| 2474 | this->ShaderProgram->SetUniformi( |
| 2475 | "renderPointsAsSpheres", actor->GetProperty()->GetRenderPointsAsSpheres() ? 1 : 0); |
| 2476 | } |
| 2477 | if (this->ShaderProgram->IsUniformUsed("renderLinesAsTubes")) |
| 2478 | { |
| 2479 | this->ShaderProgram->SetUniformi( |
| 2480 | "renderLinesAsTubes", actor->GetProperty()->GetRenderLinesAsTubes() ? 1 : 0); |
| 2481 | } |
| 2482 | if (this->ShaderProgram->IsUniformUsed("pointPicking")) |
| 2483 | { |
| 2484 | this->ShaderProgram->SetUniformi("pointPicking", this->PointPicking ? 1 : 0); |
| 2485 | } |
| 2486 | this->ShaderProgram->SetUniform3f("vertex_color", actor->GetProperty()->GetVertexColor()); |
| 2487 | this->ShaderProgram->SetUniform3f("edgeColor", actor->GetProperty()->GetEdgeColor()); |
| 2488 | this->ShaderProgram->SetUniformf("edgeOpacity", actor->GetProperty()->GetEdgeOpacity()); |
| 2489 | this->ShaderProgram->SetUniformi("edgeVisibility", actor->GetProperty()->GetEdgeVisibility()); |
| 2490 | this->ShaderProgram->SetUniformi( |
| 2491 | "wireframe", actor->GetProperty()->GetRepresentation() == VTK_WIREFRAME); |
| 2492 | // Always drive edge overlay thickness from screen-space lineWidth and clamp it |
| 2493 | // to a modest range to avoid saturating entire faces due to numerical differences |
| 2494 | // across backends (WebGL vs desktop). The tube look will be layered by color; we |
| 2495 | // do not need very large overlay widths here. |
| 2496 | if (actor->GetProperty()->GetUseLineWidthForEdgeThickness()) |
| 2497 | { |
| 2498 | this->ShaderProgram->SetUniformf("edgeWidth", lineWidth); |
| 2499 | } |
| 2500 | else |
| 2501 | { |
| 2502 | this->ShaderProgram->SetUniformf("edgeWidth", edgeWidth); |
| 2503 | } |
| 2504 | |
| 2505 | vtkOpenGLCamera* oglCam = vtkOpenGLCamera::SafeDownCast(renderer->GetActiveCamera()); |
| 2506 | if (oglCam) |
| 2507 | { |
no test coverage detected