!!VP1.0

# R0 = (y coordinate of vertex * k) + (w * t)
MAD R0.x, v[OPOS].y, c[16].x, c[16].z;

# R1 = cos(R0), R0 = any floating point number
MUL R0.x, c[11].w, R0.x; 
EXP R0.y, R0.x; 
SLT R2.x, R0.y, c[11]; 
SGE R2.yz, R0.y, c[11]; 
DP3 R2.y, R2, c[14].zwzw;   
ADD R5.xyz, -R0.y, c[10]; 
MUL R5, R5, R5;
MAD R0, c[12].xyxy, R5, c[12].zwzw; 
MAD R0, R0, R5, c[13].xyxy;      
MAD R0, R0, R5, c[13].zwzw;      
MAD R0, R0, R5, c[14].xyxy;      
MAD R0, R0, R5, c[14].zwzw;      
DP3 R1.x, R0, -R2; 

# R2 = R1 * c[10] + 1.0
MAD R2.x, R1.x, c[10].w, c[10].z;

# R3 = perturbed vertex
# R4 = perturbed normal
MOV R2.yw, c[16];
MUL R3, v[OPOS], R2.xyxw;
MUL R4, v[NRML], R2.yxyw;

# Transform vertices into clip space via modelview-projection matrix
DP4 o[HPOS].x, R3, c[0];
DP4 o[HPOS].y, R3, c[1];
DP4 o[HPOS].z, R3, c[2];
DP4 o[HPOS].w, R3, c[3];

# Transform normals via inverse transpose modelview matrix & normalize
# R5 = transformed normal
DP3 R5.x, R4, c[4];
DP3 R5.y, R4, c[5];
DP3 R5.z, R4, c[6];
DP3 R5.w, R5, R5;
RSQ R5.w, R5.w;
MUL R5, R5, R5.w;

# Get unit length eye vector to vertex....this is how we texture map
# R6 = vector
ADD R6, c[8], v[OPOS];
DP3 R6.w, R6, R6;
RSQ R6.w, R6.w;
MUL R6, R6, R6.w;

# Multiply by 0.5 for texture wrapping
MUL R6, R6, c[10].y;
	    
# Texture coord is dot product of normal and vector from eye to vertex
DP3 o[TEX0].x, R5, R6;

# Pass color through
MOV o[COL0], v[COL0];

END