[orx-fx] Add depth buffer to Post
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user