[orx-filters] Set shader parameter to null in Filter constructors

This commit is contained in:
Edwin Jakobs
2025-08-18 15:09:27 +02:00
parent 48b61c39e8
commit 8b4d31786c
15 changed files with 18 additions and 16 deletions

View File

@@ -31,7 +31,7 @@ private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur"
} }
@Description("Laser blur") @Description("Laser blur")
class LaserBlur : Filter1to1() { class LaserBlur : Filter1to1(null) {
@Vector2Parameter("center", order = 0) @Vector2Parameter("center", order = 0)
var center = Vector2.ZERO var center = Vector2.ZERO

View File

@@ -24,7 +24,7 @@ class CompositeFilter<F0 : Filter, F1 : Filter>(
private val firstParameters: F0.() -> Unit, private val firstParameters: F0.() -> Unit,
private val secondParameters: F1.() -> Unit, private val secondParameters: F1.() -> Unit,
private val useIntermediateBuffer: Boolean = false private val useIntermediateBuffer: Boolean = false
) : Filter() { ) : Filter(null) {
private var intermediate: ColorBuffer? = null private var intermediate: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {

View File

@@ -18,7 +18,7 @@ private class FluidDistortFilter : Filter(mppFilterShader(fx_fluid_distort, "flu
} }
} }
class FluidDistort : Filter1to1() { class FluidDistort : Filter1to1(null) {
var blend: Double = 1.0 var blend: Double = 1.0
var outputUV = false var outputUV = false

View File

@@ -17,7 +17,7 @@ import kotlin.math.pow
@Description("Clustered field") @Description("Clustered field")
class ClusteredField(decodeMode: DecodeMode = DecodeMode.DIRECTION, class ClusteredField(decodeMode: DecodeMode = DecodeMode.DIRECTION,
private val outputDistanceToContours: Boolean = true) : Filter1to1() { private val outputDistanceToContours: Boolean = true) : Filter1to1(null) {
@DoubleParameter("threshold", 0.0, 1.0) @DoubleParameter("threshold", 0.0, 1.0)
var threshold = 0.5 var threshold = 0.5

View File

@@ -48,7 +48,7 @@ import kotlin.math.pow
* *
*/ */
@Description("Directional field") @Description("Directional field")
class DirectionalField : Filter1to1() { class DirectionalField : Filter1to1(null) {
@DoubleParameter("threshold", 0.0, 1.0) @DoubleParameter("threshold", 0.0, 1.0)
var threshold = 0.5 var threshold = 0.5

View File

@@ -34,7 +34,7 @@ import kotlin.math.pow
* intermediate buffers to reduce memory allocation overhead. * intermediate buffers to reduce memory allocation overhead.
*/ */
@Description("Distance field") @Description("Distance field")
class DistanceField : Filter1to1() { class DistanceField : Filter1to1(null) {
@DoubleParameter("threshold", 0.0, 1.0) @DoubleParameter("threshold", 0.0, 1.0)
var threshold = 0.5 var threshold = 0.5

View File

@@ -25,7 +25,7 @@ private class InnerBevelFilter : Filter(filterShaderFromCode(jf_inner_bevel, "in
} }
@Description("Inner bevel") @Description("Inner bevel")
class InnerBevel : Filter1to1() { class InnerBevel : Filter1to1(null) {
@DoubleParameter("threshold", 0.0, 1.0) @DoubleParameter("threshold", 0.0, 1.0)
var threshold = 0.01 var threshold = 0.01

View File

@@ -34,7 +34,7 @@ private class InnerGlowFilter : Filter(filterShaderFromCode(jf_inner_glow, "inne
} }
@Description("Inner glow") @Description("Inner glow")
class InnerGlow : Filter1to1() { class InnerGlow : Filter1to1(null) {
@DoubleParameter("width", 0.0, 50.0) @DoubleParameter("width", 0.0, 50.0)
var width = 5.0 var width = 5.0

View File

@@ -30,7 +30,7 @@ private class InpaintFilter : Filter(filterShaderFromCode(jf_inpaint, "inpaint")
} }
@Description("Inpaint") @Description("Inpaint")
class Inpaint : Filter1to1() { class Inpaint : Filter1to1(null) {
@DoubleParameter("width", 0.0, 1.0) @DoubleParameter("width", 0.0, 1.0)
var width = 0.5 var width = 0.5

View File

@@ -34,7 +34,7 @@ private class OuterGlowFilter : Filter(filterShaderFromCode(jf_outer_glow, "oute
} }
@Description("Outer glow") @Description("Outer glow")
class OuterGlow : Filter1to1() { class OuterGlow : Filter1to1(null) {
@DoubleParameter("width", 0.0, 50.0) @DoubleParameter("width", 0.0, 50.0)
var width = 5.0 var width = 5.0

View File

@@ -28,7 +28,7 @@ private class SkeletonFilter : Filter(filterShaderFromCode(jf_skeleton, "skeleto
} }
@Description("Skeleton") @Description("Skeleton")
class Skeleton : Filter() { class Skeleton : Filter(null) {
@DoubleParameter("threshold", 0.0, 1.0, order = 0) @DoubleParameter("threshold", 0.0, 1.0, order = 0)
var threshold = 0.5 var threshold = 0.5

View File

@@ -31,7 +31,7 @@ private class StraightSkeletonFilter : Filter(filterShaderFromCode(jf_straight_s
} }
@Description("Skeleton") @Description("Skeleton")
class StraightSkeleton : Filter() { class StraightSkeleton : Filter(null) {
@DoubleParameter("threshold", 0.0, 1.0, order = 0) @DoubleParameter("threshold", 0.0, 1.0, order = 0)
var threshold = 0.5 var threshold = 0.5

View File

@@ -24,7 +24,7 @@ private var filterQuadFormat = vertexFormat {
/** /**
* Filter base class. Renders "full-screen" quads. * Filter base class. Renders "full-screen" quads.
*/ */
open class CubemapFilter(private val shader: Shader? = null, private val watcher: ShaderWatcher? = null) { open class CubemapFilter(private val shader: Shader? = null) {
/** /**
* parameter map * parameter map
@@ -79,7 +79,9 @@ open class CubemapFilter(private val shader: Shader? = null, private val watcher
} }
fun apply(source: Array<Cubemap>, target: RenderTarget) { fun apply(source: Array<Cubemap>, target: RenderTarget) {
val shader = if (this.watcher != null) watcher.shader!! else this.shader!! if (shader == null) {
return
}
target.bind() target.bind()
if (filterQuad == null) { if (filterQuad == null) {

View File

@@ -66,7 +66,7 @@ class PoissonBlender(val width: Int, val height: Int, type: ColorType = ColorTyp
} }
class PoissonBlend: Filter2to1() { class PoissonBlend: Filter2to1(null) {
private var blender: PoissonBlender? = null private var blender: PoissonBlender? = null
val alphaToBitmap = AlphaToBitmap() val alphaToBitmap = AlphaToBitmap()

View File

@@ -40,7 +40,7 @@ class PoissonFiller(val width: Int, val height: Int, type: ColorType = ColorType
/** /**
* Poison filling as a filter * Poison filling as a filter
*/ */
class PoissonFill : Filter1to1() { class PoissonFill : Filter1to1(null) {
private var filler: PoissonFiller? = null private var filler: PoissonFiller? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) { override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>, clip: Rectangle?) {
require(clip == null) require(clip == null)