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

[EMSUSD-1914] - Incorrect values for UsdGeomCamera when exporting USD from 3DS Max #9

Open
theblackunknown opened this issue Dec 6, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@theblackunknown
Copy link

theblackunknown commented Dec 6, 2024

Describe the bug
Hi team !
We ran into issue reading USD files exported from 3DS Max, I assume this is something which falls into this repository responsability otherwise please let me know where to direct my bug report.

In 3DS Max we can specify what is the distance unit system for our work, and this translates in the USD ecosystem into the metersPerUnit stage metadata.
The UsdGeomCamera specification is sensitive to this information as some of its information must be relative to that information.
More specifically lens and filmback properties are measured in tenths of a scene unit rather than "raw" scene units (See Units of Measure for Camera Properties).

The bug we observed is that USD files exported from 3DS Max does not fully comply with this.

Here is an excerpt of what we get for exported UsdGeomCamera when the stage is as meters

    {
        float focalLength = 74.975395
        float focusDistance = 4.333903
        float fStop = 14
        float horizontalAperture = 36
        token projection = "perspective"
        float verticalAperture = 20.25
        float3 xformOp:rotateZYX = (133.97299, 98.0366, -134.99997)
        double3 xformOp:translate = (2.949643850326538, 0.2540692687034607, 0.21139541268348694)
        uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]
    }

Here is an excerpt of what we get for exported UsdGeomCamera when the stage is as centimeters

    {
        float focalLength = 74.975395
        float focusDistance = 433.3903
        float fStop = 14
        float horizontalAperture = 36
        token projection = "perspective"
        float verticalAperture = 20.25
        float3 xformOp:rotateZYX = (133.97299, 98.0366, -134.99997)
        double3 xformOp:translate = (294.9643859863281, 25.40692710876465, 21.139541625976562)
        uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateZYX"]
    }

We feel this is a bug as some camera properties seems to behave correctly (e.g. focusDistance) but not all the relevant ones (e.g. focalLength).
Beyond authored properties, it is also important to not rely on default value when the stage metersPerUnit is not using its default.
This means that other distance properties must be authored to be correct too.
For example, if you set the stage metersPerUnit you want to make an opinion on all distance based properties. In the above example it means that you need to also author clippingRange.

Steps to reproduce
Steps to reproduce the behavior:

  1. Change the unit to be in meters
  2. Author a scene in 3DS Max with camera and depth of field effect
  3. Save your 3DS Max scene
  4. Export the scene as USD (e.g. foo.usd)
  5. Close the scene or reset the scene (you need to restart from an empty state)
  6. Change the unit to be in centimeters
  7. Reopen your saved 3DS Max scene (you should get a prompt stating the scene you are opening uses a different unit compared to the current one and asks if you want to convert it)
  8. Export the scene as different USD (e.g. bar.usd)

Both exported files should displayed camera values compliant with the UsdGeomCamera specification.
And as such they should render the same image with a USD compliant and depth of field capable renderer.

Expected behavior
When exporting to USD, we expect Camera to fully comply with the UsdGeomCamera specification.
In particular we expect any distance based property to be authored correctly following the stage metersPerUnit information.
Rules for compliance can be found in Units of Measure for Camera Properties, and the UsdGeomCamera USD schema highlight which properties are distance based or not.

Attachments

I do have 3DS Max scene to share but GitHub won't accept those, let me know how we can share those.

Specs:

  • 3ds Max version 2025
  • Plugin version 0.9
@theblackunknown theblackunknown added the bug Something isn't working label Dec 6, 2024
@theblackunknown theblackunknown changed the title Incorrect values for UsdGeomCamer awhen exporting USD from 3DS Max Incorrect values for UsdGeomCamera when exporting USD from 3DS Max Dec 6, 2024
@deboisj
Copy link
Collaborator

deboisj commented Dec 6, 2024

Thank you for the very detailed report! Indeed we write out millimeters for the focal length, and with the spec you linked, that does appear to be wrong. I will log an issue to address this internally.

This is the relevant code : https://github.com/Autodesk/3dsmax-usd/blob/dev/src/translators/CameraWriter.cpp#L107

@brossee-adsk brossee-adsk changed the title Incorrect values for UsdGeomCamera when exporting USD from 3DS Max [EMSUSD-1914] - Incorrect values for UsdGeomCamera when exporting USD from 3DS Max Dec 6, 2024
@deboisj
Copy link
Collaborator

deboisj commented Dec 6, 2024

Note that in the meantime, without fixing & recompiling the c++ code - it would also be possible to work around this using a custom chaser & context. A chaser running after the export would loop through the cameras in the usd stage and adjust the relevant attributes. There is a python sample for to do this (registering a chaser, and associated context) here : https://github.com/Autodesk/3dsmax-usd/blob/dev/samples/UserDataExportChaserSample/Contents/python/UserDataExportChaser.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants