Created
August 10, 2014 04:45
-
-
Save funatsufumiya/e8e995fc552c61deab13 to your computer and use it in GitHub Desktop.
GLSL Gradient Shader with Processing
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
uniform float millis; | |
uniform float width; | |
uniform float height; | |
void main() | |
{ | |
float rx = gl_FragCoord.x / width; | |
float ry = gl_FragCoord.y / height; | |
float rate = sin(millis)/2.0 + 0.5; | |
float rate_inv = 1.0 - rate; | |
gl_FragColor = vec4(rate * rx, rate_inv * ry, 0.0, 1.0); | |
} |
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
PShader myShader; | |
void setup() { | |
size(640, 360, P3D); | |
myShader = loadShader("gradient.glsl"); | |
fill(255); | |
noStroke(); | |
myShader.set("width", (float)width); | |
myShader.set("height", (float)height); | |
} | |
void draw() { | |
// saveFrame("rec/####.png"); | |
myShader.set("millis", millis()/1000.0); | |
shader(myShader); | |
background(0); | |
rect(0,0,width,height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment