USD metersPerUnit setting not used on import / scene units not used on export #100448

Open
opened 2022-08-16 23:42:24 +02:00 by David · 10 comments

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94

Blender Version
Broken: version: 3.4.0 Alpha, branch: master (modified), commit date: 2022-08-15 22:16, hash: c5feb4e6fe
Worked: Never

Short description of error
USD contains a setting "metersPerUnit" which dictates the scale of the file.
The USD standard sets this value to 0.01 or 1 centimeter by default if not specified.
The Blender USD importer ignores this value and assumes the file is in meters (which is what the blender exporter uses regardless of scene unit settings).

Exact steps for others to reproduce the error
Export a 1 meter cube as usda. (scene units will be discarded in favor of meters visible in text editor)
From text editor modify metersPerUnit from 1.0 to 0.01 (m to cm) and save to a new usda file.
Import both.
Both the 1m and 1cm sized cubes will both be 1m.

I've identified this as an issue in Omniverse, Maya, Nuke, Clarisse builder, & Blender
The only DCC's that seem to provide some notion of this scale are

Unity - This works however it does not read the file scale (assumes meters), but lets the user select the units once in the scene. This applies transform scale to the object (not the vertex locations) this is not ideal

Unreal - Reads metersPerUnit scale and imports mesh vertices pre-transformed (transform is still identity) - This imo is preferred.

Given the clear ambiguity throughout the industry for how to handle this it's clear there's no single answer, however some simple options for the importer / exporter should be able to correct this.

**System Information** Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 516.94 **Blender Version** Broken: version: 3.4.0 Alpha, branch: master (modified), commit date: 2022-08-15 22:16, hash: `c5feb4e6fe` Worked: Never **Short description of error** USD contains a setting "metersPerUnit" which dictates the scale of the file. The USD standard sets this value to 0.01 or 1 centimeter by default if not specified. The Blender USD importer ignores this value and assumes the file is in meters (which is what the blender exporter uses regardless of scene unit settings). **Exact steps for others to reproduce the error** Export a 1 meter cube as usda. (scene units will be discarded in favor of meters visible in text editor) From text editor modify metersPerUnit from 1.0 to 0.01 (m to cm) and save to a new usda file. Import both. Both the 1m and 1cm sized cubes will both be 1m. I've identified this as an issue in Omniverse, Maya, Nuke, Clarisse builder, & Blender The only DCC's that seem to provide some notion of this scale are Unity - This works however it does not read the file scale (assumes meters), but lets the user select the units once in the scene. This applies transform scale to the object (not the vertex locations) this is not ideal Unreal - Reads metersPerUnit scale and imports mesh vertices pre-transformed (transform is still identity) - This imo is preferred. Given the clear ambiguity throughout the industry for how to handle this it's clear there's no single answer, however some simple options for the importer / exporter should be able to correct this.
Author

Added subscriber: @Sannyasi

Added subscriber: @Sannyasi

Added subscribers: @makowalski, @deadpin

Added subscribers: @makowalski, @deadpin

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

The importer already has both a "Scale" and "Light intensity scale" option for just such situations. Might those be sufficient to mitigate this issue - there are scenes which for sure require 0.01 scale during import (typical, i.e. 1cm scale) and some rare ones which are ok at 1.0 scale.

The exporter uses your Scene->Unit Scale value correctly here. i.e. setting that to 0.01 writes the following out in the USD file (floating point rounding results in a not nice value but it should work):

#usda 1.0
(
    doc = "Blender v3.4.0 Alpha"
    metersPerUnit = 0.009999999776482582
    upAxis = "Z"
)

CC @makowalski as FYI or in case he wants to comment if the USD importer will ever make use of the metersPerUnit automatically.

The importer already has both a "Scale" and "Light intensity scale" option for just such situations. Might those be sufficient to mitigate this issue - there are scenes which for sure require 0.01 scale during import (typical, i.e. 1cm scale) and some rare ones which are ok at 1.0 scale. The exporter uses your Scene->Unit Scale value correctly here. i.e. setting that to 0.01 writes the following out in the USD file (floating point rounding results in a not nice value but it should work): ``` #usda 1.0 ( doc = "Blender v3.4.0 Alpha" metersPerUnit = 0.009999999776482582 upAxis = "Z" ) ``` CC @makowalski as FYI or in case he wants to comment if the USD importer will ever make use of the `metersPerUnit` automatically.

The universal-scene-description branch does provide an option to apply a unit conversion as a global scale on import and export, but this feature hasn't been submitted as a patch to master yet. However, I agree with @Sannyasi that a simple global scale isn't always desirable, and that having an option to transform vertices is important. I think this needs further discussion to decide the best approach.

The `universal-scene-description` branch does provide an option to apply a unit conversion as a global scale on import and export, but this feature hasn't been submitted as a patch to master yet. However, I agree with @Sannyasi that a simple global scale isn't always desirable, and that having an option to transform vertices is important. I think this needs further discussion to decide the best approach.
Author

I can add that the global scalar which currently alters the transform scale property of the imported objects (not vertex locations) is imo not an ideal scenario for a few reasons.
I think it would make sense to include an option to apply linear unit values directly onto the imported data (transform positions and vertex locations).
It would also be helpful for the usda export to do the same process in reverse using the value at

 scene.unit_settings.length_unit

And set the metersPerUnit within the file to match (no longer assume meters).
That way we can plan ahead in pipelines so all the other applications which don't use the metersPerUnit properly (read that as all of them), can be given data in their expected units.

I don't have any c++ experience (python and c#), but I downloaded the source to give it a go myself. I located where the scalar value should be applied and the math is simple enough to determine the scale factor needed, but I could not determine a way to get the metersPerUnit value from the usd stage into the prim loader functions.

I can add that the global scalar which currently alters the transform scale property of the imported objects (not vertex locations) is imo not an ideal scenario for a few reasons. I think it would make sense to include an option to apply linear unit values directly onto the imported data (transform positions and vertex locations). It would also be helpful for the usda export to do the same process in reverse using the value at ``` scene.unit_settings.length_unit ``` And set the **`metersPerUnit`** within the file to match (no longer assume meters). That way we can plan ahead in pipelines so all the other applications which don't use the **`metersPerUnit`** properly (read that as all of them), can be given data in their expected units. I don't have any c++ experience (python and c#), but I downloaded the source to give it a go myself. I located where the scalar value should be applied and the math is simple enough to determine the scale factor needed, but I could not determine a way to get the **`metersPerUnit`** value from the usd stage into the prim loader functions.

Added subscriber: @Michael-Heberlein

Added subscriber: @Michael-Heberlein

Removed subscriber: @Michael-Heberlein

Removed subscriber: @Michael-Heberlein

Added subscriber: @codeloadgame

Added subscriber: @codeloadgame
Bastien Montagne added this to the Pipeline, Assets & IO project 2023-02-09 15:39:30 +01:00
Member

So, since this apparently needs more design considerations, will make that clear by moving from "Needs Info from User" to "Needs Info from Developer"

So, since this apparently needs more design considerations, will make that clear by moving from "Needs Info from User" to "Needs Info from Developer"
Philipp Oeser added
Status
Needs Info from Developers
and removed
Status
Needs Information from User
labels 2023-02-20 12:30:58 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#100448
No description provided.