aboutsummaryrefslogtreecommitdiff
path: root/shaders/cubemap_filtering.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/cubemap_filtering.vert
parent9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff)
Restructure projectHEADmain
Diffstat (limited to 'shaders/cubemap_filtering.vert')
-rw-r--r--shaders/cubemap_filtering.vert39
1 files changed, 39 insertions, 0 deletions
diff --git a/shaders/cubemap_filtering.vert b/shaders/cubemap_filtering.vert
new file mode 100644
index 0000000..d0cf73f
--- /dev/null
+++ b/shaders/cubemap_filtering.vert
@@ -0,0 +1,39 @@
1precision highp float;
2
3#define PI 3.1415926535897932384626433832795
4#define FOVY (90.0 * PI / 180.0)
5
6uniform mat4 CameraRotation; // From camera space to world space.
7uniform float Flip;
8
9layout (location = 0) in vec2 vPosition;
10
11out vec3 Ray;
12
13// DEBUG
14// out vec2 Texcoord;
15
16// This is very similar to the skyquad vertex shader.
17//
18// The ray is not normalized because it isn't necessary for cubemap sampling.
19//
20// We also use a fixed fovy = 90 degrees because we want the frustum to pass
21// exactly through each face of the cube. The aspect ratio is also just 1.
22vec3 sky_ray(vec2 FilmPosition)
23{
24 float d = 0.5 / tan(FOVY/2.0);
25 return vec3(FilmPosition, -d);
26}
27
28void main()
29{
30 vec2 FilmPosition = vPosition * 0.5; // map [-1,1] -> [-1/2, +1/2]
31 FilmPosition *= Flip;
32 Ray = mat3(CameraRotation) * sky_ray(FilmPosition);
33 // TODO: Should disable depth test when rendering.
34 gl_Position = vec4(vPosition, 0.99999, 1.0); // z=1 -> send to background
35
36 // DEBUG
37 // Texcoord = FilmPosition + 0.5;
38 // Texcoord.y = 1.0 - Texcoord.y;
39}