Hey there
I currently trying to implement a wave/ripple shader simliar to the one of the RPG Maker 2000 (hard so show a picture here :(). I kinda got it working with a texture shader which goes like this:
Vertex Shader:
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
Fragment Shader:
uniform float time; // time in seconds
uniform sampler2D tex0;
void main(void) {
vec2 fragment = gl_TexCoord[0].xy;
vec2 temp = vec2(fragment.x, fragment.y);
// playing with sinus
fragment.x += sin(temp.y * 3.0 * 2.0 * 3.14159 + (time)) / 100.0;
vec4 color = texture2D(tex0, fragment);
gl_FragColor = color;
}
This works as expected and a get a nice wave. BUT this is only in texture spaces. So if I bind the shader and draw a texture, the fragments which will be pushed to the left or the right are jsut ignored:
I also get this strange artifacts as you can see (The rextangle is an FBO and you can also see that there are dirsty areas in the top left part of the fbo image) . I guess there is something wrong with my wave shader too… But want I want to know is, HOW can I tell the shader to set fragments out of the texture bounds?
I hope someone can help