summaryrefslogtreecommitdiffhomepage
path: root/examples/web/models/resources/shaders/glsl100
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-12-24 13:26:30 +0100
committerraysan5 <[email protected]>2020-12-24 13:26:30 +0100
commit83ab2cb01746a869b625c9d84fbb4737146b73a9 (patch)
tree010b0794848d863916e5acb4f766ea9e7ecb6e90 /examples/web/models/resources/shaders/glsl100
parentd11274dcfcb0f349fba16ab4b83d2b96bcac8d1a (diff)
downloadraylib.com-83ab2cb01746a869b625c9d84fbb4737146b73a9.tar.gz
raylib.com-83ab2cb01746a869b625c9d84fbb4737146b73a9.zip
Updated Web examples to raylib 3.5
Diffstat (limited to 'examples/web/models/resources/shaders/glsl100')
-rw-r--r--examples/web/models/resources/shaders/glsl100/cubemap.fs29
-rw-r--r--examples/web/models/resources/shaders/glsl100/cubemap.vs20
-rw-r--r--examples/web/models/resources/shaders/glsl100/skybox.fs28
-rw-r--r--examples/web/models/resources/shaders/glsl100/skybox.vs24
4 files changed, 101 insertions, 0 deletions
diff --git a/examples/web/models/resources/shaders/glsl100/cubemap.fs b/examples/web/models/resources/shaders/glsl100/cubemap.fs
new file mode 100644
index 0000000..402cdea
--- /dev/null
+++ b/examples/web/models/resources/shaders/glsl100/cubemap.fs
@@ -0,0 +1,29 @@
+#version 100
+
+precision mediump float;
+
+// Input vertex attributes (from vertex shader)
+varying vec3 fragPosition;
+
+// Input uniform values
+uniform sampler2D equirectangularMap;
+
+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 = texture2D(equirectangularMap, uv).rgb;
+
+ // Calculate final fragment color
+ gl_FragColor = vec4(color, 1.0);
+}
diff --git a/examples/web/models/resources/shaders/glsl100/cubemap.vs b/examples/web/models/resources/shaders/glsl100/cubemap.vs
new file mode 100644
index 0000000..fd8d17e
--- /dev/null
+++ b/examples/web/models/resources/shaders/glsl100/cubemap.vs
@@ -0,0 +1,20 @@
+#version 100
+
+// Input vertex attributes
+attribute vec3 vertexPosition;
+
+// Input uniform values
+uniform mat4 projection;
+uniform mat4 view;
+
+// Output vertex attributes (to fragment shader)
+varying vec3 fragPosition;
+
+void main()
+{
+ // Calculate fragment position based on model transformations
+ fragPosition = vertexPosition;
+
+ // Calculate final vertex position
+ gl_Position = projection*view*vec4(vertexPosition, 1.0);
+}
diff --git a/examples/web/models/resources/shaders/glsl100/skybox.fs b/examples/web/models/resources/shaders/glsl100/skybox.fs
new file mode 100644
index 0000000..1269a96
--- /dev/null
+++ b/examples/web/models/resources/shaders/glsl100/skybox.fs
@@ -0,0 +1,28 @@
+#version 100
+
+precision mediump float;
+
+// Input vertex attributes (from vertex shader)
+varying vec3 fragPosition;
+
+// Input uniform values
+uniform samplerCube environmentMap;
+uniform bool vflipped;
+
+void main()
+{
+ // Fetch color from texture map
+ vec4 texelColor = vec4(0.0);
+
+ if (vflipped) texelColor = textureCube(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z));
+ else texelColor = textureCube(environmentMap, fragPosition);
+
+ vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z);
+
+ // Apply gamma correction
+ color = color/(color + vec3(1.0));
+ color = pow(color, vec3(1.0/2.2));
+
+ // Calculate final fragment color
+ gl_FragColor = vec4(color, 1.0);
+}
diff --git a/examples/web/models/resources/shaders/glsl100/skybox.vs b/examples/web/models/resources/shaders/glsl100/skybox.vs
new file mode 100644
index 0000000..0d00d54
--- /dev/null
+++ b/examples/web/models/resources/shaders/glsl100/skybox.vs
@@ -0,0 +1,24 @@
+#version 100
+
+// Input vertex attributes
+attribute vec3 vertexPosition;
+
+// Input uniform values
+uniform mat4 projection;
+uniform mat4 view;
+
+// Output vertex attributes (to fragment shader)
+varying vec3 fragPosition;
+
+void main()
+{
+ // Calculate fragment position based on model transformations
+ fragPosition = vertexPosition;
+
+ // Remove translation from the view matrix
+ mat4 rotView = mat4(mat3(view));
+ vec4 clipPos = projection*rotView*vec4(vertexPosition, 1.0);
+
+ // Calculate final vertex position
+ gl_Position = clipPos.xyzw;
+}