1
$\begingroup$

I want to create a material node setup that mirrors a UV map on X and Y axes. If I don't need to prepare a mirrored version of the image (4x the pixels) it will save time and memory.

I have managed to do this using a sort of complicated setup with lots of math nodes and a color ramp, but I think there must be a simpler and memory-efficient way.

Here I have the 4 corners mapped out individually, and can preview each one at a time, but I don't know how to combine them using only vector math.

enter image description here

Desired result:

enter image description here

Thanks in advance to anyone with vector expertise who can help.

$\endgroup$
3
  • $\begingroup$ blender.stackexchange.com/a/167035/88681 $\endgroup$
    – scurest
    Jun 18 at 1:07
  • $\begingroup$ @scurest Thanks - yes, that was actually the Q&A I based my current solution on (which I am not completely satisfied with). I'm glad you posted it, as it is good to have as a reference. To the other three people who contributed answers - thank you! I will take some time to compare your answers, weight the benefits of each approach, and choose one to accept. In any case, it is good to know various ways of accomplishing this. $\endgroup$
    – Mentalist
    Jun 18 at 20:36
  • $\begingroup$ @scurest I just noticed you are the author of the accepted answer to that question. I like the simplicity of your node setup. However, the result in the screen shot doesn't tile at the halfway point (x0.5, y0.5) on the plane's UV. $\endgroup$
    – Mentalist
    Jun 18 at 20:48
3
$\begingroup$

This starts off by taking a slightly different approach than Đặng Hải Phụng and make the coordinate space of your plane stretch over -1 to 1. By default this will just tile the UV.

Then we use a Vector Math -> Absolute node so that negative numbers are treated as positive. This gives us a mirror effect on each axis.

enter image description here

$\endgroup$
2
  • $\begingroup$ Your answer is really elegant. All I needed to add was a Mapping node after Absolute for when I want to invert the scale of X or Y. This is just what I was after, so thank you. $\endgroup$
    – Mentalist
    Jun 22 at 6:30
  • $\begingroup$ Glad to have helped. $\endgroup$ Jun 22 at 12:35
1
$\begingroup$

Because blender allows colors and Vectors to be interchangeable in some cases (Both are Vec3 Containers), you should be able to get away with mixing your vectors using MixRGB Nodes blocked off with masks (exemplified in my image by the Separate XYZ and Greater Than Math nodes on the X and Y axis). Using a combination of mapping nodes to orient the initial images (especially scale by -1 on an axis to "flip it") and the masks, I was able to make this. It does use some Object texture coordinates, which I hope isn't a problem for you. I'm sure it works with UV too, I just have to find time to test it. I'll re-upload the modified .blend to save you the time of rebuilding it.

Vector

Let me know if it helps, or if it needs some alterations.

File is here -

EDIT - It works fine with UV coordinates (instead of object for the separate XYZ) - just change the Greater Than thresholds to 0.5

$\endgroup$
4
  • 1
    $\begingroup$ Hey Chris, what about absolute value? $\endgroup$ Jun 17 at 16:16
  • $\begingroup$ Sorry, I'm not sure what you mean by that. This is by no means perfect - it's just what I was able to cobble together in what little time I have. I'll come back to it later to try and find a pure Vector-Mirroring only solution when I have more time to really sink my teeth into it. $\endgroup$ Jun 17 at 16:19
  • $\begingroup$ I'm not at a computer or I'd give it a shot, but I think there is vector math -> absolute value that might do the mirroring for you $\endgroup$ Jun 17 at 16:21
  • $\begingroup$ If there is, it would be awesome. I'll look into it. Thanks. $\endgroup$ Jun 17 at 16:22
1
$\begingroup$

Note: Sorry I didn't read your questions carefully. You already worked out this solution, but I'll leave it here for others to have a look.

here's another approach:

First start with what the texture space should look like? With the understanding that Blender maps the texture (0-1) onto the texture coordinates (0-1), and the texture coordinates being 0-2 due to the tiling value set as 2, so we need to somehow make the texture coordinates become x (0 -> 1 -> 0), y (0 -> 1 -> 0).

enter image description here

This means the part 1->2 become 1->0. We can achieve this by using the mapping node, which allows us to map from one range to another. This node operates in the 0-1 space, so we need to divide the original coordinates by 2, perform the mapping, then multiply them back.

The mapping that needs to be done is (0.5-1) --> (0.5-0), so this means we map 0.5 to 0.5, 1 to 0. The (0-0.5) need to remain the same.

The node setup looks like this:

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.