aboutsummaryrefslogtreecommitdiff
path: root/Gem/cubemaptosphere.frag
blob: cd2befb6dbe906667805650dde55787a8effc4c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Antoine Rousseau september 2015
#version 120

uniform samplerCube envMap;
uniform float alpha = 1.0;

void main() {
  
    vec2 tc = gl_TexCoord[0].st ;
    vec2 thetaphi = ((tc * 2.0) - vec2(1.0)) * vec2(3.1415926535897932384626433832795, 1.5707963267948966192313216916398);
    float ctpy = cos(thetaphi.y);
    
    vec3 rayDirection = vec3(ctpy * cos(thetaphi.x), sin(thetaphi.y), ctpy * sin(thetaphi.x));
    
    gl_FragColor = textureCube(envMap, rayDirection);
    gl_FragColor.a *= alpha;
}