3
$\begingroup$

I'm trying to setup animated textures with box projection mapping for a cube. with the help of this post, I got a pretty solid result: https://i.sstatic.net/WV3NF.jpg

My current node setup, the color ramp is meant to lock the input from the value node to 0.25 increments, which is used to pan the texture up and down. The texture I'm using is on the left (size is 16x64):

enter image description here

This is what's inside the node group. I have 2 instances of the mapping for the cube, one for the side faces, one for the top and bottom faces. they're then put through the solution I found in the above post, then finally mixed together with a factor value that separates X&Y faces from Z faces:

enter image description here

The Problem:

If parts of the cube's faces end up in the negative XYZ areas of the object's origin, it'll display a different part of the texture, which is something I don't want. I'm pretty sure this is caused by the "object" setting in the texture coordinate, but I need to keep that option so the texture becomes repeatable and is locked to the object coordinates.

enter image description here

So far I've tried adding a math node set to "absolute" before each of the "modulo" math nodes, which kind of fixed it, but made every texture in the negatives get flipped 180 degrees... which is also something I don't want. I don't have deep enough knowledge of nodes to fix specific things like this, any help is appreciated.

$\endgroup$
2
  • 2
    $\begingroup$ can u please provide blend file so we don't have to rebuild? i am pretty sure it can be solved with abs-math-node $\endgroup$
    – Chris
    Commented Dec 23, 2021 at 12:15
  • 1
    $\begingroup$ added a .blend, sorry about that. tried doing this before but for some reason I thought I'd have to install a script to get it to work... realized that was optional. $\endgroup$
    – spyro
    Commented Dec 23, 2021 at 17:57

2 Answers 2

5
+50
$\begingroup$

As @Leander has suggested, there are probably simpler ways to do what you want, but, as this is a common gotcha, it may be worth mentioning .. Blender's implementation of modulo is floor-based, and dips into the negative for negative numerators, as on the left, below:

enter image description here

These graphs are in Object texture-coordinates, origin at center. The left graph is (Y > X mod(1)) the right graph is ( Y > X wrap(0,1) )

TL;DR.. replace your Modulo nodes with Wrap nodes.

$\endgroup$
5
$\begingroup$

You can add another rule for values lower than 0 with the Less Than node.

less than node

Other Method

I think, it could be easier and more flexible, if you simply unwrap the cube first. The node setup gets much easier to read. (I replaced your color ramp to make it more generic for images with more than four parts).

unwrap

node setup

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .