At the moment I'm trying to clone Nebulus, a game that I loved on my C64. Like most I do, it won't go very far, but it's still interesting on a learning point of view.
Anyway, the game features towers in the middle of the water, and I'm trying to make a mirror/wave effect. For this I'm toying with a shader found in the topic "share a shader".
Here the code at the moment:
Code: Select all
extern number time = 0.0;
extern vec2 resolution = vec2(1024, 600);
uniform sampler2D tex0;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords)
{
vec2 halfres = resolution/2.0;
vec2 cPos = pixel_coords.xy;
cPos.x -= halfres.x;
cPos.y -= halfres.y * 2.0;
float cLength = length(cPos)*1.5;
vec2 uv = pixel_coords/resolution-(cPos/cLength)*sin(cLength/30.0-time*5.0)/50.0;
vec3 col = texture2D(tex0,uv).xyz;
return vec4( col, 1.0 );
}
Code: Select all
love.graphics.setShader(fx.pulse)
love.graphics.draw(game.canvas, 0, 0)
love.graphics.setShader()
love.graphics.draw(game.canvas, 0, -500)
But if try to change the position (0, 0) from the canvas that has the shader effect, for example like this:
Code: Select all
love.graphics.setShader(fx.pulse)
love.graphics.draw(game.canvas, 0, 200)
love.graphics.setShader()
love.graphics.draw(game.canvas, 0, -300)
The canvas moved, but the content stayed in the same position. So what am I doing wrong there?
Thanks.