USD: fix various import problems with the Alab V2 scene #104515

Closed
Ashley wants to merge 8 commits from expenses/blender:usd-alab-import-fixes into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Contributor

See #100452.

  • MA_BM_HASHED seems to work a lot better as a blend method than MA_BM_BLEND.
  • The perfuv primvar is read for UVs as well as st. This is based on https://usd-alab2.s3.amazonaws.com/documentation.html#display-purpose-render.
  • Shaders that output to a red channel e.g. float inputs:opacity.connect = </root/backpack_M_hrc/MATERIAL/usd_full/full_opacity_texture.outputs:r> use a Seperate RGB node.
See https://projects.blender.org/blender/blender/issues/100452. - `MA_BM_HASHED` seems to work a lot better as a blend method than `MA_BM_BLEND`. - The `perfuv` primvar is read for UVs as well as `st`. This is based on https://usd-alab2.s3.amazonaws.com/documentation.html#display-purpose-render. - Shaders that output to a red channel e.g. `float inputs:opacity.connect = </root/backpack_M_hrc/MATERIAL/usd_full/full_opacity_texture.outputs:r>` use a Seperate RGB node.
Ashley added 1 commit 2023-02-09 14:20:07 +01:00
Ashley changed title from Fix various problems with the Alab V2 USD Scene to [USD Import] Fix various problems with the Alab V2 USD Scene 2023-02-09 14:20:14 +01:00
Brecht Van Lommel changed title from [USD Import] Fix various problems with the Alab V2 USD Scene to USD: fix various import problems with the Alab V2 scene 2023-02-09 14:42:23 +01:00
Brecht Van Lommel added this to the Pipeline, Assets & IO project 2023-02-09 14:42:28 +01:00
Brecht Van Lommel requested review from Michael Kowalski 2023-02-09 14:43:17 +01:00
Brecht Van Lommel requested changes 2023-02-09 15:05:39 +01:00
Dismissed
@ -642,3 +642,3 @@
std::string source_socket_name = usd_source_name == usdtokens::a ? "Alpha" : "Color";
link_nodes(ntree, tex_image, source_socket_name.c_str(), dest_node, dest_socket_name);
if (usd_source_name == usdtokens::r) {

Can it also happen that the g or b channel is used? And if so, can we generalize this?

Can it also happen that the g or b channel is used? And if so, can we generalize this?
Author
Contributor

USD is so adaptable that any token is possible here. In practice I think :r is the most likely situation here and that anything else is going to happen rarely.

USD is so adaptable that any token is possible here. In practice I think `:r` is the most likely situation here and that anything else is going to happen rarely.

Still might be worth supporting g and b as well?

For game engines channel packing textures is common, where you pack multiple single channel textures into one RGB textures.

Still might be worth supporting g and b as well? For game engines channel packing textures is common, where you pack multiple single channel textures into one RGB textures.
@ -805,3 +806,3 @@
}
/* In some cases, the st primvar is stored as float2 values. */
else if (name == usdtokens::st && type == pxr::SdfValueTypeNames->Float2Array) {
else if ((name == usdtokens::st || name == usdtokens::perfuv) && type == pxr::SdfValueTypeNames->Float2Array) {

There's no simple way in Blender to have a final and preview UV (besides creating two entirely separate shader node graphs and material outputs), so supporting perfuv for when there is no st seems fine.

However I think this should ensure usdtokens::st is the default UV map in case both are specified?

There's no simple way in Blender to have a final and preview UV (besides creating two entirely separate shader node graphs and material outputs), so supporting `perfuv` for when there is no `st` seems fine. However I think this should ensure `usdtokens::st` is the default UV map in case both are specified?
Author
Contributor

As only the preview .jpg textures are loaded by default, having perfuv be the default makes sense. If you click 'Import All Materials' during import, it'll load the UDIMs which the st UVs match (although they still don't seem to render correctly, perhaps related to #101320).

As only the preview .jpg textures are loaded by default, having `perfuv` be the default makes sense. If you click 'Import All Materials' during import, it'll load the UDIMs which the `st` UVs match (although they still don't seem to render correctly, perhaps related to https://projects.blender.org/blender/blender/issues/101320).

Ah, then it can take the "Import All Materials" setting into account to set the appropriate default UV map?

Ah, then it can take the "Import All Materials" setting into account to set the appropriate default UV map?
Author
Contributor

Ah, okay what needs to happen is that usd_preview materials needs to explicitly use the perfuv UV map (if set) and usd_full materials needs to explicitly use st (if set).

Ah, okay what needs to happen is that `usd_preview` materials needs to explicitly use the `perfuv` UV map (if set) and `usd_full` materials needs to explicitly use `st` (if set).
Author
Contributor

Done in ae08032f71.

Done in ae08032f71ba360a71278556e9ed47614aa71537.

Do you know if perfuv is a common naming convention for USD? I haven't seen this convention before, but maybe it's used more widely than I'm aware. I would argue that if this name is specific to the Alab scene conventions, then we shouldn't hard code a check for it. But I'm definitely open to your opinion about this.

The crux of the issue is that perfuv is represented as a float2 rather than the more correct texCoord2f type. If it were a texCoord* type, there would be no ambiguity and the current logic would handle it. I've occasionally encountered other examples where texture coordinates are represented as float2 but don't follow either the st or perfuv naming conventions, so perhaps this is an issue we should try to handle more generally.

I'm not sure of the best way to handle this. One strategy could be to broadly assume that any float2 primvar is a texture coordinate. That could result in false positives, of course, but maybe this is acceptable.

I'll bring up this question on the pipeline-asset-io chat, to start the conversation.

Do you know if `perfuv` is a common naming convention for USD? I haven't seen this convention before, but maybe it's used more widely than I'm aware. I would argue that if this name is specific to the Alab scene conventions, then we shouldn't hard code a check for it. But I'm definitely open to your opinion about this. The crux of the issue is that `perfuv` is represented as a `float2` rather than the more correct `texCoord2f` type. If it were a `texCoord*` type, there would be no ambiguity and the current logic would handle it. I've occasionally encountered other examples where texture coordinates are represented as `float2` but don't follow either the `st` or `perfuv` naming conventions, so perhaps this is an issue we should try to handle more generally. I'm not sure of the best way to handle this. One strategy could be to broadly assume that any `float2` primvar is a texture coordinate. That could result in false positives, of course, but maybe this is acceptable. I'll bring up this question on the pipeline-asset-io chat, to start the conversation.
Ashley added 1 commit 2023-02-09 16:12:09 +01:00
Bastien Montagne added the
Interest
USD
Module
Core
labels 2023-02-09 18:23:19 +01:00
Bastien Montagne modified the project from Pipeline, Assets & IO to USD 2023-02-09 18:24:00 +01:00
Brecht Van Lommel requested review from Brecht Van Lommel 2023-02-09 19:09:58 +01:00
Bastien Montagne added
Module
Pipeline, Assets & IO
and removed
Module
Core
labels 2023-02-10 12:20:11 +01:00

Thank you for this work, @expenses!

As a general comment, this overlaps with some of the issues I originally outlined in this task:

https://archive.blender.org/developer/T100452

I pushed some initial fixes (some of which are similar to yours) to this temporary branch:

https://projects.blender.org/blender/blender/src/branch/tmp-usd-alab-v2-T100452

Unfortunately, I had put that work on hold for a while, due to other priorities, and had been meaning to pick it up again recently, so your submission is very timely. It's a good opportunity to discuss some of these issues further.

I will have additional comments and questions about this PR tomorrow.

Thank you for this work, @expenses! As a general comment, this overlaps with some of the issues I originally outlined in this task: https://archive.blender.org/developer/T100452 I pushed some initial fixes (some of which are similar to yours) to this temporary branch: https://projects.blender.org/blender/blender/src/branch/tmp-usd-alab-v2-T100452 Unfortunately, I had put that work on hold for a while, due to other priorities, and had been meaning to pick it up again recently, so your submission is very timely. It's a good opportunity to discuss some of these issues further. I will have additional comments and questions about this PR tomorrow.
Brecht Van Lommel refused to review 2023-02-17 14:34:05 +01:00
Brecht Van Lommel dismissed brecht’s review 2023-02-17 14:35:30 +01:00
Ashley added 1 commit 2023-02-19 16:17:13 +01:00
Ashley added 5 commits 2023-02-19 16:24:09 +01:00
5649158db9 USD import: Alab v2 load errors.
Work in progress addressing issues loading the Alab v2 scene.

Load primvars of type Float2Array as texture coordinates.
Fixed type mismatch loading UsdPrimvarReader_float2 varname input.
For materials that have an authored opacity value, changed the blend
mode from Alpha Blend to Alpha Hashed, to mitigate object soring issue.
Added import option to specify loading materials by purpose to allow
explicitly loading full materials for debugging.
Author
Contributor

@makowalski Ah great! I've merged in your changes if that's okay, because the few that didn't overlap looked good.

@makowalski Ah great! I've merged in your changes if that's okay, because the few that didn't overlap looked good.
Author
Contributor

Hi, sorry for not following through with this. I'm going to close this PR as I believe that most if not all these changes are in the universal-scene-description branch and that I'm not knowledgeable enough to try and bring the changes from there into main.

Hi, sorry for not following through with this. I'm going to close this PR as I believe that most if not all these changes are in the `universal-scene-description` branch and that I'm not knowledgeable enough to try and bring the changes from there into `main`.
Ashley closed this pull request 2023-09-13 00:53:04 +02:00
Bastien Montagne removed this from the USD project 2023-10-06 14:26:52 +02:00

Pull request closed

Sign in to join this conversation.
No reviewers
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
3 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#104515
No description provided.