boilerplate in shader reduction

This commit is contained in:
Rakarake 2026-02-22 20:30:33 +01:00
parent f6706982ce
commit 2383faf456
2 changed files with 42 additions and 22 deletions

View file

@ -1,9 +1,3 @@
#version 330 core
uniform vec2 WindowSize;
uniform float time;
layout(location = 0) out vec4 color;
float lerp(float a, float b, float x) {
return a + x*(b-a);
}
@ -73,19 +67,20 @@ float limit(float val, float min, float max) {
return out_val;
}
void main() {
vec2 screen_uv = gl_FragCoord.xy / WindowSize;
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 screen_uv = gl_FragCoord.xy / iResolution;
// We'll make origin in the top-left.
screen_uv.y = 1.0 - screen_uv.y;
screen_uv.x *= WindowSize.x / WindowSize.y;
screen_uv.x *= iResolution.x / iResolution.y;
vec2 uv = vec2(screen_uv.x, screen_uv.y);
uv.y += sin(uv.x * 2.0 + time * 0.2) * 0.47;
uv.y += sin(uv.x * 4.3 + time * 1.34) * 0.09;
uv.y += sin(uv.x * 2.0 + iTime * 0.2) * 0.47;
uv.y += sin(uv.x * 4.3 + iTime * 1.34) * 0.09;
uv += 100.0;
float out_val = perlin_noise(uv, vec2(0.0, 0.0), time / 1.0);
float min = 0.42 + sin(time)/8.0;
float max = 0.58 + sin(time)/8.0;
float out_val = perlin_noise(uv, vec2(0.0, 0.0), iTime / 1.0);
float min = 0.42 + sin(iTime)/8.0;
float max = 0.58 + sin(iTime)/8.0;
out_val = limit(out_val, min, max);
color = vec4(out_val, 0.4, 0.8, 1.0);
fragColor = vec4(out_val, 0.4, 0.8, 1.0);
}