Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SceneGlobalsSceneIndex blocks ActiveRenderSettingsPrimPath #3367

Open
robp-sidefx opened this issue Oct 17, 2024 · 4 comments
Open

SceneGlobalsSceneIndex blocks ActiveRenderSettingsPrimPath #3367

robp-sidefx opened this issue Oct 17, 2024 · 4 comments

Comments

@robp-sidefx
Copy link

In UsdImagingGLEngine::PrepareBatch there's the following:

            if (_GetUseSceneIndices()) {
                TF_VERIFY(_stageSceneIndex);
                _stageSceneIndex->SetStage(stage);
                ...
            } else {
                ...
                // This is only necessary when using the legacy scene delegate.
                // The stage scene index provides this functionality.
                _SetActiveRenderSettingsPrimFromStageMetadata(stage);
            }

The comment is not wrong, as the StageSceneIndex does indeed populate this data, but the problem is that the SceneGlobalsSceneIndex (which is an "expected" part of the Hydra pipeline for all renderers) effectively masks the data set upstream.

HdsiSceneGlobalsSceneIndex::GetPrim() returns a prim based on a _SceneGlobalsDataSource which goes back to the Scene Index and just returns a cached value. This works fine if there was an explicit call made to HdsiSceneGlobalsSceneIndex::SetActiveRenderSettingsPrimPath() (as is the case when _GetUseSceneIndices() is false), but otherwise the cached value is an empty SdfPath rather than the path already stored on the input scene index.

Example of a USD scene with stage metadata set, loaded in USD with and without the Stage Scene Index:
rsIssue

@jesschimein
Copy link
Collaborator

Filed as internal issue #USD-10321

@robp-sidefx
Copy link
Author

I was going to try and put together a PR for this, as it felt like something easy enough to fix, but I found myself struggling over "what's the right workflow?". Given that the metadata can be in the USD Stage, and the Stage Scene Index will author it for Hydra, I question why the Scene Globals Scene Index provides an API for application-level control to set/modify the data. Let's for now proceed with the assumption that this is useful/powerful, and then I'm stuck on "what if the Stage says 'settings X' and the application says 'settings Y'?" and "what if the Stage then changes its metadata?" and "what if the application then changes its opinon?"

@blevin
Copy link
Member

blevin commented Jan 17, 2025

Hi Rob, I believe the intended use here is that the app will use this API to configure Hydra to use the appropriate render settings. Apps using USD to specify this will consult the stage metadata first, but also allow the users to specify an override (ex: when choosing to render a surface vs. volume pass).

An example of this is in usdrecord where it consults both the stage metadata and command-line arguments to determine which render settings prim to use:

https://github.com/PixarAnimationStudios/OpenUSD/blob/release/pxr/usdImaging/bin/usdrecord/usdrecord.py#L219

That rsPrimPath is subsequently passed to the HdsiSceneGlobalsSceneIndex via the FrameRecorder and then UsdImagingGLEngine::SetActiveRenderSettingsPrimPath().

hope this helps,
-B

@robp-sidefx
Copy link
Author

Thanks Brett, that seems sensible enough, but then I question whether the Stage Scene Index should stop translating this data. I struggle with it being "right behaviour" that all the Scene Indexes up to the Stage Globals Scene Index have a value and then said value disappears when the SGSI comes into play (unless the application "renews" the value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants