[orx-fx] Directional blur tweaks (#357)

This commit is contained in:
Abe Pazos
2025-07-07 16:25:31 +02:00
committed by GitHub
parent 8323054519
commit f77c338608
7 changed files with 227 additions and 25 deletions

View File

@@ -2,14 +2,14 @@
package org.openrndr.extra.fx.blur
import org.openrndr.draw.*
import org.openrndr.draw.Filter2to1
import org.openrndr.extra.fx.fx_directional_blur
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.extra.parameters.IntParameter
import org.openrndr.shape.Rectangle
/**
* Directional blur filter. Takes source image and direction buffer inputs
@@ -24,13 +24,13 @@ class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directi
var centerWindow: Boolean by parameters
/**
* The sample window, default is 5
* The sample window: how many samples to mix. The default is 5
*/
@IntParameter("window size", 1, 25)
var window: Int by parameters
/**
* Spread multiplier, default is 1.0
* Spread multiplier: the distance in pixels between sampled pixels. The default is 1.0
*/
@DoubleParameter("kernel spread", 1.0, 4.0)
var spread: Double by parameters
@@ -42,12 +42,22 @@ class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directi
var gain: Double by parameters
/**
* Should filter use directions perpendicular to those in the direction buffer?
* Should filter use directions perpendicular to those in the direction buffer? default is false
*/
@BooleanParameter("perpendicular")
var perpendicular: Boolean by parameters
/**
* Wrap around left and right edges
*/
@BooleanParameter("wrapX")
var wrapX: Boolean by parameters
/**
* Wrap around top and bottom edges
*/
@BooleanParameter("wrapY")
var wrapY: Boolean by parameters
init {
window = 5
@@ -55,11 +65,7 @@ class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directi
gain = 1.0
perpendicular = false
centerWindow = false
}
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
parameters["wrapX"] = false
parameters["wrapY"] = false
super.apply(source, target, clip)
wrapX = false
wrapY = false
}
}

View File

@@ -0,0 +1,55 @@
@file:Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED")
package org.openrndr.extra.fx.distort
import org.openrndr.draw.Filter2to1
import org.openrndr.extra.fx.fx_directional_displace
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
/**
* Directional displace filter. Takes source image and direction buffer inputs
*/
@Description("Directional displace")
class DirectionalDisplace : Filter2to1(mppFilterShader(fx_directional_displace, "directional-displace")) {
/**
* The distance of the sampled pixel. The default is 1.0
*/
@DoubleParameter("distance", 1.0, 1000.0)
var distance: Double by parameters
/**
* Post-displace gain, default is 1.0
*/
@DoubleParameter("gain", 0.0, 4.0)
var gain: Double by parameters
/**
* Should filter use directions perpendicular to those in the direction buffer? default is false
*/
@BooleanParameter("perpendicular")
var perpendicular: Boolean by parameters
/**
* Wrap around left and right edges
*/
@BooleanParameter("wrapX")
var wrapX: Boolean by parameters
/**
* Wrap around top and bottom edges
*/
@BooleanParameter("wrapY")
var wrapY: Boolean by parameters
init {
distance = 1.0
gain = 1.0
perpendicular = false
wrapX = false
wrapY = false
}
}