Shader relative to camera
Posted: Thu Aug 18, 2016 7:10 pm
Hello.
So i have this shader
Not the greatest glsl code but that's not my problem, The shader is applied only to certain areas of the screen, Based on a canvas, That would be the "map" extern. And all that works fine, However, The game also has a camera, And when said camera is moving the area of the screen that has the shader applied to it looks weird. I know why this is happening, But i don't know how to fix it. Any ideas would be appreciated.
I'm not great at explaining things, There's a .love attached. The problem becomes very apparent if you jump (w) and look at the water (blue stuff above the player)
All the relative code is in src/state/game.lua
So i have this shader
Code: Select all
extern vec2 screen;
extern Image map;
extern number t;
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 sc)
{
vec4 m = Texel(map, tc);
if (m.r == 1)
{
tc.x = tc.x + (sin((tc.y * 0.08) * screen.x + (t * 5)) * 0.002);
tc.y = tc.y + (sin((tc.x * 0.08) * screen.y + (t * 5)) * 0.002);
return Texel(tex, tc) * color;
} else {
return Texel(tex, tc) * color;
}
}
]]
I'm not great at explaining things, There's a .love attached. The problem becomes very apparent if you jump (w) and look at the water (blue stuff above the player)
All the relative code is in src/state/game.lua