JavaScript(control code)
GLSL(shader code)
Result
Documentation(GLSL function prototypes)
//Newer GLSL version compatibility
vec4 texture(sampler2D s, vec2 texcoord)
vec4 texture(samplerCube s, vec3 texcoord)
                
//HLSL compatibility
float saturate(float x)
vec2 saturate(vec2 x)
vec3 saturate(vec3 x)
vec4 saturate(vec4 x)
float frac(float x)
vec2 frac(vec2 x)
vec3 frac(vec3 x)
vec4 frac(vec4 x)
                
//Math
const float PI
vec4 taylorInvSqrt(vec4 r)
mat3 RotationEulerMatrix(vec3 rotRads)
float ExpSmoothMin(float a, float b, float k)
float ExpSmoothMin(float a, float b)
float SmoothMin(float a, float b, float k)
float SmoothMin(float a, float b)
float PowerSmoothMin(float a, float b, float k)
float PowerSmoothMin(float a, float b)
genType sqr(genType x)
genType sinh(genType x)
genType cosh(genType x)
genType tanh(genType x)
genType sigma(genType x) = x / (1.0 + abs(x))
genType sinc(genType x) = sin(x) / x
                
//SDF for 3D primitives with center at {0,0,0}
float SphereSignedDistance(vec3 point, float radius)
float PlaneSignedDistance(vec3 point)
float BoxSignedDistance(vec3 point, vec3 extents)
float RoundBoxDistance(vec3 point, vec3 extents, float radius)
float TorusSignedDistance(vec3 point, vec2 magMinRadius)
float HexPrismSignedDistance(vec3 point, vec2 h)
float CapsuleSignedDistance(vec3 point, vec3 a, vec3 b, float radius)
float TriPrismSignedDistance(vec3 point, vec2 h)
float CylinderSignedDistance(vec3 point, vec2 h)
float ConeSignedDistance(vec3 point, vec3 c)
                
//Pseudo random numbers, hashes
float frand(vec2 seed)
vec2 f2rand(vec2 seed)
vec3 f3rand(vec2 seed)
float permute(float x)
vec3 permute(vec3 x)
vec4 permute(vec4 x)
vec2 fade(vec2 t)
vec3 fade(vec3 t)
                
//Perlin noise
float snoise(vecN v)
float cnoise(vecN v[, vecN period=vecN(289.0)])
vec2 cellular(vec2 P[, vec2 rep=vec2(289.0)])
vec2 cellular(vec3 P[, vec3 rep=vec3(289.0)])
vec2 grad2(vec2 p, float rot)
float srdnoise(vec2 P, float rot, out vec2 grad)
float FloatHash(float n)
float FloatHash(vec2 v)
vec2 Vec2Hash(vec2 v)
vec3 Vec3Hash(vec2 v)
float ValueNoise2D(vec2 v)
float ValueNoise3D(vec3 v)
float ValueNoise3D(vec3 v, sampler2D noiseTex, vec2 noiseTex_PixelSize)
float GradientNoise(vec2 v)
vec2 SmoothVoronoi(vec2 v, float smoothness)
float Voronoise(vec2 x, float gridControl, float metricControl)
                
//Multiple perlin noise octaves
float PerlinOctaves(vecN coord, vecN repeat, int octaves[, float gain=0.5, float lacunarity=2.0, vecN offset=vecN(0.0)])
                
//Multiple perlin noise octaves with specified low (coeffLow) and high (gainHigh) levels of frequency.
//Matches PerlinOctaves with coeffLow = 1 and gainHigh = gain
float PerlinOctavesSpectrum(vec2 coord, vec2 period, int octaves, float coeffLow, float gainHigh[, float lacunarity, vec2 offset])
                
//Color spaces
vec3 RGB2HSV(vec3 c)
vec3 HSV2RGB(vec3 c)
vec3 RGB2YUV(vec3 rgb)
vec3 YUV2RGB(vec3 yuv)
vec4 RGB2RGBM(vec3 color)
vec3 RGBM2RGB(vec4 rgbm)
float Linear2SRGB(float x)
vec2 Linear2SRGB(vec2 x)
vec3 Linear2SRGB(vec3 x)
vec4 Linear2SRGB(vec4 x)
float SRGB2Linear(float x)
vec2 SRGB2Linear(vec2 x)
vec3 SRGB2Linear(vec3 x)
vec4 SRGB2Linear(vec4 x)
                
//Normal from height map calculation
vec3 NormalFromHeights(float center, float right, float bottom, float scale)
vec3 NormalFromHeightMapR(sampler2D hmap, vec2 pos, float scale, vec2 pixelSize)
vec3 NormalFromHeightMapG(sampler2D hmap, vec2 pos, float scale, vec2 pixelSize)
vec3 NormalFromHeightMapB(sampler2D hmap, vec2 pos, float scale, vec2 pixelSize)
vec3 NormalFromHeightMapA(sampler2D hmap, vec2 pos, float scale, vec2 pixelSize)
void Gather8AdjacentTexelsR(sampler2D tex, vec2 pos, vec2 texelSize, out vec4 top, out vec4 bottom)
void Gather8AdjacentTexelsG(sampler2D tex, vec2 pos, vec2 texelSize, out vec4 top, out vec4 bottom)
void Gather8AdjacentTexelsB(sampler2D tex, vec2 pos, vec2 texelSize, out vec4 top, out vec4 bottom)
void Gather8AdjacentTexelsA(sampler2D tex, vec2 pos, vec2 texelSize, out vec4 top, out vec4 bottom)
vec3 NormalFromHeightMapSobel3R(sampler2D hmap, vec2 pos, float scale, vec2 texelSize)
vec3 NormalFromHeightMapSobel3G(sampler2D hmap, vec2 pos, float scale, vec2 texelSize)
vec3 NormalFromHeightMapSobel3B(sampler2D hmap, vec2 pos, float scale, vec2 texelSize)
vec3 NormalFromHeightMapSobel3A(sampler2D hmap, vec2 pos, float scale, vec2 texelSize)
                
//Convolution, blur, image differentiation
vec4 ConvolutionFilter3(sampler2D s, vec2 pos, vec2 st, float kernel[9])
vec4 ConvolutionFilter5(sampler2D s, vec2 pos, vec2 st, float kernel[25])
vec4 ConvolutionFilter7(sampler2D s, vec2 pos, vec2 st, float kernel[49])
vec4 EdgeDetect(sampler2D s, vec2 pos, vec2 texelSize)
vec4 GaussianBlur9(sampler2D s, vec2 center, vec2 dir)
vec4 GaussianBlur17(sampler2D s, vec2 center, vec2 dir)
vec4 NoiseBlur(sampler2D s, vec2 center, float blurAmount)
vec4 DiffFree(sampler2D s, vec2 pos, vec2 pixSize)
                
//Filtered texture sampling
vec4 textureBicubic(sampler2D tex, vec2 texcoord, vec2 texelSize)
vec4 textureSmooth(sampler2D tex, vec2 texcoord, vec2 texelSize)
                
//Grid generation
float GenBricks(vec2 pos, ivec2 count, vec2 dist, float scrollX)
void HexGrid(out vec4 o, vec2 TexCoord)
                
//Packing float to 8-bit channels, useful for old mobile devices
vec4 EncodeFloatAsRGBA8(float v)
float DecodeFloatFromRGBA8(vec4 rgba8)
vec2 EncodeFloatAsRG8(float v)
float DecodeFloatFromRG8(vec2 rg8)