i've recently hit a wall trying to create a smooth stepped function.

Here is what i'm trying to replicate:

enter image description here

Where the rising line would represent a single float output.

I've found something on Math.stackexchange that i think could suit my needs, but my math knowledge is far too limited to try and convert what i've found there into a simple function that i can replicate with math nodes.

I've got a regular stepped function working, but the "switching" is a hard cut atm.

I'm trying to divide a color ramp in equal spacings, where the output color would be "clamped" to an increment, but not like "constant", it should blend to the next color so to say. The output would be remapped to fit the input value for the ramp. It obviously would be possible to do it manually, but i need it a bit more automated.

Hope what i'm trying to do is understandable.

Has anyone got an idea :)? Thanks in advance.


1 Answer 1


The basic idea is to use

$$\mathrm{floor}(x) + \mathrm{smooth}(\mathrm{fract}(x))$$


  • floor(x) is the floor, an unsmoothed step function
  • fract(x) is the fractional part of x
  • smooth(x) is the smoothing function of your choice, defined on the interval [0,1]. For continuity, we require smooth(1) = smooth(0) + 1.

or as nodes

Equation as nodes

where I used a Float Curve node to supply the smoothing function. This produces the following output.

As you can see, this is just a bunch of shifted copies of the smoothing function stuck together.

You can modify this by

  • Replacing the smoothing function to change the "shape" of the steps.
  • Scaling and shifting the input to change the width of the steps and the locations of the "jumps".
  • Scaling and shifting the output to change the height of the steps and the offset of the graph.
  • $\begingroup$ Thank you! Thats amazing, i was hoping i could use a visual way to change the "curve" :) Its far simpler then i thought! $\endgroup$
    – Chris
    Jul 17, 2022 at 11:17
  • $\begingroup$ @scurest Hello! Would you mind sharing the Mathematical intuition behind your Smoothed Floor function? Why did you add Floor and Smoothed out version of Fraction (for example, SmoothStep Interpolated version of Fraction)? -------- For me, it looks like you made the Floor first, then you found a way of Smoothing out the sharp transitions of Floor by adding a small value (close to zero) to the sharp edges and add 1 to both the values on the left (e.g. 1) and right (e.g. 2) of those sharp edges... $\endgroup$
    – Orange Cat
    Feb 11 at 11:38
  • 1
    $\begingroup$ @IanAmbrose That's about right. By definition x = floor(x) + fract(x), eg. 2.3 = 2 + 0.3. Applying a function to the fractional part changes the shape of the graph as it goes from 0.0 to 1.0. $\endgroup$
    – scurest
    Feb 11 at 11:53
  • $\begingroup$ @scurest ...The point of adding values close to zero to the sharp edges seem to be keeping the values there to be close to 2 (i.e. the value on the left of the sharp edge: 1 after adding 1 from the SmoothStep Interpolated values) to have a smooth transition between the left and right side of the sharp edge, smooth transition from 2 (left of sharp edge) to 3 (right of sharp edge). $\endgroup$
    – Orange Cat
    Feb 11 at 11:53
  • $\begingroup$ @scurest Oh wow, didn't expect you to reply this quickly. Thank you! $\endgroup$
    – Orange Cat
    Feb 11 at 11:55

You must log in to answer this question.

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