UV Export: add option to export UV tiles #104940

Merged
Damien Picard merged 4 commits from pioverfour/blender-addons:dp_export_uv_udim into main 2023-10-09 22:32:24 +02:00
Member

Tiles can now be exported, with either the UDIM or UVTILE numbering
scheme.

Exporters for PNG, SVG and EPS were updated. The vector formats simply
offset the view, so all UVs can end up being exported multiple times.

Only tiles containing UV points will be exported. In theory, this may
result in some polygons being ignored, if they cross a whole otherwise
empty tile, but this should not happen in practice.

Fixes #74325

Tiles can now be exported, with either the UDIM or UVTILE numbering scheme. Exporters for PNG, SVG and EPS were updated. The vector formats simply offset the view, so all UVs can end up being exported multiple times. Only tiles containing UV points will be exported. In theory, this may result in some polygons being ignored, if they cross a whole otherwise empty tile, but this should not happen in practice. Fixes #74325
Damien Picard added the
Interest
UV Editing
label 2023-10-08 23:52:29 +02:00
Damien Picard added 1 commit 2023-10-08 23:52:32 +02:00
Tiles can now be exported, with either the UDIM or UV numbering
scheme.

Exporters for PNG, SVG and EPS were updated. The vector formats simply
offset the view, so all UVs can end up being exported multiple times.

Only tiles containing UV points will be exported. In theory, this may
result in some polygons being ignored, if they cross a whole otherwise
empty tile, but this should not happen in practice.

Fixes #74325
Jesse Yurkovich reviewed 2023-10-09 03:20:45 +02:00
Jesse Yurkovich left a comment
Member

Ah, thanks for picking this task up! I should have done so when adding the UDIM and UVTILE patterns last year. Left 2 comments to consider but functionally it works well on some simple setups as well as the "Monster - UDIM" demo file.

Ah, thanks for picking this task up! I should have done so when adding the UDIM and UVTILE patterns last year. Left 2 comments to consider but functionally it works well on some simple setups as well as the "Monster - UDIM" demo file.
@ -57,0 +62,4 @@
('UDIM', "UDIM",
"Export tiles in the UDIM notation: 1001 + u-tile + 10*v-tile"),
('UV', "UV Tiles",
"Export tiles in the UV notation: u(u-tile + 1)_v(v-tile + 1)"),

I wonder if we should be more descriptive here? Maybe call the items "UDIM format" and "UVTILE format" as these are the 2 formats that both Blender and MaterialX supports and their names are somewhat known in the ecosystem [1]. Also because there's another "uvtile format" (lowercase) which is slightly different [2]

[1] https://materialx.org/assets/MaterialX.v1.38.Spec.pdf (Page 18)
[2] https://openimageio.readthedocs.io/en/v2.5.4.0/texturesys.html#udim-texture-atlases

I wonder if we should be more descriptive here? Maybe call the items "UDIM format" and "UVTILE format" as these are the 2 formats that both Blender and MaterialX supports and their names are somewhat known in the ecosystem [1]. Also because there's another "uvtile format" (lowercase) which is slightly different [2] [1] https://materialx.org/assets/MaterialX.v1.38.Spec.pdf (Page 18) [2] https://openimageio.readthedocs.io/en/v2.5.4.0/texturesys.html#udim-texture-atlases
Author
Member

Thanks, I wasn’t aware of that! I agree that “UVTILE” should be used instead of “UV Tiles”, but I’m not sure about adding “Format”, it seems redundant to me for the label. From your link, OIIO seems to call these “numbering schemes”, which is more descriptive than “notation”.
How about:

            ('UDIM', "UDIM",
             "Export tiles in the UDIM numbering scheme: 1001 + u-tile + 10*v-tile"),
            ('UVTILE', "UVTILE",
             "Export tiles in the UVTILE numbering scheme: u(u-tile + 1)_v(v-tile + 1)"),
Thanks, I wasn’t aware of that! I agree that “UVTILE” should be used instead of “UV Tiles”, but I’m not sure about adding “Format”, it seems redundant to me for the label. From your link, OIIO seems to call these “numbering schemes”, which is more descriptive than “notation”. How about: ``` ('UDIM', "UDIM", "Export tiles in the UDIM numbering scheme: 1001 + u-tile + 10*v-tile"), ('UVTILE', "UVTILE", "Export tiles in the UVTILE numbering scheme: u(u-tile + 1)_v(v-tile + 1)"), ```
deadpin marked this conversation as resolved
@ -164,0 +210,4 @@
tiles = set()
for poly in polygon_data:
for uv in poly[0]:
tiles.add((floor(uv[0]), floor(uv[1])))

There's a small gotcha here in that UV coords that "touch" the upper edge or the right edge of a tile might be categorized as existing in the tile above or to the right of its "real" tile. I.e. export the default Cube in UDIM layout and you'll get 2 tiles, 1001 and 1011.

You can mimic what's done in Cycles here to lie about such UV coords: https://projects.blender.org/blender/blender/blame/branch/main/intern/cycles/scene/attribute.cpp#L461

There's a small gotcha here in that UV coords that "touch" the upper edge or the right edge of a tile might be categorized as existing in the tile above or to the right of its "real" tile. I.e. export the default Cube in UDIM layout and you'll get 2 tiles, 1001 and 1011. You can mimic what's done in Cycles here to lie about such UV coords: https://projects.blender.org/blender/blender/blame/branch/main/intern/cycles/scene/attribute.cpp#L461
Author
Member

This works well on the cube!

This works well on the cube!
pioverfour marked this conversation as resolved
Damien Picard added 1 commit 2023-10-09 12:03:10 +02:00
- Tweak enum items
- Add a check for UVs at the edge of a tile

Also sort tiles before export so they are exported in a predictable
order.
Damien Picard added 1 commit 2023-10-09 14:14:10 +02:00
Damien Picard added 1 commit 2023-10-09 15:26:34 +02:00
Jesse Yurkovich approved these changes 2023-10-09 21:32:55 +02:00
Jesse Yurkovich left a comment
Member

Looks good to me.

Looks good to me.
Damien Picard merged commit 122534edfb into main 2023-10-09 22:32:24 +02:00
Damien Picard deleted branch dp_export_uv_udim 2023-10-09 22:32:25 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 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-addons#104940
No description provided.