USD import: add support for displayColor on non-Mesh USD shape prims #120236
No reviewers
Labels
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#120236
Loading…
Reference in New Issue
No description provided.
Delete Branch "wave/blender_wave_Apple:matt/displayColor_for_shapes_v3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blender USD import already supports the displayColor primvar, when it is specified on Mesh prims. These colors are visible in the viewport when the viewport shading color type is set to Attribute.
This PR extends this displayColor primvar support to also work with the various shape prims, such as Box, Sphere, etc.
The original displayColor support was implemented in USDMeshReader. Because USDShapeReader is a sibling to to USDMeshReader, and USDShapeReader first converts shapes to a Mesh, we have factored out the mutually beneficial code from usd_reader_mesh.cc into a new usd_mesh_utils.cc.
For now only the displayColor primvar is supported on shapes, but this could be easily extended in a future PR.
Authored by Apple: Matt McLin
I've attached a
shapes_with_colors.usda
file generated from Houdini containing various shape types with different colors that I'm using for testing. The colors come through as expected in Blender, as shown in the attached screenshot. Nice work!I might have additional comments when I complete my review.
Things look alright from my side save for a few nits. Things seem fine otherwise. I can clean the nits up shortly after this is checked in. Or, if you want, you can address them now.
There are clang-format issues that should be fixed before commit though. A
make format
should auto fix them for you I think. Requesting changes just for this one mainly.@ -0,0 +8,4 @@
#include "BKE_attribute.hh"
#include "BLI_color.hh"
#include "BLI_span.hh"
Nit: To go along with the other #include change, add the following 2 headers:
#include "BKE_report.hh"
and#include "DNA_mesh_types.h"
@ -0,0 +92,4 @@
if (!primvar.ComputeFlattened(&primvar_val, motionSampleTime)) {
BKE_reportf(reports,
RPT_WARNING,
"Unable to get array values for primvar %s",
Nit: Surround the %s with single quotes to match the other report below this one:
'%s'
and change this message to begin with "USD Import: "@ -0,0 +11,4 @@
#include "usd_reader_geom.hh"
#include <pxr/usd/sdf/types.h>
#include <pxr/usd/usdGeom/mesh.h>
Nit: Replace all of the #includes above with the following to more accurately reflect what's actually necessary:
The changes look good! Splitting out the shared attribute import functionality to
usd_mesh_utils.cc
is welcome, because I believe the attribute conversion functions can also be used in the Point Cloud import PR #120060.I was wondering if we want support for animated attributes through the mesh sequence cache modifier. I've attached
capsule_with_animating_color.usda
that can be played inUSDView
, where the capsuledisplayColor
animates from red to blue.@Matt-McLin @deadpin Is this something we want to add? I personally think this would be helpful, but I would also be fine with adding support for this later.
Based on the mesh conversion code, I wrote a very quick prototype for supporting animated attributes for shapes, just as an example to start the discussion. It appears to work in my test.
a8ad8d1bf1
The scope of the required changes includes
primvar_time_varying_map_
memberUSDShapeReader::is_time_varying()
to return true if any color primvars are time varyingapply_primvars_to_mesh()
insidemesh_from_prim()
, so primvars are read when the points are updatedJust a suggestion. As I said, I'm fine deferring this till later or taking a different approach to implement this.
BTW, this is the branch with the example code:
https://projects.blender.org/makowalski/blender/src/branch/displayColor_for_shapes_with_anim
Thank you @deadpin and @makowalski !
Michael, this is great point about animated displayColor attribute, thank you for adding this. I think it would be great to include here.
Jesse, your changes make sense, thanks for sharing the details.
I am happy to make the requested changes and incorporate Michael's commit, but am busy this week so may take some time.
If either of you would like to make the changes directly here sooner and push it through, that is fine for us.
@Matt-McLin @deadpin I can probably merge in my proposed changes for the animating attributes into this PR this week. I'll add a comment here when I've started working on this, so we don't accidentally duplicate each other's work.
FYI, I will work on merging in the animation-related changes today. Will also try to address the comments by @deadpin today.
@ -32,6 +32,8 @@ class USDShapeReader : public USDGeomReader {
pxr::VtIntArray &face_indices,
pxr::VtIntArray &face_counts) const;
void apply_primvars_to_mesh(Mesh *mesh, const double motionSampleTime);
I think
const
is necessary in the function definition but not the declaration, as per this guideline:https://developer.blender.org/docs/handbook/guidelines/c_cpp/#const
I'll remove it from the declaration when I merge in the animation changes.
@blender-bot build
I committed the animation changes and also addressed the comments by @deadpin.
Since I will be out all of next week, I will go ahead and approve this pull request.
@Matt-McLin @deadpin Please review my additional changes when you have a chance. Thanks!
@makowalski Your updates look good to me, and I confirmed it works for the couple of test files.