From ad9995da86a8fb3a933bf77e02d32a423a3bd529 Mon Sep 17 00:00:00 2001 From: Pablo Delgado Date: Mon, 19 Jun 2023 16:57:56 +0200 Subject: [PATCH 1/2] Add command line argument to specify alternative scene --- src/Testing.cpp | 1 + src/Testing.h | 1 + src/main.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Testing.cpp b/src/Testing.cpp index 04df539..d53b29b 100644 --- a/src/Testing.cpp +++ b/src/Testing.cpp @@ -173,6 +173,7 @@ void ProcessCommandLine(int argc, char** argv, donut::app::DeviceCreationParamet ("render-height", "Internal render target height, overrides window size", value(args.renderHeight)) ("save-file", "Save frame to file and exit", value(args.saveFrameFileName)) ("save-frame", "Index of the frame to save, default is 0", value(args.saveFrameIndex)) + ("scene-file", "Name of the scene file in the 'media' folder", value(args.sceneFile)) ("tone-mapping", "Tone mapping toggle", value(ui.enableToneMapping)) ("transparent", "Transparent materials toggle", value(ui.gbufferSettings.enableTransparentGeometry)) ("verbose", "Enable debug log messages", value(args.verbose)) diff --git a/src/Testing.h b/src/Testing.h index 549cfef..de88d06 100644 --- a/src/Testing.h +++ b/src/Testing.h @@ -34,6 +34,7 @@ struct CommandLineArguments bool disableBackgroundOptimization = false; int renderWidth = 0; int renderHeight = 0; + std::string sceneFile = "bistro-rtxdi.scene.json"; }; void ProcessCommandLine(int argc, char** argv, donut::app::DeviceCreationParameters& deviceParams, UIData& ui, CommandLineArguments& args); diff --git a/src/main.cpp b/src/main.cpp index 6f10311..170b047 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -212,7 +212,7 @@ class SceneRenderer : public app::ApplicationBase m_BindlessLayout = GetDevice()->createBindlessLayout(bindlessLayoutDesc); } - std::filesystem::path scenePath = "/media/bistro-rtxdi.scene.json"; + std::filesystem::path scenePath = "/media/" + m_args.sceneFile; m_DescriptorTableManager = std::make_shared(GetDevice(), m_BindlessLayout); From fc4932454ea7e0095d4cf7cd85d744b8d77cbde7 Mon Sep 17 00:00:00 2001 From: Pablo Delgado Date: Mon, 19 Jun 2023 17:03:53 +0200 Subject: [PATCH 2/2] Switch to first available camera after scene load --- src/main.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 170b047..bc01fef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -314,10 +314,27 @@ class SceneRenderer : public app::ApplicationBase m_Scene->FinishedLoading(GetFrameIndex()); - m_Camera.LookAt(float3(-7.688f, 2.0f, 5.594f), float3(-7.3341f, 2.0f, 6.5366f)); - m_Camera.SetMoveSpeed(3.f); - const auto& sceneGraph = m_Scene->GetSceneGraph(); + const auto& cameras = sceneGraph->GetCameras(); + + if (!cameras.empty()) + { + const std::shared_ptr& glTfCam = cameras[0]; + + auto camPos = glTfCam->GetViewToWorldMatrix().transformPoint(dm::float3(0.0f)); + auto camTarget = glTfCam->GetViewToWorldMatrix().transformPoint(dm::float3(0.0f, 0.0f, 1.0f)); + m_Camera.LookAt(camPos, camTarget); + + if (auto glTFPerspectiveCam = std::static_pointer_cast(glTfCam); glTFPerspectiveCam) + { + m_ui.verticalFov = dm::degrees(glTFPerspectiveCam->verticalFov); + } + } + else + { + m_Camera.LookAt(float3(-7.688f, 2.0f, 5.594f), float3(-7.3341f, 2.0f, 6.5366f)); + } + m_Camera.SetMoveSpeed(3.f); for (const auto& pLight : sceneGraph->GetLights()) {