Skip to content

Commit 8255a98

Browse files
favreaujeffamstutz
authored andcommitted
Add AOV visualization to offline render settings
1 parent 25ae753 commit 8255a98

File tree

5 files changed

+78
-0
lines changed

5 files changed

+78
-0
lines changed

tsd/apps/tools/tsdRender.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <tsd/core/scene/Scene.hpp>
77
// tsd_rendering
88
#include <tsd/rendering/pipeline/RenderPipeline.h>
9+
#include <tsd/rendering/pipeline/passes/VisualizeAOVPass.h>
910
#include <tsd/rendering/index/RenderIndexAllLayers.hpp>
1011
#include <tsd/rendering/view/ManipulatorToAnari.hpp>
1112
// tsd_app
@@ -253,6 +254,22 @@ static void setupRenderPipeline()
253254
arp->setCamera(g_camera);
254255
arp->setRunAsync(false);
255256

257+
// Add AOV visualization pass if enabled
258+
if (g_core->offline.aov.aovType != tsd::rendering::AOVType::NONE) {
259+
auto *aovPass =
260+
g_renderPipeline->emplace_back<tsd::rendering::VisualizeAOVPass>();
261+
aovPass->setAOVType(g_core->offline.aov.aovType);
262+
aovPass->setDepthRange(
263+
g_core->offline.aov.depthMin, g_core->offline.aov.depthMax);
264+
265+
// Enable necessary frame channels
266+
if (g_core->offline.aov.aovType == tsd::rendering::AOVType::ALBEDO) {
267+
arp->setEnableAlbedo(true);
268+
} else if (g_core->offline.aov.aovType == tsd::rendering::AOVType::NORMAL) {
269+
arp->setEnableNormals(true);
270+
}
271+
}
272+
256273
anari::release(g_device, r);
257274

258275
g_timer.end();

tsd/src/tsd/app/Core.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,11 @@ void OfflineRenderSequenceConfig::saveSettings(tsd::core::DataNode &root)
750750
auto &outputRoot = root["output"];
751751
outputRoot["outputDirectory"] = output.outputDirectory;
752752
outputRoot["filePrefix"] = output.filePrefix;
753+
754+
auto &aovRoot = root["aov"];
755+
aovRoot["aovType"] = static_cast<int>(aov.aovType);
756+
aovRoot["depthMin"] = aov.depthMin;
757+
aovRoot["depthMax"] = aov.depthMax;
753758
}
754759

755760
void OfflineRenderSequenceConfig::loadSettings(tsd::core::DataNode &root)
@@ -786,6 +791,13 @@ void OfflineRenderSequenceConfig::loadSettings(tsd::core::DataNode &root)
786791
auto &outputRoot = root["output"];
787792
outputRoot["outputDirectory"].getValue(ANARI_STRING, &output.outputDirectory);
788793
outputRoot["filePrefix"].getValue(ANARI_STRING, &output.filePrefix);
794+
795+
auto &aovRoot = root["aov"];
796+
int aovTypeInt = static_cast<int>(aov.aovType);
797+
aovRoot["aovType"].getValue(ANARI_INT32, &aovTypeInt);
798+
aov.aovType = static_cast<tsd::rendering::AOVType>(aovTypeInt);
799+
aovRoot["depthMin"].getValue(ANARI_FLOAT32, &aov.depthMin);
800+
aovRoot["depthMax"].getValue(ANARI_FLOAT32, &aov.depthMax);
789801
}
790802

791803
} // namespace tsd::app

tsd/src/tsd/app/Core.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "tsd/core/scene/Scene.hpp"
99
// tsd_rendering
1010
#include "tsd/rendering/index/RenderIndex.hpp"
11+
#include "tsd/rendering/pipeline/passes/VisualizeAOVPass.h"
1112
#include "tsd/rendering/view/Manipulator.hpp"
1213
// std
1314
#include <map>
@@ -196,6 +197,13 @@ struct OfflineRenderSequenceConfig
196197
std::string filePrefix{"frame_"};
197198
} output;
198199

200+
struct AOVSettings
201+
{
202+
tsd::rendering::AOVType aovType{tsd::rendering::AOVType::NONE};
203+
float depthMin{0.f};
204+
float depthMax{1.f};
205+
} aov;
206+
199207
void saveSettings(tsd::core::DataNode &root);
200208
void loadSettings(tsd::core::DataNode &root);
201209
};

tsd/src/tsd/app/renderAnimationSequence.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// tsd_rendering
1010
#include "tsd/rendering/index/RenderIndex.hpp"
1111
#include "tsd/rendering/pipeline/RenderPipeline.h"
12+
#include "tsd/rendering/pipeline/passes/VisualizeAOVPass.h"
1213
// std
1314
#include <filesystem>
1415
#include <iomanip>
@@ -95,6 +96,21 @@ static OfflineRenderRig setupRig(tsd::app::Core &core)
9596
rig.anariPass->setRenderer(r);
9697
rig.anariPass->setCamera(c);
9798

99+
// Add AOV visualization pass if enabled
100+
if (config.aov.aovType != tsd::rendering::AOVType::NONE) {
101+
auto *aovPass =
102+
rig.pipeline->emplace_back<tsd::rendering::VisualizeAOVPass>();
103+
aovPass->setAOVType(config.aov.aovType);
104+
aovPass->setDepthRange(config.aov.depthMin, config.aov.depthMax);
105+
106+
// Enable necessary frame channels
107+
if (config.aov.aovType == tsd::rendering::AOVType::ALBEDO) {
108+
rig.anariPass->setEnableAlbedo(true);
109+
} else if (config.aov.aovType == tsd::rendering::AOVType::NORMAL) {
110+
rig.anariPass->setEnableNormals(true);
111+
}
112+
}
113+
98114
rig.saveToFilePass->setEnabled(true);
99115
rig.saveToFilePass->setSingleShotMode(false);
100116

tsd/src/tsd/ui/imgui/modals/AppSettingsDialog.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,31 @@ void AppSettingsDialog::buildUI_offlineRenderSettings()
266266
ImGui::Unindent(tsd::ui::INDENT_AMOUNT);
267267
}
268268

269+
// AOV Visualization //
270+
271+
ImGui::Separator();
272+
ImGui::Text("==== AOV Visualization ====");
273+
274+
const char *aovItems[] = {"none", "depth", "albedo", "normal"};
275+
int aovIdx = static_cast<int>(core->offline.aov.aovType);
276+
if (ImGui::Combo("AOV type", &aovIdx, aovItems, IM_ARRAYSIZE(aovItems))) {
277+
core->offline.aov.aovType = static_cast<tsd::rendering::AOVType>(aovIdx);
278+
}
279+
280+
ImGui::BeginDisabled(
281+
core->offline.aov.aovType != tsd::rendering::AOVType::DEPTH);
282+
ImGui::DragFloat("depth min",
283+
&core->offline.aov.depthMin,
284+
0.1f,
285+
0.f,
286+
core->offline.aov.depthMax);
287+
ImGui::DragFloat("depth max",
288+
&core->offline.aov.depthMax,
289+
0.1f,
290+
core->offline.aov.depthMin,
291+
1e20f);
292+
ImGui::EndDisabled();
293+
269294
ImGui::Unindent(tsd::ui::INDENT_AMOUNT);
270295
}
271296

0 commit comments

Comments
 (0)