diff options
| author | Akshay Nair <phenax5@gmail.com> | 2026-10-03 23:15:07 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2026-10-04 00:34:30 +0530 |
| commit | 57ff3d2eb6c5b0d2a3f67296844390376851b13c (patch) | |
| tree | a518d3b8e8b123bcf990ede56c785fd299c354c1 /src/main/kotlin | |
| parent | b32d32248e0bfd6e763991b14c9d7bf29063ed29 (diff) | |
| download | art-playground-openrndr-57ff3d2eb6c5b0d2a3f67296844390376851b13c.tar.gz art-playground-openrndr-57ff3d2eb6c5b0d2a3f67296844390376851b13c.zip | |
More eyeball stuff
Diffstat (limited to 'src/main/kotlin')
| -rw-r--r-- | src/main/kotlin/time/TimeProgram.kt | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/main/kotlin/time/TimeProgram.kt b/src/main/kotlin/time/TimeProgram.kt index 1c39300..0f5db32 100644 --- a/src/main/kotlin/time/TimeProgram.kt +++ b/src/main/kotlin/time/TimeProgram.kt @@ -4,14 +4,14 @@ import java.time.LocalTime import org.openrndr.application import org.openrndr.color.* import org.openrndr.draw.* -import org.openrndr.extra.noise.filters.SimplexNoise3D import org.openrndr.math.* import phenax.utils.* fun main() = application { recordDuration(5.seconds()) - if (recordingEnabled || screenshotEnabled) { + // TODO: remove hardcode + if (captureEnabled) { configure { width = 1920 height = 1080 @@ -26,37 +26,28 @@ fun main() = application { } oliveProgram { - val char_size = 200.0 - val font = program.loadFont("data/fonts/default.otf", char_size) + val enableAntialiasing = captureEnabled + val charSize = 200.0 + val font = program.loadFont("data/fonts/default.otf", charSize) val cs by liveComputeShader("time") - val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8) - - val size = Math.max(width, height) * 4 - val noiseBuffer = colorBuffer(size, size, type = ColorType.UINT8) - val noiseFilter = SimplexNoise3D() - noiseFilter.scale = Vector3.ONE * 2.4 - noiseFilter.octaves = 8 - noiseFilter.premultipliedAlpha = true - noiseFilter.seed = Vector3(0.18, 0.01, 0.001) - noiseFilter.apply(emptyArray(), noiseBuffer) + val scale = if (enableAntialiasing) 2 else 1 + val computeShaderBuffer = colorBuffer(scale * width, scale * height, type = ColorType.UINT8) val characters = 0..9 val textTarget = - renderTarget(char_size.toInt() * characters.count(), char_size.toInt()) { + renderTarget(charSize.toInt() * characters.count(), charSize.toInt()) { colorBuffer(type = ColorType.UINT8) } extend { - cs.image("noise_texture", 1, noiseBuffer.imageBinding(0, ImageAccess.READ)) - drawer.isolatedWithTarget(textTarget) { drawer.clear(ColorRGBa.TRANSPARENT) drawer.ortho(textTarget) drawer.fontMap = font drawer.fill = ColorRGBa.WHITE for (char in characters) { - drawer.text(char.toString(), Vector2(char * char_size.toDouble(), char_size / 2.0 + 5)) + drawer.text(char.toString(), Vector2(char * charSize.toDouble(), charSize / 2.0 + 5)) } } @@ -65,14 +56,20 @@ fun main() = application { cs.image("text_texture", 2, textBuffer.imageBinding(0, ImageAccess.READ)) val time = LocalTime.now() - cs.uniform("hours", time.getHour().toFloat()) - cs.uniform("minutes", time.getMinute().toFloat()) - cs.uniform("seconds", time.getSecond().toFloat()) + if (recordingEnabled) { + cs.uniform("hours", 10.0) + cs.uniform("minutes", 10.0 + seconds / 60.0) + cs.uniform("seconds", time.getSecond().toFloat()) + } else { + cs.uniform("hours", time.getHour().toFloat()) + cs.uniform("minutes", time.getMinute().toFloat()) + cs.uniform("seconds", time.getSecond().toFloat()) + } cs.uniform("time", seconds) - cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE)) - cs.execute(outputBuffer.width, outputBuffer.height, 1) - drawer.image(outputBuffer) + cs.image("output_image", 0, computeShaderBuffer.imageBinding(0, ImageAccess.WRITE)) + cs.execute(computeShaderBuffer.width, computeShaderBuffer.height, 1) + drawer.image(computeShaderBuffer, 0.0, 0.0, width.toDouble(), height.toDouble()) } } } |
