10
$\begingroup$

I am trying to learn some procedural basics. Could you tell me what the fraction math node does? Is the result similar to modulo?

$\endgroup$

2 Answers 2

18
$\begingroup$

Fract returns the fractional part of a floating-point value, as described by @Merlin, but its treatment of negative fractional parts is not actually the same as Blender's implementaion of Modulo.

If you want to see what a mathematical chunk of your shader tree is doing, it can be quite handy to make it generate a graph.

Fract:

enter image description here

This plane is 8x8 units, with its origin, (so (0,0)), at its center. I've added the annotations, but you can see the function without them.

Modulo 1:

enter image description here

Thanks to @Rich Sedman for the very useful graphing tip.

$\endgroup$
5
  • $\begingroup$ Check out page 12 in this scrapbook below. I reconstructed Rich Sedman's node tree and experimentally played around with the settings in nodes. After that, I achieved over 16 interesting different patterns. docs.google.com/presentation/d/… $\endgroup$ Commented Nov 26, 2019 at 13:03
  • $\begingroup$ Merlin, it is good to know usage of each node. I previously didn't know what modulo node was for. There are not many Blenderheads who are good at mathematics. I am relearning mathematics as a hobby. $\endgroup$ Commented Nov 26, 2019 at 13:08
  • 1
    $\begingroup$ @Merlin.. Nothing wrong with your answer, ( I UV'd it :) ) It was only after posting I remembered how often the Blender node mod had caught me out, before I made my own group to do it, and edited the answer.. In GLSL, for example, mod(x,1) and fract(x) would be the same.. it's language dependent. A gotcha, not a bug, AFAIK. $\endgroup$
    – Robin Betts
    Commented Nov 26, 2019 at 14:14
  • 2
    $\begingroup$ It's good to visualize how Blender implements these, they do not always follow mathematical principle, but will favour artistic usefulness. I have updated my answer accordingly $\endgroup$
    – Moog
    Commented Nov 26, 2019 at 14:16
  • 1
    $\begingroup$ @RitaGeraghty .. some nice explorations! Recommend visiting shadertoy and having a go at translating some of those into Blender nodes, if you want a real work-out! :) $\endgroup$
    – Robin Betts
    Commented Nov 26, 2019 at 14:25
8
$\begingroup$

Mathematically it should return the fractional part of the number i.e the non whole-number part, but the blender implementation is artistic in it's implementation.

For non-negative numbers this is equivalent to using the modulo with a factor of 1.0

Equivalent modulo setup

For negative numbers it is equivalent to using modulo with a factor of -1.0

Negative numbers

The equivalent node setup of the fraction node would be:

$\endgroup$

You must log in to answer this question.

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