Skip to content

Instantly share code, notes, and snippets.

View Rexagon's full-sized avatar
🦀

Ivan Kalinin Rexagon

🦀
View GitHub Profile
@munrocket
munrocket / wgsl_3d_sdf.md
Last active September 15, 2024 15:11
WGSL 3D SDF Primitives

WGSL 3D SDF Primitives

Revision: 06.08.2023, https://compute.toys/view/407

Sphere - exact

fn sdSphere(p: vec3f, r: f32) -> f32 {
  return length(p) - r;
}
@munrocket
munrocket / wgsl_noise.md
Last active September 3, 2024 14:53
WGSL Noise Algorithms

WGSL Noise Algorithms

Good and fast integer hash

// https://www.pcg-random.org/
fn pcg(n: u32) -> u32 {
    var h = n * 747796405u + 2891336453u;
    h = ((h >> ((h >> 28u) + 4u)) ^ h) * 277803737u;
    return (h >> 22u) ^ h;
}