uniform sampler2D displacementMap;
uniform float time;
uniform float displaceAmount;
varying float distToCamera;

void main(void)
{
vec4 newVertexPos;
vec4 dv;
float df;
vec2 uv;
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
uv = gl_TexCoord[0].xy;

    uv.x -= time * -.01; //step(sin(t),0.1);
    uv.y -= time * .01; //step(sin(t),0.2);

dv = texture2D( displacementMap, uv );

df = 0.10*dv.x + 0.1*dv.y + 0.1*dv.z;


    vec4 cs_position = glModelViewMatrix * gl_Vertex;
    distToCamera = -cs_position.z;
    gl_Position = gl_ProjectionMatrix * cs_position;


newVertexPos = vec4(gl_Normal * df * disToCamera, 0.0) + gl_Vertex;

gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;
}