Skip to content

Instantly share code, notes, and snippets.

View Zi7ar21's full-sized avatar
🧓
Writing C/C++

Jacob Bingham Zi7ar21

🧓
Writing C/C++
View GitHub Profile
@Zi7ar21
Zi7ar21 / notsosmoothstep.h
Created May 19, 2023 18:36
Smoothstep but less continuous
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;
}
@Zi7ar21
Zi7ar21 / mandelbrot.glsl
Last active May 3, 2022 00:16
A simple glsl function that checks if a point is part of the mandelbrot set.
// 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
@Zi7ar21
Zi7ar21 / bezier.glsl
Last active May 3, 2022 00:17
GLSL Bezier Curve Points
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);
}