Skip to content

Instantly share code, notes, and snippets.

@danzeeeman
Created April 22, 2014 22:17
Show Gist options
  • Save danzeeeman/11196332 to your computer and use it in GitHub Desktop.
Save danzeeeman/11196332 to your computer and use it in GitHub Desktop.
I like this frag
#version 120
#define PI (3.1415926536)
#define TWO_PI (6.2831853072)
uniform sampler2DRect bumpmap;
uniform float elapsedTime;
varying vec2 TexCoord;
varying vec3 normal;
varying vec3 pos;
void main(void) {
vec4 color = texture2DRect(bumpmap, TexCoord);
float t = mod(elapsedTime/160, 80.)+15.;
float d = mod(dot(pos,normal)*1., t) / t;
float a = sin(d * TWO_PI) * 0.5+0.5;
if (a > 0.5){
gl_FragColor = vec4(vec3(1, 0, 0)*dot(abs(normal),vec3(1, 0, 0))+vec3(1, 0, 0), 1);
}
else{
// d = mod(pos.y*1.0, t) / t;
// a = sin(d * TWO_PI) * 0.5 + 0.5;
// if (a > 0.5){
// gl_FragColor = vec4(color.xyz, 1);
// }
// else{
// d = mod(pos.z*1.0, t) / t;
// a = sin(d * TWO_PI) * 0.5 + 0.5;
// if (a > 0.5){
// gl_FragColor = vec4(color.xyz, 1);
// }
// else{
gl_FragColor = vec4(0,0,0, 1);
}
// }
// }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment