Skip to content

Instantly share code, notes, and snippets.

View johnhooks's full-sized avatar

John Hooks johnhooks

View GitHub Profile
@johnhooks
johnhooks / GLSL-Noise.md
Created January 13, 2023 12:18 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

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);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@johnhooks
johnhooks / clock_and_pwm.c
Last active June 30, 2018 14:51
Use an AVR Timer/Counter for both Fast PWM and a rudimentary clock.
/**
* I want to use a counter/timer for PWM and as a rudimentary
* millisecond clock. If I initiate the counter in Fast PWM mode,
* using a clock speed of 1MHz and a prescale of 8, a millisecond will
* elapse every 125 clock ticks.
*/
typedef uint32_t millis_t;
static volatile millis_t milliseconds = 0; /* 49.71 Days of milliseconds */