diff options
Diffstat (limited to 'src/main/resources')
| -rw-r--r-- | src/main/resources/shaders/vista_night.glsl | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/src/main/resources/shaders/vista_night.glsl b/src/main/resources/shaders/vista_night.glsl new file mode 100644 index 0000000..3cabd15 --- /dev/null +++ b/src/main/resources/shaders/vista_night.glsl @@ -0,0 +1,84 @@ +#version 430 +layout(local_size_x = 1, local_size_y = 1) in; + +#include <sdf> +#include <noise> +#include <utils> + +uniform float seconds = 0; +layout(rgba8) uniform writeonly image2D output_image; + +uniform float antialiasing = 0.28; +uniform bool enable_antialiasing = true; + +vec3 image(vec2 uv) { + const vec3 mooncolor = srgb(1, 0.86, 0.99); + const vec3 starcolor = srgb(1, 0.86, 0.99); + const vec3 m1color = srgb(0.1, 0.1, 0.2); + const vec3 m2color = srgb(0.15, 0.16, 0.3); + const vec3 m3color = srgb(0.16, 0.18, 0.36); + const vec3 m4color = srgb(0.21, 0.23, 0.42); + + vec3 color = srgb(0.06, 0.07, 0.1); + + { + vec2 p = uv; + float gap = 0.06; + vec2 id = round(p / gap); + p -= id * gap; + float starry = sdf_circle(p - 0.06 * vec2(fbm(id * 100), fbm(id * 200)), 0.0015); + color = mix(color, starcolor, step(starry, 0)); + } + + { + vec2 p = uv - vec2(-0.26, 0.2); + float moon = sdf_circle(p, 0.06); + float moonshadow = sdf_circle(p - 0.02, 0.06); + color = mix(color, mooncolor, step(max(-moonshadow, moon), 0)); + } + + float yoff = 0; + { + yoff -= 0.10; + float v = yoff + uv.y - sin(smoothstep(uv.x, 1.6, 0.6) * (20 - 4 * fbm(uv * 2))) * (0.01 + 0.02 * fbm(uv * 3)); + color = mix(color, m1color, step(v, 0)); + } + { + yoff += 0.08; + float v = yoff + uv.y - sin(smoothstep(-uv.x + 0.09, 1.1, 0.5) * 18) * 0.02; + color = mix(color, m2color, step(v, 0)); + } + { + yoff += 0.08; + float v = yoff + uv.y - sin(smoothstep(uv.x - 0.06, 1.1, 0.8) * 20) * 0.03; + color = mix(color, m3color, step(v, 0)); + } + { + yoff += 0.12; + float v = yoff + uv.y - sin(smoothstep(-uv.x + 0.03, 1.1, 0.8) * 20) * 0.02; + color = mix(color, m4color, step(v, 0)); + } + + return color; +} + +vec3 antialiased_image(vec2 uv) { + vec2 resolution = vec2(imageSize(output_image).xy); + float s = antialiasing / max(resolution.x, resolution.y); + vec3 sum = vec3(0); + int count = 0; + for (int i = -2; i < 2; i++) + for (int j = -2; j < 2; j++, count++) + sum += image(uv + vec2(i, j) * s); + return sum / count; +} + +void main() { + vec2 resolution = vec2(imageSize(output_image).xy); + float aspect_ratio = resolution.y / resolution.x; + vec2 uv = (gl_GlobalInvocationID.xy - resolution / 2) * vec2(1.0, aspect_ratio) / resolution; + + vec3 color = enable_antialiasing ? antialiased_image(uv) : image(uv); + + imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1)); +} |
