aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-08-31 01:15:57 +0530
committerAkshay Nair <phenax5@gmail.com>2026-08-31 01:15:57 +0530
commit9ca804040a34b29ec1f067206eae86893a2e7997 (patch)
treec67b58b45bd2e318ed3499888d5c559a0d26baf7
parentfecebfd39809f862e098805219b15c50588bb81a (diff)
downloadart-playground-openrndr-9ca804040a34b29ec1f067206eae86893a2e7997.tar.gz
art-playground-openrndr-9ca804040a34b29ec1f067206eae86893a2e7997.zip
Compute shader testing
Diffstat (limited to '')
-rw-r--r--src/main/kotlin/play/PlayShowProgram.kt58
1 files changed, 39 insertions, 19 deletions
diff --git a/src/main/kotlin/play/PlayShowProgram.kt b/src/main/kotlin/play/PlayShowProgram.kt
index 016378f..4107cd7 100644
--- a/src/main/kotlin/play/PlayShowProgram.kt
+++ b/src/main/kotlin/play/PlayShowProgram.kt
@@ -1,12 +1,7 @@
package play
-import kotlin.math.cos
-import kotlin.math.sin
import org.openrndr.application
-import org.openrndr.color.ColorRGBa
-import org.openrndr.draw.loadFont
-import org.openrndr.draw.loadImage
-import org.openrndr.extra.color.colormatrix.tint
+import org.openrndr.draw.*
import org.openrndr.extra.olive.oliveProgram
import phenax.utils.*
@@ -20,23 +15,48 @@ fun main() = application {
}
oliveProgram {
- val image = loadImage("data/images/pm5544.png")
- val font = loadFont("data/fonts/default.otf", 64.0)
+ // val image = loadImage("data/images/pm5544.png")
+ // val font = loadFont("data/fonts/default.otf", 64.0)
+
+ val cs = computeStyle {
+ computeTransform =
+ """
+ ivec2 coords = ivec2(gl_GlobalInvocationID.xy);
+ ivec2 resolution = imageSize(p_outputImg).xy;
+ float aspect_ratio = resolution.y*1.0 / resolution.x;
+
+ vec2 uv = vec2(1.0, aspect_ratio) * (coords - 0.5*resolution)/resolution;
+ float dist = length(uv) - 0.1;
+ float step = step(0.0, dist);
+
+ vec4 color = vec4(step, 0.0, 0.0, 1.0);
+ imageStore(p_outputImg, coords, color);
+ """.trimIndent()
+ }
+
+ // val inputBuffer = colorBuffer(width, height, type = ColorType.UINT8)
+
+ val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8)
extend {
- drawer.drawStyle.colorMatrix = tint(ColorRGBa.WHITE.shade(0.2))
- drawer.image(image)
+ // drawer.drawStyle.colorMatrix = tint(ColorRGBa.WHITE.shade(0.2))
+ // drawer.image(image)
+
+ // drawer.fill = ColorRGBa.PINK
+ // drawer.circle(
+ // cos(seconds) * width / 2.0 + width / 2.0,
+ // sin(0.5 * seconds) * height / 2.0 + height / 2.0,
+ // 140.0
+ // )
- drawer.fill = ColorRGBa.PINK
- drawer.circle(
- cos(seconds) * width / 2.0 + width / 2.0,
- sin(0.5 * seconds) * height / 2.0 + height / 2.0,
- 140.0
- )
+ // drawer.fontMap = font
+ // drawer.fill = ColorRGBa.WHITE
+ // drawer.text("OPENRNDR", width / 2.0, height / 2.0)
- drawer.fontMap = font
- drawer.fill = ColorRGBa.WHITE
- drawer.text("OPENRNDR", width / 2.0, height / 2.0)
+ cs.parameter("seconds", seconds)
+ cs.image("outputImg", outputBuffer.imageBinding(0, ImageAccess.WRITE))
+ cs.execute(outputBuffer.width, outputBuffer.height, 1)
+ drawer.image(outputBuffer)
}
}
}