#include "Pipelines/NPR_Pipeline.glsl"
//Perlin noise functions adapted from https://en.wikipedia.org/wiki/Perlin_noise#Implementation by Riya.
float interpolate (float a, float b, float t)
return a + (t * (b - a));
vec2 random_gradient(int ix, int iy)
//change the first number to make it seem to churn/flow
float random = 2000 * sin(ix * 21942 + iy * 171324 + 8912) * cos(ix * 23157 * iy * 217832 + 9758);
vec2 returner = vec2(cos(random), sin(random));
float dot_grid_gradient(int ix, int iy, float x, float y)
vec2 gradient = random_gradient(ix, iy);
float x_distance = x - ix;
float y_distance = y - iy;
return ((x_distance*gradient.x) + (y_distance*gradient.y));
float perlin_2d(float x, float y, float scale)
float SmoothX = x - XLeft;
float SmoothY = y - YBottom;
float n0 = dot_grid_gradient(XLeft, YBottom, x, y);
float n1 = dot_grid_gradient(XRight,YBottom,x,y);
float interpolated_x = interpolate(n0,n1, SmoothX);
n0 = dot_grid_gradient(XLeft,YTop,x,y);
n1 = dot_grid_gradient(XRight,YTop,x,y);
float interpolated_y = interpolate(n0,n1,SmoothX);
return interpolate(interpolated_x,interpolated_y,SmoothY);