Skip to content
Snippets Groups Projects
Commit 0045b5d3 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot
Browse files

Merge topic 'backport-value-pass-depth-fix' into release


48409bc7 ci: exclude TestValuePassFloatingPoint2 from wasm builds
0a2d8407 Add second test for floating point vtkValuePass
3d4f3213 vtkValuePass: save and restores GL state to fix rendering issues

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Reviewed-by: default avatarJaswant Panchumarti (Kitware) <jaswant.panchumarti@kitware.com>
Merge-request: !11963
parents 24ddf57f 48409bc7
No related branches found
No related tags found
No related merge requests found
...@@ -570,6 +570,7 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "^wasm(32|64)") ...@@ -570,6 +570,7 @@ if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "^wasm(32|64)")
"^VTK::RenderingOpenGL2Cxx-TestTexture16Bits$" "^VTK::RenderingOpenGL2Cxx-TestTexture16Bits$"
"^VTK::RenderingOpenGL2Cxx-TestTextureBufferEmulation$" "^VTK::RenderingOpenGL2Cxx-TestTextureBufferEmulation$"
"^VTK::RenderingOpenGL2Cxx-TestValuePassFloatingPoint$" "^VTK::RenderingOpenGL2Cxx-TestValuePassFloatingPoint$"
"^VTK::RenderingOpenGL2Cxx-TestValuePassFloatingPoint2$"
"^VTK::RenderingOpenGL2Cxx-TestVBOPLYMapper$" "^VTK::RenderingOpenGL2Cxx-TestVBOPLYMapper$"
"^VTK::RenderingOpenGL2Cxx-TestWindowBlits$") "^VTK::RenderingOpenGL2Cxx-TestWindowBlits$")
endif () endif ()
......
...@@ -122,6 +122,7 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests ...@@ -122,6 +122,7 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests
TestUserShader2.cxx TestUserShader2.cxx
TestUserShader2D.cxx,NO_DATA TestUserShader2D.cxx,NO_DATA
TestValuePassFloatingPoint.cxx TestValuePassFloatingPoint.cxx
TestValuePassFloatingPoint2.cxx
TestVBOPLYMapper.cxx TestVBOPLYMapper.cxx
TestVBOPointsLines.cxx TestVBOPointsLines.cxx
TestWindowBlits.cxx TestWindowBlits.cxx
......
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
// Description:
// Tests vtkValuePass in FLOATING_POINT mode and ensures the depth test is enabled.
// Renders a scalar from a polydata into a float buffer.
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCameraPass.h"
#include "vtkFloatArray.h"
#include "vtkImageActor.h"
#include "vtkImageData.h"
#include "vtkImageMapToColors.h"
#include "vtkImageSliceMapper.h"
#include "vtkLookupTable.h"
#include "vtkNamedColors.h"
#include "vtkNew.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderPassCollection.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSequencePass.h"
#include "vtkSuperquadricSource.h"
#include "vtkValuePass.h"
#include <iostream>
#include <string>
int TestValuePassFloatingPoint2(int, char*[])
{
vtkNew<vtkSuperquadricSource> torusSource;
torusSource->SetToroidal(1);
// Render the scalar into an image
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(torusSource->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer);
renWin->SetMultiSamples(0);
vtkNew<vtkRenderWindowInteractor> iRen;
iRen->SetRenderWindow(renWin);
renderer->ResetCamera();
vtkNew<vtkValuePass> valuePass;
valuePass->SetInputArrayToProcess(VTK_SCALAR_MODE_USE_POINT_FIELD_DATA, "TextureCoords");
valuePass->SetInputComponentToProcess(0);
vtkNew<vtkRenderPassCollection> passes;
passes->AddItem(valuePass);
vtkNew<vtkSequencePass> sequence;
sequence->SetPasses(passes);
vtkNew<vtkCameraPass> cameraPass;
cameraPass->SetDelegatePass(sequence);
renderer->SetPass(cameraPass);
renWin->Render();
// Get the rendered image
vtkFloatArray* renderedArray = valuePass->GetFloatImageDataArray(renderer);
int* ext = valuePass->GetFloatImageExtents();
renderedArray->SetName("FloatArray");
vtkNew<vtkImageData> image;
image->SetExtent(ext);
image->GetPointData()->SetScalars(renderedArray);
// Now that the floating point array has been rendered, remove the renderer.
renWin->RemoveRenderer(renderer);
// Sow the rendered image on the screen
vtkNew<vtkLookupTable> lut;
lut->SetHueRange(0.6, 0);
lut->SetSaturationRange(1.0, 0);
lut->SetValueRange(0.5, 1.0);
lut->SetTableRange(image->GetScalarRange());
vtkNew<vtkImageMapToColors> mapColors;
mapColors->SetLookupTable(lut);
mapColors->SetInputDataObject(image);
vtkNew<vtkImageActor> imageActor;
imageActor->GetMapper()->SetInputConnection(mapColors->GetOutputPort());
vtkNew<vtkRenderer> newRenderer;
newRenderer->AddActor(imageActor);
vtkNew<vtkNamedColors> colors;
newRenderer->SetBackground(colors->GetColor3d("DarkSlateGray").GetData());
renWin->AddRenderer(newRenderer);
renWin->SetWindowName("RenderScalarToFloatBuffer");
renWin->Render();
iRen->Start();
return EXIT_SUCCESS;
}
2849d4a4621bda85ad65ab1d529eca8ec3162f7fd096a5ba601ad8b5f05c922664e7a52687212647f5c9bd529036ccf8e79869059ea200bf9dc9db996d9954b2
...@@ -31,6 +31,7 @@ PRIVATE_DEPENDS ...@@ -31,6 +31,7 @@ PRIVATE_DEPENDS
VTK::vtksys VTK::vtksys
VTK::nlohmannjson VTK::nlohmannjson
TEST_DEPENDS TEST_DEPENDS
VTK::CommonColor
VTK::CommonSystem VTK::CommonSystem
VTK::FiltersExtraction VTK::FiltersExtraction
VTK::FiltersGeneral VTK::FiltersGeneral
......
...@@ -621,6 +621,13 @@ bool vtkValuePass::InitializeFBO(vtkRenderer* ren) ...@@ -621,6 +621,13 @@ bool vtkValuePass::InitializeFBO(vtkRenderer* ren)
this->ImplFloat->ValueFBO = vtkOpenGLFramebufferObject::New(); this->ImplFloat->ValueFBO = vtkOpenGLFramebufferObject::New();
this->ImplFloat->ValueFBO->SetContext(renWin); this->ImplFloat->ValueFBO->SetContext(renWin);
renWin->GetState()->PushFramebufferBindings(); renWin->GetState()->PushFramebufferBindings();
// vtkOpenGLFramebufferObject::InitializeViewport disables blending, scissor test and
// depth test. Save and restore them in scoped variables.
vtkOpenGLState* glstate = renWin->GetState();
vtkOpenGLState::ScopedglEnableDisable blendState(glstate, GL_BLEND);
vtkOpenGLState::ScopedglEnableDisable depthTestState(glstate, GL_DEPTH_TEST);
vtkOpenGLState::ScopedglEnableDisable scissorTestState(glstate, GL_SCISSOR_TEST);
this->ImplFloat->ValueFBO->Bind(); this->ImplFloat->ValueFBO->Bind();
this->ImplFloat->ValueFBO->InitializeViewport(size[0], size[1]); this->ImplFloat->ValueFBO->InitializeViewport(size[0], size[1]);
/* GL_COLOR_ATTACHMENT0 */ /* GL_COLOR_ATTACHMENT0 */
...@@ -635,7 +642,7 @@ bool vtkValuePass::InitializeFBO(vtkRenderer* ren) ...@@ -635,7 +642,7 @@ bool vtkValuePass::InitializeFBO(vtkRenderer* ren)
return false; return false;
} }
renWin->GetState()->PopFramebufferBindings(); glstate->PopFramebufferBindings();
this->ImplFloat->FBOAllocated = true; this->ImplFloat->FBOAllocated = true;
return true; return true;
......
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