Skip to content

Instantly share code, notes, and snippets.

View BelmuTM's full-sized avatar
🌺
Beep Boop

Belmu BelmuTM

🌺
Beep Boop
View GitHub Profile
@BelmuTM
BelmuTM / sorting_algorithms.py
Last active May 30, 2024 21:26
Simple Python Sorting Algorithms
def quick_sort(s: list, start: int, end: int):
if start < end:
pos = start
for i in range(start, end):
if s[i] < s[end]:
s[i], s[pos] = s[pos], s[i]
pos += 1
s[pos], s[end] = s[end], s[pos]
@BelmuTM
BelmuTM / raytracer.glsl
Last active April 2, 2024 19:16
GLSL Screen Space Raytracer - Free to use for learning purposes
#define BINARY_REFINEMENT 1
#define BINARY_COUNT 4
#define BINARY_DECREASE 0.5
vec3 diagonal(mat4 mat) { return vec3(mat[0].x, mat[1].y, mat[2].z); }
vec3 projectionOrthogonal(mat4 mat, vec3 v) { return diagonal(mat) * v + mat[3].xyz; }
vec3 viewToScreen(vec3 viewPos) {
return (projectionOrthogonal(gbufferProjection, viewPosition) / -viewPosition.z) * 0.5 + 0.5;
}
@BelmuTM
BelmuTM / oren_nayar_diffuse.glsl
Last active May 1, 2022 02:05
Oren-Nayar Quantitative model - From the original paper
#define EPS 1e-4
#define PI 3.14159265
#define INV_PI 0.31830988
float maxEps(float x) { return max(EPS, x); }
float clamp01(float x) { return clamp(x, 0.0, 1.0); }
float pow2(float x) { return x*x; }
vec3 pow2(vec3 x) { return x*x; }