From 750b5ef67e85b9b09bc4fd16dd6410938eb9a680 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Wed, 28 Dec 2022 13:57:27 +0100 Subject: [PATCH] [orx-fx] Use the appropriate FilterNto1 interfaces * Fix webgl 2 compatibility * Add LumaLaplacian, ACESTonemap, ReinhardTonemap, DirectionalHashBlur --- orx-fx/src/commonMain/kotlin/Post.kt | 4 +- .../src/commonMain/kotlin/antialias/FXAA.kt | 3 +- .../commonMain/kotlin/blend/BlendFilters.kt | 42 +++--- .../kotlin/blur/ApproximateGaussianBlur.kt | 2 +- orx-fx/src/commonMain/kotlin/blur/Bloom.kt | 2 +- orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt | 2 +- .../commonMain/kotlin/blur/DirectionalBlur.kt | 11 +- .../src/commonMain/kotlin/blur/FrameBlur.kt | 2 +- .../commonMain/kotlin/blur/GaussianBlur.kt | 4 +- orx-fx/src/commonMain/kotlin/blur/HashBlur.kt | 127 +++++++++++++++++- .../src/commonMain/kotlin/blur/LaserBlur.kt | 2 +- orx-fx/src/commonMain/kotlin/blur/LineBlur.kt | 2 +- orx-fx/src/commonMain/kotlin/blur/MipBloom.kt | 2 +- orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt | 2 +- .../kotlin/color/ChromaticAberration.kt | 2 +- .../kotlin/color/ColorCorrection.kt | 2 +- .../commonMain/kotlin/color/ColorLookup.kt | 2 +- .../src/commonMain/kotlin/color/ColorMix.kt | 5 +- .../commonMain/kotlin/color/Colorspaces.kt | 9 +- orx-fx/src/commonMain/kotlin/color/Duotone.kt | 3 +- .../kotlin/color/DuotoneGradient.kt | 3 +- orx-fx/src/commonMain/kotlin/color/Invert.kt | 3 +- orx-fx/src/commonMain/kotlin/color/LumaMap.kt | 3 +- .../commonMain/kotlin/color/LumaOpacity.kt | 3 +- .../commonMain/kotlin/color/LumaThreshold.kt | 3 +- orx-fx/src/commonMain/kotlin/color/Pal.kt | 3 +- .../src/commonMain/kotlin/color/Posterize.kt | 3 +- orx-fx/src/commonMain/kotlin/color/Sepia.kt | 3 +- .../commonMain/kotlin/color/SetBackground.kt | 3 +- .../kotlin/color/SubtractConstant.kt | 3 +- .../kotlin/colormap/ColormapFilter.kt | 3 +- .../commonMain/kotlin/distort/BlockRepeat.kt | 7 +- .../kotlin/distort/DisplaceBlend.kt | 2 +- .../src/commonMain/kotlin/distort/Fisheye.kt | 2 +- .../commonMain/kotlin/distort/FluidDistort.kt | 7 +- .../src/commonMain/kotlin/distort/Lenses.kt | 7 +- .../kotlin/distort/PerspectivePlane.kt | 2 +- .../src/commonMain/kotlin/distort/Perturb.kt | 2 +- .../kotlin/distort/PolarToRectangular.kt | 7 +- .../kotlin/distort/RectangularToPolar.kt | 7 +- .../commonMain/kotlin/distort/StackRepeat.kt | 2 +- .../commonMain/kotlin/distort/StretchWaves.kt | 2 +- .../commonMain/kotlin/distort/TapeNoise.kt | 3 +- orx-fx/src/commonMain/kotlin/distort/Tiles.kt | 2 +- .../commonMain/kotlin/distort/VideoGlitch.kt | 3 +- orx-fx/src/commonMain/kotlin/distort/Wave.kt | 2 +- .../src/commonMain/kotlin/dither/ADither.kt | 3 +- .../commonMain/kotlin/dither/CMYKHalftone.kt | 3 +- .../commonMain/kotlin/dither/Crosshatch.kt | 3 +- .../commonMain/kotlin/dither/LumaHalftone.kt | 3 +- .../kotlin/edges/CannyEdgeDetector.kt | 3 +- orx-fx/src/commonMain/kotlin/edges/Contour.kt | 3 +- .../src/commonMain/kotlin/edges/EdgesWork.kt | 2 +- .../commonMain/kotlin/edges/LumaLaplacian.kt | 31 +++++ .../src/commonMain/kotlin/edges/LumaSobel.kt | 3 +- .../src/commonMain/kotlin/grain/FilmGrain.kt | 3 +- .../src/commonMain/kotlin/math/MultiplyU.kt | 3 +- .../src/commonMain/kotlin/math/MultiplyV.kt | 3 +- orx-fx/src/commonMain/kotlin/math/Square.kt | 3 +- .../commonMain/kotlin/patterns/Checkers.kt | 3 +- .../commonMain/kotlin/shadow/DropShadow.kt | 2 +- .../commonMain/kotlin/tonemap/ACESTonemap.kt | 16 +++ .../kotlin/tonemap/ReinhardTonemap.kt | 20 +++ .../kotlin/tonemap/Uncharted2Tonemap.kt | 3 +- .../kotlin/transform/FlipVertically.kt | 3 +- .../glsl/blur/approximate-gaussian-blur.frag | 12 +- .../shaders/glsl/blur/directional-blur.frag | 30 ++--- .../glsl/blur/directional-hash-blur.frag | 79 +++++++++++ orx-fx/src/shaders/glsl/blur/frame-blur.frag | 1 - orx-fx/src/shaders/glsl/blur/hash-blur.frag | 16 ++- orx-fx/src/shaders/glsl/blur/kawase-blur.frag | 2 +- orx-fx/src/shaders/glsl/blur/laser-blur.frag | 6 +- .../shaders/glsl/color/color-correction.frag | 2 +- orx-fx/src/shaders/glsl/color/pal.frag | 10 +- orx-fx/src/shaders/glsl/color/posterize.frag | 8 +- .../shaders/glsl/distort/block-repeat.frag | 2 +- orx-fx/src/shaders/glsl/distort/fisheye.frag | 8 +- .../shaders/glsl/distort/horizontal-wave.frag | 4 +- orx-fx/src/shaders/glsl/distort/lenses.frag | 6 +- orx-fx/src/shaders/glsl/distort/perturb.frag | 4 +- .../glsl/distort/polar-to-rectangular.frag | 2 +- .../glsl/distort/rectangular-to-polar.frag | 2 +- orx-fx/src/shaders/glsl/distort/tiles.frag | 4 +- .../shaders/glsl/distort/vertical-wave.frag | 2 +- .../shaders/glsl/edges/luma-laplacian.frag | 62 +++++++++ .../shaders/glsl/tonemap/aces-tonemap.frag | 25 ++++ .../glsl/tonemap/reinhard-tonemap.frag | 33 +++++ 87 files changed, 578 insertions(+), 175 deletions(-) create mode 100644 orx-fx/src/commonMain/kotlin/edges/LumaLaplacian.kt create mode 100644 orx-fx/src/commonMain/kotlin/tonemap/ACESTonemap.kt create mode 100644 orx-fx/src/commonMain/kotlin/tonemap/ReinhardTonemap.kt create mode 100644 orx-fx/src/shaders/glsl/blur/directional-hash-blur.frag create mode 100644 orx-fx/src/shaders/glsl/edges/luma-laplacian.frag create mode 100644 orx-fx/src/shaders/glsl/tonemap/aces-tonemap.frag create mode 100644 orx-fx/src/shaders/glsl/tonemap/reinhard-tonemap.frag diff --git a/orx-fx/src/commonMain/kotlin/Post.kt b/orx-fx/src/commonMain/kotlin/Post.kt index 8b1a7744..4c2e2fe3 100644 --- a/orx-fx/src/commonMain/kotlin/Post.kt +++ b/orx-fx/src/commonMain/kotlin/Post.kt @@ -36,7 +36,7 @@ class Post : Extension { inner class IntermediateBuffers { internal val buffers = mutableMapOf() - operator fun get(index: Int) : ColorBuffer { + operator fun get(index: Int): ColorBuffer { return buffers.getOrPut(index) { colorBuffer(output!!.width, output!!.height, output!!.contentScale, type = intermediateType) } @@ -63,6 +63,8 @@ class Post : Extension { // in case the attributes of the existing buffers no longer match those of the active render target if (lit.width != art.width || lit.height != art.height || lit.contentScale != art.contentScale || lit.multisample != art.multisample) { lit.colorBuffer(0).destroy() + lit.depthBuffer?.destroy() + lit.detachDepthBuffer() lit.detachColorAttachments() lit.destroy() inputTarget = null diff --git a/orx-fx/src/commonMain/kotlin/antialias/FXAA.kt b/orx-fx/src/commonMain/kotlin/antialias/FXAA.kt index ec2e727b..ebaf28f0 100644 --- a/orx-fx/src/commonMain/kotlin/antialias/FXAA.kt +++ b/orx-fx/src/commonMain/kotlin/antialias/FXAA.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.antialias import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_fxaa import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter * FXAA approximate antialiasing filter. Only works on LDR inputs */ @Description("FXAA") -class FXAA : Filter( mppFilterShader(fx_fxaa, "fxaa")) { +class FXAA : Filter1to1( mppFilterShader(fx_fxaa, "fxaa")) { /** * luma threshold, default value is 0.5 */ diff --git a/orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt b/orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt index fff9add8..1f90eab6 100644 --- a/orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt +++ b/orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt @@ -1,10 +1,12 @@ package org.openrndr.extra.fx.blend import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 +import org.openrndr.draw.Filter2to1 import org.openrndr.extra.fx.* import org.openrndr.extra.parameters.BooleanParameter -class ColorBurn : Filter(mppFilterShader(fx_color_burn, "color-burn")) { +class ColorBurn : Filter2to1(mppFilterShader(fx_color_burn, "color-burn")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -13,7 +15,7 @@ class ColorBurn : Filter(mppFilterShader(fx_color_burn, "color-burn")) { } } -class ColorDodge : Filter(mppFilterShader(fx_color_dodge, "color-dodge")) { +class ColorDodge : Filter2to1(mppFilterShader(fx_color_dodge, "color-dodge")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -22,7 +24,7 @@ class ColorDodge : Filter(mppFilterShader(fx_color_dodge, "color-dodge")) { } } -class Darken : Filter(mppFilterShader(fx_darken, "darken")) { +class Darken : Filter2to1(mppFilterShader(fx_darken, "darken")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -31,7 +33,7 @@ class Darken : Filter(mppFilterShader(fx_darken, "darken")) { } } -class HardLight : Filter(mppFilterShader(fx_hard_light, "hard-light")) { +class HardLight : Filter2to1(mppFilterShader(fx_hard_light, "hard-light")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -40,7 +42,7 @@ class HardLight : Filter(mppFilterShader(fx_hard_light, "hard-light")) { } } -class Lighten : Filter(mppFilterShader(fx_lighten, "lighten")) { +class Lighten : Filter2to1(mppFilterShader(fx_lighten, "lighten")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -49,7 +51,7 @@ class Lighten : Filter(mppFilterShader(fx_lighten, "lighten")) { } } -class Multiply : Filter(mppFilterShader(fx_multiply,"multiply")) { +class Multiply : Filter2to1(mppFilterShader(fx_multiply,"multiply")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -58,7 +60,7 @@ class Multiply : Filter(mppFilterShader(fx_multiply,"multiply")) { } } -class Normal : Filter(mppFilterShader(fx_normal, "normal")) { +class Normal : Filter2to1(mppFilterShader(fx_normal, "normal")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -67,7 +69,7 @@ class Normal : Filter(mppFilterShader(fx_normal, "normal")) { } } -class Overlay : Filter(mppFilterShader(fx_overlay, "overlay")) { +class Overlay : Filter2to1(mppFilterShader(fx_overlay, "overlay")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -76,7 +78,7 @@ class Overlay : Filter(mppFilterShader(fx_overlay, "overlay")) { } } -class Screen : Filter(mppFilterShader(fx_screen, "screen")) { +class Screen : Filter2to1(mppFilterShader(fx_screen, "screen")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -86,18 +88,18 @@ class Screen : Filter(mppFilterShader(fx_screen, "screen")) { } -class SourceIn : Filter(mppFilterShader(fx_source_in, "source-in")) -class SourceOut : Filter(mppFilterShader(fx_source_out,"source-out")) -class SourceAtop : Filter(mppFilterShader(fx_source_atop, "source-atop")) -class DestinationIn : Filter(mppFilterShader(fx_destination_in, "destination-in")) -class DestinationOut : Filter(mppFilterShader(fx_destination_out, "destination-out")) -class DestinationAtop : Filter(mppFilterShader(fx_destination_atop, "destination-atop")) -class Xor : Filter(mppFilterShader(fx_xor, "xor")) +class SourceIn : Filter2to1(mppFilterShader(fx_source_in, "source-in")) +class SourceOut : Filter2to1(mppFilterShader(fx_source_out,"source-out")) +class SourceAtop : Filter2to1(mppFilterShader(fx_source_atop, "source-atop")) +class DestinationIn : Filter2to1(mppFilterShader(fx_destination_in, "destination-in")) +class DestinationOut : Filter2to1(mppFilterShader(fx_destination_out, "destination-out")) +class DestinationAtop : Filter2to1(mppFilterShader(fx_destination_atop, "destination-atop")) +class Xor : Filter2to1(mppFilterShader(fx_xor, "xor")) -class MultiplyContrast : Filter(mppFilterShader(fx_multiply_contrast, "multiply-contrast")) +class MultiplyContrast : Filter2to1(mppFilterShader(fx_multiply_contrast, "multiply-contrast")) -class Passthrough : Filter(mppFilterShader(fx_passthrough, "passthrough")) -class Add : Filter(mppFilterShader(fx_add, "add")) { +class Passthrough : Filter1to1(mppFilterShader(fx_passthrough, "passthrough")) +class Add : Filter2to1(mppFilterShader(fx_add, "add")) { @BooleanParameter("source clip") var clip: Boolean by parameters @@ -105,7 +107,7 @@ class Add : Filter(mppFilterShader(fx_add, "add")) { clip = false } } -class Subtract : Filter(mppFilterShader(fx_subtract,"subtract")) { +class Subtract : Filter2to1(mppFilterShader(fx_subtract,"subtract")) { @BooleanParameter("source clip") var clip: Boolean by parameters diff --git a/orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt b/orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt index 5a59e7a3..9d9f8519 100644 --- a/orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt @@ -14,7 +14,7 @@ import org.openrndr.math.Vector2 * Approximate separated Gaussian blur */ @Description("Approximate Gaussian blur") -class ApproximateGaussianBlur : Filter(mppFilterShader(fx_approximate_gaussian_blur, "approximate gaussian blur")) { +class ApproximateGaussianBlur : Filter1to1(mppFilterShader(fx_approximate_gaussian_blur, "approximate gaussian blur")) { /** * blur sample window, default value is 5 */ diff --git a/orx-fx/src/commonMain/kotlin/blur/Bloom.kt b/orx-fx/src/commonMain/kotlin/blur/Bloom.kt index d79215e8..7ae6d600 100644 --- a/orx-fx/src/commonMain/kotlin/blur/Bloom.kt +++ b/orx-fx/src/commonMain/kotlin/blur/Bloom.kt @@ -9,7 +9,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Bloom") -class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(mppFilterShader(fx_bloom, "bloom")) { +class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter1to1(mppFilterShader(fx_bloom, "bloom")) { /** * the blur filter to use for the bloom, default is Approximate Gaussian Blur */ diff --git a/orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt b/orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt index 2d7a233f..ae353ff3 100644 --- a/orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt @@ -13,7 +13,7 @@ import org.openrndr.math.Vector2 * BoxBlur implemented as a separable filter */ @Description("Box-blur") -class BoxBlur : Filter(mppFilterShader(fx_box_blur,"box-blur")) { +class BoxBlur : Filter1to1(mppFilterShader(fx_box_blur,"box-blur")) { data class ColorBufferDescription(val width: Int, val height: Int, val contentScale: Double, val format: ColorFormat, val type: ColorType) diff --git a/orx-fx/src/commonMain/kotlin/blur/DirectionalBlur.kt b/orx-fx/src/commonMain/kotlin/blur/DirectionalBlur.kt index 591a6330..ec60c585 100644 --- a/orx-fx/src/commonMain/kotlin/blur/DirectionalBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/DirectionalBlur.kt @@ -12,7 +12,13 @@ import org.openrndr.extra.parameters.IntParameter * Directional blur filter. Takes source image and direction buffer inputs */ @Description("Directional blur") -class DirectionalBlur : Filter(mppFilterShader(fx_directional_blur, "directional-blur")) { +class DirectionalBlur : Filter2to1(mppFilterShader(fx_directional_blur, "directional-blur")) { + + /** + * Should the blur window be centered, default is false + */ + @BooleanParameter("center window") + var centerWindow: Boolean by parameters /** * The sample window, default is 5 @@ -38,11 +44,14 @@ class DirectionalBlur : Filter(mppFilterShader(fx_directional_blur, "directional @BooleanParameter("perpendicular") var perpendicular: Boolean by parameters + + init { window = 5 spread = 1.0 gain = 1.0 perpendicular = false + centerWindow = false } override fun apply(source: Array, target: Array) { diff --git a/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt b/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt index 43ac6380..d6c85b34 100644 --- a/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Frame blur") -class FrameBlur : Filter(mppFilterShader(fx_frame_blur, "frame-blur")) { +class FrameBlur : Filter1to1(mppFilterShader(fx_frame_blur, "frame-blur")) { @DoubleParameter("blend", 0.0, 1.0) var blend: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt b/orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt index 464d1288..82befbdb 100644 --- a/orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt @@ -1,6 +1,6 @@ package org.openrndr.extra.fx.blur -import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_gaussian_blur import org.openrndr.extra.fx.mppFilterShader @@ -12,7 +12,7 @@ import org.openrndr.extra.parameters.IntParameter * Exact Gaussian blur, implemented as a single pass filter */ @Description("Gaussian blur") -class GaussianBlur : Filter(mppFilterShader(fx_gaussian_blur,"gaussian-blur")) { +class GaussianBlur : Filter1to1(mppFilterShader(fx_gaussian_blur,"gaussian-blur")) { /** * The sample window, default value is 5 diff --git a/orx-fx/src/commonMain/kotlin/blur/HashBlur.kt b/orx-fx/src/commonMain/kotlin/blur/HashBlur.kt index a66203fc..f2682a60 100644 --- a/orx-fx/src/commonMain/kotlin/blur/HashBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/HashBlur.kt @@ -1,6 +1,10 @@ package org.openrndr.extra.fx.blur import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 +import org.openrndr.draw.Filter2to1 +import org.openrndr.draw.Filter3to1 +import org.openrndr.extra.fx.fx_directional_hash_blur import org.openrndr.extra.fx.fx_hash_blur import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description @@ -8,7 +12,10 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Hash blur") -class HashBlur : Filter(mppFilterShader(fx_hash_blur, "hash-blur")) { +class HashBlur : Filter1to1(mppFilterShader(fx_hash_blur, "hash-blur")) { + private var dynamic: Boolean by parameters + + /** * Blur radius in pixels, default is 5.0 */ @@ -33,9 +40,125 @@ class HashBlur : Filter(mppFilterShader(fx_hash_blur, "hash-blur")) { var gain: Double by parameters init { + dynamic = false radius = 5.0 time = 0.0 samples = 30 gain = 1.0 } -} \ No newline at end of file +} + +@Description("Hash blur") +class HashBlurDynamic: Filter2to1(mppFilterShader(fx_hash_blur, "hash-blur")) { + + private var dynamic: Boolean by parameters + + /** + * Blur radius in pixels, default is 5.0 + */ + @DoubleParameter("blur radius", 1.0, 25.0) + var radius: Double by parameters + + /** + * Time/seed, this should be fed with seconds, default is 0.0 + */ + var time: Double by parameters + + /** + * Number of samples, default is 30 + */ + @IntParameter("number of samples", 1, 100) + var samples: Int by parameters + + /** + * Post-blur gain, default is 1.0 + */ + @DoubleParameter("image gain", 0.0, 2.0) + var gain: Double by parameters + + init { + dynamic = true + radius = 5.0 + time = 0.0 + samples = 30 + gain = 1.0 + } +} + +@Description("Directional hash blur") +class DirectionalHashBlur : Filter2to1(mppFilterShader(fx_directional_hash_blur, "directional-hash-blur")) { + + /** + * Blur radius in pixels, default is 5.0 + */ + @DoubleParameter("blur radius", 0.0, 25.0) + var radius: Double by parameters + + @DoubleParameter("blur spread", 0.0, 25.0) + var spread: Double by parameters + + + /** + * Time/seed, this should be fed with seconds, default is 0.0 + */ + var time: Double by parameters + + /** + * Number of samples, default is 30 + */ + @IntParameter("number of samples", 1, 100) + var samples: Int by parameters + + /** + * Post-blur gain, default is 1.0 + */ + @DoubleParameter("image gain", 0.0, 2.0) + var gain: Double by parameters + + init { + radius = 5.0 + spread = 25.0 + time = 0.0 + samples = 30 + gain = 1.0 + } +} + +@Description("Directional hash blur") +class DirectionalHashBlurDynamic : Filter3to1(mppFilterShader("#define RADIUS_FROM_TEXTURE\n${fx_directional_hash_blur}", "directional-hash-blur")) { + + /** + * Blur radius in pixels, default is 5.0 + */ + @DoubleParameter("blur radius", 0.0, 25.0) + var radius: Double by parameters + + @DoubleParameter("blur spread", 0.0, 25.0) + var spread: Double by parameters + + + /** + * Time/seed, this should be fed with seconds, default is 0.0 + */ + var time: Double by parameters + + /** + * Number of samples, default is 30 + */ + @IntParameter("number of samples", 1, 100) + var samples: Int by parameters + + /** + * Post-blur gain, default is 1.0 + */ + @DoubleParameter("image gain", 0.0, 2.0) + var gain: Double by parameters + + init { + radius = 5.0 + spread = 25.0 + time = 0.0 + samples = 30 + gain = 1.0 + } +} diff --git a/orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt b/orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt index 97f90dc9..46450088 100644 --- a/orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt @@ -32,7 +32,7 @@ private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur" } @Description("Laser blur") -class LaserBlur : Filter() { +class LaserBlur : Filter1to1() { @Vector2Parameter("center", order = 0) var center = Vector2.ZERO diff --git a/orx-fx/src/commonMain/kotlin/blur/LineBlur.kt b/orx-fx/src/commonMain/kotlin/blur/LineBlur.kt index 4df10dc2..8c36e72a 100644 --- a/orx-fx/src/commonMain/kotlin/blur/LineBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/LineBlur.kt @@ -17,7 +17,7 @@ import kotlin.math.sin * BoxBlur implemented as a separable filter */ @Description("Line blur") -class LineBlur : Filter(mppFilterShader(fx_box_blur, "line-blur")) { +class LineBlur : Filter1to1(mppFilterShader(fx_box_blur, "line-blur")) { /** * The sample window, default is 5 diff --git a/orx-fx/src/commonMain/kotlin/blur/MipBloom.kt b/orx-fx/src/commonMain/kotlin/blur/MipBloom.kt index 542049eb..566c9cc9 100644 --- a/orx-fx/src/commonMain/kotlin/blur/MipBloom.kt +++ b/orx-fx/src/commonMain/kotlin/blur/MipBloom.kt @@ -42,7 +42,7 @@ class BloomCombine : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine")) } @Description("MipBloom") -open class MipBloom(val blur: T) : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine")) { +open class MipBloom(val blur: T) : Filter1to1(mppFilterShader(fx_bloom_combine, "bloom-combine")) { var passes = 6 @DoubleParameter("shape", 0.0, 4.0) diff --git a/orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt b/orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt index 2bb7bed4..0f625131 100644 --- a/orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt +++ b/orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.math.Vector2 @Description("Zoom Blur") -class ZoomBlur : Filter(mppFilterShader(fx_zoom_blur, "zoom-blur")) { +class ZoomBlur : Filter1to1(mppFilterShader(fx_zoom_blur, "zoom-blur")) { var center: Vector2 by parameters @DoubleParameter("strength", 0.0, 1.0) diff --git a/orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt b/orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt index a92bda46..63aa1c48 100644 --- a/orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt +++ b/orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.math.Vector2 @Description("Chromatic Aberration") -class ChromaticAberration : Filter(mppFilterShader(fx_chromatic_aberration, "chromatic-aberration")) { +class ChromaticAberration : Filter1to1(mppFilterShader(fx_chromatic_aberration, "chromatic-aberration")) { /** * aberration factor, default value is 8.0 */ diff --git a/orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt b/orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt index 1abdf020..974c780a 100644 --- a/orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt +++ b/orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Color correction") -class ColorCorrection : Filter(mppFilterShader(fx_color_correction, "color-correction")) { +class ColorCorrection : Filter1to1(mppFilterShader(fx_color_correction, "color-correction")) { @DoubleParameter("brightness", -1.0, 1.0, order = 0) var brightness: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/ColorLookup.kt b/orx-fx/src/commonMain/kotlin/color/ColorLookup.kt index 9473203a..d3214056 100644 --- a/orx-fx/src/commonMain/kotlin/color/ColorLookup.kt +++ b/orx-fx/src/commonMain/kotlin/color/ColorLookup.kt @@ -4,7 +4,7 @@ import org.openrndr.draw.* import org.openrndr.extra.fx.fx_color_lookup import org.openrndr.extra.fx.mppFilterShader -class ColorLookup(lookup: ColorBuffer) : Filter(mppFilterShader(fx_color_lookup, "color-lookup")) { +class ColorLookup(lookup: ColorBuffer) : Filter1to1(mppFilterShader(fx_color_lookup, "color-lookup")) { /** a color look-up texture */ var lookup: ColorBuffer by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/ColorMix.kt b/orx-fx/src/commonMain/kotlin/color/ColorMix.kt index 1704cf53..7fabef52 100644 --- a/orx-fx/src/commonMain/kotlin/color/ColorMix.kt +++ b/orx-fx/src/commonMain/kotlin/color/ColorMix.kt @@ -2,16 +2,17 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_color_mix import org.openrndr.extra.fx.fx_color_tint import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter import org.openrndr.extra.parameters.Description -class ColorMix : Filter(mppFilterShader(fx_color_mix, "color-mix")) +class ColorMix : Filter1to1(mppFilterShader(fx_color_mix, "color-mix")) @Description("Tint") -class ColorTint : Filter(mppFilterShader(fx_color_tint, "color-tint")) { +class ColorTint : Filter1to1(mppFilterShader(fx_color_tint, "color-tint")) { @ColorParameter("tint") var tint: ColorRGBa by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/Colorspaces.kt b/orx-fx/src/commonMain/kotlin/color/Colorspaces.kt index 863a9672..cc493a82 100644 --- a/orx-fx/src/commonMain/kotlin/color/Colorspaces.kt +++ b/orx-fx/src/commonMain/kotlin/color/Colorspaces.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.* import org.openrndr.extra.fx.fx_rgb_to_oklab import org.openrndr.extra.fx.fx_rgb_to_ycbcr @@ -8,15 +9,15 @@ import org.openrndr.extra.fx.fx_ycbcr_to_rgb import org.openrndr.extra.shaderphrases.preprocess import org.openrndr.extra.color.phrases.ColorPhraseBook -class RgbToYCbcr : Filter(mppFilterShader(fx_rgb_to_ycbcr, "rgb-to-ycbcr")) -class YcbcrToRgb : Filter(mppFilterShader(fx_ycbcr_to_rgb, "ycbcr_to_rgb")) +class RgbToYCbcr : Filter1to1(mppFilterShader(fx_rgb_to_ycbcr, "rgb-to-ycbcr")) +class YcbcrToRgb : Filter1to1(mppFilterShader(fx_ycbcr_to_rgb, "ycbcr_to_rgb")) -class RgbToOkLab : Filter(mppFilterShader(run { +class RgbToOkLab : Filter1to1(mppFilterShader(run { ColorPhraseBook.register() fx_rgb_to_oklab.preprocess() }, "rgb-to-oklab")) -class OkLabToRgb : Filter(mppFilterShader(run { +class OkLabToRgb : Filter1to1(mppFilterShader(run { ColorPhraseBook.register() fx_oklab_to_rgb.preprocess() }, "oklab-to-rgb")) diff --git a/orx-fx/src/commonMain/kotlin/color/Duotone.kt b/orx-fx/src/commonMain/kotlin/color/Duotone.kt index 891fbf3b..adf2568d 100644 --- a/orx-fx/src/commonMain/kotlin/color/Duotone.kt +++ b/orx-fx/src/commonMain/kotlin/color/Duotone.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_duotone import org.openrndr.extra.parameters.BooleanParameter @@ -15,7 +16,7 @@ import org.openrndr.extra.color.presets.DARK_GRAY import org.openrndr.extra.color.presets.NAVY @Description("Duotone") -class Duotone : Filter(filterShaderFromCode(run { +class Duotone : Filter1to1(filterShaderFromCode(run { ColorPhraseBook.register() fx_duotone.preprocess() }, "duotone")) { diff --git a/orx-fx/src/commonMain/kotlin/color/DuotoneGradient.kt b/orx-fx/src/commonMain/kotlin/color/DuotoneGradient.kt index 37fd4f81..2a74217d 100644 --- a/orx-fx/src/commonMain/kotlin/color/DuotoneGradient.kt +++ b/orx-fx/src/commonMain/kotlin/color/DuotoneGradient.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_duotone_gradient import org.openrndr.extra.parameters.BooleanParameter @@ -15,7 +16,7 @@ import org.openrndr.extra.color.presets.CORAL import org.openrndr.extra.color.presets.NAVY @Description("Duotone Gradient") -class DuotoneGradient : Filter(filterShaderFromCode(run { +class DuotoneGradient : Filter1to1(filterShaderFromCode(run { ColorPhraseBook.register() fx_duotone_gradient.preprocess() }, "duotone-gradient")) { diff --git a/orx-fx/src/commonMain/kotlin/color/Invert.kt b/orx-fx/src/commonMain/kotlin/color/Invert.kt index 595da689..d735ed4c 100644 --- a/orx-fx/src/commonMain/kotlin/color/Invert.kt +++ b/orx-fx/src/commonMain/kotlin/color/Invert.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_invert import org.openrndr.extra.fx.fx_sepia import org.openrndr.extra.fx.mppFilterShader @@ -8,7 +9,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Invert") -class Invert : Filter(mppFilterShader(fx_invert, "invert")) { +class Invert : Filter1to1(mppFilterShader(fx_invert, "invert")) { @DoubleParameter("amount", 0.0, 1.0) var amount: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/LumaMap.kt b/orx-fx/src/commonMain/kotlin/color/LumaMap.kt index 6c4d8b1e..2e1df54d 100644 --- a/orx-fx/src/commonMain/kotlin/color/LumaMap.kt +++ b/orx-fx/src/commonMain/kotlin/color/LumaMap.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_luma_map import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Luma map ") -class LumaMap : Filter(mppFilterShader(fx_luma_map, "luma-map")) { +class LumaMap : Filter1to1(mppFilterShader(fx_luma_map, "luma-map")) { @ColorParameter("foreground color") var foreground: ColorRGBa by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt b/orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt index 285ca00f..6ee65c4a 100644 --- a/orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt +++ b/orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_luma_opacity import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Luma map ") -class LumaOpacity : Filter(mppFilterShader(fx_luma_opacity, "luma-opacity")) { +class LumaOpacity : Filter1to1(mppFilterShader(fx_luma_opacity, "luma-opacity")) { @DoubleParameter("foreground luma",0.0, 1.0) var foregroundLuma: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt b/orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt index 6f83c677..8f5b7cfa 100644 --- a/orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt +++ b/orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_luma_threshold import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Luma threshold ") -class LumaThreshold : Filter(mppFilterShader(fx_luma_threshold, "luma-threshold")) { +class LumaThreshold : Filter1to1(mppFilterShader(fx_luma_threshold, "luma-threshold")) { @DoubleParameter("threshold value", 0.0, 1.0) var threshold: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/Pal.kt b/orx-fx/src/commonMain/kotlin/color/Pal.kt index e44c3089..1060b9d3 100644 --- a/orx-fx/src/commonMain/kotlin/color/Pal.kt +++ b/orx-fx/src/commonMain/kotlin/color/Pal.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_pal import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Pal TV Effect") -class Pal : Filter(mppFilterShader(fx_pal,"pal")) { +class Pal : Filter1to1(mppFilterShader(fx_pal,"pal")) { @DoubleParameter("amount", 0.0, 1.0) var amount: Double by parameters @DoubleParameter("pixelation", 0.0, 1.0) diff --git a/orx-fx/src/commonMain/kotlin/color/Posterize.kt b/orx-fx/src/commonMain/kotlin/color/Posterize.kt index 9e4cef88..fa00717b 100644 --- a/orx-fx/src/commonMain/kotlin/color/Posterize.kt +++ b/orx-fx/src/commonMain/kotlin/color/Posterize.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_duotone import org.openrndr.extra.fx.fx_posterize @@ -17,7 +18,7 @@ import org.openrndr.extra.color.presets.DARK_GRAY import org.openrndr.extra.color.presets.NAVY @Description("Posterize") -class Posterize : Filter(filterShaderFromCode(fx_posterize, "posterize")) { +class Posterize : Filter1to1(filterShaderFromCode(fx_posterize, "posterize")) { @IntParameter("levels", 2, 32, order = 0) var levels: Int by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/Sepia.kt b/orx-fx/src/commonMain/kotlin/color/Sepia.kt index 413e2fe8..5edb4098 100644 --- a/orx-fx/src/commonMain/kotlin/color/Sepia.kt +++ b/orx-fx/src/commonMain/kotlin/color/Sepia.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_sepia import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Sepia") -class Sepia : Filter(mppFilterShader(fx_sepia, "sepia")) { +class Sepia : Filter1to1(mppFilterShader(fx_sepia, "sepia")) { @DoubleParameter("amount", 0.0, 1.0) var amount: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/SetBackground.kt b/orx-fx/src/commonMain/kotlin/color/SetBackground.kt index 9ea7e449..84e2f469 100644 --- a/orx-fx/src/commonMain/kotlin/color/SetBackground.kt +++ b/orx-fx/src/commonMain/kotlin/color/SetBackground.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_set_background import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Set background") -class SetBackground : Filter(mppFilterShader(fx_set_background, "set-background")) { +class SetBackground : Filter1to1(mppFilterShader(fx_set_background, "set-background")) { @ColorParameter("background color") var background: ColorRGBa by parameters diff --git a/orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt b/orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt index 02af157a..ec0fe2e2 100644 --- a/orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt +++ b/orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt @@ -2,10 +2,11 @@ package org.openrndr.extra.fx.color import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_subtract_constant import org.openrndr.extra.fx.mppFilterShader -class SubtractConstant : Filter(mppFilterShader(fx_subtract_constant, "subtract-constant")) { +class SubtractConstant : Filter1to1(mppFilterShader(fx_subtract_constant, "subtract-constant")) { var constant: ColorRGBa by parameters init { diff --git a/orx-fx/src/commonMain/kotlin/colormap/ColormapFilter.kt b/orx-fx/src/commonMain/kotlin/colormap/ColormapFilter.kt index 81ab09ba..4a90904d 100644 --- a/orx-fx/src/commonMain/kotlin/colormap/ColormapFilter.kt +++ b/orx-fx/src/commonMain/kotlin/colormap/ColormapFilter.kt @@ -1,10 +1,11 @@ package org.openrndr.extra.fx.colormap import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.DoubleParameter -abstract class ColormapFilter(code: String, name: String) : Filter(mppFilterShader(code, name)) { +abstract class ColormapFilter(code: String, name: String) : Filter1to1(mppFilterShader(code, name)) { @DoubleParameter(label = "min value", low = 0.0, high = 1.0, order = 0) var minValue: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt b/orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt index eb3f76ad..a7a67d70 100644 --- a/orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt +++ b/orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt @@ -1,9 +1,6 @@ package org.openrndr.extra.fx.distort -import org.openrndr.draw.ColorBuffer -import org.openrndr.draw.Filter -import org.openrndr.draw.MagnifyingFilter -import org.openrndr.draw.MinifyingFilter +import org.openrndr.draw.* import org.openrndr.extra.fx.fx_block_repeat import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -11,7 +8,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Block repeat") -class BlockRepeat : Filter(mppFilterShader(fx_block_repeat, "block-repeat")) { +class BlockRepeat : Filter1to1(mppFilterShader(fx_block_repeat, "block-repeat")) { @DoubleParameter("block width", 0.0, 1.0, order = 0) var blockWidth: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt b/orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt index af62a319..60f98e37 100644 --- a/orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt +++ b/orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.math.Vector3 @Description("Displace blend") -class DisplaceBlend : Filter(mppFilterShader(fx_displace_blend, "displace-blend")) { +class DisplaceBlend : Filter2to1(mppFilterShader(fx_displace_blend, "displace-blend")) { var seed: Vector3 by parameters @DoubleParameter("offset", -1.0, 1.0) diff --git a/orx-fx/src/commonMain/kotlin/distort/Fisheye.kt b/orx-fx/src/commonMain/kotlin/distort/Fisheye.kt index 4da528ac..59755dd3 100644 --- a/orx-fx/src/commonMain/kotlin/distort/Fisheye.kt +++ b/orx-fx/src/commonMain/kotlin/distort/Fisheye.kt @@ -7,7 +7,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Fisheye") -class Fisheye : Filter(mppFilterShader(fx_fisheye, "fisheye")) { +class Fisheye : Filter1to1(mppFilterShader(fx_fisheye, "fisheye")) { @DoubleParameter("strength", -1.0, 1.0, order = 0) var strength: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt b/orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt index 70e91ec9..45f3674f 100644 --- a/orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt +++ b/orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt @@ -1,9 +1,6 @@ package org.openrndr.extra.fx.distort -import org.openrndr.draw.ColorBuffer -import org.openrndr.draw.Filter -import org.openrndr.draw.createEquivalent -import org.openrndr.draw.isEquivalentTo +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 @@ -20,7 +17,7 @@ private class FluidDistortFilter : Filter(mppFilterShader(fx_fluid_distort, "flu } } -class FluidDistort : Filter() { +class FluidDistort : Filter1to1() { var blend: Double = 1.0 var outputUV = false diff --git a/orx-fx/src/commonMain/kotlin/distort/Lenses.kt b/orx-fx/src/commonMain/kotlin/distort/Lenses.kt index 3e8f2d64..1926d8aa 100644 --- a/orx-fx/src/commonMain/kotlin/distort/Lenses.kt +++ b/orx-fx/src/commonMain/kotlin/distort/Lenses.kt @@ -1,9 +1,6 @@ package org.openrndr.extra.fx.distort -import org.openrndr.draw.ColorBuffer -import org.openrndr.draw.Filter -import org.openrndr.draw.MagnifyingFilter -import org.openrndr.draw.MinifyingFilter +import org.openrndr.draw.* import org.openrndr.extra.fx.fx_lenses import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -12,7 +9,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Lenses") -class Lenses : Filter(mppFilterShader(fx_lenses, "block-repeat")) { +class Lenses : Filter1to1(mppFilterShader(fx_lenses, "block-repeat")) { @IntParameter("rows", 1, 64, order = 0) var rows: Int by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt b/orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt index 5021d0f8..32c718bd 100644 --- a/orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt +++ b/orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt @@ -10,7 +10,7 @@ import org.openrndr.math.Vector3 import org.openrndr.math.transforms.transform @Description("Perspective plane") -class PerspectivePlane : Filter(mppFilterShader(fx_perspective_plane, "perspective-plane")) { +class PerspectivePlane : Filter1to1(mppFilterShader(fx_perspective_plane, "perspective-plane")) { // @DoubleParameter("camera x", -1.0, 1.0, order = 0) var cameraX: Double = 0.0 // @DoubleParameter("camera y", -1.0, 1.0, order = 1) diff --git a/orx-fx/src/commonMain/kotlin/distort/Perturb.kt b/orx-fx/src/commonMain/kotlin/distort/Perturb.kt index 0770430d..5e84efff 100644 --- a/orx-fx/src/commonMain/kotlin/distort/Perturb.kt +++ b/orx-fx/src/commonMain/kotlin/distort/Perturb.kt @@ -8,7 +8,7 @@ import org.openrndr.math.Vector2 import org.openrndr.math.Vector3 @Description("Perturb") -class Perturb : Filter(mppFilterShader(fx_perturb, "perturb")) { +class Perturb : Filter1to1(mppFilterShader(fx_perturb, "perturb")) { var seed: Vector3 by parameters /** * base noise scale, default is Vector3(1.0, 1.0, 1.0) diff --git a/orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt b/orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt index 81bbe775..cad057cd 100644 --- a/orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt +++ b/orx-fx/src/commonMain/kotlin/distort/PolarToRectangular.kt @@ -1,9 +1,6 @@ package org.openrndr.extra.fx.distort -import org.openrndr.draw.ColorBuffer -import org.openrndr.draw.Filter -import org.openrndr.draw.MagnifyingFilter -import org.openrndr.draw.MinifyingFilter +import org.openrndr.draw.* import org.openrndr.extra.fx.fx_polar_to_rectangular import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -12,7 +9,7 @@ import org.openrndr.extra.parameters.Vector2Parameter import org.openrndr.math.Vector2 @Description("Polar to rectangular") -class PolarToRectangular : Filter(mppFilterShader(fx_polar_to_rectangular, "polar-to-rectangular")) { +class PolarToRectangular : Filter1to1(mppFilterShader(fx_polar_to_rectangular, "polar-to-rectangular")) { @BooleanParameter("log polar") var logPolar:Boolean by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt b/orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt index 9a1d5ffd..50084eec 100644 --- a/orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt +++ b/orx-fx/src/commonMain/kotlin/distort/RectangularToPolar.kt @@ -1,9 +1,6 @@ package org.openrndr.extra.fx.distort -import org.openrndr.draw.ColorBuffer -import org.openrndr.draw.Filter -import org.openrndr.draw.MagnifyingFilter -import org.openrndr.draw.MinifyingFilter +import org.openrndr.draw.* import org.openrndr.extra.fx.fx_rectangular_to_polar import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -13,7 +10,7 @@ import org.openrndr.math.Vector2 import kotlin.math.log @Description("Rectangular to polar") -class RectangularToPolar : Filter(mppFilterShader(fx_rectangular_to_polar, "rectangular-to-polar")) { +class RectangularToPolar : Filter1to1(mppFilterShader(fx_rectangular_to_polar, "rectangular-to-polar")) { @BooleanParameter("log polar") var logPolar:Boolean by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt b/orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt index 4de00a9d..d8f57acf 100644 --- a/orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt +++ b/orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Stack repeat") -class StackRepeat : Filter(mppFilterShader(fx_stack_repeat, "stack-repeat")) { +class StackRepeat : Filter1to1(mppFilterShader(fx_stack_repeat, "stack-repeat")) { @DoubleParameter("zoom", -1.0, 1.0, order = 0) var zoom: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt b/orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt index 9fdc100f..22de5499 100644 --- a/orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt +++ b/orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt @@ -7,7 +7,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Stretch waves") -class StretchWaves : Filter(mppFilterShader(fx_stretch_waves, "stretch-waves")) { +class StretchWaves : Filter1to1(mppFilterShader(fx_stretch_waves, "stretch-waves")) { @DoubleParameter("distortion", -0.0,1.0, 1) var distortion: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt b/orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt index c34ac3cc..3b64141a 100644 --- a/orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt +++ b/orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.distort import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_tape_noise import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Tape noise") -class TapeNoise : Filter(mppFilterShader(fx_tape_noise, "tape-noise")) { +class TapeNoise : Filter1to1(mppFilterShader(fx_tape_noise, "tape-noise")) { var time: Double by parameters @DoubleParameter("gain", 0.0, 1.0) diff --git a/orx-fx/src/commonMain/kotlin/distort/Tiles.kt b/orx-fx/src/commonMain/kotlin/distort/Tiles.kt index 17297343..18dc0dc2 100644 --- a/orx-fx/src/commonMain/kotlin/distort/Tiles.kt +++ b/orx-fx/src/commonMain/kotlin/distort/Tiles.kt @@ -8,7 +8,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Tiles") -class Tiles : Filter(mppFilterShader(fx_tiles, "tiles")) { +class Tiles : Filter1to1(mppFilterShader(fx_tiles, "tiles")) { @DoubleParameter("rotation", -180.0, 180.0, order = 2) var rotation: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt b/orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt index dbf635e1..1297496b 100644 --- a/orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt +++ b/orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.distort import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_video_glitch import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -8,7 +9,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Video glitch") -class VideoGlitch : Filter(mppFilterShader(fx_video_glitch, "video-glitch")) { +class VideoGlitch : Filter1to1(mppFilterShader(fx_video_glitch, "video-glitch")) { var time: Double by parameters @DoubleParameter("amplitude", 0.0, 10.0) diff --git a/orx-fx/src/commonMain/kotlin/distort/Wave.kt b/orx-fx/src/commonMain/kotlin/distort/Wave.kt index 6ec60932..bffe222d 100644 --- a/orx-fx/src/commonMain/kotlin/distort/Wave.kt +++ b/orx-fx/src/commonMain/kotlin/distort/Wave.kt @@ -9,7 +9,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Horizontal wave") -class HorizontalWave : Filter(mppFilterShader(fx_horizontal_wave, "horizontal-wave")) { +class HorizontalWave : Filter1to1(mppFilterShader(fx_horizontal_wave, "horizontal-wave")) { @DoubleParameter("frequency", 0.0, 64.0, order = 1) var frequency: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/dither/ADither.kt b/orx-fx/src/commonMain/kotlin/dither/ADither.kt index 48286784..ff0d2043 100644 --- a/orx-fx/src/commonMain/kotlin/dither/ADither.kt +++ b/orx-fx/src/commonMain/kotlin/dither/ADither.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.dither import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_a_dither import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.IntParameter @Description("ADither") -class ADither: Filter(mppFilterShader(fx_a_dither, "a-dither")) { +class ADither: Filter1to1(mppFilterShader(fx_a_dither, "a-dither")) { @IntParameter("pattern index", 0, 3) var pattern: Int by parameters diff --git a/orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt b/orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt index 929940cc..6c76b3cb 100644 --- a/orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt +++ b/orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.dither import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_cmyk_halftone import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("CMYK Halftone") -class CMYKHalftone: Filter(mppFilterShader(fx_cmyk_halftone, "cmyk-halftone")) { +class CMYKHalftone: Filter1to1(mppFilterShader(fx_cmyk_halftone, "cmyk-halftone")) { @DoubleParameter("scale", 1.0, 30.0, precision = 4) var scale: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt b/orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt index b8aeb027..679a6499 100644 --- a/orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt +++ b/orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt @@ -1,13 +1,14 @@ package org.openrndr.extra.fx.dither import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_crosshatch import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Crosshatch") -class Crosshatch : Filter(mppFilterShader(fx_crosshatch, "crosshatch")) { +class Crosshatch : Filter1to1(mppFilterShader(fx_crosshatch, "crosshatch")) { @DoubleParameter("threshold 1", 0.0, 1.0) var t1: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/dither/LumaHalftone.kt b/orx-fx/src/commonMain/kotlin/dither/LumaHalftone.kt index 34ed1456..1b68a15a 100644 --- a/orx-fx/src/commonMain/kotlin/dither/LumaHalftone.kt +++ b/orx-fx/src/commonMain/kotlin/dither/LumaHalftone.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.dither import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_luma_halftone import org.openrndr.extra.parameters.BooleanParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.DoubleParameter @Description("Luma Halftone") -class LumaHalftone: Filter(filterShaderFromCode(fx_luma_halftone, "luma-halftone")) { +class LumaHalftone: Filter1to1(filterShaderFromCode(fx_luma_halftone, "luma-halftone")) { @DoubleParameter("scale", 1.0, 30.0, precision = 4) var scale: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/edges/CannyEdgeDetector.kt b/orx-fx/src/commonMain/kotlin/edges/CannyEdgeDetector.kt index 503c59ee..3233e8d8 100644 --- a/orx-fx/src/commonMain/kotlin/edges/CannyEdgeDetector.kt +++ b/orx-fx/src/commonMain/kotlin/edges/CannyEdgeDetector.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.edges import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_canny_edge_detector import org.openrndr.extra.parameters.ColorParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Canny Edge Detector") -class CannyEdgeDetector : Filter( +class CannyEdgeDetector : Filter1to1( filterShaderFromCode(fx_canny_edge_detector, "canny-edge-detector") ) { diff --git a/orx-fx/src/commonMain/kotlin/edges/Contour.kt b/orx-fx/src/commonMain/kotlin/edges/Contour.kt index c332af1e..ce97d163 100644 --- a/orx-fx/src/commonMain/kotlin/edges/Contour.kt +++ b/orx-fx/src/commonMain/kotlin/edges/Contour.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.edges import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_contour import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.extra.parameters.IntParameter @Description("Contour") -class Contour : Filter(mppFilterShader(fx_contour, "contour")) { +class Contour : Filter1to1(mppFilterShader(fx_contour, "contour")) { @DoubleParameter("levels", 1.0, 16.0) var levels: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt b/orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt index 1d15eeaf..9ad084a4 100644 --- a/orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt +++ b/orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt @@ -18,7 +18,7 @@ internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work- } @Description("Edges Work") -open class EdgesWork : Filter(mppFilterShader(fx_edges_work_2, "edges-work-2")) { +open class EdgesWork : Filter1to1(mppFilterShader(fx_edges_work_2, "edges-work-2")) { /** * radius, default value is 1.0 */ diff --git a/orx-fx/src/commonMain/kotlin/edges/LumaLaplacian.kt b/orx-fx/src/commonMain/kotlin/edges/LumaLaplacian.kt new file mode 100644 index 00000000..4df91020 --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/edges/LumaLaplacian.kt @@ -0,0 +1,31 @@ +package org.openrndr.extra.fx.edges + +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.Filter1to1 +import org.openrndr.extra.fx.fx_luma_laplacian +import org.openrndr.extra.fx.mppFilterShader +import org.openrndr.extra.parameters.ColorParameter +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter + +@Description("Luma Sobel") +class LumaLaplacian : Filter1to1(mppFilterShader(fx_luma_laplacian, "luma-laplacian")) { + @ColorParameter("background color") + var backgroundColor: ColorRGBa by parameters + + @ColorParameter("edge color") + var edgeColor: ColorRGBa by parameters + + @DoubleParameter("background opacity", 0.0, 1.0) + var backgroundOpacity: Double by parameters + + @DoubleParameter("edge opacity", 0.0, 1.0) + var edgeOpacity: Double by parameters + + init { + backgroundColor = ColorRGBa.BLACK + edgeColor = ColorRGBa.WHITE + edgeOpacity = 1.0 + backgroundOpacity = 1.0 + } +} diff --git a/orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt b/orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt index dc7aeab2..4b8888dd 100644 --- a/orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt +++ b/orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt @@ -2,6 +2,7 @@ package org.openrndr.extra.fx.edges import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_luma_sobel import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.ColorParameter @@ -9,7 +10,7 @@ import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Luma Sobel") -class LumaSobel : Filter(mppFilterShader(fx_luma_sobel, "luma-sobel")) { +class LumaSobel : Filter1to1(mppFilterShader(fx_luma_sobel, "luma-sobel")) { @ColorParameter("background color") var backgroundColor: ColorRGBa by parameters diff --git a/orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt b/orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt index 0f9061a1..343a2a42 100644 --- a/orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt +++ b/orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.grain import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_film_grain import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.BooleanParameter @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter * Film grain filter */ @Description("film grain") -class FilmGrain : Filter(mppFilterShader(fx_film_grain, "film-grain")) { +class FilmGrain : Filter1to1(mppFilterShader(fx_film_grain, "film-grain")) { @BooleanParameter("use color") var useColor: Boolean by parameters diff --git a/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt b/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt index e906e5de..0e2ddbb0 100644 --- a/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt +++ b/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt @@ -1,4 +1,5 @@ import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_film_grain import org.openrndr.extra.fx.fx_multiply_u @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter * Multiply by u coordinate */ @Description("multiply u") -class MultiplyU : Filter(filterShaderFromCode(fx_multiply_u, "multiply-u")) { +class MultiplyU : Filter1to1(filterShaderFromCode(fx_multiply_u, "multiply-u")) { @DoubleParameter("multiplication bias", 0.0, 2.0) var bias: Double by parameters init { diff --git a/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt b/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt index 2609bfd7..c1914848 100644 --- a/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt +++ b/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt @@ -1,4 +1,5 @@ import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_multiply_v import org.openrndr.extra.parameters.BooleanParameter @@ -8,7 +9,7 @@ import org.openrndr.extra.parameters.DoubleParameter * Multiply by v coordinate */ @Description("multiply v") -class MultiplyV : Filter(filterShaderFromCode(fx_multiply_v, "multiply-v")) { +class MultiplyV : Filter1to1(filterShaderFromCode(fx_multiply_v, "multiply-v")) { @DoubleParameter("multiplication bias", 0.0, 2.0) var bias: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/math/Square.kt b/orx-fx/src/commonMain/kotlin/math/Square.kt index 3806e864..259da3b8 100644 --- a/orx-fx/src/commonMain/kotlin/math/Square.kt +++ b/orx-fx/src/commonMain/kotlin/math/Square.kt @@ -1,4 +1,5 @@ import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.draw.filterShaderFromCode import org.openrndr.extra.fx.fx_square import org.openrndr.extra.parameters.Description @@ -6,5 +7,5 @@ import org.openrndr.extra.parameters.Description * Square input texture values */ @Description("square") -class Square : Filter(filterShaderFromCode(fx_square, "square")) { +class Square : Filter1to1(filterShaderFromCode(fx_square, "square")) { } \ No newline at end of file diff --git a/orx-fx/src/commonMain/kotlin/patterns/Checkers.kt b/orx-fx/src/commonMain/kotlin/patterns/Checkers.kt index 1af933d0..70e8de88 100644 --- a/orx-fx/src/commonMain/kotlin/patterns/Checkers.kt +++ b/orx-fx/src/commonMain/kotlin/patterns/Checkers.kt @@ -2,13 +2,14 @@ package org.openrndr.extra.fx.patterns import org.openrndr.color.ColorRGBa import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_checkers import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description import org.openrndr.extra.parameters.DoubleParameter @Description("Checkers pattern") -class Checkers : Filter(mppFilterShader(fx_checkers, "checkers")) { +class Checkers : Filter1to1(mppFilterShader(fx_checkers, "checkers")) { var background: ColorRGBa by parameters var foreground: ColorRGBa by parameters diff --git a/orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt b/orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt index 11f0ffde..eef485f5 100644 --- a/orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt +++ b/orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt @@ -16,7 +16,7 @@ private class Blend : Filter(mppFilterShader(fx_dropshadow_blend, "dropshadow-bl } @Description("Drop shadow") -class DropShadow : Filter(mppFilterShader(fx_dropshadow_blur, "dropshadow-blur")) { +class DropShadow : Filter1to1(mppFilterShader(fx_dropshadow_blur, "dropshadow-blur")) { @IntParameter("blur window", 1, 25) var window: Int by parameters var spread: Double by parameters diff --git a/orx-fx/src/commonMain/kotlin/tonemap/ACESTonemap.kt b/orx-fx/src/commonMain/kotlin/tonemap/ACESTonemap.kt new file mode 100644 index 00000000..8b138381 --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/tonemap/ACESTonemap.kt @@ -0,0 +1,16 @@ +package org.openrndr.extra.fx.tonemap + +import org.openrndr.draw.Filter1to1 +import org.openrndr.extra.fx.fx_aces_tonemap +import org.openrndr.extra.fx.mppFilterShader +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter + +@Description("ACES tonemap") +class ACESTonemap : Filter1to1(mppFilterShader(fx_aces_tonemap, "aces-tonemap")) { + @DoubleParameter("exposure bias", 0.0, 128.0) + var exposureBias:Double by parameters + init { + exposureBias = 1.0 + } +} \ No newline at end of file diff --git a/orx-fx/src/commonMain/kotlin/tonemap/ReinhardTonemap.kt b/orx-fx/src/commonMain/kotlin/tonemap/ReinhardTonemap.kt new file mode 100644 index 00000000..43eb669f --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/tonemap/ReinhardTonemap.kt @@ -0,0 +1,20 @@ +package org.openrndr.extra.fx.tonemap + +import org.openrndr.draw.Filter1to1 +import org.openrndr.extra.fx.fx_reinhard_tonemap +import org.openrndr.extra.fx.mppFilterShader +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter + +@Description("ACES tonemap") +class ReinhardTonemap : Filter1to1(mppFilterShader(fx_reinhard_tonemap, "reinhard-tonemap")) { + @DoubleParameter("exposure bias", 0.0, 128.0) + var exposureBias:Double by parameters + + @DoubleParameter("maximum luminance", 0.0, 128.0) + var maxLuminance:Double by parameters + init { + exposureBias = 1.0 + maxLuminance = 1.0 + } +} \ No newline at end of file diff --git a/orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt b/orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt index 5b3f1cb5..3f34dc10 100644 --- a/orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt +++ b/orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt @@ -1,6 +1,7 @@ package org.openrndr.extra.fx.tonemap import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_uncharted2_tonemap import org.openrndr.extra.fx.mppFilterShader import org.openrndr.extra.parameters.Description @@ -10,7 +11,7 @@ import org.openrndr.extra.parameters.DoubleParameter * Uncharted 2 tonemap filter */ @Description("Uncharted 2 tonemap") -class Uncharted2Tonemap : Filter(mppFilterShader(fx_uncharted2_tonemap, "uncharted2-tonemap")) { +class Uncharted2Tonemap : Filter1to1(mppFilterShader(fx_uncharted2_tonemap, "uncharted2-tonemap")) { @DoubleParameter("exposure bias", 0.0, 128.0) var exposureBias:Double by parameters init { diff --git a/orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt b/orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt index 3a2d565f..29d1accf 100644 --- a/orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt +++ b/orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt @@ -1,10 +1,11 @@ package org.openrndr.extra.fx.transform import org.openrndr.draw.Filter +import org.openrndr.draw.Filter1to1 import org.openrndr.extra.fx.fx_flip_vertically import org.openrndr.extra.fx.mppFilterShader /** * Vertically flips in the input image */ -class FlipVertically : Filter(mppFilterShader(fx_flip_vertically, "flip-vertically")) \ No newline at end of file +class FlipVertically : Filter1to1(mppFilterShader(fx_flip_vertically, "flip-vertically")) \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag b/orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag index ab7462b2..f1f9999f 100644 --- a/orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/approximate-gaussian-blur.frag @@ -11,15 +11,19 @@ uniform int sourceLevel; out vec4 o_color; void main() { - vec2 s = 1.0 / textureSize(tex0, sourceLevel).xy; + vec2 s = 1.0 / vec2(textureSize(tex0, sourceLevel).xy); int w = window; vec4 sum = vec4(0.0); - float weight = 0; + float weight = 0.0; for (int x = -w; x <= w; ++x) { - float lw = exp( -(x*x) / (2 * sigma * sigma) ) ; - vec2 tc = v_texCoord0 + x * blurDirection * s;// * spread; + float lw = exp( float(-(x*x)) / (2.0 * sigma * sigma) ) ; + vec2 tc = v_texCoord0 + float(x) * blurDirection * s;// * spread; + #ifndef OR_WEBGL2 sum += textureLod(tex0, tc, sourceLevel) * lw; + #else + sum += texture(tex0, tc); + #endif weight += lw; } o_color = (sum / weight) * gain; diff --git a/orx-fx/src/shaders/glsl/blur/directional-blur.frag b/orx-fx/src/shaders/glsl/blur/directional-blur.frag index 8fc88873..24e0db0f 100644 --- a/orx-fx/src/shaders/glsl/blur/directional-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/directional-blur.frag @@ -1,11 +1,8 @@ -#ifdef OR_IN_OUT in vec2 v_texCoord0; -#else -varying vec2 v_texCoord0; -#endif -uniform sampler2D tex0; // image -uniform sampler2D tex1; // blurDirection +uniform bool centerWindow; +uniform sampler2D tex0;// image +uniform sampler2D tex1;// blurDirection uniform vec2 textureSize0; uniform int window; @@ -16,10 +13,7 @@ uniform bool wrapX; uniform bool wrapY; uniform bool perpendicular; - -#ifndef OR_GL_FRAGCOLOR out vec4 o_color; -#endif vec2 wrap(vec2 uv) { vec2 res = uv; @@ -36,30 +30,22 @@ void main() { vec2 s = textureSize0; s = vec2(1.0 / s.x, 1.0 / s.y); - vec4 sum = vec4(0.0, 0.0, 0.0, 0.0); - #ifndef OR_GL_TEXTURE2D vec2 blurDirection = texture(tex1, v_texCoord0).xy; if (perpendicular) { blurDirection = vec2(-blurDirection.y, blurDirection.x); } float weight = 0.0; + + int start = centerWindow? -window/2 : 0; + int end = centerWindow? window/2 + 1 : window; + + for (int x = 0; x < window; ++x) { sum += texture(tex0, wrap(v_texCoord0 + float(x) * blurDirection * s * spread)); weight += 1.0; } - #else - vec2 blurDirection = texture2D(tex1, v_texCoord0); - float weight = 0.0; - sum += texture2D(tex0, wrap(v_texCoord0 * blurDirection * s * spread)); - - #endif - vec4 result = (sum/weight) * gain; - #ifdef OR_GL_FRAGCOLOR - gl_FragColor = result; - #else o_color = result; - #endif } \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/blur/directional-hash-blur.frag b/orx-fx/src/shaders/glsl/blur/directional-hash-blur.frag new file mode 100644 index 00000000..8b8a143a --- /dev/null +++ b/orx-fx/src/shaders/glsl/blur/directional-hash-blur.frag @@ -0,0 +1,79 @@ +// based on Hashed blur by David Hoskins. +// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. + +in vec2 v_texCoord0; + +layout(binding = 0) uniform sampler2D tex0; +layout(binding = 1) uniform sampler2D tex1; + +#ifdef RADIUS_FROM_TEXTURE +layout(binding = 2) uniform sampler2D tex2; +#endif + + +uniform vec2 textureSize0; +uniform float radius; +uniform float spread; + +uniform float time; +uniform int samples; +uniform float gain; + +out vec4 o_color; + +#define TAU 6.28318530718 + +//------------------------------------------------------------------------------------------- +#define HASHSCALE 443.8975 +vec2 hash22(vec2 p) { + vec3 p3 = fract(vec3(p.xyx) * HASHSCALE); + p3 += dot(p3, p3.yzx+19.19); + return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y)); +} + + +vec2 sampleOffset(inout vec2 r, vec2 direction) { + r = fract(r * vec2(33.3983, 43.4427)); + return (r.x+.001) * direction; +} + +vec2 sampleCircle(inout vec2 r) { + r = fract(r * vec2(33.3983, 43.4427)); + return sqrt(r.x+.001) * vec2(sin(r.y * TAU), cos(r.y * TAU))*.5; // <<=== circular sampling. +} + + +//------------------------------------------------------------------------------------------- +vec4 blur(vec2 uv, float r) { + float radius = r; + #ifdef RADIUS_FROM_TEXTURE + radius *= texture(tex2, uv).r; + #endif + vec2 direction = texture(tex1, uv).xy; + + vec2 line = vec2(spread) * (vec2(1.0) / textureSize0); + vec2 circle = vec2(radius) * (vec2(1.0) / textureSize0); + vec2 randomL = hash22(uv + vec2(time)); + vec2 randomC = hash22(uv + vec2(time)); + + vec4 acc = vec4(0.0); + + for (int i = 0; i < samples; i++) { + vec2 lineOffset = line * sampleOffset(randomL, direction); + vec2 circleOffset = circle * sampleCircle(randomC); + acc += textureLod(tex0, uv + circleOffset + lineOffset, 0 ); + } + return acc / float(samples); +} + +//------------------------------------------------------------------------------------------- +void main() { + vec2 uv = v_texCoord0; + float radiusSqr = pow(radius, 2.0); + + vec4 result = blur(uv, radiusSqr); + result.rgb *= gain; + + + o_color = result; +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/blur/frame-blur.frag b/orx-fx/src/shaders/glsl/blur/frame-blur.frag index c6b44797..15d55795 100644 --- a/orx-fx/src/shaders/glsl/blur/frame-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/frame-blur.frag @@ -4,7 +4,6 @@ uniform sampler2D tex1; // accumulator image uniform float blend; out vec4 o_color; void main() { - vec4 inputColor = texture(tex0, v_texCoord0); vec4 accumulator = texture(tex1, v_texCoord0); o_color = accumulator * (1.0 - blend) + inputColor * blend; diff --git a/orx-fx/src/shaders/glsl/blur/hash-blur.frag b/orx-fx/src/shaders/glsl/blur/hash-blur.frag index c16f09f4..2f52eb88 100644 --- a/orx-fx/src/shaders/glsl/blur/hash-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/hash-blur.frag @@ -8,11 +8,13 @@ varying vec2 v_texCoord0; #endif uniform sampler2D tex0; +uniform sampler2D tex1; uniform vec2 textureSize0; uniform float radius; uniform float time; uniform int samples; uniform float gain; +uniform bool dynamic; #ifndef OR_GL_FRAGCOLOR out vec4 o_color; @@ -37,18 +39,18 @@ vec2 sampleTexture(inout vec2 r) { //------------------------------------------------------------------------------------------- vec4 blur(vec2 uv, float radius) { - vec2 circle = vec2(radius) * (vec2(1.0) / textureSize0); + float r = radius; + if (dynamic) { + r *= texture(tex1, uv).r; + } + + vec2 circle = vec2(r) * (vec2(1.0) / textureSize0); vec2 random = hash22(uv + vec2(time)); vec4 acc = vec4(0.0); - for (int i = 0; i < 100; i++) { - if (i > samples) break; - #ifndef OR_GL_TEXTURE2D + for (int i = 0; i < samples; i++) { acc += texture(tex0, uv + circle * sampleTexture(random)); - #else - acc += texture2D(tex0, uv + circle * sampleTexture(random)); - #endif } return acc / float(samples); } diff --git a/orx-fx/src/shaders/glsl/blur/kawase-blur.frag b/orx-fx/src/shaders/glsl/blur/kawase-blur.frag index 6c22905e..e88794b9 100644 --- a/orx-fx/src/shaders/glsl/blur/kawase-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/kawase-blur.frag @@ -6,7 +6,7 @@ uniform float spread; void main() { ivec2 size = textureSize(tex0, 0); - vec2 pixelSize = vec2(1.0/size.x, 1.0/size.y); + vec2 pixelSize = vec2(1.0/float(size.x), 1.0/float(size.y)); vec2 halfPixelSize = pixelSize / 2.0f; vec2 d = (pixelSize.xy * vec2(iteration, iteration)) + halfPixelSize.xy; d *= spread; diff --git a/orx-fx/src/shaders/glsl/blur/laser-blur.frag b/orx-fx/src/shaders/glsl/blur/laser-blur.frag index 6aedbd21..18bf148b 100644 --- a/orx-fx/src/shaders/glsl/blur/laser-blur.frag +++ b/orx-fx/src/shaders/glsl/blur/laser-blur.frag @@ -18,7 +18,7 @@ void main() { } vec2 vt = (v_texCoord0 - vec2(0.5, 0.5) + center) * radius + vec2(0.5, 0.5) - center; - vec2 size = textureSize(tex0, 0); + vec2 size = vec2(textureSize(tex0, 0)); vec2 l = (v_texCoord0 - vec2(0.5, 0.5) + center) * vec2(1.0, size.y/size.x); float d = length(l); @@ -31,7 +31,7 @@ void main() { i1g.rgb = i1g.a > 0.0 ? i1g.rgb / i1g.a : vec3(0.0); i1b.rgb = i1b.a > 0.0 ? i1b.rgb / i1b.a : vec3(0.0); - vec4 i1 = vec4(i1r.r, i1g.g, i1b.b, 1.0) * (i1r.a + i1g.a + i1b.a)/3.0; + vec4 i1 = vec4(i1r.r, i1g.g, i1b.b, 1.0) * (i1r.a + i1g.a + i1b.a) / 3.0; if (!linearInput) { i1.rgb = pow(i1.rgb, vec3(2.2)); } @@ -44,6 +44,4 @@ void main() { if (!linearOutput) { o_output.rgb = pow(o_output.rgb, vec3(1.0 / 2.2)); } - - } \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/color/color-correction.frag b/orx-fx/src/shaders/glsl/color/color-correction.frag index 6b6b96b6..8c3a5ba1 100644 --- a/orx-fx/src/shaders/glsl/color/color-correction.frag +++ b/orx-fx/src/shaders/glsl/color/color-correction.frag @@ -58,7 +58,7 @@ void main() { vec4 nc = (color.a == 0.0) ? vec4(0.0) : vec4(color.rgb / color.a, color.a); nc.rgb = pow(nc.rgb, vec3(gamma)); nc.rgb = shiftHue(nc.rgb, (hueShift/360.0)); - vec4 cc = brightnessMatrix(brightness) * contrastMatrix((contrast + 1)) * saturationMatrix(saturation + 1) * nc; + vec4 cc = brightnessMatrix(brightness) * contrastMatrix((contrast + 1.0)) * saturationMatrix(saturation + 1.0) * nc; if(clamped) { o_color = clamp(vec4(cc.rgb, 1.0) * color.a * opacity, 0.0, 1.0); } else { diff --git a/orx-fx/src/shaders/glsl/color/pal.frag b/orx-fx/src/shaders/glsl/color/pal.frag index e2a86a0e..6d24f0c2 100644 --- a/orx-fx/src/shaders/glsl/color/pal.frag +++ b/orx-fx/src/shaders/glsl/color/pal.frag @@ -49,7 +49,7 @@ float modulated(vec2 xy, float sinwt, float coswt) { } vec2 modem_uv(vec2 xy, int ofs) { - float t = (xy.x + float(ofs) * invx) * textureSize(tex0, 0).x; + float t = (xy.x + float(ofs) * invx) * float(textureSize(tex0, 0).x); float wt = t * 2.0 * PI / width_ratio; float sinwt = sin(wt); @@ -90,8 +90,8 @@ vec3 shadow_mask(vec2 pos){ void main() { // vec2 xy = fragCoord.st / iResolution.xy; vec2 xy = v_texCoord0; - width_ratio = textureSize(tex0, 0).x / (float(FSC) / float(FLINE)); - height_ratio = textureSize(tex0, 0).y / float(VISIBLELINES); + width_ratio = float(textureSize(tex0, 0).x) / (float(FSC) / float(FLINE)); + height_ratio = float(textureSize(tex0, 0).y) / float(VISIBLELINES); altv = mod(floor(xy.y * float(VISIBLELINES) + 0.5), 2.0) * PI; invx = 0.25 / (float(FSC)/float(FLINE)); // equals 4 samples per Fsc period @@ -102,7 +102,7 @@ void main() { filtered += FIR_GAIN * uv * FIR[i]; } - float t = xy.x * textureSize(tex0, 0).x; + float t = xy.x * float(textureSize(tex0, 0).x); float wt = t * 2.0 * PI / width_ratio; float sinwt = sin(wt); @@ -111,7 +111,7 @@ void main() { float luma = modulated(xy, sinwt, coswt) - FIR_INVGAIN * (filtered.x * sinwt + filtered.y * coswt); vec3 yuv_result = vec3(luma, filtered.x, filtered.y); - vec3 rgbmask = shadow_mask( xy * vec2(1.0, textureSize(tex0,0).x / textureSize(tex0,0).y) ); // needs anisotropy like: fragCoord.st/ iResolution.y ); + vec3 rgbmask = shadow_mask( xy * vec2(1.0, float(textureSize(tex0,0).x) / float(textureSize(tex0,0).y)) ); // needs anisotropy like: fragCoord.st/ iResolution.y ); rgbmask = vec3(1.0,1.0,1.0) * (1.0-pixelation) + rgbmask * pixelation; o_color = texture(tex0,xy) * (1.0-amount) + amount * vec4(rgbmask * ( YUV_to_RGB * yuv_result ), 1.0); diff --git a/orx-fx/src/shaders/glsl/color/posterize.frag b/orx-fx/src/shaders/glsl/color/posterize.frag index 0f0e771e..92a3ae69 100644 --- a/orx-fx/src/shaders/glsl/color/posterize.frag +++ b/orx-fx/src/shaders/glsl/color/posterize.frag @@ -10,17 +10,15 @@ void main() { vec3 s = vec3(0.0); for (int v = -window; v <= window; ++v) { for (int u = -window; u <= window; ++u) { - vec4 c = texture(tex0, v_texCoord0 + (step/(2*window)) * vec2(u,v) ); + vec4 c = texture(tex0, v_texCoord0 + (step/(2.0*float(window))) * vec2(u,v) ); if (c.a != 0.0) { c.rgb /= c.a; } - vec3 q = min(floor(c.rgb * (levels))/(levels-1), vec3(1.0)); + vec3 q = min(floor(c.rgb * float(levels))/float(levels-1.0), vec3(1.0)); s += q; w += 1.0; } } vec3 q = s / w; - - - o_output = vec4(q*c.a, c.a); + o_output = vec4(q * c.a, c.a); } \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/distort/block-repeat.frag b/orx-fx/src/shaders/glsl/distort/block-repeat.frag index c593f292..27fb27bf 100644 --- a/orx-fx/src/shaders/glsl/distort/block-repeat.frag +++ b/orx-fx/src/shaders/glsl/distort/block-repeat.frag @@ -16,7 +16,7 @@ void main() { vec2 blockCoord = uv / blockSize + blockOffset; ivec2 blockIndex = ivec2(blockCoord); - vec2 blockUV = mod(blockCoord - blockIndex, vec2(1.0)); + vec2 blockUV = mod(blockCoord - vec2(blockIndex), vec2(1.0)); vec2 blockAspect = vec2(1.0); diff --git a/orx-fx/src/shaders/glsl/distort/fisheye.frag b/orx-fx/src/shaders/glsl/distort/fisheye.frag index 9e411434..7faca0b5 100644 --- a/orx-fx/src/shaders/glsl/distort/fisheye.frag +++ b/orx-fx/src/shaders/glsl/distort/fisheye.frag @@ -8,21 +8,19 @@ out vec4 o_color; void main() { vec2 uv = v_texCoord0; - vec2 ts = textureSize(tex0, 0); + vec2 ts = vec2(textureSize(tex0, 0)); vec2 step = 1.0 / ts; float phi = radians(rotation); float cp = cos(phi); float sp = sin(phi); - mat2 rm = mat2(vec2(cp,sp), vec2(-sp,cp)); - + mat2 rm = mat2(vec2(cp, sp), vec2(-sp, cp)); float aspectRatio = ts.y / ts.x; step.y /= aspectRatio; step *= feather; - vec2 intensity = vec2(strength, - strength); + vec2 intensity = vec2(strength, strength); vec2 coords = uv; coords = (coords - 0.5) * 2.0; diff --git a/orx-fx/src/shaders/glsl/distort/horizontal-wave.frag b/orx-fx/src/shaders/glsl/distort/horizontal-wave.frag index 08713145..cb14eadf 100644 --- a/orx-fx/src/shaders/glsl/distort/horizontal-wave.frag +++ b/orx-fx/src/shaders/glsl/distort/horizontal-wave.frag @@ -1,5 +1,5 @@ in vec2 v_texCoord0; -uniform sampler2D tex0; // input +uniform sampler2D tex0;// input uniform float phase; uniform float amplitude; uniform float frequency; @@ -11,7 +11,7 @@ float truncate(float x, int segments) { if (segments == 0) { return x; } else { - return floor(x*segments) / segments; + return floor(x * float(segments)) / float(segments); } } diff --git a/orx-fx/src/shaders/glsl/distort/lenses.frag b/orx-fx/src/shaders/glsl/distort/lenses.frag index 8c5aea0e..a171da99 100644 --- a/orx-fx/src/shaders/glsl/distort/lenses.frag +++ b/orx-fx/src/shaders/glsl/distort/lenses.frag @@ -9,17 +9,17 @@ uniform float distort; out vec4 o_color; void main() { vec2 uv = v_texCoord0; - vec2 blockSize = vec2(1.0/columns, 1.0/rows); + vec2 blockSize = vec2(1.0 / float(columns), 1.0 / float(rows)); vec2 blockIndex = floor(uv / blockSize); vec2 blockUV = mod(uv/blockSize, vec2(1.0)); vec2 blockUVC1 = (blockUV - vec2(0.5)) * 2.0; - vec2 blockCenter = (blockIndex+0.5) * blockSize; + vec2 blockCenter = (blockIndex + 0.5) * blockSize; float ca = cos(radians(rotation)); float sa = sin(radians(rotation)); vec2 ts = textureSize(tex0, 0); - mat2 rm = mat2(1.0, 0.0, 0.0, ts.x/ts.y) * mat2(vec2(ca, sa), vec2(-sa, ca)) * mat2(1.0, 0.0, 0.0, ts.y/ts.x); + mat2 rm = mat2(1.0, 0.0, 0.0, ts.x / ts.y) * mat2(vec2(ca, sa), vec2(-sa, ca)) * mat2(1.0, 0.0, 0.0, ts.y / ts.x); vec2 ruv = (uv - blockCenter); vec2 luv; luv.x = (1.0 - blockUVC1.y * blockUVC1.y * distort) * ruv.x; diff --git a/orx-fx/src/shaders/glsl/distort/perturb.frag b/orx-fx/src/shaders/glsl/distort/perturb.frag index d1c83125..c5305df9 100644 --- a/orx-fx/src/shaders/glsl/distort/perturb.frag +++ b/orx-fx/src/shaders/glsl/distort/perturb.frag @@ -128,8 +128,8 @@ float snoise(vec3 v) } vec3 segment(vec3 t, int x, int y) { - float sx = x == 0? t.x : floor(t.x * x) / x; - float sy = y == 0? t.y : floor(t.y * y) / y; + float sx = x == 0? t.x : floor(t.x * float(x)) / float(x); + float sy = y == 0? t.y : floor(t.y * float(y)) / float(y); return vec3(sx,sy, t.z); } diff --git a/orx-fx/src/shaders/glsl/distort/polar-to-rectangular.frag b/orx-fx/src/shaders/glsl/distort/polar-to-rectangular.frag index ad26796d..8f617524 100644 --- a/orx-fx/src/shaders/glsl/distort/polar-to-rectangular.frag +++ b/orx-fx/src/shaders/glsl/distort/polar-to-rectangular.frag @@ -22,7 +22,7 @@ void main() { float bias = 0.0; float radius = logPolar? log(1.0 + length(uv)*(exp(1.0)-bias)) / log(1.0+(exp(1.0)-bias)*sqrt(0.5)) : (length(uv) / sqrt(0.5)); - vec2 sourceUV = vec2(arg / (2*PI) + 0.5, radius); + vec2 sourceUV = vec2(arg / (2.0 * PI) + 0.5, radius); #ifndef OR_GL_TEXTURE2D vec4 result = texture(tex0, sourceUV); diff --git a/orx-fx/src/shaders/glsl/distort/rectangular-to-polar.frag b/orx-fx/src/shaders/glsl/distort/rectangular-to-polar.frag index 7ac018af..6286dd8b 100644 --- a/orx-fx/src/shaders/glsl/distort/rectangular-to-polar.frag +++ b/orx-fx/src/shaders/glsl/distort/rectangular-to-polar.frag @@ -21,7 +21,7 @@ uniform bool logPolar; void main() { vec2 uv = v_texCoord0; - float arg = (uv.x-0.5) * 2 * PI; + float arg = (uv.x-0.5) * 2.0 * PI; float radius = logPolar? (((exp(uv.y)-1.0) / (exp(1.0)-1.0))) : uv.y; vec2 sourceUV = (radius * sqrt(0.5) * vec2(cos(arg), sin(arg)) + vec2(0.5)); diff --git a/orx-fx/src/shaders/glsl/distort/tiles.frag b/orx-fx/src/shaders/glsl/distort/tiles.frag index d68a7f7a..39173079 100644 --- a/orx-fx/src/shaders/glsl/distort/tiles.frag +++ b/orx-fx/src/shaders/glsl/distort/tiles.frag @@ -11,7 +11,7 @@ float truncate(float x, int segments) { if (segments == 0) { return x; } else { - return floor(x*segments) / segments; + return floor(x * float(segments)) / float(segments); } } @@ -23,7 +23,7 @@ void main() { mat2 rm = mat2(cr, -sr, sr, cr); vec2 ruv = rm * uv; - vec2 truv = vec2( truncate(ruv.x, xSegments), truncate(ruv.y, ySegments)); + vec2 truv = vec2(truncate(ruv.x, xSegments), truncate(ruv.y, ySegments)); vec2 tuv = transpose(rm) * truv + vec2(0.5); vec4 c = vec4(0.0); diff --git a/orx-fx/src/shaders/glsl/distort/vertical-wave.frag b/orx-fx/src/shaders/glsl/distort/vertical-wave.frag index f17331a4..1eff2f4d 100644 --- a/orx-fx/src/shaders/glsl/distort/vertical-wave.frag +++ b/orx-fx/src/shaders/glsl/distort/vertical-wave.frag @@ -11,7 +11,7 @@ float truncate(float x, int segments) { if (segments == 0) { return x; } else { - return floor(x*segments) / segments; + return floor(x * float(segments)) / float(segments); } } diff --git a/orx-fx/src/shaders/glsl/edges/luma-laplacian.frag b/orx-fx/src/shaders/glsl/edges/luma-laplacian.frag new file mode 100644 index 00000000..577fc5d6 --- /dev/null +++ b/orx-fx/src/shaders/glsl/edges/luma-laplacian.frag @@ -0,0 +1,62 @@ +in vec2 v_texCoord0; + +uniform sampler2D tex0; + +uniform vec4 backgroundColor; +uniform vec4 edgeColor; +uniform float backgroundOpacity; +uniform float edgeOpacity; +out vec4 o_output; + +float step = 1.0; + +float luma(vec4 color){ + vec3 n = color.a == 0.0? vec3(0.0) : color.rgb/color.a; + return dot(n, vec3(1.0/3.0)); +} + +/** Denotes if UV coordinates falls outside an image. + \param pos the UV coordinates + \return true if the UV are outside of the image + */ +bool isOutside(vec2 pos){ + return (pos.x < 0.0 || pos.y < 0.0 || pos.x > 1.0 || pos.y > 1.0); +} + +/** Compute the Laplacian field of an input RGB image, adding a 1px black border around it before computing the gradients and divergence. */ +void main(){ + float div = 0.0; + ivec2 size = textureSize(tex0, 0).xy; + + vec3 pixelShift = vec3(0.0); + pixelShift.xy = 1.0/vec2(size); + + vec2 uvs = v_texCoord0; + if(!isOutside(uvs)){ + float col = luma(textureLod(tex0, uvs, 0.0)); + div = 4.0 * col; + } + + vec2 uvs110 = uvs + pixelShift.xz; + if(!isOutside(uvs110)){ + float col110 = luma(textureLod(tex0, uvs110, 0.0)); + div -= col110; + } + vec2 uvs101 = uvs + pixelShift.zy; + if(!isOutside(uvs101)){ + float col101 = luma(textureLod(tex0, uvs101, 0.0)); + div -= col101; + } + vec2 uvs010 = uvs - pixelShift.xz; + if(!isOutside(uvs010)){ + float col010 = luma(textureLod(tex0, uvs010, 0.0)); + div -= col010; + } + vec2 uvs001 = uvs - pixelShift.zy; + if(!isOutside(uvs001)){ + float col001 = luma(textureLod(tex0, uvs001, 0.0)); + div -= col001; + } + o_output.rgb = vec3(div); + o_output.a = 1.0f; +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/tonemap/aces-tonemap.frag b/orx-fx/src/shaders/glsl/tonemap/aces-tonemap.frag new file mode 100644 index 00000000..db244c2a --- /dev/null +++ b/orx-fx/src/shaders/glsl/tonemap/aces-tonemap.frag @@ -0,0 +1,25 @@ +uniform sampler2D tex0; +uniform float exposureBias; + +in vec2 v_texCoord0; +out vec4 o_output; + +vec3 saturate(vec3 x) { + return clamp(x, vec3(0.0), vec3(1.0)); +} + +vec3 ACESFilm(vec3 x) { + float a = 2.51f; + float b = 0.03f; + float c = 2.43f; + float d = 0.59f; + float e = 0.14f; + return saturate((x*(a*x+b))/(x*(c*x+d)+e)); +} + +void main() { + vec3 texColor = texture(tex0,v_texCoord0).rgb; + vec3 color = ACESFilm(texColor * exposureBias); + vec3 retColor = pow(color, vec3(1/2.2)); + o_output = vec4(retColor, 1); +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/tonemap/reinhard-tonemap.frag b/orx-fx/src/shaders/glsl/tonemap/reinhard-tonemap.frag new file mode 100644 index 00000000..2b9fde22 --- /dev/null +++ b/orx-fx/src/shaders/glsl/tonemap/reinhard-tonemap.frag @@ -0,0 +1,33 @@ +uniform sampler2D tex0; +uniform float exposureBias; +uniform float maxLuminance; + +in vec2 v_texCoord0; +out vec4 o_output; + +vec3 saturate(vec3 x) { + return clamp(x, vec3(0.0), vec3(1.0)); +} + +float luminance(vec3 v) { + return dot(v, vec3(0.2126f, 0.7152f, 0.0722f)); +} + +vec3 change_luminance(vec3 c_in, float l_out) { + float l_in = luminance(c_in); + return c_in * (l_out / l_in); +} + +vec3 reinhard_extended_luminance(vec3 v, float max_white_l) { + float l_old = luminance(v); + float numerator = l_old * (1.0f + (l_old / (max_white_l * max_white_l))); + float l_new = numerator / (1.0f + l_old); + return change_luminance(v, l_new); +} + +void main() { + vec3 texColor = texture(tex0,v_texCoord0).rgb; + vec3 color = reinhard_extended_luminance(texColor * exposureBias, maxLuminance); + vec3 retColor = pow(color, vec3(1/2.2)); + o_output = vec4(retColor, 1); +} \ No newline at end of file