Skip to content

Instantly share code, notes, and snippets.

@william-silversmith
william-silversmith / springfactory.js
Last active August 25, 2023 12:24
Spring Factory
/* springFactory
*
* Generate a physically realistic easing curve for a damped mass-spring system.
*
* Required:
* damping (zeta): [0, 1)
* halfcycles: 0...inf
*
* Optional:
* initial_position: -1..1, default 1
@yiwenl
yiwenl / GLSL_contrast
Last active September 3, 2023 08:53
Greyscale in glsl
float contrast(float mValue, float mScale, float mMidPoint) {
return clamp( (mValue - mMidPoint) * mScale + mMidPoint, 0.0, 1.0);
}
float contrast(float mValue, float mScale) {
return contrast(mValue, mScale, .5);
}
vec3 contrast(vec3 mValue, float mScale, float mMidPoint) {
return vec3( contrast(mValue.r, mScale, mMidPoint), contrast(mValue.g, mScale, mMidPoint), contrast(mValue.b, mScale, mMidPoint) );
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active April 30, 2024 06:01
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);