Last active
April 6, 2018 10:40
-
-
Save bmjstau/caf898d6499406e0f552441c171c2a91 to your computer and use it in GitHub Desktop.
Mockup of an OpenGL Gammatron shader. Post this into http://editor.thebookofshaders.com/ to get a quick visual impression.
This file contains hidden or 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
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform vec2 u_resolution; | |
uniform float u_time; // this should be replaced by frame number in use | |
const float tau = 2.0*3.141592654; | |
const float direction = 1.0; // must be -1 or 1 | |
const float tempPeriod = 0.7; | |
const float spacePeriod = 0.1; | |
const vec4 color1 = vec4(1,1,1,1); | |
const vec4 color2 = vec4(0,0,0,1); | |
const bool squareWave = false; | |
void main() { | |
vec2 st = gl_FragCoord.xy/u_resolution.xy; | |
float dist = distance(st, vec2(0.5)); | |
float phase = tau*u_time/tempPeriod*direction; | |
float mixValue = (sin(tau/spacePeriod * dist + phase) + 1.0)/2.0; | |
if(squareWave){ | |
mixValue = step(0.5, mixValue);} | |
gl_FragColor = mix(color1, color2, mixValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment