aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/play/PlayProgram.kt
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-09-14 11:46:56 +0530
committerAkshay Nair <phenax5@gmail.com>2026-09-14 11:46:56 +0530
commit707c8896cef6bff291f5d2f3339cf9bf46ee2242 (patch)
treefd62d97b8d92c0b0cc8ff817ce2477df771d20d7 /src/main/kotlin/play/PlayProgram.kt
parent42b66232530f933b184d446a7461e2e9f8d42bce (diff)
downloadart-playground-openrndr-707c8896cef6bff291f5d2f3339cf9bf46ee2242.tar.gz
art-playground-openrndr-707c8896cef6bff291f5d2f3339cf9bf46ee2242.zip
Refactor stuff
Diffstat (limited to '')
-rw-r--r--src/main/kotlin/play/PlayProgram.kt82
1 files changed, 22 insertions, 60 deletions
diff --git a/src/main/kotlin/play/PlayProgram.kt b/src/main/kotlin/play/PlayProgram.kt
index ea54c35..93af7b3 100644
--- a/src/main/kotlin/play/PlayProgram.kt
+++ b/src/main/kotlin/play/PlayProgram.kt
@@ -1,11 +1,11 @@
package play
-import org.openrndr.KeyModifier
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.extensions.CameraManager
import phenax.utils.*
fun main() = application {
@@ -18,77 +18,39 @@ fun main() = application {
}
oliveProgram {
- val font = loadFont("data/fonts/default.otf", 16.0)
val cs by liveComputeShader("play_shader")
val outputBuffer = colorBuffer(width, height, type = ColorType.UINT8)
- var cameraPosition: Vector3 = Vector3(0.0, 1.0, 0.0)
- var lightPosition: Vector3 = Vector3(1.0, 2.0, 1.0)
- var actionType: ActionType? = null
- var lastPos: Vector3? = null
+ val cloudNoiseBuffer = colorBuffer(width, height, type = ColorType.UINT8)
+ val cloudNoiseFilter = SimplexNoise3D()
+ cloudNoiseFilter.scale = Vector3.ONE * 1.0
+ cloudNoiseFilter.octaves = 8
+ cloudNoiseFilter.premultipliedAlpha = true
- if (!recordingEnabled) {
- mouse.moved.listen {
- val dimens = Vector3(program.width.toDouble(), program.height.toDouble(), 1.0)
- val pos = (Vector3(it.position.x, -it.position.y, 0.0) - dimens / 2.0).div(dimens)
- if (actionType == ActionType.PAN) {
- lastPos?.let { lastPos -> cameraPosition -= (pos - lastPos) }
- } else if (actionType == ActionType.LIGHT_MOVE) {
- lastPos?.let { lastPos -> lightPosition += (pos - lastPos) }
- }
- actionType?.let { lastPos = pos }
- }
- mouse.buttonDown.listen {
- val isCtrl = KeyModifier.CTRL in it.modifiers
- actionType = if (isCtrl) ActionType.LIGHT_MOVE else ActionType.PAN
- }
- mouse.scrolled.listen {
- val isCtrl = KeyModifier.CTRL in it.modifiers
- if (isCtrl) {
- lightPosition += Vector3(0.0, 0.0, it.rotation.y * 0.1)
- } else {
- cameraPosition += Vector3(0.0, 0.0, it.rotation.y * 0.1)
- }
- }
- mouse.buttonUp.listen {
- actionType = null
- lastPos = null
- }
- }
+ // val terrainNoiseBuffer = colorBuffer(2000, 2000, type = ColorType.UINT8)
+ // val terrainNoiseFilter = SimplexNoise3D()
+ // terrainNoiseFilter.seed = Vector3(0.0, 0.0, 0.0)
+ // terrainNoiseFilter.scale = Vector3.ONE * 1.0
+ // terrainNoiseFilter.octaves = 8
+ // terrainNoiseFilter.premultipliedAlpha = true
- val noiseBuffer = colorBuffer(width, height, type = ColorType.UINT8)
- val noiseFilter = SimplexNoise3D()
- noiseFilter.seed = Vector3(0.0, 0.0, 0.1)
- noiseFilter.scale = Vector3.ONE * 1.0
- noiseFilter.octaves = 8
- noiseFilter.premultipliedAlpha = true
- noiseFilter.apply(emptyArray(), noiseBuffer)
+ var camera_manager = CameraManager()
+ extend(camera_manager)
extend {
- cs.image("noise_texture", 0, noiseBuffer.imageBinding(0, ImageAccess.READ))
+ cloudNoiseFilter.seed = Vector3(0.02 * seconds, 0.0, 0.01 * seconds)
+ cloudNoiseFilter.apply(emptyArray(), cloudNoiseBuffer)
+ cs.image("cloud_noise_texture", 1, cloudNoiseBuffer.imageBinding(0, ImageAccess.READ))
+
+ // terrainNoiseFilter.apply(emptyArray(), terrainNoiseBuffer)
+ // cs.image("terrain_noise_texture", 2, terrainNoiseBuffer.imageBinding(0, ImageAccess.READ))
cs.uniform("seconds", seconds)
- cs.uniform("camera_position", cameraPosition)
- cs.uniform("primary_light_position", lightPosition)
- cs.image("output_image", 2, outputBuffer.imageBinding(0, ImageAccess.WRITE))
+ camera_manager.setUniforms(cs)
+ cs.image("output_image", 0, outputBuffer.imageBinding(0, ImageAccess.WRITE))
cs.execute(outputBuffer.width, outputBuffer.height, 1)
drawer.image(outputBuffer)
-
- if (!recordingEnabled) {
- drawer.fontMap = font
- drawer.fill = ColorRGBa.WHITE
- drawer.text(
- "C: %.2f %.2f %.2f".format(cameraPosition.x, cameraPosition.y, cameraPosition.z),
- 8.0,
- 16.0
- )
- drawer.text(
- "L: %.2f %.2f %.2f".format(lightPosition.x, lightPosition.y, lightPosition.z),
- 8.0,
- 32.0
- )
- }
}
}
}