blob: c0c46e67c5dc32246844cf1d993270221e35a24b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
uniform mat4 CameraRotation; // From camera space to world space.
uniform float Fovy;
uniform float Aspect;
layout (location = 0) in vec2 Position;
out vec3 Ray;
// We would typically normalize the vector, but there is no need to do so when
// sampling a cube map.
vec3 sky_ray(vec2 FilmPosition)
{
//float d = 0.5 / tan(Fovy/2.0);
// return vec3((FilmPosition.x - 0.5) * Aspect,
// FilmPosition.y - 0.5,
// -d);
float d = 0.5 / tan(Fovy/2.0);
return vec3(FilmPosition, -d);
}
void main()
{
vec2 FilmPosition = Position * 0.5; // map [-1,1] -> [-1/2, +1/2]
Ray = mat3(CameraRotation) * sky_ray(FilmPosition);
// Set z to the background.
gl_Position = vec4(Position, 0.99999, 1.0); // z=1 -> send to background
}
|