Add parameter annotations to most orx-fx filters

This commit is contained in:
Edwin Jakobs
2020-02-02 11:13:38 +01:00
parent 396f859d6a
commit adf4dc33c3
10 changed files with 74 additions and 10 deletions

View File

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

View File

@@ -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<ColorBufferDescription, ColorBuffer>()

View File

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

View File

@@ -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<ApproximateGaussianBlur.ColorBufferDescription, ColorBuffer>()

View File

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

View File

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

View File

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

View File

@@ -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"))) {
}
class ColorMix : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-mix.frag")))

View File

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

View File

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