Skip to content

Instantly share code, notes, and snippets.

View ItsVerday's full-sized avatar
🤖
Being a totally real human

Verday ItsVerday

🤖
Being a totally real human
View GitHub Profile
@ItsVerday
ItsVerday / clover_noise_2d.fsh
Last active April 25, 2020 16:56
Clover Noise 2D GLSL (Optimized v3, commented)
// How far points in grid cells can go from the center of the grid cell. Setting this to a value above 0.5 will make the noise discontinuous, and there will be visible seams.
// It is reccomended to leave this at 0.3.
const float CLOVER_NOISE_2D_POINT_SPREAD = .3;
// The value of pi. Used in the offset function.
const float CLOVER_NOISE_2D_PI = radians(180.);
// Hashes a 2D vector into a point. It isn't 100% random, but it's good enough for clover noise to appear random.
float clover_noise_2d_hash(vec2 p) {
return fract(1e4 * sin(17.0 * p.x + p.y * 0.1) * (0.1 + abs(sin(p.y * 13.0 + p.x))));