[orx-compositor] Reintroduce accumulation variable. (#241)
This commit is contained in:
@@ -43,8 +43,8 @@ open class Layer internal constructor(val bufferMultisample: BufferMultisample =
|
|||||||
var blendFilter: Pair<Filter, Filter.() -> Unit>? = null
|
var blendFilter: Pair<Filter, Filter.() -> Unit>? = null
|
||||||
val postFilters: MutableList<Pair<Filter, Filter.() -> Unit>> = mutableListOf()
|
val postFilters: MutableList<Pair<Filter, Filter.() -> Unit>> = mutableListOf()
|
||||||
var colorType = ColorType.UINT8
|
var colorType = ColorType.UINT8
|
||||||
private var resolvedColorBuffer: ColorBuffer? = null
|
private var unresolvedAccumulation: ColorBuffer? = null
|
||||||
private var activeRenderTargetColorBuffer: ColorBuffer? = null
|
var accumulation: ColorBuffer? = null
|
||||||
|
|
||||||
@BooleanParameter("enabled")
|
@BooleanParameter("enabled")
|
||||||
var enabled = true
|
var enabled = true
|
||||||
@@ -85,8 +85,8 @@ open class Layer internal constructor(val bufferMultisample: BufferMultisample =
|
|||||||
if (it.bufferMultisample == BufferMultisample.Disabled) {
|
if (it.bufferMultisample == BufferMultisample.Disabled) {
|
||||||
drawer.image(copyTarget.colorBuffer(0))
|
drawer.image(copyTarget.colorBuffer(0))
|
||||||
} else {
|
} else {
|
||||||
copyTarget.colorBuffer(0).copyTo(it.resolvedColorBuffer!!)
|
copyTarget.colorBuffer(0).copyTo(it.accumulation!!)
|
||||||
drawer.image(it.resolvedColorBuffer!!)
|
drawer.image(it.accumulation!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,26 +171,24 @@ open class Layer internal constructor(val bufferMultisample: BufferMultisample =
|
|||||||
if (bufferMultisample == BufferMultisample.Disabled) {
|
if (bufferMultisample == BufferMultisample.Disabled) {
|
||||||
drawer.image(layerPost, layerPost.bounds, drawer.bounds)
|
drawer.image(layerPost, layerPost.bounds, drawer.bounds)
|
||||||
} else {
|
} else {
|
||||||
layerPost.copyTo(resolvedColorBuffer!!)
|
layerPost.copyTo(accumulation!!)
|
||||||
drawer.image(resolvedColorBuffer!!, layerPost.bounds, drawer.bounds)
|
drawer.image(accumulation!!, layerPost.bounds, drawer.bounds)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
localBlendFilter.first.apply(localBlendFilter.second)
|
localBlendFilter.first.apply(localBlendFilter.second)
|
||||||
activeRenderTarget.colorBuffer(0).copyTo(activeRenderTargetColorBuffer!!)
|
activeRenderTarget.colorBuffer(0).copyTo(unresolvedAccumulation!!)
|
||||||
if (bufferMultisample == BufferMultisample.Disabled) {
|
if (bufferMultisample == BufferMultisample.Disabled) {
|
||||||
localBlendFilter.first.apply(arrayOf(activeRenderTargetColorBuffer!!, layerPost),
|
localBlendFilter.first.apply(arrayOf(unresolvedAccumulation!!, layerPost), unresolvedAccumulation!!)
|
||||||
activeRenderTargetColorBuffer!!)
|
|
||||||
} else {
|
} else {
|
||||||
layerPost.copyTo(resolvedColorBuffer!!)
|
layerPost.copyTo(accumulation!!)
|
||||||
localBlendFilter.first.apply(arrayOf(activeRenderTargetColorBuffer!!, resolvedColorBuffer!!),
|
localBlendFilter.first.apply(arrayOf(unresolvedAccumulation!!, accumulation!!), unresolvedAccumulation!!)
|
||||||
activeRenderTargetColorBuffer!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeRenderTarget !is ProgramRenderTarget) {
|
if (activeRenderTarget !is ProgramRenderTarget) {
|
||||||
activeRenderTargetColorBuffer!!.copyTo(target.colorBuffer(0))
|
unresolvedAccumulation!!.copyTo(target.colorBuffer(0))
|
||||||
}
|
}
|
||||||
activeRenderTargetColorBuffer!!.copyTo(activeRenderTarget.colorBuffer(0))
|
unresolvedAccumulation!!.copyTo(activeRenderTarget.colorBuffer(0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -205,19 +203,25 @@ open class Layer internal constructor(val bufferMultisample: BufferMultisample =
|
|||||||
activeRenderTarget: RenderTarget, drawer: Drawer, bufferMultisample: BufferMultisample
|
activeRenderTarget: RenderTarget, drawer: Drawer, bufferMultisample: BufferMultisample
|
||||||
) {
|
) {
|
||||||
layerTarget?.deepDestroy()
|
layerTarget?.deepDestroy()
|
||||||
layerTarget = renderTarget(activeRenderTarget.width, activeRenderTarget.height,
|
layerTarget = renderTarget(
|
||||||
activeRenderTarget.contentScale, bufferMultisample) {
|
activeRenderTarget.width, activeRenderTarget.height,
|
||||||
|
activeRenderTarget.contentScale, bufferMultisample
|
||||||
|
) {
|
||||||
colorBuffer(type = colorType)
|
colorBuffer(type = colorType)
|
||||||
depthBuffer()
|
depthBuffer()
|
||||||
}
|
}
|
||||||
if (bufferMultisample != BufferMultisample.Disabled) {
|
if (bufferMultisample != BufferMultisample.Disabled) {
|
||||||
resolvedColorBuffer?.destroy()
|
accumulation?.destroy()
|
||||||
resolvedColorBuffer = colorBuffer(activeRenderTarget.width, activeRenderTarget.height,
|
accumulation = colorBuffer(
|
||||||
activeRenderTarget.contentScale, type = colorType)
|
activeRenderTarget.width, activeRenderTarget.height,
|
||||||
|
activeRenderTarget.contentScale, type = colorType
|
||||||
|
)
|
||||||
}
|
}
|
||||||
activeRenderTargetColorBuffer?.destroy()
|
unresolvedAccumulation?.destroy()
|
||||||
activeRenderTargetColorBuffer = colorBuffer(activeRenderTarget.width, activeRenderTarget.height,
|
unresolvedAccumulation = colorBuffer(
|
||||||
activeRenderTarget.contentScale, type = colorType)
|
activeRenderTarget.width, activeRenderTarget.height,
|
||||||
|
activeRenderTarget.contentScale, type = colorType
|
||||||
|
)
|
||||||
layerTarget?.let {
|
layerTarget?.let {
|
||||||
drawer.withTarget(it) {
|
drawer.withTarget(it) {
|
||||||
drawer.clear(ColorRGBa.TRANSPARENT)
|
drawer.clear(ColorRGBa.TRANSPARENT)
|
||||||
|
|||||||
Reference in New Issue
Block a user