Search code examples
openglgraphics3dvertex-shader

Animating quad using vertex shader


I have a grassland where i have rendered a quad using instanced rendering with a texture containing alpha channel.

So far it looks ideal, except it doesn't move/animate. its just a quad rendered onto the screen, which just sits still and does nothing. enter image description here

What I am trying to achieve here is simple, I want a way to be able to move the quad, using some trignometric function [sine] for example, but I dont want to move the whole quad, only the upper part of it.


Solution

  • shearing is what you are after.

    first transform the quad so the bottom is at Y=0 then multiply with

    [1,d,0,0,
     0,1,0,0,
     0,0,1,0,
     0,0,0,1]
    

    and then transform it to where you need it to be

    and let d vary around 0