I have this shaders:


uniform float time;
uniform sampler2D texture;

void main()
    float t = time;
    vec2 aux = gl_TexCoord[0].xy;

    // This would also make waving/deform the texture
    //aux.x = aux.x + (sin(aux.y * time *.5) * 0.05);

    gl_FragColor = texture2D(texture, aux);


uniform float time;

void main()
    vec4 vertex = gl_Vertex;
    vertex.x = vertex.x + sin(time - vertex.y * 20) / 10;
    vertex = gl_ModelViewMatrix * vertex;

    gl_Position = gl_ProjectionMatrix * vec4(vertex.x, vertex.y, vertex.z, vertex.w);
    gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
    gl_FrontColor = gl_Color;

I am used that shader on low resolution textures(I have for example a grass tile texture of 8x8 pixels) to create a 2D waving grass effect. The problem is, that the shader effect is now very choppy because the texture resolution. Now I am wonder me, is it not possible to let the shader make more steps and make that "animation" smoother ?

  • \$\begingroup\$ use linear interpolation? also scale the time by something other than .5 \$\endgroup\$ – ratchet freak Jan 13 '15 at 14:58
  • \$\begingroup\$ Thanks, that worked fine. I also simply set the antialiasing level much higher. \$\endgroup\$ – user2933016 Jan 13 '15 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.