This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float notsosmoothstep(float x, float edge0, float edge1) { | |
x = (x - edge0) / (edge1 - edge0); // [edge0, edge1] -> [0, 1] | |
x = x < 0.0 ? 0.0 : x; // max(x, 0) | |
x = x > 1.0 ? 1.0 : x; // min(x, 1) | |
x -= 0.5; | |
return 2.0*(-x*abs(x)+x)-0.5; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mandelbrot Set | |
bool mandelbrot(vec2 c, int iter) | |
{ | |
// Initialize Z | |
vec2 z = vec2(0.0); | |
// Iterate function (z = z ^ 2 + c) | |
for(int i = 0; i < iter; i++) | |
{ | |
// Check if our point diverged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vec2 bezier(float t, vec2 p0, vec2 p1, vec2 p2, vec2 p3) | |
{ | |
vec2 a = mix(p0, p1, t); | |
vec2 b = mix(p1, p2, t); | |
vec2 c = mix(p2, p3, t); | |
return mix(mix(a, b, t), mix(b, c, t), t); | |
} |