aboutsummaryrefslogtreecommitdiff
path: root/raylib/examples/models/resources/shaders/glsl330/cubemap.fs
diff options
context:
space:
mode:
authorUneven Prankster <unevenprankster@protonmail.com>2023-10-15 21:28:29 -0300
committerUneven Prankster <unevenprankster@protonmail.com>2023-10-15 21:28:29 -0300
commit1c0cc775732201f4c4d3ee0d6772be786b3b4aa1 (patch)
treef5d692d046868261275c7430a624c3ea9ed75d3d /raylib/examples/models/resources/shaders/glsl330/cubemap.fs
parenta89f892640cf12f75c7ce18e6e88c70a8d3965ed (diff)
A lot has certainly happened!
Diffstat (limited to 'raylib/examples/models/resources/shaders/glsl330/cubemap.fs')
-rw-r--r--raylib/examples/models/resources/shaders/glsl330/cubemap.fs30
1 files changed, 30 insertions, 0 deletions
diff --git a/raylib/examples/models/resources/shaders/glsl330/cubemap.fs b/raylib/examples/models/resources/shaders/glsl330/cubemap.fs
new file mode 100644
index 0000000..f59003f
--- /dev/null
+++ b/raylib/examples/models/resources/shaders/glsl330/cubemap.fs
@@ -0,0 +1,30 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec3 fragPosition;
+
+// Input uniform values
+uniform sampler2D equirectangularMap;
+
+// Output fragment color
+out vec4 finalColor;
+
+vec2 SampleSphericalMap(vec3 v)
+{
+ vec2 uv = vec2(atan(v.z, v.x), asin(v.y));
+ uv *= vec2(0.1591, 0.3183);
+ uv += 0.5;
+ return uv;
+}
+
+void main()
+{
+ // Normalize local position
+ vec2 uv = SampleSphericalMap(normalize(fragPosition));
+
+ // Fetch color from texture map
+ vec3 color = texture(equirectangularMap, uv).rgb;
+
+ // Calculate final fragment color
+ finalColor = vec4(color, 1.0);
+}