Last active
April 18, 2020 16:09
-
-
Save CharStiles/69e7fa8d16dcbd4c02f7b8947706a559 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 150 | |
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform vec3 spectrum; | |
uniform sampler2D texture0; | |
uniform sampler2D texture1; | |
uniform sampler2D texture2; | |
uniform sampler2D texture3; | |
uniform sampler2D prevFrame; | |
uniform sampler2D prevPass; | |
in VertexData | |
{ | |
vec4 v_position; | |
vec3 v_normal; | |
vec2 v_texcoord; | |
} inData; | |
out vec4 fragColor; | |
float circ(vec2 p){ | |
return length(p) - 0.5; | |
} | |
// http://www.iquilezles.org/www/articles/palettes/palettes.htm | |
// As t runs from 0 to 1 (our normalized palette index or domain), | |
//the cosine oscilates c times with a phase of d. | |
//The result is scaled and biased by a and b to meet the desired constrast and brightness. | |
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d ) | |
{ | |
return a + b*cos( 6.28318*(c*t+d) ); | |
} | |
void main(void) | |
{ | |
vec2 fragCoord = inData.v_texcoord * resolution.xy; | |
vec2 p = (-resolution.xy + 2.0*fragCoord)/resolution.y; | |
// distance metric | |
float shape = circ(p+vec2(spectrum.x * 20)); | |
vec3 col = cosPalette(0.5,vec3(0.5),vec3(0.5),vec3(1),vec3(time*0.01,time*0.1,time*.2)); | |
// lighting: darken at the center | |
col = vec3(shape) * col; | |
// output: pixel color | |
fragColor = vec4( col.bgr, 1.0 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment