USD Import: No texture coordinates imported #93052
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
7 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#93052
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
System Information
Operating system: Linux-5.11.0-40-generic-x86_64-with-glibc2.33 64 Bits
Graphics card: AMD Radeon(TM) Vega 8 Graphics (RAVEN, DRM 3.40.0, 5.11.0-40-generic, LLVM 12.0.0) AMD 4.6 (Core Profile) Mesa 21.0.3
Blender Version
Broken: version: 3.0.0 Beta, branch: master, commit date: 2021-11-11 18:49, hash:
bd734cc441
Short description of error
I tried to import a USD file with texture coordinates. Vertices, normals, faces and USDPreviewSurface are imported correctly, but there is no UV Map. The USD file works without errors in usdview.
Exact steps for others to reproduce the error
Sample USDA file:
Added subscriber: @shauser
Added subscriber: @lichtwerk
Changed status from 'Needs Triage' to: 'Confirmed'
Can confirm, will check in a bit
Will have to concentrate on triaging for a while (and step down).
Added subscribers: @makowalski, @mont29
@makowalski Can you have a look at this one? thanks.
I was able to reproduce the issue with the test case and am investigating.
This is due to the "varying" primvar interpolation type not being handled in the UV conversion code. I'm addressing this.
Added subscriber: @codeloadgame
Removed subscriber: @codeloadgame
Added subscriber: @codeloadgame
Added subscriber: @ramakarl
Changing "varying" to "faceVarying" and using "UVMap" as the texcoord token in the input USD works.
Working USDA for texture coord input:
texCoord2f- [ ] primvars:UVMap = [(0.625, 0.5), (0.875, 0.5), (0.875, 0.75), (0.625, 0.75), (0.375, 0.75), (0.625, 0.75), (0.625, 1), (0.375, 1), (0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.125, 0.5), (0.375, 0.5), (0.375, 0.75), (0.125, 0.75), (0.375, 0.5), (0.625, 0.5), (0.625, 0.75), (0.375, 0.75), (0.375, 0.25), (0.625, 0.25), (0.625, 0.5), (0.375, 0.5)] (
interpolation = "faceVarying"
)
Although we're importing per-vertex UVs, it should also be noted the number of entries in the input array is the number of face indexed vertices (sum of all faceVertexCounts).
The USD Export writes the correct number of entries. The USD Import reads correctly if written in this way.
My own exporter (non-blender) scans thru the face-vertex-index list and looks up each vertex to write. Total number of UVs written is the number of faces * vertices_per_face.
VtArray uvs( faces*3 );
int v;
for (int i=0; i < faces3; i++) {
v = polyndx- [x]; <-- look up vertices of each face
Vector2DF uv = mesh->GetVertTex(v);
uvs- [x]- [x] = uv->x;
uvs- [x]- [x] = uv->y;
}
UsdGeomPrimvarsAPI schema (usd_mesh);
UsdGeomPrimvar tcs = schema.CreatePrimvar(TfToken("UVMap"), SdfValueTypeNames->TexCoord2fArray, UsdGeomTokens->faceVarying);
tcs.Set( uvs );
veg_birch_simple.usda
Attached an example usda file /w texcoords.
If the USD file is formatted as above, the USD import of texture coordinates works in Blender.
To handle the case where texture coordinates work in usdview but not in Blender the solution might be simply to interpret the token "varying" as "faceVarying" and token "st" as "UVMap". What happens when a USD Exported file from blender with texture coordinates is loaded into usdview?
Hope this helps.
Thanks for the advice, @ramakarl, it was indeed very helpful!
By changing "varying" to "faceVarying" and adding three uv coordinates per triangle I was able to create a valid USD file which could be imported into blender with the correct material mapping.
However, I found that replacing TfToken("st") with TfToken("UVMap") didn't work because the material created by blender's USD importer expects a uv map named "st". So the correct uv primvar creation should look like this:
UsdGeomPrimvar tcs = schema.CreatePrimvar(TfToken("st"), SdfValueTypeNames->TexCoord2fArray, UsdGeomTokens->faceVarying);
This continues to be an issue, even with the most recent daily alpha (1-9-2024). UVmaps are still not being imported. Source is a unity scene exported with their most recent Unity SDK. Opening the same file in something like Omniverse works atm (UV maps are imported without error). If I try to import into blender I get:
Seems to relate to the closed issue 112407
Thanks for reporting this. I believe I found the underlying bug causing the error. I'll confirm today.
I created pull request #116955, which appears to fix the "count inconsistent" errors for
varying
interpolation.Adding an example file. It's a different file than above (not owned by myself) but I was able to create the same error with a simplified scene.
There's a couple other unrelated errors there but at the top you'll see
@benbrennanmusic Just FYI, this issue should be fixed in the latest 4.2 Alpha and also the 4.1 release candidate.