diff options
| -rw-r--r-- | justfile | 8 | ||||
| -rw-r--r-- | screenshot/vista_night.VistaNightProgram.png | bin | 0 -> 99914 bytes | |||
| -rw-r--r-- | src/main/kotlin/vista_night/VistaNightProgram.kt | 39 | ||||
| -rw-r--r-- | src/main/resources/shaders/vista_night.glsl | 84 |
4 files changed, 127 insertions, 4 deletions
@@ -1,17 +1,17 @@ run name: - ./gradlew run -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/^(\w)/\U\1/')ProgramKt + ./gradlew run -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/(^|_)(\w)/\U\2/g')ProgramKt record name: xvfb-run --server-args="-screen 0 1920x1080x24" just record-windowed "{{name}}" record-windowed name: - ./gradlew record -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/^(\w)/\U\1/')ProgramKt + ./gradlew record -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/(^|_)(\w)/\U\2/g')ProgramKt screenshot name: xvfb-run --server-args="-screen 0 1920x1080x24" just screenshot-windowed "{{name}}" screenshot-windowed name: - ./gradlew screenshot -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/^(\w)/\U\1/')ProgramKt + ./gradlew screenshot -Popenrndr.application={{name}}.$(echo "{{name}}" | sed -E 's/(^|_)(\w)/\U\2/g')ProgramKt update: ./gradlew dependencyUpydates @@ -19,7 +19,7 @@ update: new type name: mkdir -p src/main/kotlin/{{name}} cp -r --update=none-fail templates/{{type}}/kotlin/* -t src/main/kotlin/{{name}} - mv src/main/kotlin/{{name}}/Program.kt src/main/kotlin/{{name}}/$(echo "{{name}}" | sed -E 's/^(\w)/\U\1/')Program.kt + mv src/main/kotlin/{{name}}/Program.kt src/main/kotlin/{{name}}/$(echo "{{name}}" | sed -E 's/(^|_)(\w)/\U\2/g')Program.kt sed -i "s/<<name>>/{{name}}/" src/main/kotlin/{{name}}/* cp --update=none-fail templates/{{type}}/shaders/shader.glsl src/main/resources/shaders/{{name}}.glsl diff --git a/screenshot/vista_night.VistaNightProgram.png b/screenshot/vista_night.VistaNightProgram.png Binary files differnew file mode 100644 index 0000000..a47ef95 --- /dev/null +++ b/screenshot/vista_night.VistaNightProgram.png diff --git a/src/main/kotlin/vista_night/VistaNightProgram.kt b/src/main/kotlin/vista_night/VistaNightProgram.kt new file mode 100644 index 0000000..dcd97b4 --- /dev/null +++ b/src/main/kotlin/vista_night/VistaNightProgram.kt @@ -0,0 +1,39 @@ +package vista_night + +import org.openrndr.application +import org.openrndr.color.* +import org.openrndr.draw.* +import org.openrndr.extra.noise.filters.SimplexNoise3D +import org.openrndr.math.Vector3 +import phenax.utils.* + +fun main() = application { + recordDuration(5.seconds()) + + if (recordingEnabled || screenshotEnabled) { + configure { + width = 1920 + height = 1080 + windowResizable = false + } + } else { + configure { + width = 640 + height = 360 + windowResizable = false + } + } + + oliveProgram { + val cs by liveComputeShader("vista_night") + + val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8) + + extend { + cs.uniform("seconds", seconds) + cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE)) + cs.execute(outputBuffer.width, outputBuffer.height, 1) + drawer.image(outputBuffer) + } + } +} 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)); +} |
