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

Change of behaviour of the SamplePrimvar function #3478

Closed
cpichard opened this issue Jan 6, 2025 · 1 comment
Closed

Change of behaviour of the SamplePrimvar function #3478

cpichard opened this issue Jan 6, 2025 · 1 comment

Comments

@cpichard
Copy link

cpichard commented Jan 6, 2025

Description of Issue

Hi,

We found a regression with the SamplePrimvar function which is affecting our render delegate.
The values returned by this function differ between USD 24.11 and 23.11 (or any version < 24.05)
With 23.11 the values are bounded by the camera shutter range and including the camera shutter times.
With 24.11 the values returned are the closest keyframes not including the camera shutter times if enclosing keyframes are found.

It is possible this change was introduced with this commit f3b28bc#diff-edff558696b6442b01aea0ec75bb8e1f8d59ce415739039040ec3be9bdc78242L483

The doc can be interpreted in different ways, with samples outside of the shutter range or not, but the camera shutter times should be included:
SamplePrimvar "Returns the union of the authored samples and the boundaries of the current camera shutter interval. If this number is greater than maxSampleCount, you might want to call this function again to get all the authored data."

Steps to Reproduce

I am adding a test which will pass with 24.05 and fail with 24.11, this function can be added to the testImagingDelegate.cpp file for testing

void
SamplePrimvarTest2()
{
    const std::string usdPath = "primvars.usda";
    const SdfPath pointsPath("/points_0");
    const SdfPath cameraPath("/cameras/camera1");
    UsdStageRefPtr stage = UsdStage::Open(usdPath);
    Hd_UnitTestNullRenderDelegate renderDelegate;
    std::unique_ptr<HdRenderIndex> renderIndex(
        HdRenderIndex::New(&renderDelegate, HdDriverVector()));
    TF_VERIFY(renderIndex);
    std::unique_ptr<UsdImagingDelegate> delegate(
                          new UsdImagingDelegate(renderIndex.get(),
                                                  SdfPath::AbsoluteRootPath()));
    delegate->Populate(stage->GetPseudoRoot());

    delegate->SetTime(8.0);
    delegate->SetCameraForSampling(cameraPath);
    delegate->SyncAll(/*includeUnvarying*/true);


    HdPrimvarDescriptorVector pointsPrimvars = 
        delegate->GetPrimvarDescriptors(pointsPath, HdInterpolationVertex);
    TF_VERIFY(pointsPrimvars[0].name == TfToken("points"));

    HdTimeSampleArray<VtValue, 10> pointSamples;

    delegate->HdSceneDelegate::SamplePrimvar(
        pointsPath, TfToken("points"), &pointSamples);

    TF_VERIFY(pointSamples.count == 3);
    TF_VERIFY(pointSamples.times[0] == -0.25);
    TF_VERIFY(pointSamples.times[1] == 0);
    TF_VERIFY(pointSamples.times[2] == 0.25);
}

The corresponding test file : primvars.zip has to be added in the pxr/usdImaging/usdImaging/testenv/testUsdImagingDelegate folder

System Information (OS, Hardware)

Tested on macos with USD 24.05 and 24.11

Thanks for the help.

@cpichard
Copy link
Author

cpichard commented Jan 6, 2025

Closing as I am just seeing that this behaviour change was described in the Changelog for 24.08:

When calling HdSceneDelegate::SamplePrimvar() for a time-varying primvar when the time sampling interval's start or end time falls between authored sample times, the bracketing authored sample times are now included in the output. Previously, only authored sample times within the interval were included, along with interpolated values at the interval start and end, as needed. For example, if the primvar has authored values at T = [1, 2, 3], and the sampling interval is [1.5, 2.5], the new behavior provides the authored values at T = [1, 2, 3], whereas the old behavior would provide values at T = [1.5, 2, 2.5], with the values at 1.5 and 2.5 being linear interpolations between the adjacent authored values.

It might be a good idea to update the SamplePrimvar function documentation though.

@cpichard cpichard closed this as completed Jan 6, 2025
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

1 participant