attribute mat4 transform;
attribute float flow;
uniform float noiseoff;
uniform vec3 camera;
varying float sdist;

void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0;
    gl_TexCoord[1] = vec4(gl_MultiTexCoord0.s, gl_Vertex.z/0.4 + noiseoff*flow, 0, 1);
    gl_FrontColor = gl_Color;
    
    vec4 tvert = (transform * gl_Vertex);
    gl_Position = gl_ModelViewProjectionMatrix * tvert;    
    sdist = distance(camera, tvert.xyz);
}