Created
April 23, 2018 14:26
-
-
Save GunnarKarlsson/15d9921a4b64b8295098c352516e9e5f to your computer and use it in GitHub Desktop.
Shader maker animated texture
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
// 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; | |
} |
Author
GunnarKarlsson
commented
Apr 23, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment