Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GunnarKarlsson/15d9921a4b64b8295098c352516e9e5f to your computer and use it in GitHub Desktop.
Save GunnarKarlsson/15d9921a4b64b8295098c352516e9e5f to your computer and use it in GitHub Desktop.
Shader maker animated texture
// simple vertex shader
varying vec2 texCoord;
uniform float time;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_FrontColor = gl_Color;
gl_TexCoord[0] = gl_MultiTexCoord0;
texCoord = vec2(gl_MultiTexCoord0);
texCoord.x += time;
}
// simple fragment shader
// 'time' contains seconds since the program was linked.
uniform float time;
uniform sampler2D myTexture;
varying vec2 texCoord;
vec3 dots() {
float frequency = 0.5;
vec2 nearest = 3.0*fract(frequency * texCoord) - 1.5;
float dist = length(nearest);
float radius = 1.0;
vec3 white = vec3(1.0, 1.0, 1.0);
vec3 dotCol = vec3(7.0, 3.0, 1.0);
return mix(dotCol, white, smoothstep(radius, radius+0.05, dist));
}
void main()
{
vec4 color = vec4(0.5);
vec4 texel = texture2D(myTexture, texCoord);
//gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
if (texCoord.y > 2.0) {
texel.rgb = vec3(0.2) * dots();
} else {
texel.rgb = vec3(0.5);// * dots();
}
if (texCoord.x < 0.5) {
color.rbg = vec3(1.0, 0.2, 0.2);
}
gl_FragColor = texel * color;
}
@GunnarKarlsson
Copy link
Author

screen shot 2018-04-23 at 10 27 11 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment