Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions include/hvt/engine/framePass.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <hvt/engine/syncDelegate.h>
#include <hvt/engine/taskManager.h>
#include <hvt/engine/viewportEngine.h>
#include <hvt/engine/viewportRect.h>

// clang-format off
#if defined(__clang__)
Expand Down Expand Up @@ -88,9 +87,25 @@ 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 { { { 0, 0 }, { static_cast<float>(width), static_cast<float>(height) } },
{ { 0, 0 }, { width, height } }, 1.0f };
}

/// 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 };
Expand Down Expand Up @@ -309,10 +324,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
Expand Down
4 changes: 2 additions & 2 deletions include/hvt/engine/framePassUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// @}
Expand Down
81 changes: 0 additions & 81 deletions include/hvt/engine/viewportRect.h

This file was deleted.

1 change: 0 additions & 1 deletion source/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions source/engine/framePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/engine/framePassUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand All @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions test/data/baselines/TestFramePasses_DisplayClipping1_osx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions test/data/baselines/TestFramePasses_DisplayClipping2_osx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions test/howTos/howTo02_CreateOneFramePass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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));

Expand Down
29 changes: 15 additions & 14 deletions test/howTos/howTo03_CreateTwoFramePasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include <RenderingFramework/TestContextCreator.h>

#include <hvt/tasks/resources.h>
#include <hvt/engine/viewportEngine.h>
#include <hvt/tasks/resources.h>

#include <pxr/base/plug/registry.h>

Expand Down Expand Up @@ -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.
Expand All @@ -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.

Expand All @@ -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();
Expand Down Expand Up @@ -166,8 +165,10 @@ TEST(howTo, createTwoFramePasses)
auto& params = manipulatorFramePass.sceneFramePass->params();

params.renderBufferSize = pxr::GfVec2i(context->width(), context->height());
params.viewInfo.framing = { { { posX, posY },
{ static_cast<float>(width), static_cast<float>(height) } },
{ { 0, 0 }, { width, height } }, 1.0f };

params.viewInfo.viewport = { { posX, posY }, { width, height } };
params.viewInfo.viewMatrix = stage.viewMatrix();
params.viewInfo.projectionMatrix = stage.projectionMatrix();
params.viewInfo.lights = stage.defaultLights();
Expand Down
3 changes: 2 additions & 1 deletion test/howTos/howTo04_CreateACustomRenderTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion test/howTos/howTo05_UseSSAORenderTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 2 additions & 1 deletion test/howTos/howTo06_UseFXAARenderTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
35 changes: 17 additions & 18 deletions test/howTos/howTo07_UseIncludeExclude.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,29 @@ void CreateTest(const std::shared_ptr<TestHelpers::TestContext>& 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;
};
Expand Down
Loading