summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders/resources
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-08-16 11:18:25 +0200
committerraysan5 <[email protected]>2020-08-16 11:18:25 +0200
commit26f6a64a39671487f5d1eeeffe7fce6538669051 (patch)
treefc10180da0a47da79796d58e97ca3da1c9e901e8 /examples/shaders/resources
parentebdeab7e2566aa131d6066aa7bad91b64fd27d07 (diff)
downloadraylib-26f6a64a39671487f5d1eeeffe7fce6538669051.tar.gz
raylib-26f6a64a39671487f5d1eeeffe7fce6538669051.zip
NEW EXAMPLE: shaders_hot_reloading #1198
Diffstat (limited to 'examples/shaders/resources')
-rw-r--r--examples/shaders/resources/shaders/glsl330/reload.fs40
1 files changed, 40 insertions, 0 deletions
diff --git a/examples/shaders/resources/shaders/glsl330/reload.fs b/examples/shaders/resources/shaders/glsl330/reload.fs
new file mode 100644
index 00000000..9891a4b5
--- /dev/null
+++ b/examples/shaders/resources/shaders/glsl330/reload.fs
@@ -0,0 +1,40 @@
+#version 330
+
+// Input vertex attributes (from vertex shader)
+in vec2 fragTexCoord; // Texture coordinates (sampler2D)
+in vec4 fragColor; // Tint color
+
+// Output fragment color
+out vec4 finalColor; // Output fragment color
+
+// Uniform inputs
+uniform vec2 resolution; // Viewport resolution (in pixels)
+uniform vec2 mouse; // Mouse pixel xy coordinates
+uniform float time; // Total run time (in secods)
+
+// Draw circle
+vec4 DrawCircle(vec2 fragCoord, vec2 position, float radius, vec3 color)
+{
+ float d = length(position - fragCoord) - radius;
+ float t = clamp(d, 0.0, 1.0);
+ return vec4(color, 1.0 - t);
+}
+
+void main()
+{
+ vec2 fragCoord = gl_FragCoord.xy;
+ vec2 position = vec2(mouse.x, resolution.y - mouse.y);
+ float radius = 40.0;
+
+ // Draw background layer
+ vec4 colorA = vec4(0.2,0.2,0.8, 1.0);
+ vec4 colorB = vec4(1.0,0.7,0.2, 1.0);
+ vec4 layer1 = mix(colorA, colorB, abs(sin(time*0.1)));
+
+ // Draw circle layer
+ vec3 color = vec3(0.9, 0.16, 0.21);
+ vec4 layer2 = DrawCircle(fragCoord, position, radius, color);
+
+ // Blend the two layers
+ finalColor = mix(layer1, layer2, layer2.a);
+}