summaryrefslogtreecommitdiff
path: root/src/rendering/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/rendering/shaders')
-rw-r--r--src/rendering/shaders/world.frag57
-rw-r--r--src/rendering/shaders/world.vert8
2 files changed, 65 insertions, 0 deletions
diff --git a/src/rendering/shaders/world.frag b/src/rendering/shaders/world.frag
new file mode 100644
index 0000000..06ed16f
--- /dev/null
+++ b/src/rendering/shaders/world.frag
@@ -0,0 +1,57 @@
+uniform float complexity; // 0.0 to 1.0
+uniform float time;
+uniform vec3 color1;
+uniform vec3 color2;
+uniform vec3 color3;
+uniform float layerIndex;
+
+varying vec2 vUv;
+varying vec3 vPosition;
+
+// Reduce color palette based on complexity
+vec3 quantizeColor(vec3 color, float levels) {
+ return floor(color * levels) / levels;
+}
+
+// Simple noise function
+float noise(vec2 p) {
+ return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453);
+}
+
+void main() {
+ vec2 uv = vUv;
+
+ // Base gradient
+ vec3 color = mix(color1, color2, uv.y);
+ color = mix(color, color3, sin(uv.x * 3.14159) * 0.3);
+
+ // At high complexity, add details
+ if (complexity > 0.3) {
+ // Circuit patterns
+ float circuit = step(0.98, fract(uv.x * 20.0 + time * 0.05));
+ circuit += step(0.98, fract(uv.y * 20.0 + time * 0.03));
+ color += vec3(0.0, 0.5, 1.0) * circuit * complexity * 0.2;
+
+ // Scanlines
+ float scanline = sin(uv.y * 200.0) * 0.5 + 0.5;
+ color *= 0.95 + scanline * 0.05 * complexity;
+ }
+
+ // At medium complexity, add some glow
+ if (complexity > 0.5) {
+ float glow = sin(time * 2.0 + uv.y * 10.0) * 0.5 + 0.5;
+ color += color2 * glow * 0.1 * complexity;
+ }
+
+ // Reduce color palette as complexity decreases
+ float levels = mix(4.0, 256.0, complexity);
+ color = quantizeColor(color, levels);
+
+ // Fade edges at low complexity
+ float edge = 1.0;
+ if (complexity < 0.3) {
+ edge = smoothstep(0.0, 0.1, uv.x) * smoothstep(1.0, 0.9, uv.x);
+ }
+
+ gl_FragColor = vec4(color, edge);
+}
diff --git a/src/rendering/shaders/world.vert b/src/rendering/shaders/world.vert
new file mode 100644
index 0000000..f4410b6
--- /dev/null
+++ b/src/rendering/shaders/world.vert
@@ -0,0 +1,8 @@
+varying vec2 vUv;
+varying vec3 vPosition;
+
+void main() {
+ vUv = uv;
+ vPosition = position;
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
+}