diff --git a/include/hvt/engine/framePass.h b/include/hvt/engine/framePass.h index f28debf5..e7dc0ffe 100644 --- a/include/hvt/engine/framePass.h +++ b/include/hvt/engine/framePass.h @@ -22,7 +22,6 @@ #include #include #include -#include // clang-format off #if defined(__clang__) @@ -88,9 +87,24 @@ struct HVT_API ViewParams PXR_NS::GfVec3d cameraPosition; - /// The viewport dimensions including position and size. - /// \note viewport used in HdxRenderTaskParams is a right-down coordinate system - ViewportRect viewport; + /// Defines the framing. + PXR_NS::CameraUtilFraming framing; + + /// Helper to get a default framing. + static PXR_NS::CameraUtilFraming GetDefaultFraming(int width, int height) + { + /// \note This is to display all the render buffer content into the screen. + return GetDefaultFraming(0, 0, width, height); + } + + /// Helper to get a default framing. + static PXR_NS::CameraUtilFraming GetDefaultFraming(int posX, int posY, int width, int height) + { + /// \note This is to display all the render buffer content into the screen potentially + /// moving its origin and resizing it. + return PXR_NS::CameraUtilFraming( + PXR_NS::GfRect2i(PXR_NS::GfVec2i(posX, posY), width, height)); + } bool isOrtho { false }; double cameraDistance { 0.0 }; @@ -309,10 +323,16 @@ class HVT_API FramePass /// \return A collection of parameters that can be set for this frame pass. inline const FramePassParams& params() const { return _passParams; } - /// Gets the viewport dimensions. - virtual const PXR_NS::GfVec4i GetViewport() const + /// Gets the display window position & dimension. + inline const PXR_NS::GfRange2f GetDisplayWindow() const + { + return params().viewInfo.framing.displayWindow; + } + + /// Gets the data window dimension. + inline const PXR_NS::GfRect2i GetDataWindow() const { - return params().viewInfo.viewport.ConvertToVec4i(); + return params().viewInfo.framing.dataWindow; } /// \name Shadows diff --git a/include/hvt/engine/framePassUtils.h b/include/hvt/engine/framePassUtils.h index c5082232..d33db94b 100644 --- a/include/hvt/engine/framePassUtils.h +++ b/include/hvt/engine/framePassUtils.h @@ -28,11 +28,11 @@ namespace HVT_NS /// Returns the first picked prim from a specific frame pass. /// \param pass The selected frame pass. /// \param pickingMatrix The picking matrix. -/// \param viewport The viewport dimensions. +/// \param framing The framing (i.e., data & display windows). /// \param viewMatrix The view matrix. /// \return Returns the first selected prim. HVT_API extern PXR_NS::SdfPath GetPickedPrim(FramePass* pass, - PXR_NS::GfMatrix4d const& pickingMatrix, ViewportRect const& viewport, + PXR_NS::GfMatrix4d const& pickingMatrix, PXR_NS::CameraUtilFraming const& framing, PXR_NS::GfMatrix4d const& viewMatrix); /// @} diff --git a/include/hvt/engine/viewportRect.h b/include/hvt/engine/viewportRect.h deleted file mode 100644 index b34fac9f..00000000 --- a/include/hvt/engine/viewportRect.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2025 Autodesk, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#pragma once - -#include - -// clang-format off -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" -#pragma clang diagnostic ignored "-Wdeprecated-copy" -#pragma clang diagnostic ignored "-Wmissing-field-initializers" -#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#elif defined(_MSC_VER) -#pragma warning(push) -#endif -// clang-format on - -#include -#include -#include - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(_MSC_VER) -#pragma warning(pop) -#endif - -#include - -namespace HVT_NS -{ - -/// Defines the position and size of a viewport on the screen. -struct HVT_API ViewportRect -{ - /// Top left corner of the viewport on the screen. - PXR_NS::GfVec2i position {}; - - /// Width and height of the viewport on the screen. - PXR_NS::GfVec2i size {}; - - /// Returns the viewport rect as a PXR_NS::GfVec4i (x, y, width, height). - PXR_NS::GfVec4i ConvertToVec4i() const - { - return PXR_NS::GfVec4i(position[0], position[1], size[0], size[1]); - } - - /// Returns the viewport rect as a PXR_NS::GfRect2i. - PXR_NS::GfRect2i ConvertToRect2i() const - { - return PXR_NS::GfRect2i(PXR_NS::GfVec2i(position[0], position[1]), size[0], size[1]); - } - - bool operator==(ViewportRect const& rhs) const - { - return position == rhs.position && size == rhs.size; - } - - bool operator!=(ViewportRect const& rhs) const { return !(*this == rhs); } -}; - -/// Operator to stream out the ViewportRect. -HVT_API inline std::ostream& operator<<(std::ostream& out, ViewportRect const& rect) -{ - out << "ViewportRect: Position: " << rect.position << " Size: " << rect.size; - return out; -} - -} // namespace HVT_NS diff --git a/source/engine/CMakeLists.txt b/source/engine/CMakeLists.txt index b06d324b..8a452f3e 100644 --- a/source/engine/CMakeLists.txt +++ b/source/engine/CMakeLists.txt @@ -57,7 +57,6 @@ set(_HEADER_FILES "${_ENGINE_INCLUDE_DIR}/usdStageUtils.h" "${_ENGINE_INCLUDE_DIR}/viewport.h" "${_ENGINE_INCLUDE_DIR}/viewportEngine.h" - "${_ENGINE_INCLUDE_DIR}/viewportRect.h" ) # Define the library. diff --git a/source/engine/framePass.cpp b/source/engine/framePass.cpp index 25fe33b3..7c74a74d 100644 --- a/source/engine/framePass.cpp +++ b/source/engine/framePass.cpp @@ -270,9 +270,7 @@ HdTaskSharedPtrVector FramePass::GetRenderTasks(RenderBufferBindings const& inpu // Sets the framing. // Note: Do not set the viewport as it's deprecated. - - const GfRect2i viewport4d = _passParams.viewInfo.viewport.ConvertToRect2i(); - SetFraming(_passParams.renderParams, CameraUtilFraming(viewport4d), GetRenderIndex()); + SetFraming(_passParams.renderParams, _passParams.viewInfo.framing, GetRenderIndex()); // Set the specified AOV as the one to visualize using the color output. By default this is // the color AOV, with no special transformation performed. For any other AOV, the AOV data is diff --git a/source/engine/framePassUtils.cpp b/source/engine/framePassUtils.cpp index 3d6e790d..7dac52cd 100644 --- a/source/engine/framePassUtils.cpp +++ b/source/engine/framePassUtils.cpp @@ -20,7 +20,7 @@ namespace HVT_NS { SdfPath GetPickedPrim(FramePass* pass, GfMatrix4d const& pickingMatrix, - ViewportRect const& viewport, GfMatrix4d const& viewMatrix) + CameraUtilFraming const& framing, GfMatrix4d const& viewMatrix) { if (!pass || !pass->IsInitialized()) { @@ -30,7 +30,7 @@ SdfPath GetPickedPrim(FramePass* pass, GfMatrix4d const& pickingMatrix, SdfPath hitPrimPath; - pass->params().viewInfo.viewport = viewport; + pass->params().viewInfo.framing = framing; pass->params().viewInfo.viewMatrix = viewMatrix; pass->params().viewInfo.projectionMatrix = pickingMatrix; diff --git a/test/RenderingFramework/MetalTestContext.mm b/test/RenderingFramework/MetalTestContext.mm index effcc51a..343dc953 100644 --- a/test/RenderingFramework/MetalTestContext.mm +++ b/test/RenderingFramework/MetalTestContext.mm @@ -196,7 +196,10 @@ void composeToFrameBuffer( pxr::HgiMetal* hgi = static_cast(_hgi.get()); - const pxr::GfVec4d& renderPassViewport = framePass->GetViewport(); + const pxr::GfVec4d renderPassViewport = { framePass->GetDisplayWindow().GetMin()[0], + framePass->GetDisplayWindow().GetMin()[1], + framePass->GetDisplayWindow().GetSize()[0], + framePass->GetDisplayWindow().GetSize()[1] }; if (!_inFlightSemaphore) { diff --git a/test/RenderingFramework/VulkanTestContext.cpp b/test/RenderingFramework/VulkanTestContext.cpp index 5a778378..d601aa82 100644 --- a/test/RenderingFramework/VulkanTestContext.cpp +++ b/test/RenderingFramework/VulkanTestContext.cpp @@ -730,7 +730,13 @@ void VulkanRendererContext::Composite(hvt::FramePass* framePass) pxr::HgiVulkanTexture* vkTex = static_cast(_finalColorTarget.Get()); VkImage inputColor = vkTex->GetImage(); VkImageLayout inputColorLayout = vkTex->GetImageLayout(); - return Composite(inputColor, inputColorLayout, framePass->GetViewport()); + + const pxr::GfVec4d rect = { framePass->GetDisplayWindow().GetMin()[0], + framePass->GetDisplayWindow().GetMin()[1], + framePass->GetDisplayWindow().GetSize()[0], + framePass->GetDisplayWindow().GetSize()[1] }; + + return Composite(inputColor, inputColorLayout, rect); } } diff --git a/test/data/baselines/TestFramePasses_DisplayClipping1.png b/test/data/baselines/TestFramePasses_DisplayClipping1.png new file mode 100644 index 00000000..e8cb20a5 --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7b8e393750788ec6e5ff2547f022d975be3944db3bd9c6bea922e6f38340f13 +size 4529 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping1_android.png b/test/data/baselines/TestFramePasses_DisplayClipping1_android.png new file mode 100644 index 00000000..69a286fc --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping1_android.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:58be86a0901a763bdf411b5382665d7ec81329c10e8bee3323b88538d1cb0682 +size 4504 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping1_designforipad_ios.png b/test/data/baselines/TestFramePasses_DisplayClipping1_designforipad_ios.png new file mode 100644 index 00000000..d2fd1908 --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping1_designforipad_ios.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21c506b2f8ad23b756c262ad78290e1b26e125b355bff98b88815413fec99a12 +size 4569 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping1_osx.png b/test/data/baselines/TestFramePasses_DisplayClipping1_osx.png new file mode 100644 index 00000000..2c85abd7 --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping1_osx.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6d492c3f4efe9559724c09edb608ccf59dbcf656bf313665bbca70ad0538b6cc +size 4545 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping2.png b/test/data/baselines/TestFramePasses_DisplayClipping2.png new file mode 100644 index 00000000..4ac296d4 --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edc5b8bcf550291ae012d3c4be374583b5db13e956760377395a6775eea80f18 +size 3506 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping2_android.png b/test/data/baselines/TestFramePasses_DisplayClipping2_android.png new file mode 100644 index 00000000..41d33bec --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping2_android.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7dd7647a6faabd0d91b1608276f9c022b5cfdd5615014792913df5efc04674a8 +size 3481 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping2_designforipad_ios.png b/test/data/baselines/TestFramePasses_DisplayClipping2_designforipad_ios.png new file mode 100644 index 00000000..cd1e2e0a --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping2_designforipad_ios.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b458e9f524ed28e0236446aaa8190f502bd2d0064c198dbcaf9a177be8271f53 +size 3431 diff --git a/test/data/baselines/TestFramePasses_DisplayClipping2_osx.png b/test/data/baselines/TestFramePasses_DisplayClipping2_osx.png new file mode 100644 index 00000000..87b61eeb --- /dev/null +++ b/test/data/baselines/TestFramePasses_DisplayClipping2_osx.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed7a3901bc31bdd3f0c26e6b91ff20207a0a0d31af07bdb5192eb477036d6a1f +size 3530 diff --git a/test/howTos/howTo02_CreateOneFramePass.cpp b/test/howTos/howTo02_CreateOneFramePass.cpp index d3696d40..344ffcd7 100644 --- a/test/howTos/howTo02_CreateOneFramePass.cpp +++ b/test/howTos/howTo02_CreateOneFramePass.cpp @@ -71,8 +71,9 @@ TEST(howTo, createOneFramePass) auto& params = sceneFramePass->params(); params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -96,8 +97,8 @@ TEST(howTo, createOneFramePass) // Validates the rendering result. - const std::string imageFile = std::string(test_info_->test_suite_name()) + - std::string("/") + std::string(test_info_->name()); + const std::string imageFile = std::string(test_info_->test_suite_name()) + std::string("/") + + std::string(test_info_->name()); ASSERT_TRUE(context->_backend->saveImage(imageFile)); diff --git a/test/howTos/howTo03_CreateTwoFramePasses.cpp b/test/howTos/howTo03_CreateTwoFramePasses.cpp index e859805e..8bc6e443 100644 --- a/test/howTos/howTo03_CreateTwoFramePasses.cpp +++ b/test/howTos/howTo03_CreateTwoFramePasses.cpp @@ -18,8 +18,8 @@ #include -#include #include +#include #include @@ -72,10 +72,9 @@ TEST(howTo, createTwoFramePasses) // Creates the frame pass instance. hvt::FramePassDescriptor passDesc; - passDesc.renderIndex = mainFramePass.renderIndex->RenderIndex(); - passDesc.uid = pxr::SdfPath("/sceneFramePass"); - mainFramePass.sceneFramePass = - hvt::ViewportEngine::CreateFramePass(passDesc); + passDesc.renderIndex = mainFramePass.renderIndex->RenderIndex(); + passDesc.uid = pxr::SdfPath("/sceneFramePass"); + mainFramePass.sceneFramePass = hvt::ViewportEngine::CreateFramePass(passDesc); } // Defines a secondary frame pass containing a manipulator. @@ -86,8 +85,7 @@ TEST(howTo, createTwoFramePasses) hvt::RendererDescriptor renderDesc; renderDesc.hgiDriver = &context->_backend->hgiDriver(); renderDesc.rendererName = "HdStormRendererPlugin"; - hvt::ViewportEngine::CreateRenderer( - manipulatorFramePass.renderIndex, renderDesc); + hvt::ViewportEngine::CreateRenderer(manipulatorFramePass.renderIndex, renderDesc); // Loads an arbitrary USD asset e.g., a manipulator in this case. @@ -104,24 +102,25 @@ TEST(howTo, createTwoFramePasses) // Creates the frame pass instance. hvt::FramePassDescriptor passDesc; - passDesc.renderIndex = manipulatorFramePass.renderIndex->RenderIndex(); - passDesc.uid = pxr::SdfPath("/sceneFramePass"); - manipulatorFramePass.sceneFramePass = - hvt::ViewportEngine::CreateFramePass(passDesc); + passDesc.renderIndex = manipulatorFramePass.renderIndex->RenderIndex(); + passDesc.uid = pxr::SdfPath("/sceneFramePass"); + manipulatorFramePass.sceneFramePass = hvt::ViewportEngine::CreateFramePass(passDesc); } // Renders 10 times (i.e., arbitrary number to guarantee best result). int frameCount = 10; - auto render = [&]() { + auto render = [&]() + { // Updates the main frame pass. { auto& params = mainFramePass.sceneFramePass->params(); params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -166,8 +165,9 @@ TEST(howTo, createTwoFramePasses) auto& params = manipulatorFramePass.sceneFramePass->params(); params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(posX, posY, width, height); - params.viewInfo.viewport = { { posX, posY }, { width, height } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/howTos/howTo04_CreateACustomRenderTask.cpp b/test/howTos/howTo04_CreateACustomRenderTask.cpp index 4fbe8f5a..ddb2cc46 100644 --- a/test/howTos/howTo04_CreateACustomRenderTask.cpp +++ b/test/howTos/howTo04_CreateACustomRenderTask.cpp @@ -109,8 +109,9 @@ TEST(howTo, createACustomRenderTask) auto& params = sceneFramePass->params(); params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/howTos/howTo05_UseSSAORenderTask.cpp b/test/howTos/howTo05_UseSSAORenderTask.cpp index 52f75da1..cb016128 100644 --- a/test/howTos/howTo05_UseSSAORenderTask.cpp +++ b/test/howTos/howTo05_UseSSAORenderTask.cpp @@ -120,8 +120,9 @@ TEST(howTo, useSSAORenderTask) { auto& params = sceneFramePass->params(); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); diff --git a/test/howTos/howTo06_UseFXAARenderTask.cpp b/test/howTos/howTo06_UseFXAARenderTask.cpp index 64be0b47..85d40784 100644 --- a/test/howTos/howTo06_UseFXAARenderTask.cpp +++ b/test/howTos/howTo06_UseFXAARenderTask.cpp @@ -107,8 +107,9 @@ TEST(howTo, useFXAARenderTask) auto& params = sceneFramePass->params(); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); diff --git a/test/howTos/howTo07_UseIncludeExclude.cpp b/test/howTos/howTo07_UseIncludeExclude.cpp index 983311bb..a12bbfe9 100644 --- a/test/howTos/howTo07_UseIncludeExclude.cpp +++ b/test/howTos/howTo07_UseIncludeExclude.cpp @@ -76,30 +76,29 @@ void CreateTest(const std::shared_ptr& context, auto render = [&]() { // Updates the main frame pass. - { - auto& params = sceneFramePass->params(); + auto& params = sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; - params.viewInfo.viewMatrix = stage.viewMatrix(); - params.viewInfo.projectionMatrix = stage.projectionMatrix(); - params.viewInfo.lights = stage.defaultLights(); - params.viewInfo.material = stage.defaultMaterial(); - params.viewInfo.ambient = stage.defaultAmbient(); + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); - params.colorspace = HdxColorCorrectionTokens->sRGB; - params.backgroundColor = TestHelpers::ColorDarkGrey; - params.selectionColor = TestHelpers::ColorYellow; + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; - params.enablePresentation = context->presentationEnabled(); + params.enablePresentation = context->presentationEnabled(); - // Selects what prims to render. - params.collection = collection; + // Selects what prims to render. + params.collection = collection; - // Renders. - sceneFramePass->Render(); - } + // Renders. + sceneFramePass->Render(); return --frameCount > 0; }; diff --git a/test/howTos/howTo08_UseBoundingBoxSceneIndex.cpp b/test/howTos/howTo08_UseBoundingBoxSceneIndex.cpp index 371e9417..cda29e98 100644 --- a/test/howTos/howTo08_UseBoundingBoxSceneIndex.cpp +++ b/test/howTos/howTo08_UseBoundingBoxSceneIndex.cpp @@ -83,26 +83,25 @@ TEST(howTo, useBoundingBoxSceneIndexFilter) auto render = [&]() { // Updates the main frame pass. - { - auto& params = sceneFramePass->params(); + auto& params = sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; - params.viewInfo.viewMatrix = stage.viewMatrix(); - params.viewInfo.projectionMatrix = stage.projectionMatrix(); - params.viewInfo.lights = stage.defaultLights(); - params.viewInfo.material = stage.defaultMaterial(); - params.viewInfo.ambient = stage.defaultAmbient(); + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); - params.colorspace = HdxColorCorrectionTokens->sRGB; - params.backgroundColor = TestHelpers::ColorDarkGrey; - params.selectionColor = TestHelpers::ColorYellow; + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; - params.enablePresentation = context->presentationEnabled(); + params.enablePresentation = context->presentationEnabled(); - sceneFramePass->Render(); - } + sceneFramePass->Render(); return --frameCount > 0; }; diff --git a/test/howTos/howTo09_UseWireFrameSceneIndex.cpp b/test/howTos/howTo09_UseWireFrameSceneIndex.cpp index f1a1f008..895eee84 100644 --- a/test/howTos/howTo09_UseWireFrameSceneIndex.cpp +++ b/test/howTos/howTo09_UseWireFrameSceneIndex.cpp @@ -85,30 +85,29 @@ TEST(howTo, useWireFrameCollectionRepr) auto render = [&]() { // Updates the main frame pass. - { - auto& params = sceneFramePass->params(); + auto& params = sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; - params.viewInfo.viewMatrix = stage.viewMatrix(); - params.viewInfo.projectionMatrix = stage.projectionMatrix(); - params.viewInfo.lights = stage.defaultLights(); - params.viewInfo.material = stage.defaultMaterial(); - params.viewInfo.ambient = stage.defaultAmbient(); + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); - params.colorspace = HdxColorCorrectionTokens->sRGB; - params.backgroundColor = TestHelpers::ColorDarkGrey; - params.selectionColor = TestHelpers::ColorYellow; + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; - params.enablePresentation = context->presentationEnabled(); + params.enablePresentation = context->presentationEnabled(); - // Changes the geometry representation. - params.collection = - HdRprimCollection(HdTokens->geometry, HdReprSelector(HdReprTokens->wire)); + // Changes the geometry representation. + params.collection = + HdRprimCollection(HdTokens->geometry, HdReprSelector(HdReprTokens->wire)); - sceneFramePass->Render(); - } + sceneFramePass->Render(); return --frameCount > 0; }; @@ -185,26 +184,25 @@ TEST(howTo, useWireFrameSceneIndex) auto render = [&]() { // Updates the main frame pass. - { - auto& params = sceneFramePass->params(); + auto& params = sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; - params.viewInfo.viewMatrix = stage.viewMatrix(); - params.viewInfo.projectionMatrix = stage.projectionMatrix(); - params.viewInfo.lights = stage.defaultLights(); - params.viewInfo.material = stage.defaultMaterial(); - params.viewInfo.ambient = stage.defaultAmbient(); + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); - params.colorspace = HdxColorCorrectionTokens->sRGB; - params.backgroundColor = TestHelpers::ColorDarkGrey; - params.selectionColor = TestHelpers::ColorYellow; + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; - params.enablePresentation = context->presentationEnabled(); + params.enablePresentation = context->presentationEnabled(); - sceneFramePass->Render(); - } + sceneFramePass->Render(); return --frameCount > 0; }; diff --git a/test/howTos/howTo10_CustomListOfTasks.cpp b/test/howTos/howTo10_CustomListOfTasks.cpp index b1929c55..2a15542d 100644 --- a/test/howTos/howTo10_CustomListOfTasks.cpp +++ b/test/howTos/howTo10_CustomListOfTasks.cpp @@ -84,8 +84,9 @@ TEST(howTo, createDefaultListOfTasks) auto& params = framePass->params(); params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -184,8 +185,9 @@ TEST(howTo, createDefaultListOfTasks2) auto& params = framePass->params(); params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -280,8 +282,9 @@ TEST(howTo, createMinimalListOfTasks) auto& params = framePass->params(); params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/howTos/howTo11_UseSkyDomeTask.cpp b/test/howTos/howTo11_UseSkyDomeTask.cpp index 0a546e30..a9504c60 100644 --- a/test/howTos/howTo11_UseSkyDomeTask.cpp +++ b/test/howTos/howTo11_UseSkyDomeTask.cpp @@ -110,8 +110,9 @@ TEST(howTo, useSkyDomeTask) auto& params = sceneFramePass->params(); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); diff --git a/test/tests/composeTaskHelpers.cpp b/test/tests/composeTaskHelpers.cpp index 8c1f3e13..a5585c5f 100644 --- a/test/tests/composeTaskHelpers.cpp +++ b/test/tests/composeTaskHelpers.cpp @@ -72,8 +72,10 @@ void RenderFirstFramePass(TestHelpers::FramePassInstance& framePass1, int width, { hvt::FramePassParams& params = framePass1.sceneFramePass->params(); - params.renderBufferSize = GfVec2i(width, height); - params.viewInfo.viewport = { { 0, 0 }, { width, height } }; + params.renderBufferSize = GfVec2i(width, height); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width, height); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -99,8 +101,9 @@ void RenderSecondFramePass(TestHelpers::FramePassInstance& framePass2, int width auto& params = framePass2.sceneFramePass->params(); params.renderBufferSize = GfVec2i(width, height); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width, height); - params.viewInfo.viewport = { { 0, 0 }, { width, height } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/tests/testComposeTask.cpp b/test/tests/testComposeTask.cpp index 0dfd5fb5..cd0f7281 100644 --- a/test/tests/testComposeTask.cpp +++ b/test/tests/testComposeTask.cpp @@ -95,8 +95,10 @@ TEST(TestViewportToolbox, compose_ComposeTask) { hvt::FramePassParams& params = framePass2.sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -190,8 +192,10 @@ TEST(TestViewportToolbox, compose_ShareTextures) { hvt::FramePassParams& params = framePass2.sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/tests/testFramePass.cpp b/test/tests/testFramePass.cpp index f3fe81cb..0986c1b4 100644 --- a/test/tests/testFramePass.cpp +++ b/test/tests/testFramePass.cpp @@ -205,8 +205,9 @@ void TestDynamicFramePassParams( auto& params = sceneFramePass->params(); params.renderBufferSize = renderSize; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(renderSize[0], renderSize[1]); - params.viewInfo.viewport = { { 0, 0 }, renderSize }; params.viewInfo.viewMatrix = viewMatrix; params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = lights; @@ -411,9 +412,11 @@ TEST(TestViewportToolbox, TestFramePassSelectionSettingsProvider) // Simulate what happens during a render. - FramePass updates provider settings GfVec2i renderSize(testContext->width(), testContext->height()); + framePassParams.renderBufferSize = renderSize; + framePassParams.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(renderSize[0], renderSize[1]); - framePassParams.viewInfo.viewport = { { 0, 0 }, renderSize }; framePassParams.viewInfo.viewMatrix = stage.viewMatrix(); framePassParams.viewInfo.projectionMatrix = stage.projectionMatrix(); framePassParams.viewInfo.lights = stage.defaultLights(); diff --git a/test/tests/testFramePasses.cpp b/test/tests/testFramePasses.cpp index 269d7d02..b87fbe1f 100644 --- a/test/tests/testFramePasses.cpp +++ b/test/tests/testFramePasses.cpp @@ -73,8 +73,10 @@ TEST(TestViewportToolbox, TestFramePasses_MainOnly) { hvt::FramePassParams& params = _sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -182,8 +184,10 @@ TEST(TestViewportToolbox, TestFramePasses_MainWithBlur) auto& params = _sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -291,8 +295,10 @@ TEST(TestViewportToolbox, TestFramePasses_MainWithFxaa) auto& params = _sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -373,8 +379,10 @@ TEST(TestViewportToolbox, TestFramePasses_SceneIndex) hvt::FramePassParams& params = sceneFramePass->params(); - params.renderBufferSize = GfVec2i(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; + params.renderBufferSize = pxr::GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); + params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); @@ -461,7 +469,9 @@ TEST(TestViewportToolbox, TestFramePasses_MultiViewports) params.renderBufferSize = GfVec2i(width, height); // To display on the left part of the viewport. - params.viewInfo.viewport = { { 0, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, height); + params.viewInfo.viewMatrix = stage1.viewMatrix(); params.viewInfo.projectionMatrix = stage1.projectionMatrix(); params.viewInfo.lights = stage1.defaultLights(); @@ -497,7 +507,9 @@ TEST(TestViewportToolbox, TestFramePasses_MultiViewports) params.renderBufferSize = GfVec2i(width, height); // To display on the right part of the viewport. - params.viewInfo.viewport = { { width / 2, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, 0, width / 2, height); + params.viewInfo.viewMatrix = stage2.viewMatrix(); params.viewInfo.projectionMatrix = stage2.projectionMatrix(); params.viewInfo.lights = stage2.defaultLights(); @@ -583,7 +595,9 @@ TEST(TestViewportToolbox, TestFramePasses_MultiViewportsClearDepth) params.renderBufferSize = GfVec2i(width, height); // To display on the left part of the viewport. - params.viewInfo.viewport = { { 0, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, height); + params.viewInfo.viewMatrix = stage1.viewMatrix(); params.viewInfo.projectionMatrix = stage1.projectionMatrix(); params.viewInfo.lights = stage1.defaultLights(); @@ -622,7 +636,9 @@ TEST(TestViewportToolbox, TestFramePasses_MultiViewportsClearDepth) params.renderBufferSize = GfVec2i(width, height); // To display on the right part of the viewport. - params.viewInfo.viewport = { { width / 2, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, 0, width / 2, height); + params.viewInfo.viewMatrix = stage2.viewMatrix(); params.viewInfo.projectionMatrix = stage2.projectionMatrix(); params.viewInfo.lights = stage2.defaultLights(); @@ -708,7 +724,9 @@ TEST(TestViewportToolbox, TestFramePasses_TestDynamicAovInputs) params.renderBufferSize = GfVec2i(width, height); // To display on the left part of the viewport. - params.viewInfo.viewport = { { 0, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, height); + params.viewInfo.viewMatrix = stage1.viewMatrix(); params.viewInfo.projectionMatrix = stage1.projectionMatrix(); params.viewInfo.lights = stage1.defaultLights(); @@ -748,7 +766,9 @@ TEST(TestViewportToolbox, TestFramePasses_TestDynamicAovInputs) params.renderBufferSize = GfVec2i(width, height); // To display on the right part of the viewport. - params.viewInfo.viewport = { { width / 2, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, 0, width / 2, height); + params.viewInfo.viewMatrix = stage2.viewMatrix(); params.viewInfo.projectionMatrix = stage2.projectionMatrix(); params.viewInfo.lights = stage2.defaultLights(); @@ -833,7 +853,8 @@ TEST(TestViewportToolbox, TestFramePasses_ClearDepthBuffer) params.renderBufferSize = GfVec2i(width, height); // To display on the left part of the viewport. - params.viewInfo.viewport = { { 0, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, height); params.viewInfo.viewMatrix = stage1.viewMatrix(); params.viewInfo.projectionMatrix = stage1.projectionMatrix(); params.viewInfo.lights = stage1.defaultLights(); @@ -872,7 +893,8 @@ TEST(TestViewportToolbox, TestFramePasses_ClearDepthBuffer) params.renderBufferSize = GfVec2i(width, height); // To display on the right part of the viewport. - params.viewInfo.viewport = { { width / 2, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, 0, width / 2, height); params.viewInfo.viewMatrix = stage2.viewMatrix(); params.viewInfo.projectionMatrix = stage2.projectionMatrix(); params.viewInfo.lights = stage2.defaultLights(); @@ -968,7 +990,8 @@ TEST(TestViewportToolbox, TestFramePasses_ClearColorBuffer) params.renderBufferSize = GfVec2i(width, height); // To display on the left part of the viewport. - params.viewInfo.viewport = { { 0, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, height); params.viewInfo.viewMatrix = stage1.viewMatrix(); params.viewInfo.projectionMatrix = stage1.projectionMatrix(); params.viewInfo.lights = stage1.defaultLights(); @@ -1007,7 +1030,8 @@ TEST(TestViewportToolbox, TestFramePasses_ClearColorBuffer) params.renderBufferSize = GfVec2i(width, height); // To display on the right part of the viewport. - params.viewInfo.viewport = { { width / 2, 0 }, { width / 2, height } }; + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(width / 2, 0, width / 2, height); params.viewInfo.viewMatrix = stage2.viewMatrix(); params.viewInfo.projectionMatrix = stage2.projectionMatrix(); params.viewInfo.lights = stage2.defaultLights(); @@ -1052,3 +1076,134 @@ TEST(TestViewportToolbox, TestFramePasses_ClearColorBuffer) ASSERT_TRUE(context->_backend->compareImages(imageFile)); } + +TEST(TestViewportToolbox, TestFramePasses_DisplayClipping1) +{ + // This unit test uses a frame pass to only display a part of the USD 3D model. + + auto context = TestHelpers::CreateTestContext(); + + TestHelpers::TestStage stage(context->_backend); + ASSERT_TRUE(stage.open(context->_sceneFilepath)); + + TestHelpers::FramePassInstance framePass = + TestHelpers::FramePassInstance::CreateInstance(stage.stage(), context->_backend); + + // Render 10 times (i.e., arbitrary number to guaranty best result). + int frameCount = 10; + + auto render = [&]() + { + hvt::FramePassParams& params = framePass.sceneFramePass->params(); + + const auto width = context->width(); + const auto height = context->height(); + + params.renderBufferSize = pxr::GfVec2i(width, height); + // Takes all the rendered image but only displays the left part. + params.viewInfo.framing = { + // Data window: full render buffer. + { { 0, 0 }, { static_cast(width), static_cast(height) } }, + // Display window: left part only. + { { 0, 0 }, { width / 2, height } }, + 1.0f + }; + + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); + + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; + + params.enablePresentation = context->presentationEnabled(); + + framePass.sceneFramePass->Render(); + + return --frameCount > 0; + }; + + // Run the render loop. + + context->run(render, framePass.sceneFramePass.get()); + + // Validate the rendering result. + + const std::string imageFile = std::string(test_info_->name()); + ASSERT_TRUE(context->_backend->saveImage(imageFile)); + + ASSERT_TRUE(context->_backend->compareImages(imageFile)); +} + +TEST(TestViewportToolbox, TestFramePasses_DisplayClipping2) +{ + // This unit test uses a frame pass to display only the center quarter of the USD 3D model + // with additional offset, creating a more complex clipping scenario. + + auto context = TestHelpers::CreateTestContext(); + + TestHelpers::TestStage stage(context->_backend); + ASSERT_TRUE(stage.open(context->_sceneFilepath)); + + TestHelpers::FramePassInstance framePass = + TestHelpers::FramePassInstance::CreateInstance(stage.stage(), context->_backend); + + // Renders 10 times (i.e., arbitrary number to guarantee best result). + int frameCount = 10; + + auto render = [&]() + { + hvt::FramePassParams& params = framePass.sceneFramePass->params(); + + const auto width = context->width(); + const auto height = context->height(); + + params.renderBufferSize = pxr::GfVec2i(width, height); + + // More complex clipping: Display only the center quarter with a slight offset + // Render buffer covers the full image size. + // Display region shows a quarter-size window offset slightly from center. + const int quarterWidth = width / 4; + const int quarterHeight = height / 4; + const int offsetX = width / 3; // Offset from left (33% from left edge) + const int offsetY = height / 3; // Offset from top (33% from top edge) + + params.viewInfo.framing = { + // Data window: full render buffer. + { { 0, 0 }, { static_cast(width), static_cast(height) } }, + // Display window: center quarter with offset. + { { offsetX, offsetY }, { offsetX + quarterWidth, offsetY + quarterHeight } }, + 1.0f + }; + + params.viewInfo.viewMatrix = stage.viewMatrix(); + params.viewInfo.projectionMatrix = stage.projectionMatrix(); + params.viewInfo.lights = stage.defaultLights(); + params.viewInfo.material = stage.defaultMaterial(); + params.viewInfo.ambient = stage.defaultAmbient(); + + params.colorspace = HdxColorCorrectionTokens->sRGB; + params.backgroundColor = TestHelpers::ColorDarkGrey; + params.selectionColor = TestHelpers::ColorYellow; + + params.enablePresentation = context->presentationEnabled(); + + framePass.sceneFramePass->Render(); + + return --frameCount > 0; + }; + + // Run the render loop. + + context->run(render, framePass.sceneFramePass.get()); + + // Validate the rendering result. + + const std::string imageFile = std::string(test_info_->name()); + ASSERT_TRUE(context->_backend->saveImage(imageFile)); + + ASSERT_TRUE(context->_backend->compareImages(imageFile)); +} diff --git a/test/tests/testSearches.cpp b/test/tests/testSearches.cpp index a6b078a5..fd8721e7 100644 --- a/test/tests/testSearches.cpp +++ b/test/tests/testSearches.cpp @@ -66,8 +66,9 @@ FramePassInstance _CreateFramePass( auto& params = frameInst.framePass->params(); params.renderBufferSize = GfVec2i(context->width(), context->height()); + params.viewInfo.framing = + hvt::ViewParams::GetDefaultFraming(context->width(), context->height()); - params.viewInfo.viewport = { { 0, 0 }, { context->width(), context->height() } }; params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix(); params.viewInfo.lights = stage.defaultLights(); diff --git a/test/tests/testTaskManager.cpp b/test/tests/testTaskManager.cpp index 51fba70d..a0cc5c0f 100644 --- a/test/tests/testTaskManager.cpp +++ b/test/tests/testTaskManager.cpp @@ -84,11 +84,11 @@ TEST(TestViewportToolbox, TestTaskManager) // Lets define the application parameters. struct AppParams { - hvt::ViewportRect viewport; + PXR_NS::CameraUtilFraming framing; float blur { 3.25f }; //... } app; - app.viewport = { { 0, 0 }, { testContext->width(), testContext->height() } }; + app.framing = hvt::ViewParams::GetDefaultFraming(testContext->width(), testContext->height()); auto renderBufferAccessor = framePass->GetRenderBufferAccessor(); auto lightingAccessor = framePass->GetLightingAccessor(); @@ -152,8 +152,8 @@ TEST(TestViewportToolbox, TestTaskManager) // Updates the frame pass parameters (in case of app resize for example). hvt::FramePassParams& params = framePass->params(); - params.viewInfo.viewport = app.viewport; - params.renderBufferSize = GfVec2i(testContext->width(), testContext->height()); + params.viewInfo.framing = app.framing; + params.renderBufferSize = GfVec2i(testContext->width(), testContext->height()); params.viewInfo.viewMatrix = stage.viewMatrix(); params.viewInfo.projectionMatrix = stage.projectionMatrix();