Hopefully I can finish this one today.
This one is super straight forward. It gives you either -1 or 1 according to the sign of the input.
y = sign(x)
It's useful to get a square wave, by retrieving the sign of sin of x. y=sign(sin(x))
:
Straight forward as well, but I can already see so many uses for this.
For example, if we clamp our abs() example from before, we can get some flat mesas:
y = clamp(abs(sin(x)), 0.2, 0.6)
If I add a bit of mouse interaction it becomes a bit easier to understand. Move the mouse left & right to control the min clamp value and the move it up & down to control the max clamp value:
y = clamp(abs(sin(x)), (mouse.y / resolution.y), (mouse.x / resolution.x))
The other two functions mentioned are max() and min(), but those are so simple I won't create a shader for them.
The next section, "Advanced shaping functions" is very theory heavy. I want to make sure I fully understand it before continuing, by going back to 3B1B videos.