What about this one. Rather than the last method, what about this one. Take the cross product and get the normal.
vec3 getnorm2(vec3 pos,float time){
vec3 ret;
vec3 newpos3=pos;
vec3 newpos1=pos;
vec3 newpos2=pos;
newpos1.z+= -0.05;
newpos2.x+= -0.05;
newpos3.x+= 0.05;
float h1=swell2(newpos1,time);
float h2=swell2(newpos2,time);
float h3=swell2(newpos3,time);
newpos1.y=h1;
newpos2.y=h2;
newpos3.y=h3;
vec3 u=newpos3-newpos1;
vec3 v=newpos2-newpos1;
ret=u*v;
ret=normalize(ret);
return ret;
}
It for some reason is not working.