Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 22nd, 2012  |  syntax: None  |  size: 0.56 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. GLSL shader that scroll texture
  2. /*VERTEX_PROGRAM*/
  3.  
  4. in vec4 in_Vertex;
  5. in vec4 in_TexCoord;
  6.  
  7. uniform mat4 ModelViewMatrix;
  8. uniform mat4 ProjectionMatrix;
  9.  
  10. out vec2 TexCoord;
  11.  
  12. void main()
  13. {
  14.      gl_Position = ProjectionMatrix * ModelViewMatrix * in_Vertex;
  15.  
  16.      TexCoord = vec2( in_TexCoord );
  17. }
  18.  
  19. /*FRAGMENT_PROGRAM*/
  20.  
  21. in vec2 TexCoord;
  22.  
  23. uniform sampler2D Texture0;
  24.  
  25. /// Updated in external code
  26. uniform float Time;
  27.  
  28. out vec4 out_FragColor;
  29.  
  30. void main()
  31. {
  32.    /// "u" coordinate is altered
  33.    out_FragColor = texture( Texture0, vec2(TexCoord.x + Time, TexCoord.y) );
  34. }