Nodes: the modulo math node problem

Hi all :slight_smile:

just a little word about this node:

and the way it works…
as it took 1 day to me for understanding it didn’t work as i thought.
Blender docs on nodes are this shitty that they limit to explain that the output of a node comes from the choosen operation on input data XD

while it’s true, it’s far from clear and if ‘abs’ has no possible discussion, some nodes like modulo, have !

First of all let’s have a look a the wikipedia info about modulo.

( oh nice, the forum shows the picture… )

what modulo node does is the curves of the top.
what i need is the curves of the bottom ( for wrapping uv coords on an atlas texture )

there fore i had to rewrite my own modulo so that it works like i need.
here it is in case someone would need it :slight_smile:

happy blending !

Looks very familiar to my own fModContinuous node. I didn’t check the math, but I assume it produces a continuous sawtooth across zero? Sometimes I prefer to just add some random integer to avoid negatives, but this is safer as you shouldn’t loose accuracy in far away places.

Put three of them together and you have a vModContinuous node as well - very useful as well.

i wish i found your node before :wink:

Yes i produce always a positive and same sawtooth over and under 0

and it works fine for wrapping textures coords whatever the domain is, positive or negative.

I’ve hit the same problem in the past. My solution was to Modulo, Add, then Modulo again (all using the “Modulus” value) and I believe this produces the correct result :


Hmmmm i should test this one ^^ how do you handle the sign change ?

but it looks interresting :slight_smile:
thx @BaldingWizard

happy blending ^^

@pitibonom With this method the result is always positive regardless of the sign of the modulus or the input - so it produces the output as defined in the Euclidian Division in your linked examples, ideal for UV mapping.

shit ! this is not obvious ! but sounds great and much simpler than my nodes !!!

have to test this right now ! x))

thanks @BaldingWizard !

happy blending !

waw !!!

This is those king of things i love !!!
ppl with a knowledge i haven’t, giving lil treasures to the community 8-D

Firts let’s confirm i’m a dumb ass in math and algebra ( i’m better in other things… i hope :stuck_out_tongue: )

here’s the standard modulo result:

here green is Y and red is X ( and we’re interrested in X as it’s where i apply the modulo on this example )…

Another pic ( the same with some writings from me… )

at the left of this limit,
what i need is red 100%. and when moving left, red decaying to 0%.
what i got is red 0% 0% and 0%… red is just less than one and cannot be displayed in another way than 0…

now here’s the result from MY modulo ( the one nodes i posted above )

It’s just perfectly what i need !
Under 0 red becomes 100% and moving towards negative values, red fades to 0 ( according to the modulus ) and then restarts at 100%… etc…

just what i need !!! 8-D

@BaldingWizard’s node result:

except that:
His nodes solution is much simpler than mine and above all is purely algebric ! ( with no test for above/under zero )

just have to write: RESPECT !!!

and thank you very much @BaldingWizard for this lil pearl :slight_smile:

We can substract both nodes ( mine and @BaldingWizard’s one ) and multiply the difference to enhance discontinuities… there’s none… red totally disappears and this are perfect.

Definetely i adopt this nodes as THE modulo node when i need to wrap UVs in another way than 0-1

happy blending !


Really glad I could help - and that’s a really thorough analysis! In case you’re interested, I came up with this solution as part of a StackExchange answer at and there’s additional explanation there.

happy blending ! :slight_smile:

1 Like

this is just amazing ! and explain all :slight_smile:

thx again @BaldingWizard !

and happy blending ! :slight_smile:

1 Like