aboutsummaryrefslogtreecommitdiff
path: root/shaders/skyquad.vert
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
committer3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
commitbd57f345ed9dbed1d81683e48199626de2ea9044 (patch)
tree4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /shaders/skyquad.vert
parent9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff)
Restructure projectHEADmain
Diffstat (limited to 'shaders/skyquad.vert')
-rw-r--r--shaders/skyquad.vert27
1 files changed, 27 insertions, 0 deletions
diff --git a/shaders/skyquad.vert b/shaders/skyquad.vert
new file mode 100644
index 0000000..c0c46e6
--- /dev/null
+++ b/shaders/skyquad.vert
@@ -0,0 +1,27 @@
1uniform mat4 CameraRotation; // From camera space to world space.
2uniform float Fovy;
3uniform float Aspect;
4
5layout (location = 0) in vec2 Position;
6
7out vec3 Ray;
8
9// We would typically normalize the vector, but there is no need to do so when
10// sampling a cube map.
11vec3 sky_ray(vec2 FilmPosition)
12{
13 //float d = 0.5 / tan(Fovy/2.0);
14 // return vec3((FilmPosition.x - 0.5) * Aspect,
15 // FilmPosition.y - 0.5,
16 // -d);
17 float d = 0.5 / tan(Fovy/2.0);
18 return vec3(FilmPosition, -d);
19}
20
21void main()
22{
23 vec2 FilmPosition = Position * 0.5; // map [-1,1] -> [-1/2, +1/2]
24 Ray = mat3(CameraRotation) * sky_ray(FilmPosition);
25 // Set z to the background.
26 gl_Position = vec4(Position, 0.99999, 1.0); // z=1 -> send to background
27}