[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

@@ -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)
}
}