Skip to content

Instantly share code, notes, and snippets.

View amytraylor's full-sized avatar
🎯
Focusing

Amy Traylor amytraylor

🎯
Focusing
View GitHub Profile
// Define some constants
const int steps = 128; // This is the maximum amount a ray can march.
const float smallNumber = 0.0001;
const float maxDist = 30.; // This is the maximum distance a ray can travel.
float smin( float a, float b, float k )
{
float h = clamp( 0.5+0.5*(b-a)/k, 0.0, 1.0 );
return mix( b, a, h ) - k*h*(1.0-h);
// Define some constants
const int steps = 128; // This is the maximum amount a ray can march.
const float smallNumber = 0.001;
const float maxDist = 10.; // This is the maximum distance a ray can travel.
float fOpUnionStairs(float a, float b, float r, float n) {
float s = r/n;
float u = b-r;
return min(min(a,b), 0.5 * (u + a + abs ((mod (u - a + s, 2.0 * s)) - s)));
float getBPMVis(float bpm){
// this function can be found graphed out here :https://www.desmos.com/calculator/rx86e6ymw7
float bps = 60./bpm; // beats per second
float bpmVis = tan((time*PI)/bps);
// multiply it by PI so that tan has a regular spike every 1 instead of PI
// divide by the beat per second so there are that many spikes per second
bpmVis = clamp(bpmVis,0.,10.);
// tan goes to infinity so lets clamp it at 10
bpmVis = abs(bpmVis)/20.;
void main() {
vec2 pos = uv(); // origin is in center
// who remembers SOH CAH TOA ?
// tan, given an angle will return the ratio
// so if we only have the ratio of position
// we use atan to get the angle
float angle = atan(pos.y/pos.x);
// i copied and pasted these functions from the sticker sheet
// to read more about turbo: https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
// in short, its good for colorblindness, getting more deatil (based on human perception), high contrast
// but still smooth interpretation of the in-value
vec3 turboPalette(float x){ // t can be any floating point number that changes, like time or pos.x;
float m = 1.0; // it repeats every 1 unit, because thats the turbo function's range
float t = m - abs(mod(x*20. , (2.*m)) - m);
// this line turns an increasing value into a triangle wave, linear interpolation of length 1 up
// linear interpolation of length 1 down. like this: /\/\/\/\/\/\/\/\/\/\/\/\/\/