Skip to content
Snippets Groups Projects
Commit 41c1ba6d authored by Tom Clabault's avatar Tom Clabault Committed by Kitware Robot
Browse files

Merge topic 'WebGPUBackfaceCulling'


3adfd2ea Expose FaceCulling property of vtkWebGPUActor

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Merge-request: !11212
parents 44518e15 3adfd2ea
No related branches found
No related tags found
No related merge requests found
## Expose face culling property of vtkWebGPUActor
The support for this property has been added and the mapper now takes it into account for proper rendering.
# (vtk/vtk#19322): Run these tests in CI for wasm with _vtk_test_cxx_wasm_enabled_in_browser=1
# (vtk/vtk#19322): Add baselines for these unit tests
vtk_add_test_cxx(vtkRenderingWebGPUCxxTests tests
TestActorFaceCullingProperty.cxx,NO_DATA
TestCellScalarMappedColors.cxx,NO_DATA,NO_VALID
TestCompositePolyDataMapper.cxx,NO_DATA,NO_VALID
TestComputeDoublePipelineRenderBuffer.cxx,NO_DATA
......
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
* This test ensures that the face culling property of a vtkWebGPUActor is taken into account during
* rendering
*/
#include "vtkActor.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
int TestActorFaceCullingProperty(int argc, char* argv[])
{
vtkNew<vtkSphereSource> sphereSource;
sphereSource->SetPhiResolution(10);
sphereSource->SetThetaResolution(10);
sphereSource->Update();
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(sphereSource->GetOutput());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
actor->GetProperty()->FrontfaceCullingOn();
vtkNew<vtkRenderWindow> renwin;
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->ResetCamera();
renwin->AddRenderer(renderer);
renwin->Render();
int retVal = vtkRegressionTestImageThreshold(renwin, 0.05);
return !retVal;
}
c1e634e12d7cc3272cfab7ea4072441803d1a0893cad1c5768abc33e0f12dbc44c365f64fedab5d72e92895705e3b1ead17816662cd955a10090032cc7ebce80
......@@ -1212,12 +1212,23 @@ void vtkWebGPUPolyDataMapper::SetupGraphicsPipeline(
const int representation = actor->GetProperty()->GetRepresentation();
const std::string reprAsStr = actor->GetProperty()->GetRepresentationAsString();
///@}
if (actor->GetProperty()->GetBackfaceCulling())
{
descriptor.primitive.cullMode = wgpu::CullMode::Back;
}
else if (actor->GetProperty()->GetFrontfaceCulling())
{
descriptor.primitive.cullMode = wgpu::CullMode::Front;
}
if (this->PointPrimitiveBGInfo.VertexCount > 0)
{
std::string info = "primitive=VTK_POINT;representation=" + reprAsStr;
descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
this->PointPrimitiveBGInfo.Pipeline = device.CreateRenderPipeline(&descriptor);
}
if (this->LinePrimitiveBGInfo.VertexCount > 0)
{
std::string info = "primitive=VTK_LINE;representation=" + reprAsStr;
......@@ -1226,6 +1237,7 @@ void vtkWebGPUPolyDataMapper::SetupGraphicsPipeline(
: wgpu::PrimitiveTopology::LineList;
this->LinePrimitiveBGInfo.Pipeline = device.CreateRenderPipeline(&descriptor);
}
if (this->TrianglePrimitiveBGInfo.VertexCount > 0)
{
std::string info = "primitive=VTK_TRIANGLE;representation=" + reprAsStr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment