Skip to content

Instantly share code, notes, and snippets.

@Nehon
Created July 15, 2017 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nehon/687890630061f7aafa471ce3d96d7875 to your computer and use it in GitHub Desktop.
Save Nehon/687890630061f7aafa471ce3d96d7875 to your computer and use it in GitHub Desktop.
uniform sampler2D m_ColorMap;
varying vec2 texCoord;
void main(){
gl_FragColor = texture2D(m_ColorMap, texCoord);
}
MaterialDef Anim {
MaterialParameters {
Texture2D ColorMap
Float InvSizeX : 1
Float InvSizeY : 1
Float Speed
}
Technique {
VertexShader GLSL100: MatDefs/Anim.vert
FragmentShader GLSL100: MatDefs/Anim.frag
WorldParameters {
WorldViewProjectionMatrix
Time
}
Defines {
}
}
}
uniform mat4 g_WorldViewProjectionMatrix;
uniform float g_Time;
uniform float m_InvSizeX;
uniform float m_InvSizeY;
uniform float m_Speed;
attribute vec3 inPosition;
attribute vec2 inTexCoord;
varying vec2 texCoord;
void main(){
float t = fract(g_Time) * m_Speed;
texCoord.x = inTexCoord.x * m_InvSizeX + floor(t / m_InvSizeX) * m_InvSizeX;
float adjust = step(1.0,inTexCoord.x) * step(texCoord.x,floor(texCoord.x ));
texCoord.y = (1.0 - inTexCoord.y) * m_InvSizeY + floor(texCoord.x - adjust) * m_InvSizeY ;
gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment