[orx-fx] Use the appropriate FilterNto1 interfaces

* Fix webgl 2 compatibility
 * Add LumaLaplacian, ACESTonemap, ReinhardTonemap, DirectionalHashBlur
This commit is contained in:
Edwin Jakobs
2022-12-28 13:57:27 +01:00
parent beb53bbde7
commit 750b5ef67e
87 changed files with 578 additions and 175 deletions

View File

@@ -36,7 +36,7 @@ class Post : Extension {
inner class IntermediateBuffers {
internal val buffers = mutableMapOf<Int, ColorBuffer>()
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

View File

@@ -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
*/

View File

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

View File

@@ -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
*/

View File

@@ -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
*/

View File

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

View File

@@ -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<ColorBuffer>, target: Array<ColorBuffer>) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -42,7 +42,7 @@ class BloomCombine : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine"))
}
@Description("MipBloom")
open class MipBloom<T : Filter>(val blur: T) : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine")) {
open class MipBloom<T : Filter>(val blur: T) : Filter1to1(mppFilterShader(fx_bloom_combine, "bloom-combine")) {
var passes = 6
@DoubleParameter("shape", 0.0, 4.0)

View File

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

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

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

View File

@@ -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")) {

View File

@@ -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")) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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")
) {

View File

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

View File

@@ -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
*/

View File

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

View File

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

View File

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

View File

@@ -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 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 {

View File

@@ -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"))
class FlipVertically : Filter1to1(mppFilterShader(fx_flip_vertically, "flip-vertically"))

View File

@@ -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;

View File

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

View File

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

View File

@@ -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;

View File

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

View File

@@ -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;

View File

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

View File

@@ -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 {

View File

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

View File

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

View File

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

View File

@@ -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;

View File

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

View File

@@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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