diff --git a/orx-jvm/orx-dnk3/build.gradle.kts b/orx-jvm/orx-dnk3/build.gradle.kts index b6613c38..03be06af 100644 --- a/orx-jvm/orx-dnk3/build.gradle.kts +++ b/orx-jvm/orx-dnk3/build.gradle.kts @@ -13,7 +13,9 @@ dependencies { implementation(libs.openrndr.math) implementation(libs.kotlin.coroutines) demoImplementation(project(":orx-mesh-generators")) + demoImplementation(project(":orx-camera")) demoImplementation(project(":orx-noise")) + demoImplementation(project(":orx-shader-phrases")) demoImplementation(libs.openrndr.ffmpeg) demoImplementation(libs.openrndr.filter) } \ No newline at end of file diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt index cb878d7a..a0350442 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt @@ -19,12 +19,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/box-animated/BoxAnimated.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt index cd467397..1c7bce0e 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt @@ -12,16 +12,9 @@ fun main() = application { configure { width = 1280 height = 720 - //multisample = WindowMultisample.SampleCount(8) } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/camera/Scene.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt index 65038b2a..cd539338 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt @@ -17,11 +17,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } extend(Orbital()) { eye = Vector3(4.0, 4.0, 4.0) } diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt index 3b1cedd7..540d8e48 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt @@ -1,87 +1,82 @@ -import org.openrndr.application -import org.openrndr.color.ColorRGBa -import org.openrndr.extensions.SingleScreenshot -import org.openrndr.extra.dnk3.dsl.* -import org.openrndr.extra.dnk3.renderers.dryRenderer -import org.openrndr.extra.dnk3.tools.addSkybox -import org.openrndr.extra.noise.simplex -import org.openrndr.extra.camera.Orbital -import org.openrndr.extra.meshgenerators.groundPlaneMesh -import org.openrndr.math.Vector3 -import org.openrndr.math.transforms.transform -import org.openrndr.shape.path3D - -fun main() = application { - configure { - width = 1280 - height = 720 - } - - program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - extend(Orbital()) { - eye = Vector3(4.0, 4.0, 4.0) - } - - val renderer = dryRenderer() - val scene = scene { - - addSkybox("file:demo-data/cubemaps/garage_iem.dds") - - root.hemisphereLight { - upColor = ColorRGBa.WHITE.shade(0.1) - downColor = ColorRGBa.BLACK - } - - root.node { - transform = transform { - translate(0.0, 2.0, 0.0) - } - - pointLight { - constantAttenuation = 0.0 - quadraticAttenuation = 1.0 - } - } - - root.node { - simpleMesh { - vertexBuffer = groundPlaneMesh(100.0, 100.0) - material = pbrMaterial { - color = ColorRGBa.GREEN - } - } - } - - root.node { - pathMesh { - weight = 10.0 - material = pbrMaterial { - color = ColorRGBa.PINK - } - update { - paths = mutableListOf( - path3D { - val t = seconds * 0.1 - moveTo(Vector3.ZERO) - val control = Vector3.simplex(3032, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 - val target = Vector3.simplex(5077, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 - val end = Vector3.simplex(9041, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 - curveTo(control, target) - continueTo(end) - } - ) - } - } - } - } - extend { - drawer.clear(ColorRGBa.BLACK) - renderer.draw(drawer, scene) - } - } -} \ No newline at end of file +//import org.openrndr.application +//import org.openrndr.color.ColorRGBa +//import org.openrndr.extensions.SingleScreenshot +//import org.openrndr.extra.dnk3.dsl.* +//import org.openrndr.extra.dnk3.renderers.dryRenderer +//import org.openrndr.extra.dnk3.tools.addSkybox +//import org.openrndr.extra.noise.simplex +//import org.openrndr.extra.camera.Orbital +//import org.openrndr.extra.meshgenerators.groundPlaneMesh +//import org.openrndr.math.Vector3 +//import org.openrndr.math.transforms.transform +//import org.openrndr.shape.path3D +// +//fun main() = application { +// configure { +// width = 1280 +// height = 720 +// } +// +// program { +// extend(Orbital()) { +// eye = Vector3(4.0, 4.0, 4.0) +// } +// +// val renderer = dryRenderer() +// val scene = scene { +// +// addSkybox("file:demo-data/cubemaps/garage_iem.dds") +// +// root.hemisphereLight { +// upColor = ColorRGBa.WHITE.shade(0.1) +// downColor = ColorRGBa.BLACK +// } +// +// root.node { +// transform = transform { +// translate(0.0, 2.0, 0.0) +// } +// +// pointLight { +// constantAttenuation = 0.0 +// quadraticAttenuation = 1.0 +// } +// } +// +// root.node { +// simpleMesh { +// vertexBuffer = groundPlaneMesh(100.0, 100.0) +// material = pbrMaterial { +// color = ColorRGBa.GREEN +// } +// } +// } +// +// root.node { +// pathMesh { +// weight = 10.0 +// material = pbrMaterial { +// color = ColorRGBa.PINK +// } +// update { +// paths = mutableListOf( +// path3D { +// val t = seconds * 0.1 +// moveTo(Vector3.ZERO) +// val control = Vector3.simplex(3032, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 +// val target = Vector3.simplex(5077, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 +// val end = Vector3.simplex(9041, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0 +// curveTo(control, target) +// continueTo(end) +// } +// ) +// } +// } +// } +// } +// extend { +// drawer.clear(ColorRGBa.BLACK) +// renderer.draw(drawer, scene) +// } +// } +//} \ No newline at end of file diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt index 20ef33ea..5303f2b5 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt @@ -37,13 +37,6 @@ fun main() = application { } program { - - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/irradiance-probes/model.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt index 96462791..811a79b8 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt @@ -17,12 +17,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/point-light/Scene.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt index 696668d7..7e49a65a 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt @@ -17,12 +17,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/spot-light/Scene.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt index b2e20476..9818d956 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt @@ -17,12 +17,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/directional-light/Scene.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt index 69d20213..ddb8d91f 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt @@ -9,12 +9,6 @@ import java.io.File fun main() = application { program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/duck/Duck.gltf")) val meshes = gltf.meshes.map { it.createDrawCommands(gltf) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt index 0cd92792..cff00adf 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt @@ -18,12 +18,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/suzanne/Suzanne.gltf")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt index 128f67ca..d5c81207 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt @@ -1,6 +1,5 @@ import org.openrndr.application import org.openrndr.color.ColorRGBa -import org.openrndr.extensions.SingleScreenshot import org.openrndr.extra.dnk3.* import org.openrndr.extra.dnk3.gltf.buildSceneNodes @@ -18,12 +17,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/duck/Duck.gltf")) val scene = Scene(SceneNode()) @@ -38,7 +31,7 @@ fun main() = application { scene.root.entities.add(HemisphereLight().apply { upColor = ColorRGBa.WHITE.shade(1.0) downColor = ColorRGBa.WHITE.shade(0.1) - }) + }) scene.root.children.add(lightNode) scene.root.children.addAll(gltf.buildSceneNodes().scenes.first()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt index bc1e0f63..fc062e8a 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt @@ -18,11 +18,6 @@ fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } val root = SceneNode() val scene = Scene(root) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt index 6a7c4441..7496737e 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt @@ -1,3 +1,4 @@ +import org.openrndr.WindowMultisample import org.openrndr.application import org.openrndr.color.ColorRGBa import org.openrndr.draw.BufferMultisample @@ -15,15 +16,10 @@ fun main() = application { configure { width = 1280 height = 720 - //multisample = WindowMultisample.SampleCount(8) + multisample = WindowMultisample.SampleCount(8) } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } val gltf = loadGltfFromFile(File("demo-data/gltf-models/fox/Fox.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt index 5c77f14e..1632bc76 100644 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt +++ b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt @@ -10,7 +10,7 @@ import org.openrndr.math.Vector3 import org.openrndr.math.mod_ import java.io.File -suspend fun main() = application { +fun main() = application { configure { width = 1280 height = 720 @@ -18,12 +18,6 @@ suspend fun main() = application { } program { - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - val gltf = loadGltfFromFile(File("demo-data/gltf-models/fox/Fox.glb")) val scene = Scene(SceneNode()) diff --git a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoVoxelConeTracing01.kt b/orx-jvm/orx-dnk3/src/demo/kotlin/DemoVoxelConeTracing01.kt deleted file mode 100644 index 170c0bc0..00000000 --- a/orx-jvm/orx-dnk3/src/demo/kotlin/DemoVoxelConeTracing01.kt +++ /dev/null @@ -1,114 +0,0 @@ -import kotlinx.coroutines.yield -import org.openrndr.* -import org.openrndr.color.ColorRGBa -import org.openrndr.draw.* -import org.openrndr.extensions.SingleScreenshot -import org.openrndr.extra.dnk3.* -import org.openrndr.extra.dnk3.features.addVoxelConeTracing -import org.openrndr.extra.dnk3.gltf.buildSceneNodes -import org.openrndr.extra.dnk3.gltf.loadGltfFromFile -import org.openrndr.extra.dnk3.renderers.postRenderer -import org.openrndr.extra.camera.Orbital -import org.openrndr.extra.meshgenerators.sphereMesh -import org.openrndr.filter.color.Delinearize -import org.openrndr.math.Spherical -import org.openrndr.math.Vector3 -import org.openrndr.math.transforms.transform -import java.io.File -import kotlin.math.cos -import kotlin.math.sin - -fun main() = application { - configure { - width = 1280 - height = 720 - multisample = WindowMultisample.SampleCount(8) - } - - program { - - if (System.getProperty("takeScreenshot") == "true") { - extend(SingleScreenshot()) { - this.outputFile = System.getProperty("screenshotPath") - } - } - - val gltf = loadGltfFromFile(File("demo-data/gltf-models/irradiance-probes/model.glb")) - val scene = Scene(SceneNode()) - - val probeBox = sphereMesh(16, 16, 0.1) - val probeGeometry = Geometry(listOf(probeBox), null, DrawPrimitive.TRIANGLES, 0, probeBox.vertexCount) - - val c = 5 -// scene.addIrradianceSH(c, c, c, 3.0 / c, cubemapSize = 32, offset = Vector3(0.0, 0.0, 0.0)) - val vctFeature = scene.addVoxelConeTracing(64,64,64, 0.1) - - - - val sceneData = gltf.buildSceneNodes() - scene.root.children.addAll(sceneData.scenes.first()) - - // -- create a renderer - val renderer = postRenderer() - - -// renderer.postSteps.add( -// FilterPostStep(1.0, ScreenspaceReflections(), listOf("color", "clipDepth", "viewNormal"), "reflections", ColorFormat.RGB, ColorType.FLOAT16) { -// val p = Matrix44.scale(drawer.width / 2.0, drawer.height / 2.0, 1.0) * Matrix44.translate(Vector3(1.0, 1.0, 0.0)) * drawer.projection -// this.projection = p -// this.projectionMatrixInverse = drawer.projection.inversed -// } -// ) - -// renderer.postSteps.add( -// FilterPostStep(1.0, VolumetricIrradiance(), listOf("color", "clipDepth"), "volumetric-irradiance", ColorFormat.RGB, ColorType.FLOAT16) { -// this.irradianceSH = scene.features[0] as IrradianceSH -// this.projectionMatrixInverse = drawer.projection.inversed -// this.viewMatrixInverse = drawer.view.inversed -// } -// ) - - renderer.postSteps.add( - FilterPostStep(1.0, Delinearize(), listOf("color"), "ldr", ColorFormat.RGB, ColorType.FLOAT16) - ) - - val orb = extend(Orbital()) { - this.fov = 20.0 - camera.setView(Vector3(-0.49, -0.24, 0.20), Spherical(26.56, 90.0, 6.533), 40.0) - } - - renderer.draw(drawer, scene) - - val dynNode = SceneNode() - val dynMaterial = PBRMaterial() - val dynPrimitive = MeshPrimitive(probeGeometry, dynMaterial) - val dynMesh = Mesh(listOf(dynPrimitive)) - dynNode.entities.add(dynMesh) - scene.root.children.add(dynNode) - - scene.dispatcher.launch { - while (true) { - dynNode.transform = transform { - translate(cos(seconds) * 0.5, 0.5, sin(seconds) * 0.5) - scale(2.0) - } - yield() - } - } - - val viz = colorBuffer(64,64) - extend { - drawer.clear(ColorRGBa.BLACK) - renderer.draw(drawer, scene) - drawer.defaults() - - for (i in 0 until 128) { - vctFeature.voxelMap?.let { - it.copyTo(viz, i) - } - drawer.image(viz, (i * 128) % width + 0.0, ((i * 128)/width * 128 + 0.0 )) - } - drawer.image(vctFeature.voxelRenderTarget!!.colorBuffer(0)) - } - } -} \ No newline at end of file diff --git a/orx-jvm/orx-dnk3/src/main/kotlin/features/IrradianceSH.kt b/orx-jvm/orx-dnk3/src/main/kotlin/features/IrradianceSH.kt index 0da366af..817444d9 100644 --- a/orx-jvm/orx-dnk3/src/main/kotlin/features/IrradianceSH.kt +++ b/orx-jvm/orx-dnk3/src/main/kotlin/features/IrradianceSH.kt @@ -102,7 +102,10 @@ private fun SceneRenderer.processIrradiance(drawer: Drawer, scene: Scene, featur feature.shMap?.let { buffer.rewind() it.write(buffer) - it.saveToFile(File("data/scene-cache/sh-$hash.orb")) + val f = File("data/scene-cache/sh-$hash.orb") + if (f.canWrite()) { + it.saveToFile(f) + } } } }