-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge topic 'fix-line-scalar-coloring-macos'
6246609 Fix cell coloring for thick lines on apple silicon Acked-by: Kitware Robot <[email protected]> Acked-by: buildbot <[email protected]> Reviewed-by: Sankhesh Jhaveri <[email protected]> Merge-request: !11794
- Loading branch information
Showing
7 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## Fix wide lines with cell colors for Apple silicon | ||
|
||
You can now render thick lines and map colors using cell scalars on Apple silicon. Previously, Apple silicon | ||
chips would only render the first half of the line segments with cell scalar color and the rest of the lines | ||
would not be drawn at all. VTK now handles this bug in upstream Apple driver by patching the shader code at | ||
runtime. VTK applies the patch only for Apple OpenGL over Metal driver. | ||
|
||
You can check for the presence of this bug in Apple drivers with the | ||
`bool vtkOpenGLRenderWindow::IsPrimIDBugPresent()` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
Rendering/Core/Testing/Cxx/TestMixedGeometryCellScalars.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
#include "vtkActor.h" | ||
#include "vtkAppendPolyData.h" | ||
#include "vtkArrayCalculator.h" | ||
#include "vtkColorTransferFunction.h" | ||
#include "vtkNew.h" | ||
#include "vtkPolyDataMapper.h" | ||
#include "vtkPolyLineSource.h" | ||
#include "vtkProperty.h" | ||
#include "vtkRegressionTestImage.h" | ||
#include "vtkRegularPolygonSource.h" | ||
#include "vtkRenderWindow.h" | ||
#include "vtkRenderWindowInteractor.h" | ||
#include "vtkRenderer.h" | ||
#include "vtkSmartPointer.h" | ||
|
||
#include <initializer_list> | ||
#include <string> | ||
|
||
namespace | ||
{ | ||
vtkSmartPointer<vtkAlgorithm> AddCellScalarArray( | ||
const std::string expression, vtkSmartPointer<vtkAlgorithm> input) | ||
{ | ||
vtkNew<vtkArrayCalculator> calculator; | ||
calculator->SetAttributeTypeToCellData(); | ||
calculator->SetFunction(expression.c_str()); | ||
calculator->SetInputConnection(input->GetOutputPort()); | ||
return calculator; | ||
} | ||
|
||
vtkSmartPointer<vtkAlgorithm> Append( | ||
std::initializer_list<vtkSmartPointer<vtkAlgorithm>> inputAlgorithms) | ||
{ | ||
vtkNew<vtkAppendPolyData> append; | ||
for (const auto& inputAlgorithm : inputAlgorithms) | ||
{ | ||
append->AddInputConnection(inputAlgorithm->GetOutputPort()); | ||
} | ||
return append; | ||
} | ||
} | ||
|
||
int TestMixedGeometryCellScalars(int argc, char* argv[]) | ||
{ | ||
vtkNew<vtkPolyPointSource> points; | ||
points->SetNumberOfPoints(5); | ||
points->SetPoint(0, 0, 0, 0); | ||
points->SetPoint(1, 1, 0, 0); | ||
points->SetPoint(2, 2, 1, 0); | ||
points->SetPoint(3, 2, 2, 0); | ||
points->SetPoint(4, 1, 3, 0); | ||
|
||
vtkNew<vtkPolyLineSource> polyline; | ||
polyline->SetClosed(false); | ||
polyline->SetNumberOfPoints(5); | ||
polyline->SetPoint(0, 0, 0, 0); | ||
polyline->SetPoint(1, 1, 0, 0); | ||
polyline->SetPoint(2, 2, 1, 0); | ||
polyline->SetPoint(3, 2, 2, 0); | ||
polyline->SetPoint(4, 1, 3, 0); | ||
|
||
vtkNew<vtkRegularPolygonSource> polygon; | ||
polygon->SetGeneratePolyline(false); | ||
polygon->SetCenter(5, 5, 0); | ||
polygon->SetRadius(2); | ||
polygon->SetNumberOfSides(8); | ||
|
||
auto append = ::Append({ ::AddCellScalarArray("0.1", points), | ||
::AddCellScalarArray("0.5", polyline), ::AddCellScalarArray("0.9", polygon) }); | ||
|
||
vtkNew<vtkPolyDataMapper> mapper; | ||
mapper->SetInputConnection(append->GetOutputPort()); | ||
|
||
vtkNew<vtkColorTransferFunction> ctf; | ||
ctf->AddRGBPoint(0.0, 1.0, 0.0, 0.0); | ||
ctf->AddRGBPoint(0.5, 0.0, 0.5, 1.0); | ||
ctf->AddRGBPoint(1.0, 0.0, 1.0, 0.0); | ||
mapper->SetLookupTable(ctf); | ||
|
||
vtkNew<vtkActor> actor; | ||
actor->SetMapper(mapper); | ||
actor->GetProperty()->SetLineWidth(10); | ||
actor->GetProperty()->SetPointSize(20); | ||
|
||
vtkNew<vtkRenderer> renderer; | ||
renderer->AddActor(actor); | ||
renderer->SetBackground(1, 1, 1); | ||
|
||
vtkNew<vtkRenderWindow> renderWindow; | ||
renderWindow->AddRenderer(renderer); | ||
|
||
vtkNew<vtkRenderWindowInteractor> interactor; | ||
interactor->SetRenderWindow(renderWindow); | ||
int retVal = vtkRegressionTestImage(renderWindow); | ||
if (retVal == vtkTesting::DO_INTERACTOR) | ||
{ | ||
interactor->Start(); | ||
} | ||
return retVal == vtkTesting::FAILED ? EXIT_FAILURE : EXIT_SUCCESS; | ||
} |
1 change: 1 addition & 0 deletions
1
Rendering/Core/Testing/Data/Baseline/TestMixedGeometryCellScalars.png.sha512
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2e1784ec9d9aba8f59119c7dcc115371a3343063bcd8fd964ff17c3cd08850cc8527948e6aaa9a03f660fe108bb392ecbad500db46d363a9ae859ed7adb59809 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters