[orx-fx, orx-jumpflood] Match changes to Filter

This commit is contained in:
Edwin Jakobs
2023-12-14 17:52:09 +01:00
parent ad9177e085
commit 3ec3f0bafb
39 changed files with 162 additions and 118 deletions

View File

@@ -11,6 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
/** /**
* Approximate separated Gaussian blur * Approximate separated Gaussian blur
@@ -50,7 +51,7 @@ class ApproximateGaussianBlur : Filter1to1(mppFilterShader(fx_approximate_gaussi
sigma = 1.0 sigma = 1.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type) val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
val intermediate = intermediateCache.getOrPut(intermediateDescription) { val intermediate = intermediateCache.getOrPut(intermediateDescription) {
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type) colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
@@ -58,10 +59,10 @@ class ApproximateGaussianBlur : Filter1to1(mppFilterShader(fx_approximate_gaussi
intermediate.let { intermediate.let {
parameters["blurDirection"] = Vector2(1.0, 0.0) parameters["blurDirection"] = Vector2(1.0, 0.0)
super.apply(source, arrayOf(it)) super.apply(source, arrayOf(it), clip)
parameters["blurDirection"] = Vector2(0.0, 1.0) parameters["blurDirection"] = Vector2(0.0, 1.0)
super.apply(arrayOf(it), target) super.apply(arrayOf(it), target, clip)
} }
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Bloom") @Description("Bloom")
class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShader(fx_bloom, "bloom")) { class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShader(fx_bloom, "bloom")) {
@@ -51,7 +52,7 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShad
private val blendAdd = Add() private val blendAdd = Add()
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
val src = source[0] val src = source[0]
val dest = target[0] val dest = target[0]
@@ -81,7 +82,7 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShad
blur.apply(bufferCurrA, bufferNextB) blur.apply(bufferCurrA, bufferNextB)
blendAdd.apply(arrayOf(bufferNextA, bufferNextB), bufferNextA) blendAdd.apply(arrayOf(bufferNextA, bufferNextB), bufferNextA)
} else { } else {
super.apply(arrayOf(src, bufferCurrA), target) super.apply(arrayOf(src, bufferCurrA), target, clip)
} }
} }
} }

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
/** /**
* BoxBlur implemented as a separable filter * BoxBlur implemented as a separable filter
@@ -45,7 +46,7 @@ class BoxBlur : Filter1to1(mppFilterShader(fx_box_blur,"box-blur")) {
gain = 1.0 gain = 1.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type) val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
val intermediate = intermediateCache.getOrPut(intermediateDescription) { val intermediate = intermediateCache.getOrPut(intermediateDescription) {
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type) colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
@@ -55,10 +56,10 @@ class BoxBlur : Filter1to1(mppFilterShader(fx_box_blur,"box-blur")) {
parameters["wrapY"] = false parameters["wrapY"] = false
intermediate.let { intermediate.let {
parameters["blurDirection"] = Vector2(1.0, 0.0) parameters["blurDirection"] = Vector2(1.0, 0.0)
super.apply(source, arrayOf(it)) super.apply(source, arrayOf(it), clip)
parameters["blurDirection"] = Vector2(0.0, 1.0) parameters["blurDirection"] = Vector2(0.0, 1.0)
super.apply(arrayOf(it), target) super.apply(arrayOf(it), target, clip)
} }
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
/** /**
* Directional blur filter. Takes source image and direction buffer inputs * Directional blur filter. Takes source image and direction buffer inputs
@@ -56,9 +57,9 @@ class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directi
centerWindow = false centerWindow = false
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
parameters["wrapX"] = false parameters["wrapX"] = false
parameters["wrapY"] = false parameters["wrapY"] = false
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.fx_frame_blur
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Frame blur") @Description("Frame blur")
class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) : class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
@@ -22,7 +23,8 @@ class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
blend = 0.5 blend = 0.5
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
if (source.isNotEmpty() && target.isNotEmpty()) { if (source.isNotEmpty() && target.isNotEmpty()) {
intermediate?.let { intermediate?.let {
if (it.isEquivalentTo(target[0], ignoreFormat = true, ignoreLevels = true)) { if (it.isEquivalentTo(target[0], ignoreFormat = true, ignoreLevels = true)) {
@@ -36,7 +38,7 @@ class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
intermediate?.fill(ColorRGBa.TRANSPARENT) intermediate?.fill(ColorRGBa.TRANSPARENT)
} }
super.apply(arrayOf(source[0], intermediate!!), arrayOf(intermediate!!)) super.apply(arrayOf(source[0], intermediate!!), arrayOf(intermediate!!), clip)
intermediate!!.copyTo(target[0]) intermediate!!.copyTo(target[0])
} }
} }

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.fx.fx_laser_blur
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.* import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
import kotlin.math.pow import kotlin.math.pow
private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur")) { private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur")) {
@@ -76,8 +77,7 @@ class LaserBlur : Filter1to1() {
val intermediates = mutableListOf<ColorBuffer>() val intermediates = mutableListOf<ColorBuffer>()
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip:Rectangle?) {
pass.center = center pass.center = center
pass.radius = radius pass.radius = radius
pass.amp0 = amp0 pass.amp0 = amp0
@@ -101,18 +101,18 @@ class LaserBlur : Filter1to1() {
pass.linearInput = linearInput pass.linearInput = linearInput
pass.linearOutput = true pass.linearOutput = true
pass.apply(source[0], intermediates[0]) pass.apply(source[0], intermediates[0], clip)
for (i in 0 until passes - 1) { for (i in 0 until passes - 1) {
pass.linearInput = true pass.linearInput = true
pass.linearOutput = true pass.linearOutput = true
pass.radius = 1.0 + pow(exp, i + 1.0) * radius //(1.0 + simplex(0, phase + i)) / 2.0 pass.radius = 1.0 + pow(exp, i + 1.0) * radius //(1.0 + simplex(0, phase + i)) / 2.0
pass.apply(intermediates[i % 2], intermediates[(i + 1) % 2]) pass.apply(intermediates[i % 2], intermediates[(i + 1) % 2], clip)
} }
pass.radius = 1.0 + pow(exp, (passes) * 1.0) * radius pass.radius = 1.0 + pow(exp, (passes) * 1.0) * radius
pass.linearInput = true pass.linearInput = true
pass.linearOutput = linearOutput pass.linearOutput = linearOutput
pass.apply(intermediates[(passes + 1) % 2], target[0]) pass.apply(intermediates[(passes + 1) % 2], target[0], clip)
} }
} }

View File

@@ -12,6 +12,7 @@ import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.math.asRadians import org.openrndr.math.asRadians
import org.openrndr.shape.Rectangle
import kotlin.math.cos import kotlin.math.cos
import kotlin.math.sin import kotlin.math.sin
@@ -60,8 +61,8 @@ class LineBlur : Filter1to1(mppFilterShader(fx_box_blur, "line-blur")) {
wrapY = false wrapY = false
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
parameters["blurDirection"] = Vector2(cos(blurAngle.asRadians), sin(blurAngle.asRadians)) parameters["blurDirection"] = Vector2(cos(blurAngle.asRadians), sin(blurAngle.asRadians))
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -14,6 +14,7 @@ import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.filter.color.delinearize import org.openrndr.filter.color.delinearize
import org.openrndr.filter.color.linearize import org.openrndr.filter.color.linearize
import org.openrndr.shape.Rectangle
class BloomDownscale : Filter(mppFilterShader(fx_bloom_downscale,"bloom-downscale")) class BloomDownscale : Filter(mppFilterShader(fx_bloom_downscale,"bloom-downscale"))
@@ -76,7 +77,8 @@ open class MipBloom<T : Filter>(val blur: T) : Filter1to1(mppFilterShader(fx_blo
val downScale = BloomDownscale() val downScale = BloomDownscale()
val combine = BloomCombine() val combine = BloomCombine()
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
sourceCopy?.let { sourceCopy?.let {
if (!it.isEquivalentTo(source[0], ignoreType = true)) { if (!it.isEquivalentTo(source[0], ignoreType = true)) {
it.destroy() it.destroy()
@@ -106,26 +108,26 @@ open class MipBloom<T : Filter>(val blur: T) : Filter1to1(mppFilterShader(fx_blo
if (sRGB) { if (sRGB) {
linearize.apply(sourceCopy!!, sourceCopy!!) linearize.apply(sourceCopy!!, sourceCopy!!, clip)
} }
upscale.noiseGain = noiseGain upscale.noiseGain = noiseGain
upscale.noiseSeed = noiseSeed upscale.noiseSeed = noiseSeed
downScale.apply(sourceCopy!!, intermediates[0]) downScale.apply(sourceCopy!!, intermediates[0], clip)
blur.apply(intermediates[0], intermediates[0]) blur.apply(intermediates[0], intermediates[0], clip)
for (pass in 1 until passes) { for (pass in 1 until passes) {
downScale.apply(intermediates[pass - 1], intermediates[pass]) downScale.apply(intermediates[pass - 1], intermediates[pass], clip)
blur.apply(intermediates[pass], intermediates[pass]) blur.apply(intermediates[pass], intermediates[pass], clip)
} }
upscale.apply(intermediates.toTypedArray(), arrayOf(target[0])) upscale.apply(intermediates.toTypedArray(), arrayOf(target[0]), clip)
combine.gain = gain combine.gain = gain
combine.pregain = pregain combine.pregain = pregain
combine.apply(arrayOf(sourceCopy!!, target[0]), target) combine.apply(arrayOf(sourceCopy!!, target[0]), target, clip)
if (sRGB) { if (sRGB) {
delinearize.apply(target[0], target[0]) delinearize.apply(target[0], target[0], clip)
} }
} }
} }
@@ -145,10 +147,10 @@ class HashBloom : MipBloom<HashBlur>(blur = HashBlur()) {
@IntParameter("number of samples", 1, 100) @IntParameter("number of samples", 1, 100)
var samples: Int = 30 var samples: Int = 30
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
blur.radius = radius blur.radius = radius
blur.samples = samples blur.samples = samples
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -166,9 +168,9 @@ class GaussianBloom : MipBloom<GaussianBlur>(blur = GaussianBlur()) {
@DoubleParameter("kernel sigma", 0.0, 25.0) @DoubleParameter("kernel sigma", 0.0, 25.0)
var sigma: Double = 1.0 var sigma: Double = 1.0
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
blur.window = window blur.window = window
blur.sigma = sigma blur.sigma = sigma
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("Zoom Blur") @Description("Zoom Blur")
class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) { class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) {
@@ -23,7 +24,8 @@ class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) {
private var intermediate: ColorBuffer? = null private var intermediate: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
intermediate?.let { intermediate?.let {
if (it.width != target[0].width || it.height != target[0].height) { if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null intermediate = null
@@ -37,9 +39,7 @@ class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) {
intermediate?.let { intermediate?.let {
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble()) parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
super.apply(source, arrayOf(it), clip)
super.apply(source, arrayOf(it))
it.copyTo(target[0]) it.copyTo(target[0])
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("Chromatic Aberration") @Description("Chromatic Aberration")
class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration, "chromatic-aberration")) { class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration, "chromatic-aberration")) {
@@ -23,7 +24,9 @@ class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration,
private var intermediate: ColorBuffer? = null private var intermediate: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
intermediate?.let { intermediate?.let {
if (it.width != target[0].width || it.height != target[0].height) { if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null intermediate = null
@@ -36,9 +39,7 @@ class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration,
intermediate?.let { intermediate?.let {
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble()) parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
super.apply(source, arrayOf(it), clip)
super.apply(source, arrayOf(it))
it.copyTo(target[0]) it.copyTo(target[0])
} }
} }

View File

@@ -3,6 +3,7 @@ package org.openrndr.extra.fx.color
import org.openrndr.draw.* import org.openrndr.draw.*
import org.openrndr.extra.fx.fx_color_lookup import org.openrndr.extra.fx.fx_color_lookup
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.shape.Rectangle
class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_lookup, "color-lookup")) { class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_lookup, "color-lookup")) {
/** a color look-up texture */ /** a color look-up texture */
@@ -24,8 +25,8 @@ class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_loo
this.seed = 0.0 this.seed = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
lookup.filter(MinifyingFilter.LINEAR, MagnifyingFilter.LINEAR) lookup.filter(MinifyingFilter.LINEAR, MagnifyingFilter.LINEAR)
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -4,6 +4,7 @@ import org.openrndr.draw.ColorBuffer
import org.openrndr.draw.Filter import org.openrndr.draw.Filter
import org.openrndr.draw.createEquivalent import org.openrndr.draw.createEquivalent
import org.openrndr.draw.isEquivalentTo import org.openrndr.draw.isEquivalentTo
import org.openrndr.shape.Rectangle
/** /**
* @param first the filter that is applied first * @param first the filter that is applied first
@@ -26,15 +27,15 @@ class CompositeFilter<F0 : Filter, F1 : Filter>(
) : Filter() { ) : Filter() {
private var intermediate: ColorBuffer? = null private var intermediate: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
val firstSource = firstSource(source.toList()).toTypedArray() val firstSource = firstSource(source.toList()).toTypedArray()
if (!useIntermediateBuffer) { if (!useIntermediateBuffer) {
first.firstParameters() first.firstParameters()
first.apply(firstSource, target) first.apply(firstSource, target, clip)
second.secondParameters() second.secondParameters()
val secondSource = secondSource(source.toList(), target.first()).toTypedArray() val secondSource = secondSource(source.toList(), target.first()).toTypedArray()
second.apply(secondSource, target) second.apply(secondSource, target, clip)
} else { } else {
val li = intermediate val li = intermediate
if (li != null && !li.isEquivalentTo(target.first())) { if (li != null && !li.isEquivalentTo(target.first())) {
@@ -45,10 +46,10 @@ class CompositeFilter<F0 : Filter, F1 : Filter>(
intermediate = target.first().createEquivalent() intermediate = target.first().createEquivalent()
} }
first.firstParameters() first.firstParameters()
first.apply(firstSource, arrayOf(intermediate!!)) first.apply(firstSource, arrayOf(intermediate!!), clip)
val secondSource = secondSource(source.toList(), intermediate!!).toTypedArray() val secondSource = secondSource(source.toList(), intermediate!!).toTypedArray()
second.secondParameters() second.secondParameters()
second.apply(secondSource, target) second.apply(secondSource, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.BooleanParameter import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Block repeat") @Description("Block repeat")
class BlockRepeat : Filter1to1(mppFilterShader(fx_block_repeat, "block-repeat")) { class BlockRepeat : Filter1to1(mppFilterShader(fx_block_repeat, "block-repeat")) {
@@ -38,12 +39,12 @@ class BlockRepeat : Filter1to1(mppFilterShader(fx_block_repeat, "block-repeat"))
@BooleanParameter("bicubic filtering") @BooleanParameter("bicubic filtering")
var bicubicFiltering: Boolean by parameters var bicubicFiltering: Boolean by parameters
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
init { init {

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
import org.openrndr.shape.Rectangle
@Description("Displace blend") @Description("Displace blend")
class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-blend")) { class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-blend")) {
@@ -42,7 +43,8 @@ class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-bl
var bicubicFiltering = true var bicubicFiltering = true
private var intermediate: ColorBuffer? = null private var intermediate: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
if (source.size >= 2) { if (source.size >= 2) {
if (target[0] === source[0] || target[0] === source[1]) { if (target[0] === source[0] || target[0] === source[1]) {
if (intermediate == null) { if (intermediate == null) {
@@ -53,7 +55,7 @@ class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-bl
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, arrayOf(intermediate ?: target[0])) super.apply(source, arrayOf(intermediate ?: target[0]), clip)
intermediate?.copyTo(target[0]) intermediate?.copyTo(target[0])
} }
} }

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.fx.fx_fisheye
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Fisheye") @Description("Fisheye")
class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) { class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) {
@@ -30,11 +31,11 @@ class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) {
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -4,6 +4,7 @@ import org.openrndr.draw.*
import org.openrndr.extra.fx.fx_fluid_distort import org.openrndr.extra.fx.fx_fluid_distort
import org.openrndr.extra.fx.fx_uvmap import org.openrndr.extra.fx.fx_uvmap
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.shape.Rectangle
import kotlin.math.cos import kotlin.math.cos
private class UVMap: Filter( mppFilterShader(fx_uvmap, "uvmap")) private class UVMap: Filter( mppFilterShader(fx_uvmap, "uvmap"))
@@ -28,8 +29,8 @@ class FluidDistort : Filter1to1() {
private var buffer0: ColorBuffer? = null private var buffer0: ColorBuffer? = null
private var buffer1: ColorBuffer? = null private var buffer1: ColorBuffer? = null
private var index = 0 private var index = 0
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
distort.blend = blend distort.blend = blend
distort.random = cos(index*0.5)*0.5+0.5 distort.random = cos(index*0.5)*0.5+0.5
@@ -51,12 +52,12 @@ class FluidDistort : Filter1to1() {
buffer1 = target[0].createEquivalent() buffer1 = target[0].createEquivalent()
} }
val buffers = arrayOf(buffer0!!, buffer1!!) val buffers = arrayOf(buffer0!!, buffer1!!)
distort.apply(buffers[index%2], buffers[(index+1)%2]) distort.apply(buffers[index%2], buffers[(index+1)%2], clip)
if (!outputUV) { if (!outputUV) {
uvmap.apply(arrayOf(buffers[(index + 1) % 2], source[0]), target[0]) uvmap.apply(arrayOf(buffers[(index + 1) % 2], source[0]), target[0], clip)
} else { } else {
buffers[(index+1)%2].copyTo(target[0]) buffers[(index+1)%2]. copyTo(target[0])
} }
index++ index++
blend = 0.0 blend = 0.0

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Lenses") @Description("Lenses")
class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) { class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) {
@@ -30,12 +31,12 @@ class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) {
@BooleanParameter("bicubic filtering") @BooleanParameter("bicubic filtering")
var bicubicFiltering: Boolean by parameters var bicubicFiltering: Boolean by parameters
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
init { init {

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
import org.openrndr.math.transforms.transform import org.openrndr.math.transforms.transform
import org.openrndr.shape.Rectangle
@Description("Perspective plane") @Description("Perspective plane")
class PerspectivePlane : Filter1to1(mppFilterShader(fx_perspective_plane, "perspective-plane")) { class PerspectivePlane : Filter1to1(mppFilterShader(fx_perspective_plane, "perspective-plane")) {
@@ -43,7 +44,7 @@ class PerspectivePlane : Filter1to1(mppFilterShader(fx_perspective_plane, "persp
tile = false tile = false
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
source[0].wrapU = WrapMode.REPEAT source[0].wrapU = WrapMode.REPEAT
@@ -55,6 +56,6 @@ class PerspectivePlane : Filter1to1(mppFilterShader(fx_perspective_plane, "persp
rotate(Vector3.UNIT_Y, planeYaw) rotate(Vector3.UNIT_Y, planeYaw)
rotate(Vector3.UNIT_Z, planeRoll) rotate(Vector3.UNIT_Z, planeRoll)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.* import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.math.Vector3 import org.openrndr.math.Vector3
import org.openrndr.shape.Rectangle
@Description("Perturb") @Description("Perturb")
class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) { class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) {
@@ -71,11 +72,11 @@ class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) {
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.Vector2Parameter import org.openrndr.extra.parameters.Vector2Parameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("Polar to rectangular") @Description("Polar to rectangular")
class PolarToRectangular : Filter1to1(mppFilterShader(fx_polar_to_rectangular, "polar-to-rectangular")) { class PolarToRectangular : Filter1to1(mppFilterShader(fx_polar_to_rectangular, "polar-to-rectangular")) {
@@ -21,11 +22,11 @@ class PolarToRectangular : Filter1to1(mppFilterShader(fx_polar_to_rectangular, "
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.Vector2Parameter import org.openrndr.extra.parameters.Vector2Parameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
import kotlin.math.log import kotlin.math.log
@Description("Rectangular to polar") @Description("Rectangular to polar")
@@ -23,11 +24,11 @@ class RectangularToPolar : Filter1to1(mppFilterShader(fx_rectangular_to_polar, "
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Stack repeat") @Description("Stack repeat")
class StackRepeat : Filter1to1(mppFilterShader(fx_stack_repeat, "stack-repeat")) { class StackRepeat : Filter1to1(mppFilterShader(fx_stack_repeat, "stack-repeat")) {
@@ -43,11 +44,11 @@ class StackRepeat : Filter1to1(mppFilterShader(fx_stack_repeat, "stack-repeat"))
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.fx.fx_stretch_waves
import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Stretch waves") @Description("Stretch waves")
class StretchWaves : Filter1to1(mppFilterShader(fx_stretch_waves, "stretch-waves")) { class StretchWaves : Filter1to1(mppFilterShader(fx_stretch_waves, "stretch-waves")) {
@@ -34,11 +35,11 @@ class StretchWaves : Filter1to1(mppFilterShader(fx_stretch_waves, "stretch-waves
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Tiles") @Description("Tiles")
class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) { class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) {
@@ -27,11 +28,11 @@ class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) {
} }
var bicubicFiltering = false var bicubicFiltering = false
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Horizontal wave") @Description("Horizontal wave")
class HorizontalWave : Filter1to1(mppFilterShader(fx_horizontal_wave, "horizontal-wave")) { class HorizontalWave : Filter1to1(mppFilterShader(fx_horizontal_wave, "horizontal-wave")) {
@@ -32,12 +33,12 @@ class HorizontalWave : Filter1to1(mppFilterShader(fx_horizontal_wave, "horizonta
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -63,11 +64,11 @@ class VerticalWave : Filter1to1(mppFilterShader(fx_vertical_wave, "vertical-wave
} }
var bicubicFiltering = true var bicubicFiltering = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) { if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps() source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR) source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work-1")) { internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work-1")) {
var delta: Vector2 by parameters var delta: Vector2 by parameters
@@ -38,7 +39,7 @@ open class EdgesWork : Filter1to1(mppFilterShader(fx_edges_work_2, "edges-work-2
delta = Vector2.ZERO delta = Vector2.ZERO
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
val intermediateDescription = ColorBufferDescription( val intermediateDescription = ColorBufferDescription(
target[0].width, target[0].width,
target[0].height, target[0].height,
@@ -52,10 +53,10 @@ open class EdgesWork : Filter1to1(mppFilterShader(fx_edges_work_2, "edges-work-2
intermediate.let { intermediate.let {
work1.delta = Vector2(radius / it.effectiveWidth.toDouble(), 0.0) work1.delta = Vector2(radius / it.effectiveWidth.toDouble(), 0.0)
work1.apply(source, arrayOf(it)) work1.apply(source, arrayOf(it), clip)
parameters["delta"] = Vector2(0.0, radius / it.effectiveHeight.toDouble()) parameters["delta"] = Vector2(0.0, radius / it.effectiveHeight.toDouble())
super.apply(arrayOf(it), target) super.apply(arrayOf(it), target, clip)
} }
} }
} }

View File

@@ -12,6 +12,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.extra.parameters.IntParameter import org.openrndr.extra.parameters.IntParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
private class Blend : Filter(mppFilterShader(fx_dropshadow_blend, "dropshadow-blend")) { private class Blend : Filter(mppFilterShader(fx_dropshadow_blend, "dropshadow-blend")) {
var shift: Vector2 by parameters var shift: Vector2 by parameters
@@ -45,7 +46,7 @@ class DropShadow : Filter1to1(mppFilterShader(fx_dropshadow_blur, "dropshadow-bl
gain = 1.0 gain = 1.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
intermediate?.let { intermediate?.let {
if (it.width != target[0].width || it.height != target[0].height) { if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null intermediate = null
@@ -65,13 +66,13 @@ class DropShadow : Filter1to1(mppFilterShader(fx_dropshadow_blur, "dropshadow-bl
intermediate?.let { intermediate?.let {
parameters["blurDirection"] = Vector2(1.0, 0.0) parameters["blurDirection"] = Vector2(1.0, 0.0)
super.apply(source, arrayOf(it)) super.apply(source, arrayOf(it), clip)
parameters["blurDirection"] = Vector2(0.0, 1.0) parameters["blurDirection"] = Vector2(0.0, 1.0)
super.apply(arrayOf(it), arrayOf(intermediate2!!)) super.apply(arrayOf(it), arrayOf(intermediate2!!), clip)
b.shift = (Vector2(xShift,yShift)) / Vector2(target[0].width * 1.0, target[0].height * 1.0) b.shift = (Vector2(xShift,yShift)) / Vector2(target[0].width * 1.0, target[0].height * 1.0)
b.apply(arrayOf(intermediate2!!, source[0]), target) b.apply(arrayOf(intermediate2!!, source[0]), target, clip)
} }
} }
} }

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.IntRectangle import org.openrndr.shape.IntRectangle
import org.openrndr.shape.Rectangle
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.log2 import kotlin.math.log2
import kotlin.math.max import kotlin.math.max
@@ -40,7 +41,8 @@ class ClusteredField(decodeMode: DecodeMode = DecodeMode.DIRECTION,
private var fit: ColorBuffer? = null private var fit: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt() val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt()
val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt() val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt()
val advisedSize = max(advisedWidth, advisedHeight) val advisedSize = max(advisedWidth, advisedHeight)
@@ -98,7 +100,7 @@ class ClusteredField(decodeMode: DecodeMode = DecodeMode.DIRECTION,
decodeFilter.normalizedDistance = normalizedDistance decodeFilter.normalizedDistance = normalizedDistance
decodeFilter.unitDirection = unitDirection decodeFilter.unitDirection = unitDirection
decodeFilter.flipV = flipV decodeFilter.flipV = flipV
decodeFilter.apply(arrayOf(result, encoded!!), arrayOf(result)) decodeFilter.apply(arrayOf(result, encoded!!), arrayOf(result), clip)
result.copyTo( result.copyTo(
target[0], target[0],

View File

@@ -6,6 +6,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.IntRectangle import org.openrndr.shape.IntRectangle
import org.openrndr.shape.Rectangle
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.log2 import kotlin.math.log2
import kotlin.math.max import kotlin.math.max
@@ -38,7 +39,9 @@ class DirectionalField : Filter1to1() {
private var fit: ColorBuffer? = null private var fit: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt() val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt()
val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt() val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt()
val advisedSize = max(advisedWidth, advisedHeight) val advisedSize = max(advisedWidth, advisedHeight)

View File

@@ -6,6 +6,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.shape.IntRectangle import org.openrndr.shape.IntRectangle
import org.openrndr.shape.Rectangle
import kotlin.math.ceil import kotlin.math.ceil
import kotlin.math.log2 import kotlin.math.log2
import kotlin.math.max import kotlin.math.max
@@ -32,7 +33,8 @@ class DistanceField : Filter1to1() {
@BooleanParameter("signed distance") @BooleanParameter("signed distance")
var signedDistance = true var signedDistance = true
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt() val advisedWidth = 2.0.pow(ceil(log2(source[0].effectiveWidth.toDouble()))).toInt()
val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt() val advisedHeight = 2.0.pow(ceil(log2(source[0].effectiveHeight.toDouble()))).toInt()
val advisedSize = max(advisedWidth, advisedHeight) val advisedSize = max(advisedWidth, advisedHeight)

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.jumpflood.jf_sdf_stroke_fill
import org.openrndr.extra.parameters.ColorParameter import org.openrndr.extra.parameters.ColorParameter
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("SDF stroke and fill") @Description("SDF stroke and fill")
class SDFStrokeFill : Filter(filterShaderFromCode(jf_sdf_stroke_fill, "sdf-stroke-fill")) { class SDFStrokeFill : Filter(filterShaderFromCode(jf_sdf_stroke_fill, "sdf-stroke-fill")) {
@@ -34,8 +35,4 @@ class SDFStrokeFill : Filter(filterShaderFromCode(jf_sdf_stroke_fill, "sdf-strok
fillColor = ColorRGBa.WHITE fillColor = ColorRGBa.WHITE
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
super.apply(source, target)
}
} }

View File

@@ -1,3 +1,5 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.jumpfill.fx package org.openrndr.extra.jumpfill.fx
import org.openrndr.draw.* import org.openrndr.draw.*
@@ -9,6 +11,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
private class InnerBevelFilter : Filter(filterShaderFromCode(jf_inner_bevel, "inner-bevel")) { private class InnerBevelFilter : Filter(filterShaderFromCode(jf_inner_bevel, "inner-bevel")) {
var angle: Double by parameters var angle: Double by parameters
@@ -45,7 +48,7 @@ class InnerBevel : Filter1to1() {
private var distance: ColorBuffer? = null private var distance: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (jumpFlooder == null) { if (jumpFlooder == null) {
jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel()) jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel())
} }
@@ -60,6 +63,6 @@ class InnerBevel : Filter1to1() {
bevelFilter.angle = angle bevelFilter.angle = angle
bevelFilter.width = width bevelFilter.width = width
bevelFilter.noise = noise bevelFilter.noise = noise
bevelFilter.apply(arrayOf(source[0], distance!!), target[0]) bevelFilter.apply(arrayOf(source[0], distance!!), target[0], clip)
} }
} }

View File

@@ -11,6 +11,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
private class InnerGlowFilter : Filter(filterShaderFromCode(jf_inner_glow, "inner-glow")) { private class InnerGlowFilter : Filter(filterShaderFromCode(jf_inner_glow, "inner-glow")) {
var angle: Double by parameters var angle: Double by parameters
@@ -56,7 +57,7 @@ class InnerGlow : Filter1to1() {
private val glowFilter = InnerGlowFilter() private val glowFilter = InnerGlowFilter()
private var distance: ColorBuffer? = null private var distance: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (jumpFlooder == null) { if (jumpFlooder == null) {
jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel()) jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel())
} }
@@ -73,6 +74,6 @@ class InnerGlow : Filter1to1() {
glowFilter.noise = noise glowFilter.noise = noise
glowFilter.shape = shape glowFilter.shape = shape
glowFilter.imageOpacity = imageOpacity glowFilter.imageOpacity = imageOpacity
glowFilter.apply(arrayOf(source[0], distance!!), target[0]) glowFilter.apply(arrayOf(source[0], distance!!), target[0], clip)
} }
} }

View File

@@ -9,6 +9,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
private class InpaintFilter : Filter(filterShaderFromCode(jf_inpaint, "inpaint")) { private class InpaintFilter : Filter(filterShaderFromCode(jf_inpaint, "inpaint")) {
@@ -50,7 +51,7 @@ class Inpaint : Filter1to1() {
private var distance: ColorBuffer? = null private var distance: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (jumpFlooder == null) { if (jumpFlooder == null) {
jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel()) jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel())
} }
@@ -67,6 +68,6 @@ class Inpaint : Filter1to1() {
inpaintFilter.opacity = opacity inpaintFilter.opacity = opacity
inpaintFilter.shape = shape inpaintFilter.shape = shape
inpaintFilter.width = width inpaintFilter.width = width
inpaintFilter.apply(arrayOf(source[0], distance!!), target[0]) inpaintFilter.apply(arrayOf(source[0], distance!!), target[0], clip)
} }
} }

View File

@@ -11,6 +11,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
private class OuterGlowFilter : Filter(filterShaderFromCode(jf_outer_glow, "outer-glow")) { private class OuterGlowFilter : Filter(filterShaderFromCode(jf_outer_glow, "outer-glow")) {
var angle: Double by parameters var angle: Double by parameters
@@ -57,7 +58,7 @@ class OuterGlow : Filter1to1() {
private var distance: ColorBuffer? = null private var distance: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (jumpFlooder == null) { if (jumpFlooder == null) {
jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel()) jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel())
} }
@@ -74,6 +75,6 @@ class OuterGlow : Filter1to1() {
glowFilter.noise = noise glowFilter.noise = noise
glowFilter.shape = shape glowFilter.shape = shape
glowFilter.imageOpacity = imageOpacity glowFilter.imageOpacity = imageOpacity
glowFilter.apply(arrayOf(source[0], distance!!), target[0]) glowFilter.apply(arrayOf(source[0], distance!!), target[0], clip)
} }
} }

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
private class SkeletonFilter : Filter(filterShaderFromCode(jf_skeleton, "skeleton")) { private class SkeletonFilter : Filter(filterShaderFromCode(jf_skeleton, "skeleton")) {
var skeletonColor: ColorRGBa by parameters var skeletonColor: ColorRGBa by parameters
@@ -50,7 +51,9 @@ class Skeleton : Filter() {
private val decodeFilter = PixelDistance() private val decodeFilter = PixelDistance()
private val skeletonFilter = SkeletonFilter() private val skeletonFilter = SkeletonFilter()
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null)
if (thresholded == null) { if (thresholded == null) {
thresholded = colorBuffer(target[0].width, target[0].height, format = ColorFormat.R) thresholded = colorBuffer(target[0].width, target[0].height, format = ColorFormat.R)
} }

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2 import org.openrndr.math.Vector2
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
import kotlin.math.sqrt import kotlin.math.sqrt
private class StraightSkeletonFilter : Filter(filterShaderFromCode(jf_straight_skeleton, "straight-skeleton")) { private class StraightSkeletonFilter : Filter(filterShaderFromCode(jf_straight_skeleton, "straight-skeleton")) {
@@ -56,7 +57,7 @@ class StraightSkeleton : Filter() {
private val decodeFilter = PixelDirection() private val decodeFilter = PixelDirection()
private val skeletonFilter = StraightSkeletonFilter() private val skeletonFilter = StraightSkeletonFilter()
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (thresholded == null) { if (thresholded == null) {
thresholded = colorBuffer(target[0].width, target[0].height, format = ColorFormat.R) thresholded = colorBuffer(target[0].width, target[0].height, format = ColorFormat.R)
} }
@@ -83,6 +84,6 @@ class StraightSkeleton : Filter() {
skeletonFilter.skeletonColor = skeletonColor skeletonFilter.skeletonColor = skeletonColor
skeletonFilter.backgroundColor = backgroundColor skeletonFilter.backgroundColor = backgroundColor
skeletonFilter.foregroundColor = foregroundColor skeletonFilter.foregroundColor = foregroundColor
skeletonFilter.apply(copied!!, target[0]) skeletonFilter.apply(copied!!, target[0], clip)
} }
} }

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.jumpflood.*
import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
class SDFSmoothUnion : Filter(filterShaderFromCode(jf_sdf_smooth_union, "sdf-smooth-union")) { class SDFSmoothUnion : Filter(filterShaderFromCode(jf_sdf_smooth_union, "sdf-smooth-union")) {
var radius: Double by parameters var radius: Double by parameters
@@ -16,11 +17,11 @@ class SDFSmoothUnion : Filter(filterShaderFromCode(jf_sdf_smooth_union, "sdf-smo
radius = 0.0 radius = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -31,11 +32,11 @@ class SDFSmoothIntersection : Filter(filterShaderFromCode(jf_sdf_smooth_intersec
radius = 0.0 radius = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@Description("SDF smooth difference") @Description("SDF smooth difference")
@@ -47,11 +48,11 @@ class SDFSmoothDifference : Filter(filterShaderFromCode(jf_sdf_smooth_difference
radius = 0.0 radius = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -63,11 +64,11 @@ class SDFRound : Filter(filterShaderFromCode(jf_sdf_round, "sdf-round")) {
radius = 0.0 radius = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -78,11 +79,11 @@ class SDFOnion : Filter(filterShaderFromCode(jf_sdf_onion, "sdf-onion")) {
radius = 0.0 radius = 0.0
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }
@@ -93,10 +94,10 @@ class SDFBlend : Filter(filterShaderFromCode(jf_sdf_blend, "sdf-blend")) {
factor = 0.5 factor = 0.5
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
super.apply(source, target) super.apply(source, target, clip)
} }
} }

View File

@@ -6,6 +6,7 @@ import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.math.Matrix44 import org.openrndr.math.Matrix44
import org.openrndr.math.Vector4 import org.openrndr.math.Vector4
import org.openrndr.resourceUrl import org.openrndr.resourceUrl
import org.openrndr.shape.Rectangle
import org.openrndr.shape.Shape import org.openrndr.shape.Shape
import org.openrndr.shape.ShapeContour import org.openrndr.shape.ShapeContour
@@ -76,7 +77,7 @@ class ShapeSDF : Filter(filterShaderFromCode(jf_shape_sdf, "shape-sdf")) {
segmentCount = from.size segmentCount = from.size
} }
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) { require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
"needs a floating point target" "needs a floating point target"
} }
@@ -85,6 +86,6 @@ class ShapeSDF : Filter(filterShaderFromCode(jf_shape_sdf, "shape-sdf")) {
parameters["segmentCount"] = segmentCount parameters["segmentCount"] = segmentCount
// -- bit of an hack // -- bit of an hack
val effectiveSource = if (source.isNotEmpty()) source else target val effectiveSource = if (source.isNotEmpty()) source else target
super.apply(effectiveSource, target) super.apply(effectiveSource, target, clip)
} }
} }