Skip to content

Frame number resolving scene index, with test. - #491

Open
ppt-adsk wants to merge 3 commits into
devfrom
tremblp/HYDRA-2428/hash_marks_in_product_name
Open

Frame number resolving scene index, with test.#491
ppt-adsk wants to merge 3 commits into
devfrom
tremblp/HYDRA-2428/hash_marks_in_product_name

Conversation

@ppt-adsk

@ppt-adsk ppt-adsk commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Provides support for authoring the USD RenderProduct.productName property with one or more sequences of hash marks ('#'). These hash mark sequences will be replaced with the current frame number at render time by a new frame resolving scene index.

@ppt-adsk
ppt-adsk requested a review from benyoon-adsk August 17, 2026 20:20

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to this change, but useful for debugging.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

std::unique_ptr<PXR_NS::HdxTaskController> _taskController;
PXR_NS::HdPluginRenderDelegateUniqueHandle _renderDelegate = nullptr;
PXR_NS::HdSceneIndexBaseRefPtr _lastFilteringSceneIndexBeforeCustomFiltering {nullptr};
PXR_NS::HdSceneIndexBaseRefPtr _inputSceneIndexOfFilteringSceneIndicesChain {nullptr};

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary data member, removed.


void _SetRenderPurposeTags(const PXR_NS::MayaHydraParams& delegateParams);
void _CreateSceneIndicesChainAfterMergingSceneIndex();
void _CreateSceneIndicesChainAfterMergingSceneIndex(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change interface to pass in the appropriate scene index, rather than reading it from a data member.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted from AnimCubeRenderSettings.ma

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted from AnimCubeRenderSettings.usda

{
HdSceneIndexPrim prim = GetInputSceneIndex()->GetPrim(primPath);

auto sceneGlobals = HdSceneGlobalsSchema::GetFromSceneIndex(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have no scene globals to get time from, can't do anything.

auto activeRenderSettingsDs = sceneGlobals.GetActiveRenderSettingsPrim();
if (!activeRenderSettingsDs
|| activeRenderSettingsDs->GetTypedValue(0) != primPath) {
return prim;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point USD render products have been flattened into data sources in the render settings prims. If this prim is not the active render settings prim, nothing to do, pass through.

return prim;
}

auto renderProductsDs = HdVectorDataSource::Cast(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get the render products in the Hydra flattened render settings prim.

HdRenderSettingsSchemaTokens->renderSettings,
HdRenderSettingsSchemaTokens->renderProducts);

prim.dataSource = HdContainerDataSourceEditor(prim.dataSource)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolve all render products for frame number.

// (but n is usually small), and requires the FrameNbResolvingSceneIndex to
// be downstream of the scene globals scene index.
//
HdSceneIndexObserver::DirtiedPrimEntries augmented(entries);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the time change in the scene globals? If so, dirty the render products in the active render settings prim. This might dirty too much, if the render products are not animated (default value) and have no '#' sequences (but that is not a very interesting use case), or if the render products are animated (time sampled) and have no '#' sequences. This is plausible, but we are not dirtying much, so the simplicity of this approach is worth it.

/// zero-padded or truncated to match the width of the '#' run.
///
/// For example, given frame 57 and product name "####frame#.jpg", the
/// resolved name is "0057frame7.jpg".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand why we would need to truncate the frame number for a smaller '#' width, is there something I'm missing? Is this the existing behavior in Maya?

  1. I don't see why there should be multiple occurrences of # in a single product name (i.e. ####frame#.jpg ? why not just ####frame.jpg or frame####.jpg)? I see that the test scene has the product name /mainCamFrame_#_##_###.png, so would it be mainCamFrame_7_57_057.png? What would be the use case?
    a. In Maya the hash marks seem to be on one side or another (i.e. ####frame.jpg or frame####.jpg, not ####frame#.jpg?)
  2. Why truncate when '#' is smaller than the frame digit length? what if the product name is frame#.jpg and frame 57? wouldn't it overwrite itself every 10 frames?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Don't really see a use case for it, it was simple enough to implement. I looked at the code to only consider the first run of '#' characters, and it's more complex for no gain that I can think of. Therefore, since I think there's no harm in this, and the code is simpler, I suggest leaving it in, even though there's no need for it.
  2. As per your comment in fvpFrameNbResolvingSceneIndex.cpp, I'll remove the truncation and set the replacement as a minimal field width, thanks for picking this up.

Comment on lines +65 to +79
FrameNbResolvingSceneIndex(
const PXR_NS::HdSceneIndexBaseRefPtr& inputSceneIndex);

void _PrimsAdded(
const PXR_NS::HdSceneIndexBase& sender,
const PXR_NS::HdSceneIndexObserver::AddedPrimEntries& entries) override;

void _PrimsRemoved(
const PXR_NS::HdSceneIndexBase& sender,
const PXR_NS::HdSceneIndexObserver::RemovedPrimEntries& entries) override;

void _PrimsDirtied(
const PXR_NS::HdSceneIndexBase& sender,
const PXR_NS::HdSceneIndexObserver::DirtiedPrimEntries& entries) override;
};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add FVP_API to these? I noticed some files add it, some don't.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I think they should be added, if derived classes want to call these methods.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

result.append(frameStr);
} else {
// Truncate: take the rightmost runLen digits.
result.append(frameStr, frameStr.size() - runLen, runLen);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this overwrite images if the frame number digits are larger than the width of '#' (i.e. every 10, 100, ... frames) ? Unless this is intended behavior. See point 2 in the comment in: lib/flowViewport/sceneIndex/fvpFrameNbResolvingSceneIndex.h

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix and will set as minimal field width, without truncation. Thanks for the comment.

@ppt-adsk
ppt-adsk marked this pull request as ready for review August 21, 2026 18:59
@ppt-adsk
ppt-adsk requested a review from benyoon-adsk August 21, 2026 18:59
@ppt-adsk ppt-adsk self-assigned this Aug 21, 2026
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

Successfully merging this pull request may close these issues.

2 participants