UDIM: Support virtual filenames for tile sets #92696
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#92696
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?
Context
Texture files belonging to a UDIM tile set all share a particular naming convention which indicates which file belongs to which tile and vice versa. For example, a 3 texture UDIM tile set might look like the following:
monster-albedo.1001.png, monster-albedo.1002.png, monster-albedo.1003.png
There are several conventions besides the 4-digit example above. Additionally, the information can technically be placed anywhere within the filename, and it might be ambiguous with other fragments of the filename which might contain things like version numbers, image sequence numbers, or frame numbers.
In order to correctly and reliably handle such conventions, as well as display and reference an entire tile set, most software allows the use of substitution markers/tokens indicating exactly where in the filename to look for and place the UDIM information. Other open initiatives like MaterialX use these tokens and libraries like OIIO support substitutions natively today.
Filenames with these markers/tokens present will be known as "virtual filenames" for the rest of this document.
Problem
Blender does not support "virtual filenames" and instead relies on the existing Image Sequence detection code to find digits somewhere in the filename. Additionally, this processing only occurs during file load/save workflows, leaving importers/exporters to find their own solution to the problem.
This leads to the following issues:
Prior bugs discussing these issues for reference: https:*developer.blender.org/T77989, https:*developer.blender.org/T90535
Example Tokens
filename.<UDIM>_ver0023.png --> filename.1014_ver0023.png
filename.<u><v>_ver0023.png --> filename.u3v1_ver0023.png
filename.<U><V>_ver0023.png --> filename.u4v2_ver0023.png
filename.<UVTILE>_ver0023.png --> filename.u4_v2_ver0023.png
Note: Blender uses the format but does not support the substitution token. Blender attempts to search and use the first sequence of consecutive numbers it finds within the filename.
Note: Notice that it's generally impossible to guess the correct format if the 0-based or 1-based formats are used within filenames.
MaterialX docs: http://www.materialx.org/assets/MaterialX.v1.38.Spec.pdf (page 18)
OIIO docs: https://openimageio.readthedocs.io/en/master/texturesys.html#udim-texture-atlases
USD docs: https://graphics.pixar.com/usd/docs/api/usd_mtlx_page_front.html
High-Level Goals
Approaches and Constraints
The user's natural workflow imposes a variety of opposing constraints here:
The crux of this is how and where to allow the user to perform scenarios 3 and 4 while still allowing scenarios 1 and 2 to function correctly.
Proposal
Therefore, the proposal is to follow the below approach:
Example Patch to support and token formats during load/save as well as the "fixup" approach outlined above
Note: This patch is not meant to be final code. It disables the existence check on image load and does not implement the "nicer" apis necessary for importers/exporters. It merely demonstrates basic functionality and marks the major code paths that would have to change.
D13057
[Master -- Out of sync + Non-sensical]
[Patch -- Showing what's possible so far]
Added subscriber: @deadpin
Added subscriber: @GeorgiaPacific
Added subscribers: @LukasStockner, @ideasman42, @brecht
@LukasStockner, @brecht, @ideasman42 : I'd like your input on this task before I go further. Feedback on the high-level goals, the approach I outlined, as well as any ideas you might have for this feature would be appreciated.
Gentle nudge for @brecht and @campbellbarton. I'd like to make progress on this for 3.1 but need some feedback on the general approach before solidifying the patch above any further. I'm available here and in chat for any clarifying questions or feedback.
Added subscriber: @mont29
Sorry for the late reply.
All this sounds good.
This sounds reasonable to support by itself, but in the screenshot I see the image file path has tokens in it. That goes beyond the file browser, and affects add-ons, file packing, find missing files and other types of generic file path handling in Blender.
Can we put UDIM tokens in
image.filepath
, and what are the implications of that for the rest of Blender and add-ons? Or do we perhaps store a separate filename with tokens? It could be argued that in order for add-ons and built-in operators to fully support UDIM, they need to be aware of it regardless and storing the filename with tokens separately would still require them to be updated in some other way. So then we might as well bite the bullet? And then we need to look through the various places that use this filepath to asses what needs to be done.@mont29 might also have an opinion on this. It's rather annoying to have to deal with file paths that are not really one filepath. Though we already have this with e.g. image or alembic sequences, just that the filepath normally actually exists on disk as the first frame in the sequence.
Or are you proposing to make a more limited change that only affects the file browser? If so I don't really understand what the plan is for e.g. importers/exporters.
@brecht Good point. You're correct that the
Image.filepath
field would be virtual for IMA_SRC_TILED images now. Any internal/external code that handles tiled images, AND makes use of the filepath, would change in some way. If we add another field, and keep the original filepath referencing a concrete path, downstream code would still have to change as you mention to handle things correctly[1].This is the reason I had to start the patch, to see what actually breaks. If I remember right, the only thing that immediately broke, and still needs addressing, is the file existence check you allude to on Image load (BKE_image_load). It's skipped wholesale in the prototype but we'd have to do something different for real to not regress normal image sources. The general workflow for UV editing/painting/rendering seems fine but that is the extant of what I've tested to prove out the prototype.
Perhaps we're also lucky in that, today, UDIMs do not support packing...
For importers/exporters, the plan is to provide them an API that would get them out of the business of using the filepath directly as much as possible.
For reference you can see Michael's USD code that's in review which has to do things the hard way and is duplicative in some form: https://developer.blender.org/D13297 (usd_reader_material.cc)
Ideally, there would be a somewhat general way for USD to exchange with blender the virtual paths directly. So yes the proposal does go beyond the File-Selector / filepath issues and extends to the I/O area but I do not have an API example to provide just yet.
Putting UDIM tokens in
Image.filepath
I think is reasonable then, the practical impact does not seem that big.For built-in operators, I can only think of image open and save operators, and find missing files. For find missing files we could perhaps add an option for the path iterator to return one real filename from the first tile.
I would rather really, really prefer to not allow forbidden path characters in our file paths. For any reasons. Doing otherwise means you have to check the entire filepath handling code to ensure it is resilient to those invalid characters, it does not 'fix' them in some places (see
BLI_filename_make_safe()
inBLI_path_util
, that change there in D13057 is an absolute red flag for me), while still not allowing them in all-but-special-allowed-cases...This would be opening a can of worms, and adding a significant amount of complexity to our path handling system.
So I would advocate for using a specific dedicated field for those tokens, with a dedicated proper API for it (probably at
BKE_image
level), and not make generic filepath handling have to deal with such special corner case all over the place.I think there's two levels to this. I agree that we should not be making changes at the
BLI_path
level. The only thing that's really relevant to this inBLI_path
seems to beBLI_filename_make_safe
andBLI_path_make_safe
. We could keep those unchanged.<
and>
even work fine in filenames on Linux and macOS, and we can load and save e.g. .blend files with such characters. The reason these functions were modified in D13057 seems to be for the file browser path validation, but we can instead handle the UDIM case at the file browser level.The other thing is if we allow these characters in
Image.filepath
, and I think when it comes to that it is cleaner to do that rather than store them separately. We have to deal with them one way or another, but in practice the amount of affected code seem small. I'm guessing the idea with UDIM was also that such tokens generally pass through file path handling in various apps and libraries ok.I updated the patch to address the
<
and>
issue for the File-Selector, indeed the only reasonBLI_filename_make_safe
had to change was because of this particular code path. All other existing users of it should now be unaffected at least.All tests now pass as well.
Changed status from 'Needs Triage' to: 'Confirmed'
Changed status from 'Confirmed' to: 'Resolved'
This design task has been resolved by D13057/rB180b66ae8a1f.