Guest User

Untitled

a guest
Jul 7th, 2013
720
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. varying vec3 vColor;
  2. varying vec2 uv;
  3.  
  4. uniform sampler2D tex;
  5. uniform vec2 resolution;
  6. vec4 HmdWarpParam = vec4(1.4, 0.22, 0.24, 80);
  7.  
  8. void main(void)
  9. {
  10. float x;
  11. float y;
  12.  
  13. float rSq;
  14.  
  15. vec2 theta = vec2(x,y);
  16.  
  17. theta.x = gl_FragCoord.x / resolution.x * 1.7;
  18. theta.y = gl_FragCoord.y / resolution.y;
  19.  
  20. if(gl_FragCoord.x > resolution.x / 2.0)
  21. theta.x -= 0.7;
  22.  
  23. theta.x -= 0.5;
  24. theta.y -= 0.5;
  25.  
  26. rSq = theta.x*theta.x + theta.y*theta.y;
  27.  
  28. vec2 rvector;
  29. rvector = theta * (HmdWarpParam.x + HmdWarpParam.y*rSq + HmdWarpParam.z * rSq * rSq + HmdWarpParam.w * rSq * rSq * rSq);
  30.  
  31. x = rvector.x;
  32. y = rvector.y;
  33.  
  34. rvector.x+=0.5;
  35. rvector.y+=0.5;
  36.  
  37. rvector.y = 1.0-rvector.y;
  38.  
  39. if(rvector.x >= 0.0 && rvector.y >= 0.0 && rvector.x <= 1.0 && rvector.y <= 1.0) {
  40. gl_FragColor = texture2D(tex, rvector);
  41. }
  42. else {
  43. // red
  44. gl_FragColor = vec4(0.0,0.0,0.0,1.0);
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment