aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-10-07 18:07:46 +0530
committerAkshay Nair <phenax5@gmail.com>2026-10-07 18:07:46 +0530
commit56a6b43ec8509012755c9d63608fb98155b52a9a (patch)
treeac4fa365cea7c6a10fb85d485dd32c51cb92aba3 /src
parent26c45b3bbb42ce3338a715a284cb69322346b3bc (diff)
downloadart-playground-openrndr-56a6b43ec8509012755c9d63608fb98155b52a9a.tar.gz
art-playground-openrndr-56a6b43ec8509012755c9d63608fb98155b52a9a.zip
Add flow
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/flow/FlowProgram.kt52
-rw-r--r--src/main/resources/shaders/cloak.glsl2
-rw-r--r--src/main/resources/shaders/flow.glsl68
-rw-r--r--src/main/resources/shaders/modules/utils.glsl2
-rw-r--r--src/main/resources/shaders/mrdoor.glsl2
-rw-r--r--src/main/resources/shaders/time.glsl2
6 files changed, 122 insertions, 6 deletions
diff --git a/src/main/kotlin/flow/FlowProgram.kt b/src/main/kotlin/flow/FlowProgram.kt
new file mode 100644
index 0000000..de7611f
--- /dev/null
+++ b/src/main/kotlin/flow/FlowProgram.kt
@@ -0,0 +1,52 @@
+package flow
+
+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(12.seconds())
+
+ if (captureEnabled || true) {
+ configure {
+ width = 1920
+ height = 1080
+ windowResizable = false
+ }
+ } else {
+ configure {
+ width = 640
+ height = 360
+ windowResizable = false
+ }
+ }
+
+ oliveProgram {
+ val enableAntialiasing = captureEnabled
+
+ val cs by liveComputeShader("flow")
+ val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8)
+
+ val size = Math.max(width, height) * 2
+ val noiseBuffer = colorBuffer(size, size, type = ColorType.UINT8)
+ val noiseFilter = SimplexNoise3D()
+ noiseFilter.scale = Vector3.ONE * 2.4
+ noiseFilter.octaves = 8
+ noiseFilter.premultipliedAlpha = true
+
+ extend {
+ noiseFilter.seed = Vector3(0.01, 0.01, 0.001)
+ noiseFilter.apply(emptyArray(), noiseBuffer)
+ cs.image("noise_texture", 1, noiseBuffer.imageBinding(0, ImageAccess.READ))
+
+ cs.uniform("seconds", seconds)
+ cs.uniform("enable_antialiasing", enableAntialiasing)
+ 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/cloak.glsl b/src/main/resources/shaders/cloak.glsl
index c249760..451de27 100644
--- a/src/main/resources/shaders/cloak.glsl
+++ b/src/main/resources/shaders/cloak.glsl
@@ -4,8 +4,6 @@ layout(local_size_x = 1, local_size_y = 1) in;
#include <utils>
#include <noise>
-#define PI 3.14159265358979323
-
const float antialiasing = 0.28;
uniform float seconds = 0;
layout(rgba8) uniform writeonly image2D output_image;
diff --git a/src/main/resources/shaders/flow.glsl b/src/main/resources/shaders/flow.glsl
new file mode 100644
index 0000000..fe0aaad
--- /dev/null
+++ b/src/main/resources/shaders/flow.glsl
@@ -0,0 +1,68 @@
+#version 430
+layout(local_size_x = 1, local_size_y = 1) in;
+
+#include <utils>
+#include <noise>
+
+uniform float seconds = 0;
+layout(rgba8) uniform readonly image2D noise_texture;
+layout(rgba8) uniform writeonly image2D output_image;
+
+uniform float antialiasing = 0.28;
+uniform bool enable_antialiasing = false;
+
+float sample_noise(in vec2 p) {
+ vec4 noise = imageLoad(noise_texture, ivec2(p * imageSize(noise_texture)));
+ return noise.x;
+}
+
+vec3 image(vec2 uv) {
+ const vec3 bg_color = srgb(0.10, 0.10, 0.14);
+ const vec3 line1_color = srgb(0.2, 0.25, 0.4);
+ const vec3 line2_color = srgb(0.8, 0.3, 0.4);
+
+ vec3 color = bg_color;
+
+ float line_thickness = 0.04;
+ vec2 p = (vec2(uv.y, uv.x)) * 50;
+ int max = 40;
+ float t = mod(seconds, 12) * 0.7;
+
+ vec3 l1c = line1_color;
+ vec3 l2c = line2_color;
+
+ for (int i = 0; i < max; i++) {
+ float a = i * PI * (1 + t / 10) / 62;
+ float r = 5 * sin(a + t / 6) * sin(a + t / 6);
+ vec2 off = r * vec2(cos(a), sin(a)) + (1 + t / 1000.) * i * 0.2;
+ vec2 pos = (p + off) * mat2x2(cos(a), -sin(a), sin(a), cos(a));
+ float line = abs(sin(pos.x * (0.7 + 0.3 * fbm(p / 10)) + t * 2) / 3 - pos.y) - line_thickness;
+ vec3 line_color = mix(l1c, l2c, smoothstep(0, 1, float(i - 1) / (2. * max)));
+ color = mix(color, line_color, step(line, 0));
+ }
+
+ // color = mix(color, vec3(1), step(mixer, 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));
+}
diff --git a/src/main/resources/shaders/modules/utils.glsl b/src/main/resources/shaders/modules/utils.glsl
index 10e3a48..961480f 100644
--- a/src/main/resources/shaders/modules/utils.glsl
+++ b/src/main/resources/shaders/modules/utils.glsl
@@ -1,3 +1,5 @@
+#define PI 3.14159265358979323
+
float smin(float a, float b, float k) {
float h = clamp(0.5 + 0.5 * (b - a) / k, 0.0, 1.0);
return mix(b, a, h) - k * h * (1.0 - h);
diff --git a/src/main/resources/shaders/mrdoor.glsl b/src/main/resources/shaders/mrdoor.glsl
index 19290ce..6869df5 100644
--- a/src/main/resources/shaders/mrdoor.glsl
+++ b/src/main/resources/shaders/mrdoor.glsl
@@ -15,8 +15,6 @@ uniform float antialiasing = 0.28;
// const vec3 door1_light_position = vec3(0.8, 4, 0.4);
// const vec3 sunlight_color = vec3(1, 0.99, 0.99);
-#define PI 3.14159265358979323
-
struct Obj {
int objid;
float dist;
diff --git a/src/main/resources/shaders/time.glsl b/src/main/resources/shaders/time.glsl
index 0450062..0c6996f 100644
--- a/src/main/resources/shaders/time.glsl
+++ b/src/main/resources/shaders/time.glsl
@@ -5,8 +5,6 @@ layout(local_size_x = 1, local_size_y = 1) in;
#include <utils>
#include <noise>
-#define PI 3.14159265358979323
-
uniform float hours = 0;
uniform float minutes = 0;
uniform float time = 0;