From adf4dc33c32e1f5b3215820db92edb98a3e12c55 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 2 Feb 2020 11:13:38 +0100 Subject: [PATCH] Add parameter annotations to most orx-fx filters --- orx-fx/src/main/kotlin/antialias/FXAA.kt | 7 +++++++ .../main/kotlin/blur/ApproximateGaussianBlur.kt | 10 ++++++++-- orx-fx/src/main/kotlin/blur/Bloom.kt | 10 ++++++++-- orx-fx/src/main/kotlin/blur/BoxBlur.kt | 7 +++++++ orx-fx/src/main/kotlin/blur/GaussianBlur.kt | 8 ++++++++ orx-fx/src/main/kotlin/blur/HashBlur.kt | 7 +++++++ .../main/kotlin/color/ChromaticAberration.kt | 7 +++++-- orx-fx/src/main/kotlin/color/ColorMix.kt | 4 +--- orx-fx/src/main/kotlin/grain/FilmGrain.kt | 17 +++++++++++++++++ .../main/kotlin/tonemap/Uncharted2Tonemap.kt | 7 ++++++- 10 files changed, 74 insertions(+), 10 deletions(-) diff --git a/orx-fx/src/main/kotlin/antialias/FXAA.kt b/orx-fx/src/main/kotlin/antialias/FXAA.kt index 07d81482..3a924cb6 100644 --- a/orx-fx/src/main/kotlin/antialias/FXAA.kt +++ b/orx-fx/src/main/kotlin/antialias/FXAA.kt @@ -3,29 +3,36 @@ package org.openrndr.extra.fx.antialias import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter /** * FXAA approximate antialiasing filter. Only works on LDR inputs */ +@Description("FXAA") class FXAA : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("antialias/fxaa.frag"))) { /** * luma threshold, default value is 0.5 */ + @DoubleParameter("luma threshold", 0.0, 1.0) var lumaThreshold: Double by parameters /** * max search span, default value is 8.0 */ + @DoubleParameter("max search span", 1.0, 16.0) var maxSpan: Double by parameters /** * direction reduce multiplier, default value is 0.0 */ + @DoubleParameter("direction reduce multiplier", 0.0, 1.0) var directionReduceMultiplier: Double by parameters /** * direction reduce minimum, default value is 0.0 */ + @DoubleParameter("direction reduce minium", 0.0, 1.0) var directionReduceMinimum: Double by parameters init { diff --git a/orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt b/orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt index 85eca199..e98a475f 100644 --- a/orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt +++ b/orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt @@ -2,39 +2,45 @@ package org.openrndr.extra.fx.blur import org.openrndr.draw.* import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter +import org.openrndr.extra.parameters.IntParameter import org.openrndr.math.Vector2 /** * Approximate separated Gaussian blur */ +@Description("Approximate Gaussian blur") class ApproximateGaussianBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blur/approximate-gaussian-blur.frag"))) { data class ColorBufferDescription(val width: Int, val height: Int, val contentScale: Double, val format: ColorFormat, val type: ColorType) - /** * blur sample window, default value is 5 */ + @IntParameter("window size", 1, 25) var window: Int by parameters /** * spread multiplier, default value is 1.0 */ + @DoubleParameter("kernel spread", 1.0, 4.0) var spread: Double by parameters /** * blur sigma, default value is 1.0 */ + @DoubleParameter("kernel sigma", 0.0, 25.0) var sigma: Double by parameters /** * post blur gain, default value is 1.0 */ + @DoubleParameter("gain", 0.0, 4.0) var gain: Double by parameters - private var intermediateCache = mutableMapOf() diff --git a/orx-fx/src/main/kotlin/blur/Bloom.kt b/orx-fx/src/main/kotlin/blur/Bloom.kt index e83e3340..56c448e6 100644 --- a/orx-fx/src/main/kotlin/blur/Bloom.kt +++ b/orx-fx/src/main/kotlin/blur/Bloom.kt @@ -3,8 +3,11 @@ package org.openrndr.extra.fx.blur import org.openrndr.draw.* import org.openrndr.extra.fx.blend.Add import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter +import org.openrndr.extra.parameters.IntParameter - +@Description("Bloom") class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("blur/bloom.frag"))) { /** * the blur filter to use for the bloom, default is Approximate Gaussian Blur @@ -14,21 +17,25 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(Shader.createFrom /** * number of downsampled textures to use, default value is 2 */ + @IntParameter("blur iterations", 1, 8) var downsamples: Int = 2 /** * rate of downsampling, f.ex: 4 -> 4x, 8x, 16x.., default value is 2 */ + @IntParameter("downsamping rate", 1, 4) var downsampleRate: Int = 2 /** * blending amount between original image and blurred, default value is 0.5 */ + @DoubleParameter("blend factor", 0.0, 1.0) var blendFactor: Double by parameters /** * brightness of the resulting image, default value is 0.5 */ + @DoubleParameter("brightness", 0.0, 1.0) var brightness: Double by parameters init { @@ -62,7 +69,6 @@ class Bloom(blur: Filter = ApproximateGaussianBlur()) : Filter(Shader.createFrom blur.apply(src, bufferA) } - for ((index, buffers) in samplers.asReversed().withIndex()) { val (bufferCurrA) = buffers diff --git a/orx-fx/src/main/kotlin/blur/BoxBlur.kt b/orx-fx/src/main/kotlin/blur/BoxBlur.kt index 54106104..2d37a07e 100644 --- a/orx-fx/src/main/kotlin/blur/BoxBlur.kt +++ b/orx-fx/src/main/kotlin/blur/BoxBlur.kt @@ -2,12 +2,16 @@ package org.openrndr.extra.fx.blur import org.openrndr.draw.* import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter +import org.openrndr.extra.parameters.IntParameter import org.openrndr.math.Vector2 /** * BoxBlur implemented as a separable filter */ +@Description("Box-blur") class BoxBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blur/box-blur.frag"))) { @@ -16,16 +20,19 @@ class BoxBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, /** * The sample window, default is 5 */ + @IntParameter("window size", 1, 25) var window: Int by parameters /** * Spread multiplier, default is 1.0 */ + @DoubleParameter("kernel spread", 1.0, 4.0) var spread: Double by parameters /** * Post-blur gain, default is 1.0 */ + @DoubleParameter("gain", 0.0, 4.0) var gain: Double by parameters private var intermediateCache = mutableMapOf() diff --git a/orx-fx/src/main/kotlin/blur/GaussianBlur.kt b/orx-fx/src/main/kotlin/blur/GaussianBlur.kt index 78ab7e8b..05969265 100644 --- a/orx-fx/src/main/kotlin/blur/GaussianBlur.kt +++ b/orx-fx/src/main/kotlin/blur/GaussianBlur.kt @@ -1,33 +1,41 @@ package org.openrndr.extra.fx.blur +import jdk.jfr.Description import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.DoubleParameter +import org.openrndr.extra.parameters.IntParameter /** * Exact Gaussian blur, implemented as a single pass filter */ +@Description("Gaussian blur") class GaussianBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blur/gaussian-blur.frag"))) { /** * The sample window, default value is 5 */ + @IntParameter("window size", 1, 25) var window: Int by parameters /** * Spread multiplier, default value is 1.0 */ + @DoubleParameter("kernel spread", 1.0, 4.0) var spread: Double by parameters /** * Blur kernel sigma, default value is 1.0 */ + @DoubleParameter("kernel sigma", 0.0, 25.0) var sigma: Double by parameters /** * Post-blur gain, default value is 1.0 */ + @DoubleParameter("gain", 0.0, 4.0) var gain: Double by parameters init { diff --git a/orx-fx/src/main/kotlin/blur/HashBlur.kt b/orx-fx/src/main/kotlin/blur/HashBlur.kt index 7aa48d1d..bdb7826b 100644 --- a/orx-fx/src/main/kotlin/blur/HashBlur.kt +++ b/orx-fx/src/main/kotlin/blur/HashBlur.kt @@ -1,14 +1,19 @@ package org.openrndr.extra.fx.blur +import jdk.jfr.Description import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.DoubleParameter +import org.openrndr.extra.parameters.IntParameter +@Description("Hash blur") class HashBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blur/hash-blur.frag"))) { /** * Blur radius in pixels, default is 5.0 */ + @DoubleParameter("blur radius", 1.0, 25.0) var radius: Double by parameters /** @@ -19,11 +24,13 @@ class HashBlur : Filter(Shader.createFromCode(Filter.filterVertexCode, /** * 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 { diff --git a/orx-fx/src/main/kotlin/color/ChromaticAberration.kt b/orx-fx/src/main/kotlin/color/ChromaticAberration.kt index d6544020..901b0875 100644 --- a/orx-fx/src/main/kotlin/color/ChromaticAberration.kt +++ b/orx-fx/src/main/kotlin/color/ChromaticAberration.kt @@ -2,16 +2,19 @@ package org.openrndr.extra.fx.color import org.openrndr.draw.* import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter import org.openrndr.math.Vector2 import org.openrndr.resourceUrl +@Description("Chromatic Aberration") class ChromaticAberration : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/chromatic-aberration.frag"))){ /** - * aberration factor, default value is 1.0 + * aberration factor, default value is 8.0 */ + @DoubleParameter("aberration factor", 0.0, 16.0) var aberrationFactor: Double by parameters - init { aberrationFactor = 8.0 } diff --git a/orx-fx/src/main/kotlin/color/ColorMix.kt b/orx-fx/src/main/kotlin/color/ColorMix.kt index 2e2cf451..2c80c288 100644 --- a/orx-fx/src/main/kotlin/color/ColorMix.kt +++ b/orx-fx/src/main/kotlin/color/ColorMix.kt @@ -4,6 +4,4 @@ import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode -class ColorMix : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-mix.frag"))) { - -} \ No newline at end of file +class ColorMix : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-mix.frag"))) \ No newline at end of file diff --git a/orx-fx/src/main/kotlin/grain/FilmGrain.kt b/orx-fx/src/main/kotlin/grain/FilmGrain.kt index 7811662b..355423b1 100644 --- a/orx-fx/src/main/kotlin/grain/FilmGrain.kt +++ b/orx-fx/src/main/kotlin/grain/FilmGrain.kt @@ -1,17 +1,34 @@ import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.BooleanParameter +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter /** * Film grain filter */ +@Description("film grain") class FilmGrain : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("grain/film-grain.frag"))) { + + @BooleanParameter("use color") var useColor: Boolean by parameters + var time: Double by parameters; + + @DoubleParameter("grain lift ratio", 0.0, 1.0) var grainLiftRatio: Double by parameters + + @DoubleParameter("grain strength", 0.0, 1.0) var grainStrength: Double by parameters + + @DoubleParameter("grain rate", 0.0, 1.0) var grainRate: Double by parameters + + @DoubleParameter("grain pitch", 0.0, 1.0) var grainPitch: Double by parameters + + @DoubleParameter("color level", 0.0, 1.0) var colorLevel: Double by parameters init { diff --git a/orx-fx/src/main/kotlin/tonemap/Uncharted2Tonemap.kt b/orx-fx/src/main/kotlin/tonemap/Uncharted2Tonemap.kt index 36d81962..6f9a667f 100644 --- a/orx-fx/src/main/kotlin/tonemap/Uncharted2Tonemap.kt +++ b/orx-fx/src/main/kotlin/tonemap/Uncharted2Tonemap.kt @@ -3,12 +3,17 @@ package org.openrndr.extra.fx.tonemap import org.openrndr.draw.Filter import org.openrndr.draw.Shader import org.openrndr.extra.fx.filterFragmentCode +import org.openrndr.extra.parameters.Description +import org.openrndr.extra.parameters.DoubleParameter /** * Uncharted 2 tonemap filter */ +@Description("Uncharted 2 tonemap") class Uncharted2Tonemap : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("tonemap/uncharted2-tonemap.frag"))) { - var exposureBias by parameters + + @DoubleParameter("exposure bias", 0.0, 128.0) + var exposureBias:Double by parameters init { exposureBias = 2.0 }