aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-09-14 22:32:29 +0530
committerAkshay Nair <phenax5@gmail.com>2026-09-14 22:32:29 +0530
commita7c26079aedf1c04563eb35a51e5903d576821b4 (patch)
tree6c39bfd9d9ba165478335a7c164508afe4fbadf2 /src/main
parent707c8896cef6bff291f5d2f3339cf9bf46ee2242 (diff)
downloadart-playground-openrndr-a7c26079aedf1c04563eb35a51e5903d576821b4.tar.gz
art-playground-openrndr-a7c26079aedf1c04563eb35a51e5903d576821b4.zip
Fun patterns for funzies
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/warping/WarpingProgram.kt43
-rw-r--r--src/main/resources/shaders/warping.glsl37
2 files changed, 80 insertions, 0 deletions
diff --git a/src/main/kotlin/warping/WarpingProgram.kt b/src/main/kotlin/warping/WarpingProgram.kt
new file mode 100644
index 0000000..a84f335
--- /dev/null
+++ b/src/main/kotlin/warping/WarpingProgram.kt
@@ -0,0 +1,43 @@
+package warping
+
+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())
+
+ configure {
+ width = 640
+ height = 480
+ windowResizable = false
+ }
+
+ oliveProgram {
+ val cs by liveComputeShader("warping")
+
+ 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 * Math.sin(seconds), 0.01 * Math.cos(seconds), 0.006 * seconds)
+ // 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.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/warping.glsl b/src/main/resources/shaders/warping.glsl
new file mode 100644
index 0000000..044e324
--- /dev/null
+++ b/src/main/resources/shaders/warping.glsl
@@ -0,0 +1,37 @@
+#version 430
+layout(local_size_x = 1, local_size_y = 1) in;
+
+#include <sdf>
+#include <utils>
+#include <noise>
+
+uniform float seconds = 0;
+layout(rgba8) uniform readonly image2D noise_texture;
+layout(rgba8) uniform writeonly image2D output_image;
+
+float sample_noise(in vec2 p) {
+ vec4 noise = imageLoad(noise_texture, ivec2(p * imageSize(noise_texture)));
+ return noise.x;
+}
+
+float gen_pattern(in vec2 p, out vec3 coloring_factor, out vec3 coloring_factor2) {
+ float s1 = sample_noise(p + sample_noise(p) * vec2(0.5, 0.1));
+ float s2 = sample_noise(p + sample_noise(p) * vec2(0.8, 0.4));
+ float s3 = sample_noise(p + sample_noise(p));
+ coloring_factor = vec3(s1, s2, 0.8);
+ coloring_factor2 = vec3(s2, 0.2, s3);
+ return sample_noise(p + s2 * s1 * s3);
+}
+
+void main() {
+ vec2 resolution = vec2(imageSize(output_image).xy);
+ float aspect_ratio = resolution.y / resolution.x;
+ vec2 uv = gl_GlobalInvocationID.xy * vec2(1.0, aspect_ratio) / resolution;
+
+ vec3 coloring_factor;
+ vec3 coloring_factor2;
+ float v = gen_pattern(uv, coloring_factor, coloring_factor2);
+ vec3 color = mix(coloring_factor, coloring_factor2, v);
+
+ imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1));
+}