[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.math.Vector2
import org.openrndr.shape.Rectangle
/**
* Approximate separated Gaussian blur
@@ -50,7 +51,7 @@ class ApproximateGaussianBlur : Filter1to1(mppFilterShader(fx_approximate_gaussi
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 intermediate = intermediateCache.getOrPut(intermediateDescription) {
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 {
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)
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("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()
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 dest = target[0]
@@ -81,7 +82,7 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShad
blur.apply(bufferCurrA, bufferNextB)
blendAdd.apply(arrayOf(bufferNextA, bufferNextB), bufferNextA)
} 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.math.Vector2
import org.openrndr.shape.Rectangle
/**
* BoxBlur implemented as a separable filter
@@ -45,7 +46,7 @@ class BoxBlur : Filter1to1(mppFilterShader(fx_box_blur,"box-blur")) {
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 intermediate = intermediateCache.getOrPut(intermediateDescription) {
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
intermediate.let {
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)
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
/**
* Directional blur filter. Takes source image and direction buffer inputs
@@ -56,9 +57,9 @@ class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directi
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["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.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Frame blur")
class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
@@ -22,7 +23,8 @@ class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
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()) {
intermediate?.let {
if (it.isEquivalentTo(target[0], ignoreFormat = true, ignoreLevels = true)) {
@@ -36,7 +38,7 @@ class FrameBlur(val colorType: ColorType = ColorType.FLOAT16) :
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])
}
}

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.fx.fx_laser_blur
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.*
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
import kotlin.math.pow
private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur")) {
@@ -76,8 +77,7 @@ class LaserBlur : Filter1to1() {
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.radius = radius
pass.amp0 = amp0
@@ -101,18 +101,18 @@ class LaserBlur : Filter1to1() {
pass.linearInput = linearInput
pass.linearOutput = true
pass.apply(source[0], intermediates[0])
pass.apply(source[0], intermediates[0], clip)
for (i in 0 until passes - 1) {
pass.linearInput = true
pass.linearOutput = true
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.linearInput = true
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.asRadians
import org.openrndr.shape.Rectangle
import kotlin.math.cos
import kotlin.math.sin
@@ -60,8 +61,8 @@ class LineBlur : Filter1to1(mppFilterShader(fx_box_blur, "line-blur")) {
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))
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.filter.color.delinearize
import org.openrndr.filter.color.linearize
import org.openrndr.shape.Rectangle
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 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 {
if (!it.isEquivalentTo(source[0], ignoreType = true)) {
it.destroy()
@@ -106,26 +108,26 @@ open class MipBloom<T : Filter>(val blur: T) : Filter1to1(mppFilterShader(fx_blo
if (sRGB) {
linearize.apply(sourceCopy!!, sourceCopy!!)
linearize.apply(sourceCopy!!, sourceCopy!!, clip)
}
upscale.noiseGain = noiseGain
upscale.noiseSeed = noiseSeed
downScale.apply(sourceCopy!!, intermediates[0])
blur.apply(intermediates[0], intermediates[0])
downScale.apply(sourceCopy!!, intermediates[0], clip)
blur.apply(intermediates[0], intermediates[0], clip)
for (pass in 1 until passes) {
downScale.apply(intermediates[pass - 1], intermediates[pass])
blur.apply(intermediates[pass], intermediates[pass])
downScale.apply(intermediates[pass - 1], intermediates[pass], clip)
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.pregain = pregain
combine.apply(arrayOf(sourceCopy!!, target[0]), target)
combine.apply(arrayOf(sourceCopy!!, target[0]), target, clip)
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)
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.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)
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.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.DoubleParameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("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
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 {
if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null
@@ -37,9 +39,7 @@ class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) {
intermediate?.let {
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
super.apply(source, arrayOf(it))
super.apply(source, arrayOf(it), clip)
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.DoubleParameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("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
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 {
if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null
@@ -36,9 +39,7 @@ class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration,
intermediate?.let {
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
super.apply(source, arrayOf(it))
super.apply(source, arrayOf(it), clip)
it.copyTo(target[0])
}
}

View File

@@ -3,6 +3,7 @@ package org.openrndr.extra.fx.color
import org.openrndr.draw.*
import org.openrndr.extra.fx.fx_color_lookup
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.shape.Rectangle
class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_lookup, "color-lookup")) {
/** a color look-up texture */
@@ -24,8 +25,8 @@ class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_loo
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)
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.createEquivalent
import org.openrndr.draw.isEquivalentTo
import org.openrndr.shape.Rectangle
/**
* @param first the filter that is applied first
@@ -26,15 +27,15 @@ class CompositeFilter<F0 : Filter, F1 : Filter>(
) : Filter() {
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()
if (!useIntermediateBuffer) {
first.firstParameters()
first.apply(firstSource, target)
first.apply(firstSource, target, clip)
second.secondParameters()
val secondSource = secondSource(source.toList(), target.first()).toTypedArray()
second.apply(secondSource, target)
second.apply(secondSource, target, clip)
} else {
val li = intermediate
if (li != null && !li.isEquivalentTo(target.first())) {
@@ -45,10 +46,10 @@ class CompositeFilter<F0 : Filter, F1 : Filter>(
intermediate = target.first().createEquivalent()
}
first.firstParameters()
first.apply(firstSource, arrayOf(intermediate!!))
first.apply(firstSource, arrayOf(intermediate!!), clip)
val secondSource = secondSource(source.toList(), intermediate!!).toTypedArray()
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.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("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")
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()) {
source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
}
super.apply(source, target)
super.apply(source, target, clip)
}
init {

View File

@@ -8,6 +8,7 @@ import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector3
import org.openrndr.shape.Rectangle
@Description("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
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 (target[0] === source[0] || target[0] === source[1]) {
if (intermediate == null) {
@@ -53,7 +55,7 @@ class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-bl
source[0].generateMipmaps()
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])
}
}

View File

@@ -7,6 +7,7 @@ import org.openrndr.extra.fx.fx_fisheye
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("Fisheye")
class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) {
@@ -30,11 +31,11 @@ class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) {
}
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()) {
source[0].generateMipmaps()
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_uvmap
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.shape.Rectangle
import kotlin.math.cos
private class UVMap: Filter( mppFilterShader(fx_uvmap, "uvmap"))
@@ -28,8 +29,8 @@ class FluidDistort : Filter1to1() {
private var buffer0: ColorBuffer? = null
private var buffer1: ColorBuffer? = null
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.random = cos(index*0.5)*0.5+0.5
@@ -51,12 +52,12 @@ class FluidDistort : Filter1to1() {
buffer1 = target[0].createEquivalent()
}
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) {
uvmap.apply(arrayOf(buffers[(index + 1) % 2], source[0]), target[0])
uvmap.apply(arrayOf(buffers[(index + 1) % 2], source[0]), target[0], clip)
} else {
buffers[(index+1)%2].copyTo(target[0])
buffers[(index+1)%2]. copyTo(target[0])
}
index++
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Lenses")
class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) {
@@ -30,12 +31,12 @@ class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) {
@BooleanParameter("bicubic filtering")
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()) {
source[0].generateMipmaps()
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
}
super.apply(source, target)
super.apply(source, target, clip)
}
init {

View File

@@ -10,6 +10,7 @@ import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector3
import org.openrndr.math.transforms.transform
import org.openrndr.shape.Rectangle
@Description("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
}
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].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
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_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.math.Vector2
import org.openrndr.math.Vector3
import org.openrndr.shape.Rectangle
@Description("Perturb")
class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) {
@@ -71,11 +72,11 @@ class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) {
}
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()) {
source[0].generateMipmaps()
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.Vector2Parameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
@Description("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
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps()
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.Vector2Parameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
import kotlin.math.log
@Description("Rectangular to polar")
@@ -23,11 +24,11 @@ class RectangularToPolar : Filter1to1(mppFilterShader(fx_rectangular_to_polar, "
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()) {
source[0].generateMipmaps()
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("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
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps()
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.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.shape.Rectangle
@Description("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
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps()
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("Tiles")
class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) {
@@ -27,11 +28,11 @@ class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) {
}
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()) {
source[0].generateMipmaps()
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.DoubleParameter
import org.openrndr.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
@Description("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
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps()
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
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
if (bicubicFiltering && source.isNotEmpty()) {
source[0].generateMipmaps()
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.IntParameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work-1")) {
var delta: Vector2 by parameters
@@ -38,7 +39,7 @@ open class EdgesWork : Filter1to1(mppFilterShader(fx_edges_work_2, "edges-work-2
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(
target[0].width,
target[0].height,
@@ -52,10 +53,10 @@ open class EdgesWork : Filter1to1(mppFilterShader(fx_edges_work_2, "edges-work-2
intermediate.let {
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())
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.IntParameter
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle
private class Blend : Filter(mppFilterShader(fx_dropshadow_blend, "dropshadow-blend")) {
var shift: Vector2 by parameters
@@ -45,7 +46,7 @@ class DropShadow : Filter1to1(mppFilterShader(fx_dropshadow_blur, "dropshadow-bl
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 {
if (it.width != target[0].width || it.height != target[0].height) {
intermediate = null
@@ -65,13 +66,13 @@ class DropShadow : Filter1to1(mppFilterShader(fx_dropshadow_blur, "dropshadow-bl
intermediate?.let {
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)
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.apply(arrayOf(intermediate2!!, source[0]), target)
b.apply(arrayOf(intermediate2!!, source[0]), target, clip)
}
}
}