Can't import OBJs that were exported with Apple's Model I/O API (Patch included) #71618
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
8 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#71618
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: Windows 10 1903 (18362.418)
Graphics card: Nvidia GTX 1070
Blender Version
Broken: 2.80
Short description of error
OBJ files that were generated using Apple's Model I/O API trip up Blender's MTL parser, making it impossible to import them.
Exact steps for others to reproduce the error
Download the following files.
They were generated by downloading the publicly accessible .usdz model of the AirPods Pro from Apple's product website and converting it to .obj using this tool I wrote: https://github.com/SamusAranX/USDConverter/blob/master/USDConverter/main.swift
airpods_pro_ios13.obj
airpods_pro_ios13.mtl
Try to import the .obj into Blender as you would with any other .obj file.
Get an error message telling you that the list index is out of range.
I wrote a silly little patch for myself, but re-applying it after every update is getting to be tedious, so I finally created an account here.
My patched import_obj.py file is here: https://gist.github.com/SamusAranX/de1663abe2346fc0dc49791ec9d5205a
I don't have a compehensive test suite, but for me, at least, it has reliably worked without breaking anything else so far.
I'm new to contributing to Blender, so please forgive me if this isn't the proper channel for this.
Added subscriber: @GordenFreemant
blender/blender-addons#64264 was marked as duplicate of this issue
Added subscriber: @StephenSwaney
What exactly is the problem?
Also, a diff would be nice.
This is the problem.
The .mtl files generated by Model I/O don't use
Ks x y z
, they doKs scalar
with just one number.I don't know if there's actually any official .mtl standard that this violates, but it'd be great to support this in Blender anyway.
Regarding the diff, is this okay?
Added subscriber: @Harley
The report seems a little confusing. It reads like "Apple has files in a new format and when I convert them myself using a particular library the resulting output is not valid"
But it appears to be a much simpler bug.
As far as I can see, MTL material files have material color statements (Ka, Kd, Ks, Tf) that are generally r g b values (0-1) separated by spaces. But the spec does say that the "g and b arguments are optional. If only r is specified, then g, and b are assumed to be equal to r."
Your supplied "mtl" file contains many lines that are a single value like "Ks 0". In this case our import should treat this as if it were "Ks 0 0 0".
If our import is indeed barfing on single values there then that is the bug to be reported, along with this kind of detail and sample files. But if you also want to submit a fix for this problem you'd really need to handle ALL of these color statements (Ka, Kd, Ks, Tf), not just Ks, since all can take single values.
Thanks, Peter. That is exactly I was looking for.
The fix looks good. It even has comments!
Handling the other K* statements would be nice for completeness, but I have no idea if they are common in MTL files.
I updated the diff for all three of the K* statements.
I took a look at Tf as well, but it's apparently not supported by Blender at all, so there were no changes necessary.
This issue was referenced by blender/blender-addons@4fd8ee12db
Changed status from 'Open' to: 'Resolved'
Ooh, that's even better. Thanks for the quick fix!
Added subscriber: @lichtwerk
That was the same as blender/blender-addons#64264 (OBJ import gives error for Ke / emmisive (single value instead of color)), right?
Added subscribers: @filibis, @pipelineTDBadBoy, @HasKha, @Nocturnial, @BrendonMurphy, @DJJudd, @mont29
Indeed, thanks for the headup :)
It was the same, but the merged fix did not include the Ke (emmisive) parameter. Is it possible to add that in? Even though Ke is not in the original OBJ spec, it is defined in the PBR Extension, and is supported by Blender if defined in the three-tuple format: Ke 0.0 0.0 0.0.
Additional info:
http://exocortex.com/blog/extending_wavefront_mtl_to_support_pbr
This is my first time commenting here, so please let me know if I'm breaking any etiquette rules. :)
Removed subscriber: @Nocturnial
@pipelineTDBadBoy I’d suggest you actually check the commit first, you'll see that it did include fix for Ke as well…
My apologies, I assumed the pasted code in the thread was the commit. I'm still learning how things work here. Thanks again, this fix is very helpful!!