Hello!
There is a general question in the end, but I need this for my another attempt for waving flora shader, having a fp for quad that is having currently 3 textures multiplied or added together, one of them containing green-like pixels of flora and focusing on that part:
(...)
vec4 color_normal = texture2D(tex0, uv.xy);
vec2 uv = var_texcoord0.xy;
// if color is green-like modify coords
if (color_normal.g > 0.4 && color_normal.r < 0.4 && color_normal.b < 0.4)
{
float X = uv.x*25.+time.x; //time.x is currently constant, so no waving effect
float Y = uv.y*25.+time.x;
uv.y += cos(X+Y)*0.01*cos(Y);
uv.x += sin(X-Y)*0.01*sin(Y);
}
color_normal = texture2D(tex0, uv.xy);
(...)
And after this it is all drawn blended on screen with lights and other effects.
But what is annoying me is that it is dependent on the position of camera that is following the character - aka position of each pixel on the screen - when it is changing, the whole calculation is obviously giving different result. This is just an example, but my problem applies to every simple shader that is having coords of texel in the calculations.
How should I approach such coords-related shaders to get rid of this effect ?