diff --git a/orx-fx/src/commonMain/kotlin/Post.kt b/orx-fx/src/commonMain/kotlin/Post.kt index 6be90250..8b1a7744 100644 --- a/orx-fx/src/commonMain/kotlin/Post.kt +++ b/orx-fx/src/commonMain/kotlin/Post.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx import org.openrndr.Extension import org.openrndr.Program +import org.openrndr.color.ColorRGBa import org.openrndr.draw.* class Post : Extension { @@ -25,6 +26,11 @@ class Post : Extension { */ var inputType = ColorType.UINT8 + /** + * The depth format to use for the input buffer + */ + var inputDepthFormat = DepthFormat.DEPTH_STENCIL + private var output: ColorBuffer? = null private var postFunction = { input: ColorBuffer, output: ColorBuffer -> input.copyTo(output) } @@ -77,6 +83,7 @@ class Post : Extension { // create new targets and buffers inputTarget = renderTarget(art.width, art.height, art.contentScale, multisample = art.multisample) { colorBuffer(type = inputType) + depthBuffer(format = inputDepthFormat) } if (art.multisample != BufferMultisample.Disabled) { resolved = colorBuffer(art.width, art.height, art.contentScale) @@ -85,6 +92,7 @@ class Post : Extension { } // bind input target, the next extensions will draw into it inputTarget!!.bind() + drawer.clear(ColorRGBa.TRANSPARENT) } override fun afterDraw(drawer: Drawer, program: Program) { diff --git a/orx-fx/src/demo/kotlin/DemoPost01.kt b/orx-fx/src/demo/kotlin/DemoPost01.kt index f6157802..95109150 100644 --- a/orx-fx/src/demo/kotlin/DemoPost01.kt +++ b/orx-fx/src/demo/kotlin/DemoPost01.kt @@ -3,6 +3,8 @@ import org.openrndr.application import org.openrndr.extra.fx.Post import org.openrndr.extra.fx.blend.Add import org.openrndr.extra.fx.blur.ApproximateGaussianBlur +import org.openrndr.shape.Circle +import kotlin.math.cos fun main() = application { configure { @@ -14,7 +16,7 @@ fun main() = application { val add = Add() post { input, output -> blur.window = 50 - blur.sigma = 50.0 + blur.sigma = 50.0 * (cos(seconds) * 0.5 + 0.5) blur.apply(input, intermediate[0]) add.apply(arrayOf(input, intermediate[0]), output) }