Improve USD camera import/export and round-tripping #112905

Merged
Brecht Van Lommel merged 3 commits from dkvnyc/blender:feature/CameraUSDRoundtripFixes into blender-v4.0-release 2023-10-05 19:47:19 +02:00
Contributor

Improve USD camera import/export and round-tripping

Bugfix for camera USD import

  • wrong units, flipped shiftx / shifty values
  • clip_start to match Blender's property range (defined in rna_camera.cc)

Bugfix for camera USD export

  • wrong units (should be tenth of a stage unit for horizontal/vertical aperture and aperture offsets, focal length)
  • Auto sensor-fit with height > width (uses sensor_x instead of sensor_y)

Challenges/Limitations

  • Blender does not support aperture offsets in absolute values: shiftx and shifty store these as a fraction of the sensor size.
  • Blender only supports a single sensor size (either sensor_x or sensor_y, depending on Sensor Fit) and only one global aspect ratio for all cameras (defined using RenderData's xsch*xasp, ysch*yasp)
  • If Sensor Fit is set to Auto, Blender always uses sensor_x as the sensor size, regardless of whether sensor_y > sensor_x or not. So importing a camera from USD is best done with the Sensor Fit explicitly set to Horizontal or Vertical - this makes sure the respective sensor_x or sensor_y value is used, and makes the shift values more predictable when RenderData's aspect ratio does not exactly match the camera sensor's.

Testing

  • Create new Blender scene
  • Go to camera's object data properties,
  • Set Shift X to 0.1,
  • Set Shift Y to 0.2,
  • Set Clip Start to 0 (this will change to 0.000001 m due to rna_camera's RNA_def_property_range).
  • Export to a USD file, say Cameras.usda
  • Import Cameras.usda into Blender
  • Toggle between new vs. original camera views and compare their camera frames (note that the values for sensor size and shift values will necessarily be different if the camera's sensor fit is Vertical and the original camera's is Auto - however the visual result should be identical).
  • Open Cameras.usda with usdview (command line tool from the OpenUSD repo).
  • In the 3D View, turn on Camera>Camera Guides>Camera Frame, and set the camera with Camera>Select Camera>Camera, compare with Blender's camera frame.
# Improve USD camera import/export and round-tripping ## Bugfix for camera USD import - wrong units, flipped `shiftx` / `shifty` values - `clip_start` to match Blender's property range (defined in `rna_camera.cc`) ## Bugfix for camera USD export - wrong units (should be tenth of a stage unit for horizontal/vertical aperture and aperture offsets, focal length) - `Auto` sensor-fit with height > width (uses `sensor_x` instead of `sensor_y`) # Challenges/Limitations - Blender does not support aperture offsets in absolute values: `shiftx` and `shifty` store these as a fraction of the sensor size. - Blender only supports a single sensor size (either `sensor_x` or `sensor_y`, depending on Sensor Fit) and only one global aspect ratio for all cameras (defined using `RenderData`'s `xsch*xasp`, `ysch*yasp`) - If Sensor Fit is set to `Auto`, Blender always uses `sensor_x` as the sensor size, regardless of whether `sensor_y > sensor_x` or not. So importing a camera from USD is best done with the Sensor Fit explicitly set to `Horizontal` or `Vertical` - this makes sure the respective `sensor_x` or `sensor_y` value is used, and makes the shift values more predictable when `RenderData`'s aspect ratio does not exactly match the camera sensor's. # Testing - Create new Blender scene - Go to camera's object data properties, - Set `Shift X` to `0.1`, - Set `Shift Y` to `0.2`, - Set `Clip Start` to `0` (this will change to `0.000001 m` due to `rna_camera`'s `RNA_def_property_range`). - Export to a USD file, say `Cameras.usda` - Import `Cameras.usda` into Blender - Toggle between new vs. original camera views and compare their camera frames (note that the values for sensor size and shift values will necessarily be different if the camera's sensor fit is `Vertical` and the original camera's is `Auto` - however the visual result should be identical). - Open `Cameras.usda` with `usdview` (command line tool from the `OpenUSD` repo). - In the 3D View, turn on `Camera>Camera Guides>Camera Frame`, and set the camera with `Camera>Select Camera>Camera`, compare with Blender's camera frame.
Denis Kovacs added 1 commit 2023-09-26 14:45:42 +02:00
Denis Kovacs requested review from Sybren A. Stüvel 2023-09-26 14:58:28 +02:00
Denis Kovacs requested review from Michael Kowalski 2023-09-26 14:59:06 +02:00
Sybren A. Stüvel refused to review 2023-09-26 16:55:04 +02:00
Sybren A. Stüvel added the
Module
Pipeline, Assets & IO
Interest
USD
labels 2023-09-26 16:55:18 +02:00
Brecht Van Lommel requested review from Brecht Van Lommel 2023-09-26 19:52:54 +02:00

This is great, we could consider this as a bugfix for 4.0 since it's really quite far off now.

This is great, we could consider this as a bugfix for 4.0 since it's really quite far off now.

The "WIP" prefix usually means the pull request is not ready for review yet. Are you planning further changes?

The "WIP" prefix usually means the pull request is not ready for review yet. Are you planning further changes?
Denis Kovacs changed title from WIP: Improve USD camera import/export and round-tripping to Improve USD camera import/export and round-tripping 2023-09-27 00:26:33 +02:00
Author
Contributor

The "WIP" prefix usually means the pull request is not ready for review yet. Are you planning further changes?

Sorry, no I am not planning any further changes. I removed the WIP tag.

> The "WIP" prefix usually means the pull request is not ready for review yet. Are you planning further changes? Sorry, no I am not planning any further changes. I removed the WIP tag.
Brecht Van Lommel changed title from Improve USD camera import/export and round-tripping to Improve USD camera import/export and round-tripping 2023-09-27 15:54:34 +02:00
brecht changed target branch from main to blender-v4.0-release 2023-09-27 15:54:37 +02:00
Brecht Van Lommel added 2 commits 2023-10-04 21:46:25 +02:00

@blender-bot build

@blender-bot build
Brecht Van Lommel approved these changes 2023-10-05 19:36:12 +02:00
Brecht Van Lommel left a comment
Owner

Works well in my tests, thanks!

Works well in my tests, thanks!
Brecht Van Lommel merged commit 7a9284107d into blender-v4.0-release 2023-10-05 19:47:19 +02:00
Brecht Van Lommel deleted branch feature/CameraUSDRoundtripFixes 2023-10-05 19:47:21 +02: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 project
No Assignees
2 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#112905
No description provided.