Performance problem with shader on android

hello, I am playing with a shader that simulates simple water waves on 2D (side view) it is very simple, I adapted the code from this tutorial for libglx:


it works well on linux, but in android, when I change between scenes and repeat the effect, the water line starts to look pixelated. it doesn’t seems to be a performance issue of the game itself and checking this forums I found some old posts that maybe are related in some way:

these are my versions of the shader, I appreciate any hint or suggestion to debug the issue (btw, I load the shader using GLProgramCache, but that seems not to have impact):

#ifdef GL_ES
precision mediump float;
#endif
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
void main()
{
vec2 displacement=texture2D (CC_Texture1, v_texCoord/6.0).xy;
float t= v_texCoord.y + displacement.y *0.1-0.15+ (sin (v_texCoord.x * 40.0+CC_Time.w) * 0.03);
gl_FragColor = v_fragmentColor * texture2D (CC_Texture0, vec2 (v_texCoord.x, t));
}

attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
void main()
{
gl_Position = CC_PMatrix * a_position;
v_fragmentColor = a_color;
v_texCoord = a_texCoord;
}

Hi cesarpachon.
If you have problems when changing scenes maybe the time (CC_Time1) is your problem.
Change time with your costume uniform data that begins when scene created.

Your issue might be due to sine/cos calculations present in shader code. I had a similar issue lately, try this post it might help. Shader lag after some time
Keep us posted of your final result

Thanks

hi @Lazy_Gamer and @amin13a, I confirm that the issue is the large time value being passed into the sin function. I tried the suggestion of passing a custom uniform but I need to evaluate sin including pixel position as part of the argument, so in this particular shader that is of not help (or I was not able to figure out how to use a uniform to mock that behavior).
I am considering passing as uniform a 1D texture with a variable sine function codified within, that way I will be able to get sin values different for each pixel (I hope).
EDIT: before going on with the 1D approach, I tried using sin( … mod(CC_TIME[3], 100) …) and it worked, only that sometimes there are glitches (I guess that each 100 seconds). I suppose it is a matter of matching the cross by zero of sin and mod.