The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.
step(y, x) _is_ a conditional! It compiles to identical code as:
float val = (x >= y ? 1.0 : 0.0)
or
float val = 0.0;
if (x >= y) val = 1.0;
Quote
SHADER BASICS 4
STEP AND SMOOTHSTEP
As I mentioned, having conditionals in shader is usually frowned upon, so
"step" and "smoothstep" come in to save the day by giving you a whole lot of flexibility in that regard!
twitter.com/HarryAlisavaki
#shaders #shaderbasics
125

