Created
May 22, 2017 15:32
-
-
Save fand/c34f468e49be37902f814566ba71a5bf to your computer and use it in GitHub Desktop.
1分でわかるglsl
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
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform float time; | |
uniform vec2 mouse; | |
uniform vec2 resolution; | |
uniform sampler2D backBuffer; | |
#define PI 3.141592 | |
// [0,1) の乱数を返す | |
float rand (float v) { | |
return sin(v * 123.4567) * 0.5 + 0.5; | |
} | |
void main( void ) { | |
vec2 p = (gl_FragCoord.xy * 2. - resolution) / min(resolution.x, resolution.y); | |
float a = atan(p.y, p.x) * 2.; | |
float c = 0.; | |
float l = length(p); | |
c = 0.1 / l; | |
gl_FragColor = vec4(vec3(c), 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
#ifdef GL_ES | |
precision mediump float; | |
#endif | |
uniform float time; | |
uniform vec2 mouse; | |
uniform vec2 resolution; | |
uniform sampler2D backBuffer; | |
#define PI 3.141592 | |
// [0,1) の乱数を返す | |
float rand (float v) { | |
return sin(v * 123.4567) * 0.5 + 0.5; | |
} | |
float c(vec2 p) { | |
float a = atan(p.y, p.x) * 2.; | |
float c = 0.; | |
float l = length(p); | |
l *= 16.; | |
c = sin(a * floor(rand(floor(l)) * 10. + 2.) + time * 10.); | |
return c; | |
} | |
void main( void ) { | |
vec2 p = (gl_FragCoord.xy * 2. - resolution) / min(resolution.x, resolution.y); | |
float r = c(p); | |
float g = c(p + 0.03); | |
float b= c(p + 0.03); | |
gl_FragColor = vec4(r, g, b, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment