Added mirror and flip functionality to Layer Special Menu#363
Added mirror and flip functionality to Layer Special Menu#363uraniumcrystalsmaster wants to merge 3 commits into
Conversation
|
Thanks for the PR! I'll test it later 👍 |
|
I'm not sure if I use it correctly or not, but it doesn't work when I tried the mirror operator like the video below. 0001-0331.mp4This is the file to test |
|
I made a faulty assumption: The mirror/flip functionality was not operating on the modifier (wrench tab) transformed object. It was operating on the original object. The best solution I could think of is to use the object's final rendered state for the mirror/flip functionality as there are four modifiers which have additional render settings (sub. surf., ocean, screw, and multi. res.). This ensures the image/paint doesn't look incorrectly mirrored/flipped during rendering unless the render settings of the modifier are changed after. I have implemented the solution completely and will update the PR tomorrow. |
|
Thanks! Just in case you didn't know, you can get the mesh with applied modifier directly in python ( https://blender.stackexchange.com/questions/7196/how-to-get-a-new-mesh-with-modifiers-applied-using-blender-python-api) Anyway, I haven't read the code yet, but why you need the mesh data when you only want to mirror the 2d image, isn't numpy enough for this kind of operation? |
…flipping pass to use a better algorithm
Also, the old face texture transfer of the old mirror/flip when faces were not perfectly symmetrical would create artifacts that looked like severe pixelization because it was copying faces. The new algorithm copies individual pixels and has almost no artifacts. |
|
I see, I'm sorry, I thought it was just a simple image flip at first. This is apparently a very sophisticated operator. I tested this again with the previous file and even non-mirrored UV, and it all works! Nice! But it seems it doesn't produce margin pixels around UV islands, like in the video below. 0001-0529.mp4Sample file: 501_2D_mirror_test_1.zip Also, the projected image is a bit grainy. Is there any way to work around these issues? Maybe sample options or something? One more thing, the operator also doesn't work in UDIM tile outside the number |
Closes #347. Adds two new operators on the right part of the layer special menu under resize and invert for mirroring/flipping texture data across an axis using 3D mesh geometry.
Mirror (wm.y_mirror_image): Overwrites the target side's texture with the source side's.
Flip (wm.y_flip_image): Swaps texture data between both sides.
The user selects an axis (X/Y/Z) and in addition, for mirroring, which side to treat as the source. For perfectly symmetrical meshes, face correspondence is found by mirroring vertex positions and matching via KDTree. For asymmetric meshes, a second pass is used to find the nearest source faces by center distances and interpolate texture data using barycentric coordinates. Expensive operations use numpy for good performance.