Hello. I draw sprites using a shader, AFTERWARDS i want to clip the resulting texture. (Cutting of top,bottom,left and/or right, by making it transparant or so).
I can do it by drawing the sprite with the shader in a texture, then clip the texture, then draw it on to the renderwindow, but i use a lot of these sprites, and things get slow.
This is my shader witch i use on lots of 64x72 pixel sprites:
uniform float wave_phase;
uniform vec2 wave_amplitude;
void main()
{
vec4 vertex = gl_Vertex;
vertex.x += (cos(gl_Vertex.y * 0.02 + wave_phase * 3.
+ sin(gl_Vertex.y * 0.02 + wave_phase * 6.3) * 0.3) * wave_amplitude.x;
vertex.y += (sin(gl_Vertex.x * 0.02 + wave_phase * 2.4) + cos(gl_Vertex.x * 0.02 + wave_phase * 5.2) * 0.3) * wave_amplitude.y;
gl_Position = gl_ModelViewProjectionMatrix * vertex;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
gl_FrontColor = gl_Color;
}
Somebody have any idea how to clip the resulting texture? Like with 4 parameters for clipping the top,bottom, left and/or right of the texture?
Thanks in advance.
See example video: Clipping is now done before the shader changes size/position, then clipping is not correct.
I want the sprites to go under the viaduct properly cut off.