SHARE
TWEET

Untitled

a guest Jun 19th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   vec3 c = camerapos.xyz;
  2.   vec3 t = pixelpos.xyz;
  3.  
  4.   const float wave_h = 1.0 / 8.0;
  5.   float zmax = +wave_h;
  6.   float zmin = -wave_h;
  7.  
  8.   float i, x1, y1, z1, zmid;
  9.   zmid = 0;
  10.   x1 = (zmid - c.y) / (t.y - c.y) * (t.x - c.x) + c.x;
  11.   y1 = (zmid - c.z) / (t.z - c.z) * (t.y - c.y) + c.y;
  12.   for (i = 0.0; i < 8.0; i++)
  13.   {
  14.     z1 = sin(-pi*4.0*2.0 * sqrt(x1 * x1 + y1 * y1) + timer * 1.0) * wave_h;
  15.    
  16.     if (zmid > z1)
  17.       zmax = zmid;
  18.     else
  19.       zmin = zmid;
  20.     zmid = (zmax + zmin) / 2.0;
  21.  
  22.     x1 = (zmid - c.z) / (t.z - c.z) * (t.x - c.x) + c.x;
  23.     y1 = (zmid - c.z) / (t.z - c.z) * (t.y - c.y) + c.y;
  24.   }
  25.  
  26.   //return texture2D(tex, vec2(0.5, 0.5) + vec2(x1 * sin(ang), y1 * cos(ang)));
  27.   return texture2D(tex, vec2(0.5, 0.5) + vec2(y1, x1));
RAW Paste Data
Want to get better at C?
Learn to code C in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top