- Duncan-Readle changed review status to Awaiting Review
- 1 mo
Snap UV's to user defined custom grid with a single button!
Note: the operator picks the corners of the UV selection based on the UVs closest to the boundaries of the atlas box they lie within. If you're getting strange results, try moving the four UVs you want to act as the corners during snapping closer to the corners of the atlas box they're in.
The UV workflow that this add-on supports is based on atlas textures, grid based textures that can be used to add edge details to objects. The intention is that the edges of a face, or group of faces, should match up to the grid lines on the atlas, which is where snapping comes in handy. The texture itself can be made however you like, but the mesh version has some requirements:
See the images on this page for an example of what an atlas might look like. An example atlas with a matching texture can be added to the scene using the "Create Example Atlas" button.
This extension does not require special permissions.
I add cube and torus, set one of them as Atlas option, go into edit mode for second option, press "Snap UV to Atlas" and get giant python error.
Please provide more information about how to use the add-on. Video only shows snapping happening, but not how it should be set up. Written text would be good about what atlases are, how they should be used, what qualifies as good atlas and etc.
I see that you're using bpy.ops
submodule for some operations, which are very unsafe and context dependant. It is generally recommended to avoid using it whenever possible and instead use lower-level API to perform operations, but if its unavoidable at least you should implement proper polls or measures to guarantee correct context (which is most of the time object mode)
I confirmed that previous error I mentioned happens when I don't have UVs selected.
When I have cube as atlas and go into edit mode with torus, and select only one UV face and click operator I get this error
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 1197, in execute
CurrentBox, UVBoundsCentre, UVBounds = FindCurrentBox(bm, vert_array, edge_uv_array, atlas_u, atlas_v)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 566, in FindCurrentBox
boxbounds.append(FindClosestValuefromArray(UVBounds[2], atlas_u, 1))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 146, in FindClosestValuefromArray
closest_value = min(value_dist_array, key=lambda i: i[1])[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: min() arg is an empty sequence
Error: Python: Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 1197, in execute
CurrentBox, UVBoundsCentre, UVBounds = FindCurrentBox(bm, vert_array, edge_uv_array, atlas_u, atlas_v)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 566, in FindCurrentBox
boxbounds.append(FindClosestValuefromArray(UVBounds[2], atlas_u, 1))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Blender Foundation\blender-4.3.0-alpha+main.1bc0ec1b80a1-windows.amd64-release\portable\extensions\user_default\UV_Snapper\__init__.py", line 146, in FindClosestValuefromArray
closest_value = min(value_dist_array, key=lambda i: i[1])[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: min() arg is an empty sequence
My bad, completely forgot to explain the atlas side of things. I'll add a section to the description on how to create one, a video to go with it and some example images. There's a few places at the start where I think I need to use bpy.ops to help validate the UV selection, but I can probably get rid of a lot of the others. In terms of validation/context, the operator button won't appear unless the user is in edit mode, but I'll add some extra steps to make sure everything is valid
Added a quick start video, more explanation in the description, multiple input validation checks and a "Create Example Atlas" operator
I missed this one. When you make requested changes you need to choose "Awaiting Review" tag when commenting so moderators are notified. Can you set the tag now so we can attend to this in coming days?
Sorry, think that's it now?
Audio in video uploaded is inaudible, Can you take a look at that? And issue I pointed out isn't resolved. It still throws giant error when I:
Does it NEED to be example object it creates? Does it not work with any given object? To be honest I'm struggling to understand purpose of this. In first video it seems to have bounds defined and unwraps to that bounds, but only way I can use it is to straighten UVs. That surely can't be only purpose of this?
Hi Nick, Neither of the two videos have any audio. This is intentional as I didn't plan on adding voice over commentary. Is this required? If so I'll happily add it.
Totally my bad on the error, that specific set of objects creates an edge case which I hadn't considered. Should have tested that! I'll add an error message explaining what is wrong with the atlas object.
The example object is there as an example of what an atlas looks like for this texturing workflow. In addition to the written section explaining the intended use and basic requirements for the atlas which I've included on this page, I will replace the first video with a longer video which will detail the same requirements and give a demonstration of the texture/uv workflow which the add-on is designed to support. This will include captions, and audio if that is required.
Audio isn't required, but second video has it and it threw me off. I think you accidentally recorded it. When you fix error we can approve, any workflow is fine we just need to account for common errors.
Yep that was an accident, I'll remove the audio from the second one. Error fix will be a quick one, I'll push that and then add a clearer video a bit later then. Thanks for your help
Updated the quick start video (hopefully without audio now), added an error message to that exception, and added a png atlas texture which matches the generated example atlas.
Thanks
updated description
Sign in to comment.
Ready for review