Advertisement
CrushedPixel

Untitled

Sep 17th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #version 110
  2.  
  3. #define PI 3.141592653589793238462643383279
  4. #define HALF_PI 1.5707963267948966192313216916398
  5.  
  6. uniform samplerCube cubeMap;
  7.  
  8. //whether or not to flip the image
  9. uniform int flip;
  10.  
  11. //direction correction in radiants
  12. uniform float yawCorrection;
  13. uniform float pitchCorrection;
  14.  
  15. void main() {
  16.     float x = gl_TexCoord[0].x;
  17.     float y = gl_TexCoord[0].y;
  18.  
  19.     if (flip == 0) {
  20.         y = 1.0 - gl_TexCoord[0].y; //image is flipped by default. unflip it.
  21.     }
  22.  
  23.     vec2 textureCoordinates = vec2(x, y);
  24.     vec2 thetaphi = ((textureCoordinates * 2.0) - vec2(1.0)) * vec2(PI, HALF_PI);
  25.     vec3 rayDirection = vec3(cos(thetaphi.y) * cos(thetaphi.x), sin(thetaphi.y), cos(thetaphi.y) * sin(thetaphi.x));
  26.  
  27.     gl_FragColor = textureCube(cubeMap, rayDirection);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement