Add per-viewport AOV selection (stageView.py GetRendererAovs port)

Exposes the render delegate's available AOVs in the gear popup under a new
"AOV" sub-menu. Selecting an AOV calls SetRendererAov on the engine and
persists the choice per-viewport in viewport_settings.ini. Switching the
render delegate resets the AOV to "color", matching stageView.py's
_handleRendererChanged. Menu is greyed-out when the delegate reports no AOVs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 03:03:00 +08:00
parent 6adf022c13
commit 862f3c9745
5 changed files with 47 additions and 4 deletions
+22 -4
View File
@@ -167,6 +167,7 @@ void main() { outColor = color; }
UsdSceneRenderer::UsdSceneRenderer()
: m_showGrid(true)
, m_showCameraGuide(false)
, m_currentAov(pxr::TfToken("color"))
, m_aaEnabled(false)
, m_backgroundColor(0.15f, 0.15f, 0.15f)
, m_shadingMode(ShadingMode::SmoothShaded)
@@ -296,8 +297,8 @@ void UsdSceneRenderer::InitRenderer() {
}
LOG_INFO("Selected renderer: " + std::string(m_renderer->GetCurrentRendererId().GetText()));
// Enable AOV "color" (matches stageView._handleRendererChanged)
m_renderer->SetRendererAov(pxr::TfToken("color"));
// Enable AOV (matches stageView._handleRendererChanged; uses saved m_currentAov)
m_renderer->SetRendererAov(m_currentAov);
// Selection highlight color (usdview default: yellow)
m_renderer->SetSelectionColor(pxr::GfVec4f(1.0f, 1.0f, 0.0f, 1.0f));
@@ -342,8 +343,9 @@ bool UsdSceneRenderer::SetRendererPlugin(const pxr::TfToken& pluginId) {
bool ok = m_renderer->SetRendererPlugin(pluginId);
if (ok) {
// Re-enable colour AOV after delegate switch (mirrors usdtweak behaviour)
m_renderer->SetRendererAov(pxr::TfToken("color"));
// Reset AOV to "color" on every delegate switch (mirrors stageView._handleRendererChanged)
m_currentAov = pxr::TfToken("color");
m_renderer->SetRendererAov(m_currentAov);
LOG_INFO("Render delegate switched to: " + std::string(pluginId.GetText()));
} else {
LOG_ERROR("Failed to switch render delegate to: " + std::string(pluginId.GetText()));
@@ -351,6 +353,22 @@ bool UsdSceneRenderer::SetRendererPlugin(const pxr::TfToken& pluginId) {
return ok;
}
pxr::TfTokenVector UsdSceneRenderer::GetRendererAovs() const
{
if (!m_renderer) return {};
return m_renderer->GetRendererAovs();
}
bool UsdSceneRenderer::SetCurrentAov(const pxr::TfToken& aov)
{
if (!m_renderer) return false;
if (m_renderer->SetRendererAov(aov)) {
m_currentAov = aov;
return true;
}
return false;
}
// ===========================================================================
// Camera State
// ===========================================================================
+5
View File
@@ -183,6 +183,10 @@ public:
bool ShowCameraGuide() const { return m_showCameraGuide; }
void SetShowCameraGuide(bool show) { m_showCameraGuide = show; }
const pxr::TfToken& GetCurrentAov() const { return m_currentAov; }
pxr::TfTokenVector GetRendererAovs() const;
bool SetCurrentAov(const pxr::TfToken& aov);
bool GetAAEnabled() const { return m_aaEnabled; }
void SetAAEnabled(bool enabled) { m_aaEnabled = enabled; }
@@ -331,6 +335,7 @@ private:
bool m_showGrid;
bool m_showCameraGuide;
pxr::TfToken m_currentAov;
bool m_aaEnabled; ///< GL_LINE_SMOOTH anti-aliasing for all line overlays
pxr::GfVec3f m_backgroundColor;