someone please help me out here, im a beginner and im really frustated
from what i understand, the modulo operation (outside blender) returns the remainder of a division operation?
for example 5 mod 2 = 1 or 3 mod 3 = 0, have i got this right?
but inside blender shading nodes, when i connect the same value node (3) to both inputs of a math truncated modulo node (so 3 mod 3), the output i get is 3
i expected the output to be 0 since the remainder of 3/3 is 0
thanks for the reply, im afraid i cant understand your suggestion though
the compare node compares the modulo output against the value of 3 with an epsilon set to 0.010 and outputs 1 / white which means that the modulo output value falls within the range of 2.990 to 3.010
so how could it be 0 as you say? am i missing something?
here is epsilon set to 0 as you suggested, unsurprisingly same result, the compare node still outputs 1 / white showing that the modulo output is 3
could you please try something if its not much trouble
set the same nodes as shown in the picture with the exact same values (exact though)
then toggle between eevee and cycles and tell me if you see any differences
yes, i know, thats what i was expecting to get obviously, thnx for the reply
no, there are no other material slots
i found two clues
the problem happens only with eevee, not with cycles
the behavior occurs only with certain values
if the value is 1, 2, 4, 5, 10, 11 etc then the result is black in eevee and in cycles
if the value is 3, 6, 12, 13, 14, 15, 24, 30 etc then the result is white in eevee and black in cycles
here are some screenshots plus the file itself although i dont expect it to be of any help
thnx for the reply, so you think it might be a bug then?
then at least i can finally stop trying to make it work and just do it with division and subtraction nodes
im building a large and complex shader and this was frustrating me
still, im a bit hesitant to report it as a bug because everyone else says its working fine on their system but also i dont see how such an obvious bug in such a popular (i assume) basic node could have gone unnoticed by other users
3 mod 3 == 0 but Blender (Eevee) says 3 mod 3 == 3, then it has to be a bug. (something designed and supposed to work, but it doesn’t)
I can also confirm that it’s happening in my machine (AMD, all versions since 3.6 up to 4.3.1).didn’t test even older versions… but it might still be there
It’s funny that until now nobody really stepped into this!!!
(I rarelly use Eevee, but still…)
Yeah I’d report it aswell. To give you some feedback I dont get with integer values here as you get, just with some float values like eg 3.2, but then also just in Eevee and not Cycles. I am not sure if the modulo node here is defined to work fully on float values though.
It may be that NVidia cards don’t have this problem… (and would explain that I’ve never encountered this before)
If it’s a floating point error, then it’s completly dependent on the video card/driver, and some alternative procedure must be created for the ‘faulty’ chipsets.
Still, it’s a bug and should be reported.
wow, so its not just me
and it could be related to hardware (i really wouldnt see that coming)
but that would explain why some users get it and some dont
also its safe to assume that the majority of users would be using nvidia for the benefit of gpu acceleration so that also partially answers why not many people have encountered this issue if the source of the problem is indeed hardware/driver related
i will mark Secrop s answer as a solution
also thanks a lot for your replies and tests everyone
Out of curiosity, does it happen with cycles set to CPU too? And are both floored and truncated modulo buggy? (Cannot replicate it here either btw, gtx 1060)
comparing mod output with input value and 0 and then multiply the inverse would be my idea for a workaround but this is definitely a bug. modulo_bug.blend (453.4 KB)