[orx-fx] convert to MPP
This commit is contained in:
13
orx-fx/src/commonMain/kotlin/FilterTools.kt
Normal file
13
orx-fx/src/commonMain/kotlin/FilterTools.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.openrndr.extra.fx
|
||||
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.draw.filterShaderFromCode
|
||||
import org.openrndr.internal.Driver
|
||||
import org.openrndr.resourceUrl
|
||||
|
||||
fun mppFilterShader(code: String, name: String) : Shader =
|
||||
filterShaderFromCode("${Driver.instance.shaderConfiguration()}\n${code}", name)
|
||||
|
||||
internal data class ColorBufferDescription(val width: Int, val height: Int, val contentScale: Double, val format: ColorFormat, val type: ColorType)
|
||||
44
orx-fx/src/commonMain/kotlin/antialias/FXAA.kt
Normal file
44
orx-fx/src/commonMain/kotlin/antialias/FXAA.kt
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.openrndr.extra.fx.antialias
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_fxaa
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
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( mppFilterShader(fx_fxaa, "fxaa")) {
|
||||
/**
|
||||
* 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 {
|
||||
lumaThreshold = 0.5
|
||||
maxSpan = 8.0
|
||||
directionReduceMinimum = 0.0
|
||||
directionReduceMultiplier = 0.0
|
||||
}
|
||||
}
|
||||
115
orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt
Normal file
115
orx-fx/src/commonMain/kotlin/blend/BlendFilters.kt
Normal file
@@ -0,0 +1,115 @@
|
||||
package org.openrndr.extra.fx.blend
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.*
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
|
||||
class ColorBurn : Filter(mppFilterShader(fx_color_burn, "color-burn")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class ColorDodge : Filter(mppFilterShader(fx_color_dodge, "color-dodge")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Darken : Filter(mppFilterShader(fx_darken, "darken")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class HardLight : Filter(mppFilterShader(fx_hard_light, "hard-light")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Lighten : Filter(mppFilterShader(fx_lighten, "lighten")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Multiply : Filter(mppFilterShader(fx_multiply,"multiply")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Normal : Filter(mppFilterShader(fx_normal, "normal")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Overlay : Filter(mppFilterShader(fx_overlay, "overlay")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
class Screen : Filter(mppFilterShader(fx_screen, "screen")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 MultiplyContrast : Filter(mppFilterShader(fx_multiply_contrast, "multiply-contrast"))
|
||||
|
||||
class Passthrough : Filter(mppFilterShader(fx_passthrough, "passthrough"))
|
||||
class Add : Filter(mppFilterShader(fx_add, "add")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
class Subtract : Filter(mppFilterShader(fx_subtract,"subtract")) {
|
||||
@BooleanParameter("source clip")
|
||||
var clip: Boolean by parameters
|
||||
|
||||
init {
|
||||
clip = false
|
||||
}
|
||||
}
|
||||
65
orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt
Normal file
65
orx-fx/src/commonMain/kotlin/blur/ApproximateGaussianBlur.kt
Normal file
@@ -0,0 +1,65 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.ColorBufferDescription
|
||||
import org.openrndr.extra.fx.fx_approximate_gaussian_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
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(mppFilterShader(fx_approximate_gaussian_blur, "approximate gaussian blur")) {
|
||||
/**
|
||||
* 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>()
|
||||
|
||||
init {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
sigma = 1.0
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
val intermediate = intermediateCache.getOrPut(intermediateDescription) {
|
||||
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate.let {
|
||||
parameters["blurDirection"] = Vector2(1.0, 0.0)
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
parameters["blurDirection"] = Vector2(0.0, 1.0)
|
||||
super.apply(arrayOf(it), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
86
orx-fx/src/commonMain/kotlin/blur/Bloom.kt
Normal file
86
orx-fx/src/commonMain/kotlin/blur/Bloom.kt
Normal file
@@ -0,0 +1,86 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.blend.Add
|
||||
import org.openrndr.extra.fx.fx_bloom
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
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(mppFilterShader(fx_bloom, "bloom")) {
|
||||
/**
|
||||
* the blur filter to use for the bloom, default is Approximate Gaussian Blur
|
||||
*/
|
||||
var blur: Filter = blur
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
blendFactor = 0.5
|
||||
brightness = 0.5
|
||||
}
|
||||
|
||||
private val samplers: MutableList<Pair<ColorBuffer, ColorBuffer>> = mutableListOf()
|
||||
private var lastDownsampleRate = 0
|
||||
|
||||
private val blendAdd = Add()
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
val src = source[0]
|
||||
val dest = target[0]
|
||||
|
||||
if (samplers.isEmpty() || samplers.size != downsamples || lastDownsampleRate != downsampleRate) {
|
||||
samplers.clear()
|
||||
|
||||
lastDownsampleRate = downsampleRate
|
||||
|
||||
for (downsample in 0 until downsamples) {
|
||||
val div = 1 shl downsample
|
||||
val bufferA = colorBuffer(dest.width / div, dest.height / div, 1.0, target[0].format, ColorType.FLOAT16)
|
||||
val bufferB = colorBuffer(dest.width / div, dest.height / div, 1.0, target[0].format, ColorType.FLOAT16)
|
||||
samplers.add(Pair(bufferA, bufferB))
|
||||
}
|
||||
}
|
||||
|
||||
for ((bufferA, _) in samplers) {
|
||||
blur.apply(src, bufferA)
|
||||
}
|
||||
|
||||
for ((index, buffers) in samplers.asReversed().withIndex()) {
|
||||
val (bufferCurrA) = buffers
|
||||
|
||||
if (index + 1 <= samplers.lastIndex) {
|
||||
val (bufferNextA, bufferNextB) = samplers.asReversed()[index + 1]
|
||||
|
||||
blur.apply(bufferCurrA, bufferNextB)
|
||||
blendAdd.apply(arrayOf(bufferNextA, bufferNextB), bufferNextA)
|
||||
} else {
|
||||
super.apply(arrayOf(src, bufferCurrA), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt
Normal file
60
orx-fx/src/commonMain/kotlin/blur/BoxBlur.kt
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_box_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
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(mppFilterShader(fx_box_blur,"box-blur")) {
|
||||
|
||||
data class ColorBufferDescription(val width: Int, val height: Int, val contentScale: Double, val format: ColorFormat, val type: ColorType)
|
||||
|
||||
/**
|
||||
* 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<ColorBufferDescription, ColorBuffer>()
|
||||
|
||||
init {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
val intermediateDescription = ColorBufferDescription(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
val intermediate = intermediateCache.getOrPut(intermediateDescription) {
|
||||
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate.let {
|
||||
parameters["blurDirection"] = Vector2(1.0, 0.0)
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
parameters["blurDirection"] = Vector2(0.0, 1.0)
|
||||
super.apply(arrayOf(it), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
41
orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt
Normal file
41
orx-fx/src/commonMain/kotlin/blur/FrameBlur.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_frame_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Frame blur")
|
||||
class FrameBlur : Filter(mppFilterShader(fx_frame_blur, "frame-blur")) {
|
||||
|
||||
@DoubleParameter("blend", 0.0, 1.0)
|
||||
var blend: Double by parameters
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
|
||||
init {
|
||||
blend = 0.5
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (target.isNotEmpty()) {
|
||||
intermediate?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
it.destroy()
|
||||
intermediate = null
|
||||
}
|
||||
}
|
||||
|
||||
if (intermediate == null) {
|
||||
intermediate = colorBuffer(target[0].width, target[0].height, type = ColorType.FLOAT16)
|
||||
//intermediate?.fill(ColorRGBa.TRANSPARENT)
|
||||
TODO("no mpp colorbuffer.fill")
|
||||
}
|
||||
|
||||
super.apply(arrayOf(source[0], intermediate!!), arrayOf(intermediate!!))
|
||||
intermediate!!.copyTo(target[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
47
orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt
Normal file
47
orx-fx/src/commonMain/kotlin/blur/GaussianBlur.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_gaussian_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
|
||||
import org.openrndr.extra.parameters.Description
|
||||
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(mppFilterShader(fx_gaussian_blur,"gaussian-blur")) {
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
sigma = 1.0
|
||||
gain = 1.0
|
||||
}
|
||||
}
|
||||
41
orx-fx/src/commonMain/kotlin/blur/HashBlur.kt
Normal file
41
orx-fx/src/commonMain/kotlin/blur/HashBlur.kt
Normal file
@@ -0,0 +1,41 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_hash_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
@Description("Hash blur")
|
||||
class HashBlur : Filter(mppFilterShader(fx_hash_blur, "hash-blur")) {
|
||||
/**
|
||||
* 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 {
|
||||
radius = 5.0
|
||||
time = 0.0
|
||||
samples = 30
|
||||
gain = 1.0
|
||||
}
|
||||
}
|
||||
119
orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt
Normal file
119
orx-fx/src/commonMain/kotlin/blur/LaserBlur.kt
Normal file
@@ -0,0 +1,119 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_laser_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.*
|
||||
import org.openrndr.math.Vector2
|
||||
import kotlin.math.pow
|
||||
|
||||
private class LaserBlurPass : Filter(mppFilterShader(fx_laser_blur, "laser-blur")) {
|
||||
var radius: Double by parameters
|
||||
var amp0: Double by parameters
|
||||
var amp1: Double by parameters
|
||||
var center: Vector2 by parameters
|
||||
var vignette: Double by parameters
|
||||
var vignetteSize: Double by parameters
|
||||
var aberration: Double by parameters
|
||||
var linearInput: Boolean by parameters
|
||||
var linearOutput: Boolean by parameters
|
||||
|
||||
init {
|
||||
radius = 0.0
|
||||
amp0 = 1.0
|
||||
amp1 = 1.0
|
||||
center = Vector2.ZERO
|
||||
vignette = 0.0
|
||||
vignetteSize = 1.0
|
||||
aberration = 0.0
|
||||
linearInput = false
|
||||
linearOutput = false
|
||||
}
|
||||
}
|
||||
|
||||
@Description("Laser blur")
|
||||
class LaserBlur : Filter() {
|
||||
@Vector2Parameter("center", order = 0)
|
||||
var center = Vector2.ZERO
|
||||
|
||||
@DoubleParameter("radius", -2.0, 2.0, order = 1)
|
||||
var radius = -0.18
|
||||
|
||||
@DoubleParameter("amp0", 0.0, 1.0, order = 2)
|
||||
var amp0 = 0.5
|
||||
|
||||
@DoubleParameter("amp1", 0.0, 1.0, order = 3)
|
||||
var amp1 = 0.5
|
||||
|
||||
@DoubleParameter("vignette", 0.0, 1.0, order = 4)
|
||||
var vignette = 0.0
|
||||
|
||||
@DoubleParameter("vignette size", 0.0, 1.0, order = 5)
|
||||
var vignetteSize = 0.0
|
||||
|
||||
@DoubleParameter("aberration", -1.0, 1.0, order = 6)
|
||||
var aberration = 0.006
|
||||
|
||||
@DoubleParameter("exp", -1.0, 1.0, order = 7)
|
||||
var exp = 0.739
|
||||
|
||||
@BooleanParameter("linear input", order = 8)
|
||||
var linearInput = false
|
||||
|
||||
@BooleanParameter("linear output", order = 9)
|
||||
var linearOutput = false
|
||||
|
||||
@DoubleParameter("phase", -1.0, 1.0, order = 7)
|
||||
var phase = 0.0
|
||||
|
||||
|
||||
private val pass = LaserBlurPass()
|
||||
|
||||
@IntParameter("passes", 2, 32, order = 4)
|
||||
var passes = 15
|
||||
|
||||
val intermediates = mutableListOf<ColorBuffer>()
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
|
||||
pass.center = center
|
||||
pass.radius = radius
|
||||
pass.amp0 = amp0
|
||||
pass.amp1 = amp1
|
||||
pass.vignette = vignette
|
||||
pass.vignetteSize = vignetteSize
|
||||
pass.aberration = aberration
|
||||
|
||||
if ((!intermediates.all { it.isEquivalentTo(source[0], ignoreFormat = true, ignoreType = true) })) {
|
||||
intermediates.forEach {
|
||||
it.destroy()
|
||||
}
|
||||
intermediates.clear()
|
||||
}
|
||||
if (intermediates.size == 0) {
|
||||
intermediates.add(source[0].createEquivalent(type = ColorType.FLOAT16))
|
||||
intermediates.add(source[0].createEquivalent(type = ColorType.FLOAT16))
|
||||
}
|
||||
|
||||
pass.radius = 1.0 + pow(exp, 0.0) * radius
|
||||
|
||||
pass.linearInput = linearInput
|
||||
pass.linearOutput = true
|
||||
pass.apply(source[0], intermediates[0])
|
||||
for (i in 0 until passes - 1) {
|
||||
pass.linearInput = true
|
||||
pass.linearOutput = true
|
||||
|
||||
pass.radius = 1.0 + pow(exp, i + 1.0) * radius //(1.0 + simplex(0, phase + i)) / 2.0
|
||||
pass.apply(intermediates[i % 2], intermediates[(i + 1) % 2])
|
||||
}
|
||||
pass.radius = 1.0 + pow(exp, (passes) * 1.0) * radius
|
||||
pass.linearInput = true
|
||||
pass.linearOutput = linearOutput
|
||||
pass.apply(intermediates[(passes + 1) % 2], target[0])
|
||||
}
|
||||
}
|
||||
|
||||
private fun pow(a: Double, x: Double): Double {
|
||||
return a.pow(x)
|
||||
}
|
||||
165
orx-fx/src/commonMain/kotlin/blur/MipBloom.kt
Normal file
165
orx-fx/src/commonMain/kotlin/blur/MipBloom.kt
Normal file
@@ -0,0 +1,165 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_bloom_combine
|
||||
import org.openrndr.extra.fx.fx_bloom_downscale
|
||||
import org.openrndr.extra.fx.fx_bloom_upscale
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
import org.openrndr.filter.color.delinearize
|
||||
import org.openrndr.filter.color.linearize
|
||||
|
||||
class BloomDownscale : Filter(mppFilterShader(fx_bloom_downscale,"bloom-downscale"))
|
||||
|
||||
class BloomUpscale : Filter(mppFilterShader(fx_bloom_upscale, "bloom-upscale")) {
|
||||
var gain: Double by parameters
|
||||
var shape: Double by parameters
|
||||
var noiseSeed: Double by parameters
|
||||
var noiseGain: Double by parameters
|
||||
|
||||
init {
|
||||
gain = 1.0
|
||||
shape = 1.0
|
||||
noiseSeed = 1.0
|
||||
noiseGain = 0.25
|
||||
}
|
||||
}
|
||||
|
||||
class BloomCombine : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine")) {
|
||||
var gain: Double by parameters
|
||||
var bias: ColorRGBa by parameters
|
||||
|
||||
init {
|
||||
bias = ColorRGBa.BLACK
|
||||
gain = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
@Description("MipBloom")
|
||||
open class MipBloom<T : Filter>(val blur: T) : Filter(mppFilterShader(fx_bloom_combine, "bloom-combine")) {
|
||||
var passes = 6
|
||||
|
||||
@DoubleParameter("shape", 0.0, 4.0)
|
||||
var shape: Double = 1.0
|
||||
|
||||
@DoubleParameter("gain", 0.0, 4.0)
|
||||
var gain: Double = 1.0
|
||||
|
||||
/**
|
||||
* noise gain. low noise gains will result in visible banding of the image. default value is 0.25
|
||||
*/
|
||||
@DoubleParameter("noise gain", 0.0, 1.0)
|
||||
var noiseGain: Double = 0.25
|
||||
|
||||
@DoubleParameter("noise seed", 0.0, 1000.0)
|
||||
var noiseSeed: Double = 0.0
|
||||
|
||||
@BooleanParameter("sRGB")
|
||||
var sRGB = true
|
||||
|
||||
var intermediates = mutableListOf<ColorBuffer>()
|
||||
var sourceCopy: ColorBuffer? = null
|
||||
|
||||
val upscale = BloomUpscale()
|
||||
val downScale = BloomDownscale()
|
||||
val combine = BloomCombine()
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
sourceCopy?.let {
|
||||
if (!it.isEquivalentTo(source[0], ignoreType = true)) {
|
||||
it.destroy()
|
||||
sourceCopy = null
|
||||
}
|
||||
}
|
||||
if (sourceCopy == null) {
|
||||
sourceCopy = source[0].createEquivalent(type = ColorType.FLOAT16)
|
||||
}
|
||||
|
||||
source[0].copyTo(sourceCopy!!)
|
||||
|
||||
upscale.shape = shape
|
||||
if (intermediates.size != passes
|
||||
|| (intermediates.isNotEmpty() && (!intermediates[0].isEquivalentTo(target[0], ignoreType = true, ignoreFormat = true)))) {
|
||||
intermediates.forEach {
|
||||
it.destroy()
|
||||
}
|
||||
intermediates.clear()
|
||||
|
||||
for (pass in 0 until passes) {
|
||||
val tdiv = 1 shl (pass + 1)
|
||||
val cb = colorBuffer(target[0].width / tdiv, target[0].height / tdiv, type = ColorType.FLOAT16)
|
||||
intermediates.add(cb)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (sRGB) {
|
||||
linearize.apply(sourceCopy!!, sourceCopy!!)
|
||||
}
|
||||
|
||||
upscale.noiseGain = noiseGain
|
||||
upscale.noiseSeed = noiseSeed
|
||||
downScale.apply(sourceCopy!!, intermediates[0])
|
||||
blur.apply(intermediates[0], intermediates[0])
|
||||
|
||||
for (pass in 1 until passes) {
|
||||
downScale.apply(intermediates[pass - 1], intermediates[pass])
|
||||
blur.apply(intermediates[pass], intermediates[pass])
|
||||
}
|
||||
|
||||
upscale.apply(intermediates.toTypedArray(), arrayOf(target[0]))
|
||||
combine.gain = gain
|
||||
combine.apply(arrayOf(sourceCopy!!, target[0]), target)
|
||||
|
||||
if (sRGB) {
|
||||
delinearize.apply(target[0], target[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Description("Hash bloom")
|
||||
class HashBloom : MipBloom<HashBlur>(blur = HashBlur()) {
|
||||
|
||||
/**
|
||||
* Blur radius in pixels, default is 5.0
|
||||
*/
|
||||
@DoubleParameter("blur radius", 1.0, 25.0)
|
||||
var radius: Double = 5.0
|
||||
|
||||
/**
|
||||
* Number of samples, default is 30
|
||||
*/
|
||||
@IntParameter("number of samples", 1, 100)
|
||||
var samples: Int = 30
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
blur.radius = radius
|
||||
blur.samples = samples
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Description("Gaussian bloom")
|
||||
class GaussianBloom : MipBloom<GaussianBlur>(blur = GaussianBlur()) {
|
||||
/**
|
||||
* blur sample window, default value is 5
|
||||
*/
|
||||
@IntParameter("window size", 1, 25)
|
||||
var window: Int = 5
|
||||
|
||||
/**
|
||||
* blur sigma, default value is 1.0
|
||||
*/
|
||||
@DoubleParameter("kernel sigma", 0.0, 25.0)
|
||||
var sigma: Double = 1.0
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
blur.window = window
|
||||
blur.sigma = sigma
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
44
orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt
Normal file
44
orx-fx/src/commonMain/kotlin/blur/ZoomBlur.kt
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_zoom_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
@Description("Zoom Blur")
|
||||
class ZoomBlur : Filter(mppFilterShader(fx_zoom_blur, "zoom-blur")) {
|
||||
var center: Vector2 by parameters
|
||||
|
||||
@DoubleParameter("strength", 0.0, 1.0)
|
||||
var strength: Double by parameters
|
||||
|
||||
init {
|
||||
center = Vector2.ONE / 2.0
|
||||
strength = 0.2
|
||||
}
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
intermediate?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate = null
|
||||
}
|
||||
}
|
||||
|
||||
if (intermediate == null) {
|
||||
intermediate =
|
||||
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate?.let {
|
||||
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
|
||||
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
it.copyTo(target[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
43
orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt
Normal file
43
orx-fx/src/commonMain/kotlin/color/ChromaticAberration.kt
Normal file
@@ -0,0 +1,43 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_chromatic_aberration
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
@Description("Chromatic Aberration")
|
||||
class ChromaticAberration : Filter(mppFilterShader(fx_chromatic_aberration, "chromatic-aberration")) {
|
||||
/**
|
||||
* aberration factor, default value is 8.0
|
||||
*/
|
||||
@DoubleParameter("aberration factor", 0.0, 16.0)
|
||||
var aberrationFactor: Double by parameters
|
||||
|
||||
init {
|
||||
aberrationFactor = 8.0
|
||||
}
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
intermediate?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate = null
|
||||
}
|
||||
}
|
||||
|
||||
if (intermediate == null) {
|
||||
intermediate = colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate?.let {
|
||||
parameters["dimensions"] = Vector2(it.effectiveWidth.toDouble(), it.effectiveHeight.toDouble())
|
||||
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
it.copyTo(target[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
42
orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt
Normal file
42
orx-fx/src/commonMain/kotlin/color/ColorCorrection.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_color_correction
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Color correction")
|
||||
class ColorCorrection : Filter(mppFilterShader(fx_color_correction, "color-correction")) {
|
||||
@DoubleParameter("brightness", -1.0, 1.0, order = 0)
|
||||
var brightness: Double by parameters
|
||||
|
||||
@DoubleParameter("contrast", -1.0, 1.0, order = 1)
|
||||
var contrast: Double by parameters
|
||||
|
||||
@DoubleParameter("saturation", -1.0, 1.0, order = 2)
|
||||
var saturation: Double by parameters
|
||||
|
||||
@DoubleParameter("hue shift", -180.0, 180.0, order = 3)
|
||||
var hueShift: Double by parameters
|
||||
|
||||
@DoubleParameter("gamma", 0.0, 5.0, order = 4)
|
||||
var gamma: Double by parameters
|
||||
|
||||
@DoubleParameter("opacity", 0.0, 1.0, order = 5)
|
||||
var opacity: Double by parameters
|
||||
|
||||
@BooleanParameter("clamp", order = 6)
|
||||
var clamped: Boolean by parameters
|
||||
|
||||
init {
|
||||
contrast = 0.0
|
||||
brightness = 0.0
|
||||
saturation = 0.0
|
||||
hueShift = 0.0
|
||||
gamma = 1.0
|
||||
opacity = 1.0
|
||||
clamped = true
|
||||
}
|
||||
}
|
||||
31
orx-fx/src/commonMain/kotlin/color/ColorLookup.kt
Normal file
31
orx-fx/src/commonMain/kotlin/color/ColorLookup.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
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")) {
|
||||
/** a color look-up texture */
|
||||
var lookup: ColorBuffer by parameters
|
||||
|
||||
/**
|
||||
* noise gain in look-up, default value is 0.0
|
||||
*/
|
||||
var noiseGain: Double by parameters
|
||||
|
||||
/**
|
||||
* noise seed, default value is 0.0
|
||||
*/
|
||||
var seed: Double by parameters
|
||||
|
||||
init {
|
||||
this.lookup = lookup
|
||||
this.noiseGain = 0.0
|
||||
this.seed = 0.0
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
lookup.filter(MinifyingFilter.LINEAR, MagnifyingFilter.LINEAR)
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
21
orx-fx/src/commonMain/kotlin/color/ColorMix.kt
Normal file
21
orx-fx/src/commonMain/kotlin/color/ColorMix.kt
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
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"))
|
||||
|
||||
@Description("Tint")
|
||||
class ColorTint : Filter(mppFilterShader(fx_color_tint, "color-tint")) {
|
||||
@ColorParameter("tint")
|
||||
var tint: ColorRGBa by parameters
|
||||
|
||||
init {
|
||||
tint = ColorRGBa.PINK
|
||||
}
|
||||
}
|
||||
9
orx-fx/src/commonMain/kotlin/color/Colorspaces.kt
Normal file
9
orx-fx/src/commonMain/kotlin/color/Colorspaces.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_rgb_to_ycbcr
|
||||
import org.openrndr.extra.fx.fx_ycbcr_to_rgb
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
|
||||
class RgbToYCbcr : Filter(mppFilterShader(fx_rgb_to_ycbcr, "rgb-to-ycbcr"))
|
||||
class YcbcrToRgb : Filter(mppFilterShader(fx_ycbcr_to_rgb, "ycbcr_to_rgb"))
|
||||
31
orx-fx/src/commonMain/kotlin/color/LumaMap.kt
Normal file
31
orx-fx/src/commonMain/kotlin/color/LumaMap.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_luma_map
|
||||
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 map ")
|
||||
class LumaMap : Filter(mppFilterShader(fx_luma_map, "luma-map")) {
|
||||
@ColorParameter("foreground color")
|
||||
var foreground: ColorRGBa by parameters
|
||||
|
||||
@ColorParameter("background color")
|
||||
var background: ColorRGBa by parameters
|
||||
|
||||
@DoubleParameter("background opacity", 0.0, 1.0)
|
||||
var backgroundOpacity: Double by parameters
|
||||
|
||||
@DoubleParameter("foreground opacity", 0.0, 1.0)
|
||||
var foregroundOpacity: Double by parameters
|
||||
|
||||
init {
|
||||
foreground = ColorRGBa.WHITE
|
||||
background = ColorRGBa.BLACK
|
||||
foregroundOpacity = 1.0
|
||||
backgroundOpacity = 1.0
|
||||
}
|
||||
}
|
||||
29
orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt
Normal file
29
orx-fx/src/commonMain/kotlin/color/LumaOpacity.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@DoubleParameter("foreground luma",0.0, 1.0)
|
||||
var foregroundLuma: Double by parameters
|
||||
|
||||
@DoubleParameter("background luma", 0.0,1.0)
|
||||
var backgroundLuma: Double by parameters
|
||||
|
||||
@DoubleParameter("background opacity", 0.0, 1.0, order = 0)
|
||||
var backgroundOpacity: Double by parameters
|
||||
|
||||
@DoubleParameter("foreground opacity", 0.0, 1.0, order = 1)
|
||||
var foregroundOpacity: Double by parameters
|
||||
|
||||
init {
|
||||
foregroundLuma = 1.0
|
||||
backgroundLuma = 0.0
|
||||
foregroundOpacity = 1.0
|
||||
backgroundOpacity = 0.0
|
||||
}
|
||||
}
|
||||
35
orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt
Normal file
35
orx-fx/src/commonMain/kotlin/color/LumaThreshold.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_luma_threshold
|
||||
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 threshold ")
|
||||
class LumaThreshold : Filter(mppFilterShader(fx_luma_threshold, "luma-threshold")) {
|
||||
@DoubleParameter("threshold value", 0.0, 1.0)
|
||||
var threshold: Double by parameters
|
||||
|
||||
@ColorParameter("foreground color")
|
||||
var foreground: ColorRGBa by parameters
|
||||
|
||||
@ColorParameter("background color")
|
||||
var background: ColorRGBa by parameters
|
||||
|
||||
@DoubleParameter("background opacity", 0.0, 1.0)
|
||||
var backgroundOpacity: Double by parameters
|
||||
|
||||
@DoubleParameter("foreground opacity", 0.0, 1.0)
|
||||
var foregroundOpacity: Double by parameters
|
||||
|
||||
init {
|
||||
threshold = 0.5
|
||||
foreground = ColorRGBa.WHITE
|
||||
background = ColorRGBa.BLACK
|
||||
foregroundOpacity = 1.0
|
||||
backgroundOpacity = 1.0
|
||||
}
|
||||
}
|
||||
25
orx-fx/src/commonMain/kotlin/color/Pal.kt
Normal file
25
orx-fx/src/commonMain/kotlin/color/Pal.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@DoubleParameter("amount", 0.0, 1.0)
|
||||
var amount: Double by parameters
|
||||
@DoubleParameter("pixelation", 0.0, 1.0)
|
||||
var pixelation: Double by parameters
|
||||
@DoubleParameter("filter_gain", 0.0, 10.0)
|
||||
var filter_gain: Double by parameters
|
||||
@DoubleParameter("filter_invgain", 0.0, 10.0)
|
||||
var filter_invgain: Double by parameters
|
||||
init {
|
||||
amount = 1.0
|
||||
pixelation = 0.0
|
||||
filter_gain = 1.0
|
||||
filter_invgain = 1.6
|
||||
}
|
||||
}
|
||||
17
orx-fx/src/commonMain/kotlin/color/Sepia.kt
Normal file
17
orx-fx/src/commonMain/kotlin/color/Sepia.kt
Normal file
@@ -0,0 +1,17 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@DoubleParameter("amount", 0.0, 1.0)
|
||||
var amount: Double by parameters
|
||||
|
||||
init {
|
||||
amount = 0.5
|
||||
}
|
||||
}
|
||||
23
orx-fx/src/commonMain/kotlin/color/SetBackground.kt
Normal file
23
orx-fx/src/commonMain/kotlin/color/SetBackground.kt
Normal file
@@ -0,0 +1,23 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_set_background
|
||||
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("Set background")
|
||||
class SetBackground : Filter(mppFilterShader(fx_set_background, "set-background")) {
|
||||
@ColorParameter("background color")
|
||||
var background: ColorRGBa by parameters
|
||||
|
||||
@DoubleParameter("background opacity", 0.0, 1.0)
|
||||
var backgroundOpacity: Double by parameters
|
||||
|
||||
init {
|
||||
background = ColorRGBa.GRAY
|
||||
backgroundOpacity = 1.0
|
||||
}
|
||||
}
|
||||
14
orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt
Normal file
14
orx-fx/src/commonMain/kotlin/color/SubtractConstant.kt
Normal file
@@ -0,0 +1,14 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_subtract_constant
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
|
||||
class SubtractConstant : Filter(mppFilterShader(fx_subtract_constant, "subtract-constant")) {
|
||||
var constant: ColorRGBa by parameters
|
||||
|
||||
init {
|
||||
constant = ColorRGBa(1.0, 1.0, 1.0, 0.0)
|
||||
}
|
||||
}
|
||||
44
orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt
Normal file
44
orx-fx/src/commonMain/kotlin/distort/BlockRepeat.kt
Normal file
@@ -0,0 +1,44 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_block_repeat
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Block repeat")
|
||||
class BlockRepeat : Filter(mppFilterShader(fx_block_repeat, "block-repeat")) {
|
||||
@DoubleParameter("block width", 0.0, 1.0, order = 0)
|
||||
var blockWidth: Double by parameters
|
||||
|
||||
@DoubleParameter("block height", 0.0, 1.0, order = 1)
|
||||
var blockHeight: Double by parameters
|
||||
|
||||
@DoubleParameter("block x-offset", -0.5, 0.5, order = 2)
|
||||
var blockOffsetX: Double by parameters
|
||||
|
||||
@DoubleParameter("block y-offset", -0.5, 0.5, order = 3)
|
||||
var blockOffsetY: Double by parameters
|
||||
|
||||
/**
|
||||
* Source scale, 0.0 is a 1:1 mapping, 1.0 fits entire source image in block
|
||||
*/
|
||||
@DoubleParameter("source scale", 0.0, 1.0, order = 4)
|
||||
var sourceScale: Double by parameters
|
||||
|
||||
@DoubleParameter("source x-offset", -0.5, 0.5, order = 5)
|
||||
var sourceOffsetX: Double by parameters
|
||||
|
||||
@DoubleParameter("source y-offset", -.5, .5, order = 6)
|
||||
var sourceOffsetY: Double by parameters
|
||||
|
||||
init {
|
||||
blockWidth = 0.25
|
||||
blockHeight = 0.25
|
||||
blockOffsetX = 0.0
|
||||
blockOffsetY = 0.0
|
||||
sourceOffsetX = 0.0
|
||||
sourceOffsetY = 0.0
|
||||
sourceScale = 0.0
|
||||
}
|
||||
}
|
||||
58
orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt
Normal file
58
orx-fx/src/commonMain/kotlin/distort/DisplaceBlend.kt
Normal file
@@ -0,0 +1,58 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_displace_blend
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
@Description("Displace blend")
|
||||
class DisplaceBlend : Filter(mppFilterShader(fx_displace_blend, "displace-blend")) {
|
||||
var seed: Vector3 by parameters
|
||||
|
||||
@DoubleParameter("offset", -1.0, 1.0)
|
||||
var offset: Double by parameters
|
||||
|
||||
@DoubleParameter("gain", 0.0, 4.0)
|
||||
var gain: Double by parameters
|
||||
|
||||
@DoubleParameter("feather", 1.0, 100.0)
|
||||
var feather: Double by parameters
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0)
|
||||
var rotation: Double by parameters
|
||||
|
||||
@DoubleParameter("source opacity", 0.0, 1.0)
|
||||
var sourceOpacity: Double by parameters
|
||||
|
||||
@DoubleParameter("target opacity", 0.0, 1.0)
|
||||
var targetOpacity: Double by parameters
|
||||
|
||||
init {
|
||||
gain = 0.1
|
||||
offset = 0.5
|
||||
rotation = 0.0
|
||||
feather = 1.0
|
||||
sourceOpacity = 1.0
|
||||
targetOpacity = 1.0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
private var intermediate: ColorBuffer? = null
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (source.size >= 2) {
|
||||
if (target[0] === source[0] || target[0] === source[1]) {
|
||||
if (intermediate == null) {
|
||||
intermediate = colorBuffer(target[0].width, target[0].height, type = target[0].type, format = target[0].format)
|
||||
}
|
||||
}
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, arrayOf(intermediate ?: target[0]))
|
||||
intermediate?.copyTo(target[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
38
orx-fx/src/commonMain/kotlin/distort/Fisheye.kt
Normal file
38
orx-fx/src/commonMain/kotlin/distort/Fisheye.kt
Normal file
@@ -0,0 +1,38 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_fisheye
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Fisheye")
|
||||
class Fisheye : Filter(mppFilterShader(fx_fisheye, "fisheye")) {
|
||||
@DoubleParameter("strength", -1.0, 1.0, order = 0)
|
||||
var strength: Double by parameters
|
||||
|
||||
@DoubleParameter("scale", 0.0, 2.0, order = 0)
|
||||
var scale: Double by parameters
|
||||
|
||||
@DoubleParameter("feather", 0.0, 100.0, order = 1)
|
||||
var feather: Double by parameters
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0, order = 1)
|
||||
var rotation: Double by parameters
|
||||
|
||||
init {
|
||||
strength = 0.1
|
||||
feather = 1.0
|
||||
scale = 1.0
|
||||
rotation = 0.0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
68
orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt
Normal file
68
orx-fx/src/commonMain/kotlin/distort/FluidDistort.kt
Normal file
@@ -0,0 +1,68 @@
|
||||
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.extra.fx.fx_fluid_distort
|
||||
import org.openrndr.extra.fx.fx_uvmap
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import kotlin.math.cos
|
||||
|
||||
private class UVMap: Filter( mppFilterShader(fx_uvmap, "uvmap"))
|
||||
|
||||
private class FluidDistortFilter : Filter(mppFilterShader(fx_fluid_distort, "fluid-distort")) {
|
||||
var blend : Double by parameters
|
||||
var random: Double by parameters
|
||||
init {
|
||||
blend = 0.0
|
||||
random = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
class FluidDistort : Filter() {
|
||||
var blend: Double = 1.0
|
||||
|
||||
var outputUV = false
|
||||
|
||||
private val distort = FluidDistortFilter()
|
||||
private val uvmap = UVMap()
|
||||
|
||||
private var buffer0: ColorBuffer? = null
|
||||
private var buffer1: ColorBuffer? = null
|
||||
private var index = 0
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
|
||||
distort.blend = blend
|
||||
distort.random = cos(index*0.5)*0.5+0.5
|
||||
|
||||
buffer0?.let {
|
||||
if (!it.isEquivalentTo(target[0])) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
if (buffer0 == null) {
|
||||
buffer0 = target[0].createEquivalent()
|
||||
}
|
||||
|
||||
buffer1?.let {
|
||||
if (!it.isEquivalentTo(target[0])) {
|
||||
it.destroy()
|
||||
}
|
||||
}
|
||||
if (buffer1 == null) {
|
||||
buffer1 = target[0].createEquivalent()
|
||||
}
|
||||
val buffers = arrayOf(buffer0!!, buffer1!!)
|
||||
distort.apply(buffers[index%2], buffers[(index+1)%2])
|
||||
|
||||
if (!outputUV) {
|
||||
uvmap.apply(arrayOf(buffers[(index + 1) % 2], source[0]), target[0])
|
||||
} else {
|
||||
buffers[(index+1)%2].copyTo(target[0])
|
||||
}
|
||||
index++
|
||||
blend = 0.0
|
||||
}
|
||||
|
||||
}
|
||||
58
orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt
Normal file
58
orx-fx/src/commonMain/kotlin/distort/PerspectivePlane.kt
Normal file
@@ -0,0 +1,58 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_perspective_plane
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
|
||||
@Description("Perspective plane")
|
||||
class PerspectivePlane : Filter(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)
|
||||
var cameraY: Double = 0.0
|
||||
// @DoubleParameter("camera z", -1.0, 1.0, order = 2)
|
||||
var cameraZ: Double = 1.0
|
||||
|
||||
|
||||
@DoubleParameter("plane x", -1.0, 1.0, order = 3)
|
||||
var planeX: Double = 0.0
|
||||
@DoubleParameter("plane y", -1.0, 1.0, order = 4)
|
||||
var planeY: Double = 0.0
|
||||
@DoubleParameter("plane z", -1.0, 1.0, order = 5)
|
||||
var planeZ: Double = 0.5
|
||||
|
||||
@DoubleParameter("plane yaw", -180.0, 180.0, order = 6)
|
||||
var planeYaw: Double = 0.0
|
||||
@DoubleParameter("plane pitch", -180.0, 180.0, order = 7)
|
||||
var planePitch: Double = 0.0
|
||||
@DoubleParameter("plane roll", -180.0, 180.0, order = 8)
|
||||
var planeRoll: Double = 0.0
|
||||
|
||||
|
||||
@BooleanParameter("tile input")
|
||||
var tile: Boolean by parameters
|
||||
|
||||
init {
|
||||
tile = false
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
source[0].wrapU = WrapMode.REPEAT
|
||||
source[0].wrapV = WrapMode.REPEAT
|
||||
parameters["cameraPosition"] = Vector3(cameraX, cameraY, cameraZ)
|
||||
parameters["planePosition"] = Vector3(planeX, planeY, planeZ)
|
||||
parameters["planeMatrix"] = transform {
|
||||
rotate(Vector3.UNIT_X, planePitch)
|
||||
rotate(Vector3.UNIT_Y, planeYaw)
|
||||
rotate(Vector3.UNIT_Z, planeRoll)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
75
orx-fx/src/commonMain/kotlin/distort/Perturb.kt
Normal file
75
orx-fx/src/commonMain/kotlin/distort/Perturb.kt
Normal file
@@ -0,0 +1,75 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_perturb
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
@Description("Perturb")
|
||||
class Perturb : Filter(mppFilterShader(fx_perturb, "perturb")) {
|
||||
var seed: Vector3 by parameters
|
||||
/**
|
||||
* base noise scale, default is Vector3(1.0, 1.0, 1.0)
|
||||
*/
|
||||
@DoubleParameter("scale", 0.01, 8.0, order = 0)
|
||||
var scale: Double by parameters
|
||||
|
||||
@DoubleParameter("phase", -2.0, 2.0, order = 1)
|
||||
var phase: Double by parameters
|
||||
|
||||
/**
|
||||
* lacunarity is the amount by which scale is modulated per octave, default is Vector3(2.0, 2.0, 2.0)
|
||||
*/
|
||||
@DoubleParameter("lacunarity", 0.0, 1.0, order = 2)
|
||||
var lacunarity: Double by parameters
|
||||
|
||||
@DoubleParameter("gain", 0.0, 1.0, order = 3)
|
||||
var gain: Double by parameters
|
||||
|
||||
@DoubleParameter("decay", 0.0, 1.0, order = 4)
|
||||
var decay: Double by parameters
|
||||
|
||||
/**
|
||||
* the number of octaves of noise to generate, default is 4
|
||||
*/
|
||||
@IntParameter("octaves", 1, 10, order = 5)
|
||||
var octaves: Int by parameters
|
||||
|
||||
@IntParameter("x segments", 0, 256, order = 6)
|
||||
var xSegments: Int by parameters
|
||||
|
||||
@IntParameter("y segments", 0, 256, order = 7)
|
||||
var ySegments: Int by parameters
|
||||
|
||||
@BooleanParameter("output UV", order = 8)
|
||||
var outputUV: Boolean by parameters
|
||||
|
||||
@Vector2Parameter("offset", -1.0, 1.0, order = 9)
|
||||
var offset: Vector2 by parameters
|
||||
|
||||
|
||||
init {
|
||||
seed = Vector3.ZERO
|
||||
scale = 1.0
|
||||
lacunarity = 2.0
|
||||
gain = 0.5
|
||||
decay = 0.5
|
||||
octaves = 4
|
||||
phase = 0.0
|
||||
xSegments = 0
|
||||
ySegments = 0
|
||||
outputUV = false
|
||||
offset = Vector2.ZERO
|
||||
|
||||
}
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
51
orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt
Normal file
51
orx-fx/src/commonMain/kotlin/distort/StackRepeat.kt
Normal file
@@ -0,0 +1,51 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_stack_repeat
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
@Description("Stack repeat")
|
||||
class StackRepeat : Filter(mppFilterShader(fx_stack_repeat, "stack-repeat")) {
|
||||
@DoubleParameter("zoom", -1.0, 1.0, order = 0)
|
||||
var zoom: Double by parameters
|
||||
|
||||
@DoubleParameter("x-origin", -1.0, 1.0, order = 1)
|
||||
var xOrigin: Double by parameters
|
||||
|
||||
@DoubleParameter("y-origin", -1.0, 1.0, order = 2)
|
||||
var yOrigin: Double by parameters
|
||||
|
||||
@DoubleParameter("x-offset", -1.0, 1.0, order = 3)
|
||||
var xOffset: Double by parameters
|
||||
|
||||
@DoubleParameter("y-offset", -1.0, 1.0, order = 4)
|
||||
var yOffset: Double by parameters
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0, order = 5)
|
||||
var rotation: Double by parameters
|
||||
|
||||
@IntParameter("repeats", 0, 16, order = 6)
|
||||
var repeats: Int by parameters
|
||||
|
||||
init {
|
||||
zoom = 0.0
|
||||
repeats = 2
|
||||
xOffset = 0.0
|
||||
yOffset = 0.0
|
||||
xOrigin = 0.0
|
||||
yOrigin = 0.0
|
||||
rotation = 0.0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
42
orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt
Normal file
42
orx-fx/src/commonMain/kotlin/distort/StretchWaves.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_stretch_waves
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Stretch waves")
|
||||
class StretchWaves : Filter(mppFilterShader(fx_stretch_waves, "stretch-waves")) {
|
||||
@DoubleParameter("distortion", -0.0,1.0, 1)
|
||||
var distortion: Double by parameters
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0)
|
||||
var rotation: Double by parameters
|
||||
|
||||
@DoubleParameter("phase", -1.0, 1.0)
|
||||
var phase: Double by parameters
|
||||
|
||||
@DoubleParameter("frequency", 0.0, 100.0)
|
||||
var frequency: Double by parameters
|
||||
|
||||
@DoubleParameter("feather", 0.0, 100.0, order = 1)
|
||||
var feather: Double by parameters
|
||||
|
||||
init {
|
||||
distortion = 0.0
|
||||
rotation = 0.0
|
||||
phase = 0.0
|
||||
frequency = 10.0
|
||||
feather = 1.0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
55
orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt
Normal file
55
orx-fx/src/commonMain/kotlin/distort/TapeNoise.kt
Normal file
@@ -0,0 +1,55 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_tape_noise
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Tape noise")
|
||||
class TapeNoise : Filter(mppFilterShader(fx_tape_noise, "tape-noise")) {
|
||||
var time: Double by parameters
|
||||
|
||||
@DoubleParameter("gain", 0.0, 1.0)
|
||||
var gain: Double by parameters
|
||||
|
||||
@DoubleParameter("noise low", 0.0, 1.0)
|
||||
var noiseLow: Double by parameters
|
||||
|
||||
@DoubleParameter("noise high", 0.0, 1.0)
|
||||
var noiseHigh: Double by parameters
|
||||
|
||||
@DoubleParameter("gap frequency", 0.0, 2.0)
|
||||
var gapFrequency: Double by parameters
|
||||
|
||||
@DoubleParameter("gap low", -1.0, 1.0)
|
||||
var gapLow: Double by parameters
|
||||
@DoubleParameter("gap high", -1.0, 1.0)
|
||||
var gapHigh: Double by parameters
|
||||
|
||||
@DoubleParameter("deform amplitude", 0.0, 1.0)
|
||||
var deformAmplitude: Double by parameters
|
||||
|
||||
@DoubleParameter("deform frequency", 0.0, 1.0)
|
||||
var deformFrequency: Double by parameters
|
||||
|
||||
@ColorParameter("tint")
|
||||
var tint: ColorRGBa by parameters
|
||||
|
||||
@BooleanParameter("monochrome")
|
||||
var monochrome: Boolean by parameters
|
||||
|
||||
init {
|
||||
gain = 0.5
|
||||
noiseLow = 0.5
|
||||
noiseHigh = 0.8
|
||||
tint = ColorRGBa.WHITE
|
||||
monochrome = false
|
||||
gapFrequency = 10.0
|
||||
gapLow = -1.0
|
||||
gapHigh = -0.99
|
||||
}
|
||||
}
|
||||
35
orx-fx/src/commonMain/kotlin/distort/Tiles.kt
Normal file
35
orx-fx/src/commonMain/kotlin/distort/Tiles.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_tiles
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
@Description("Tiles")
|
||||
class Tiles : Filter(mppFilterShader(fx_tiles, "tiles")) {
|
||||
@DoubleParameter("rotation", -180.0, 180.0, order = 2)
|
||||
var rotation: Double by parameters
|
||||
|
||||
@IntParameter("x segments", 0, 256, order = 0)
|
||||
var xSegments: Int by parameters
|
||||
|
||||
@IntParameter("y segments", 0, 256, order = 0)
|
||||
var ySegments: Int by parameters
|
||||
|
||||
init {
|
||||
rotation = 0.0
|
||||
xSegments = 32
|
||||
ySegments = 32
|
||||
}
|
||||
|
||||
var bicubicFiltering = false
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
56
orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt
Normal file
56
orx-fx/src/commonMain/kotlin/distort/VideoGlitch.kt
Normal file
@@ -0,0 +1,56 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_video_glitch
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.BooleanParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
@Description("Video glitch")
|
||||
class VideoGlitch : Filter(mppFilterShader(fx_video_glitch, "video-glitch")) {
|
||||
var time: Double by parameters
|
||||
|
||||
@DoubleParameter("amplitude", 0.0, 10.0)
|
||||
var amplitude: Double by parameters
|
||||
|
||||
@DoubleParameter("border height", 0.0, 0.5)
|
||||
var borderHeight: Double by parameters
|
||||
|
||||
@DoubleParameter("vertical frequency", 0.0, 10.0)
|
||||
var vfreq: Double by parameters
|
||||
|
||||
@DoubleParameter("horizontal frequency", 0.0, 80.0)
|
||||
var hfreq: Double by parameters
|
||||
|
||||
@DoubleParameter("p frequency", 0.0, 10.0)
|
||||
var pfreq: Double by parameters
|
||||
|
||||
@DoubleParameter("p offset", -1.0, 1.0)
|
||||
var poffset: Double by parameters
|
||||
|
||||
@DoubleParameter("scroll offset 0", 0.0, 1.0)
|
||||
var scrollOffset0: Double by parameters
|
||||
|
||||
@DoubleParameter("scroll offset 1", 0.0, 1.0)
|
||||
var scrollOffset1: Double by parameters
|
||||
|
||||
@BooleanParameter("linear input")
|
||||
var linearInput: Boolean by parameters
|
||||
|
||||
@BooleanParameter("linear output")
|
||||
var linearOutput: Boolean by parameters
|
||||
|
||||
init {
|
||||
amplitude = 1.0
|
||||
vfreq = 4.0
|
||||
pfreq = 10.0
|
||||
hfreq = 80.0
|
||||
poffset = 0.0
|
||||
scrollOffset0 = 0.0
|
||||
scrollOffset1 = 0.0
|
||||
borderHeight = 0.05
|
||||
linearInput = false
|
||||
linearOutput = false
|
||||
}
|
||||
}
|
||||
71
orx-fx/src/commonMain/kotlin/distort/Wave.kt
Normal file
71
orx-fx/src/commonMain/kotlin/distort/Wave.kt
Normal file
@@ -0,0 +1,71 @@
|
||||
package org.openrndr.extra.fx.distort
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_horizontal_wave
|
||||
import org.openrndr.extra.fx.fx_vertical_wave
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
|
||||
@Description("Horizontal wave")
|
||||
class HorizontalWave : Filter(mppFilterShader(fx_horizontal_wave, "horizontal-wave")) {
|
||||
@DoubleParameter("frequency", 0.0, 64.0, order = 1)
|
||||
var frequency: Double by parameters
|
||||
|
||||
@DoubleParameter("amplitude", 0.0, 1.0, order = 0)
|
||||
var amplitude: Double by parameters
|
||||
|
||||
@DoubleParameter("phase", -0.5, 0.5, order = 2)
|
||||
var phase: Double by parameters
|
||||
|
||||
@IntParameter("segments", 0, 256, order = 3)
|
||||
var segments: Int by parameters
|
||||
|
||||
init {
|
||||
frequency = 1.0
|
||||
amplitude = 0.1
|
||||
phase = 0.0
|
||||
segments = 0
|
||||
}
|
||||
|
||||
var bicubicFiltering = true
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
|
||||
@Description("Vertical wave")
|
||||
class VerticalWave : Filter(mppFilterShader(fx_vertical_wave, "vertical-wave")) {
|
||||
@DoubleParameter("frequency", 0.0, 64.0, order = 1)
|
||||
var frequency: Double by parameters
|
||||
|
||||
@DoubleParameter("amplitude", 0.0, 1.0, order = 0)
|
||||
var amplitude: Double by parameters
|
||||
|
||||
@DoubleParameter("phase", -0.5, 0.5, order = 2)
|
||||
var phase: Double by parameters
|
||||
|
||||
@IntParameter("segments", 0, 256, order = 3)
|
||||
var segments: Int by parameters
|
||||
|
||||
init {
|
||||
frequency = 1.0
|
||||
amplitude = 0.1
|
||||
phase = 0.0
|
||||
segments = 0
|
||||
}
|
||||
var bicubicFiltering = true
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
if (bicubicFiltering && source.isNotEmpty()) {
|
||||
source[0].generateMipmaps()
|
||||
source[0].filter(MinifyingFilter.LINEAR_MIPMAP_LINEAR, MagnifyingFilter.LINEAR)
|
||||
}
|
||||
super.apply(source, target)
|
||||
}
|
||||
}
|
||||
21
orx-fx/src/commonMain/kotlin/dither/ADither.kt
Normal file
21
orx-fx/src/commonMain/kotlin/dither/ADither.kt
Normal file
@@ -0,0 +1,21 @@
|
||||
package org.openrndr.extra.fx.dither
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@IntParameter("pattern index", 0, 3)
|
||||
var pattern: Int by parameters
|
||||
|
||||
@IntParameter("levels", 1, 64)
|
||||
var levels: Int by parameters
|
||||
|
||||
init {
|
||||
levels = 4
|
||||
pattern = 3
|
||||
}
|
||||
}
|
||||
25
orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt
Normal file
25
orx-fx/src/commonMain/kotlin/dither/CMYKHalftone.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.openrndr.extra.fx.dither
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@DoubleParameter("scale", 1.0, 30.0, precision = 4)
|
||||
var scale: Double by parameters
|
||||
|
||||
@DoubleParameter("dotSize", 1.0, 3.0, precision = 4)
|
||||
var dotSize: Double by parameters
|
||||
|
||||
@DoubleParameter("rotation", -180.0, 180.0)
|
||||
var rotation: Double by parameters
|
||||
|
||||
init {
|
||||
scale = 3.0
|
||||
rotation = 0.0
|
||||
dotSize = 1.0
|
||||
}
|
||||
}
|
||||
29
orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt
Normal file
29
orx-fx/src/commonMain/kotlin/dither/Crosshatch.kt
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.openrndr.extra.fx.dither
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
@DoubleParameter("threshold 1", 0.0, 1.0)
|
||||
var t1: Double by parameters
|
||||
|
||||
@DoubleParameter("threshold 2", 0.0, 1.0)
|
||||
var t2: Double by parameters
|
||||
|
||||
@DoubleParameter("threshold 3", 0.0, 1.0)
|
||||
var t3: Double by parameters
|
||||
|
||||
@DoubleParameter("threshold 4", 0.0, 1.0)
|
||||
var t4: Double by parameters
|
||||
|
||||
init {
|
||||
t1 = 1.0
|
||||
t2 = 0.75
|
||||
t3 = 0.5
|
||||
t4 = 0.3
|
||||
}
|
||||
}
|
||||
35
orx-fx/src/commonMain/kotlin/edges/Contour.kt
Normal file
35
orx-fx/src/commonMain/kotlin/edges/Contour.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.openrndr.extra.fx.edges
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_contour
|
||||
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("Contour")
|
||||
class Contour : Filter(mppFilterShader(fx_contour, "contour")) {
|
||||
@DoubleParameter("levels", 1.0, 16.0)
|
||||
var levels: Double by parameters
|
||||
|
||||
@DoubleParameter("contour width", 0.0, 4.0)
|
||||
var contourWidth: Double by parameters
|
||||
|
||||
@DoubleParameter("contour opacity", 0.0, 1.0)
|
||||
var contourOpacity: Double by parameters
|
||||
|
||||
@DoubleParameter("background opacity", 0.0, 1.0)
|
||||
var backgroundOpacity: Double by parameters
|
||||
|
||||
@ColorParameter("contour color")
|
||||
var contourColor: ColorRGBa by parameters
|
||||
|
||||
init {
|
||||
levels = 6.0
|
||||
contourWidth = 0.4
|
||||
contourColor = ColorRGBa.BLACK
|
||||
backgroundOpacity = 1.0
|
||||
contourOpacity = 1.0
|
||||
}
|
||||
}
|
||||
60
orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt
Normal file
60
orx-fx/src/commonMain/kotlin/edges/EdgesWork.kt
Normal file
@@ -0,0 +1,60 @@
|
||||
package org.openrndr.extra.fx.edges
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.ColorBufferDescription
|
||||
import org.openrndr.extra.fx.fx_edges_work_1
|
||||
import org.openrndr.extra.fx.fx_edges_work_2
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
internal class EdgesWork1 : Filter(mppFilterShader(fx_edges_work_1, "edges-work-1")) {
|
||||
var delta: Vector2 by parameters
|
||||
|
||||
init {
|
||||
delta = Vector2.ZERO
|
||||
}
|
||||
}
|
||||
|
||||
@Description("Edges Work")
|
||||
open class EdgesWork : Filter(mppFilterShader(fx_edges_work_2, "edges-work-2")) {
|
||||
/**
|
||||
* radius, default value is 1.0
|
||||
*/
|
||||
@IntParameter("radius", 1, 400)
|
||||
var radius: Int by parameters
|
||||
|
||||
private var delta: Vector2 by parameters
|
||||
|
||||
private val work1 = EdgesWork1()
|
||||
|
||||
private var intermediateCache = mutableMapOf<ColorBufferDescription, ColorBuffer>()
|
||||
|
||||
init {
|
||||
radius = 1
|
||||
delta = Vector2.ZERO
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
val intermediateDescription = ColorBufferDescription(
|
||||
target[0].width,
|
||||
target[0].height,
|
||||
target[0].contentScale,
|
||||
target[0].format,
|
||||
target[0].type
|
||||
)
|
||||
val intermediate = intermediateCache.getOrPut(intermediateDescription) {
|
||||
colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate.let {
|
||||
work1.delta = Vector2(radius / it.effectiveWidth.toDouble(), 0.0)
|
||||
work1.apply(source, arrayOf(it))
|
||||
|
||||
parameters["delta"] = Vector2(0.0, radius / it.effectiveHeight.toDouble())
|
||||
super.apply(arrayOf(it), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt
Normal file
31
orx-fx/src/commonMain/kotlin/edges/LumaSobel.kt
Normal file
@@ -0,0 +1,31 @@
|
||||
package org.openrndr.extra.fx.edges
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_luma_sobel
|
||||
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 LumaSobel : Filter(mppFilterShader(fx_luma_sobel, "luma-sobel")) {
|
||||
@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
|
||||
}
|
||||
}
|
||||
40
orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt
Normal file
40
orx-fx/src/commonMain/kotlin/grain/FilmGrain.kt
Normal file
@@ -0,0 +1,40 @@
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_film_grain
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
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(mppFilterShader(fx_film_grain, "film-grain")) {
|
||||
@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 {
|
||||
useColor = false
|
||||
grainLiftRatio = 0.5
|
||||
grainStrength = 1.0
|
||||
grainRate = 1.0
|
||||
grainPitch = 1.0
|
||||
colorLevel = 1.0
|
||||
}
|
||||
}
|
||||
27
orx-fx/src/commonMain/kotlin/patterns/Checkers.kt
Normal file
27
orx-fx/src/commonMain/kotlin/patterns/Checkers.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.openrndr.extra.fx.patterns
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.Filter
|
||||
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")) {
|
||||
var background: ColorRGBa by parameters
|
||||
var foreground: ColorRGBa by parameters
|
||||
|
||||
@DoubleParameter("size", 0.0, 1.0)
|
||||
var size: Double by parameters
|
||||
|
||||
@DoubleParameter("opacity", 0.0, 1.0)
|
||||
var opacity: Double by parameters
|
||||
|
||||
init {
|
||||
size = 1.0 / 64.0
|
||||
opacity = 1.0
|
||||
foreground = ColorRGBa.WHITE.shade(0.9)
|
||||
background = ColorRGBa.WHITE.shade(0.8)
|
||||
}
|
||||
}
|
||||
75
orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt
Normal file
75
orx-fx/src/commonMain/kotlin/shadow/DropShadow.kt
Normal file
@@ -0,0 +1,75 @@
|
||||
package org.openrndr.extra.fx.shadow
|
||||
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.fx_dropshadow_blend
|
||||
import org.openrndr.extra.fx.fx_dropshadow_blur
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.ColorParameter
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
import org.openrndr.extra.parameters.IntParameter
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
private class Blend : Filter(mppFilterShader(fx_dropshadow_blend, "dropshadow-blend")) {
|
||||
var shift: Vector2 by parameters
|
||||
}
|
||||
|
||||
@Description("Drop shadow")
|
||||
class DropShadow : Filter(mppFilterShader(fx_dropshadow_blur, "dropshadow-blur")) {
|
||||
@IntParameter("blur window", 1, 25)
|
||||
var window: Int by parameters
|
||||
var spread: Double by parameters
|
||||
@DoubleParameter("gain", 0.0, 4.0)
|
||||
var gain: Double by parameters
|
||||
|
||||
@DoubleParameter("x shift", -30.0, 30.0)
|
||||
var xShift: Double = 0.0
|
||||
|
||||
@DoubleParameter("y shift", -30.0, 30.0)
|
||||
var yShift: Double = 0.0
|
||||
|
||||
@ColorParameter("color")
|
||||
var color: ColorRGBa by parameters
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
private var intermediate2: ColorBuffer? = null
|
||||
private var b = Blend()
|
||||
|
||||
init {
|
||||
color = ColorRGBa.BLACK
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
}
|
||||
|
||||
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||
intermediate?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate = null
|
||||
}
|
||||
}
|
||||
intermediate2?.let {
|
||||
if (it.width != target[0].width || it.height != target[0].height) {
|
||||
intermediate2 = null
|
||||
}
|
||||
}
|
||||
if (intermediate == null) {
|
||||
intermediate = colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
if (intermediate2 == null) {
|
||||
intermediate2 = colorBuffer(target[0].width, target[0].height, target[0].contentScale, target[0].format, target[0].type)
|
||||
}
|
||||
|
||||
intermediate?.let {
|
||||
parameters["blurDirection"] = Vector2(1.0, 0.0)
|
||||
super.apply(source, arrayOf(it))
|
||||
|
||||
parameters["blurDirection"] = Vector2(0.0, 1.0)
|
||||
super.apply(arrayOf(it), arrayOf(intermediate2!!))
|
||||
|
||||
b.shift = (Vector2(xShift,yShift)) / Vector2(target[0].width * 1.0, target[0].height * 1.0)
|
||||
b.apply(arrayOf(intermediate2!!, source[0]), target)
|
||||
}
|
||||
}
|
||||
}
|
||||
19
orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt
Normal file
19
orx-fx/src/commonMain/kotlin/tonemap/Uncharted2Tonemap.kt
Normal file
@@ -0,0 +1,19 @@
|
||||
package org.openrndr.extra.fx.tonemap
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.extra.fx.fx_uncharted2_tonemap
|
||||
import org.openrndr.extra.fx.mppFilterShader
|
||||
import org.openrndr.extra.parameters.Description
|
||||
import org.openrndr.extra.parameters.DoubleParameter
|
||||
|
||||
/**
|
||||
* Uncharted 2 tonemap filter
|
||||
*/
|
||||
@Description("Uncharted 2 tonemap")
|
||||
class Uncharted2Tonemap : Filter(mppFilterShader(fx_uncharted2_tonemap, "uncharted2-tonemap")) {
|
||||
@DoubleParameter("exposure bias", 0.0, 128.0)
|
||||
var exposureBias:Double by parameters
|
||||
init {
|
||||
exposureBias = 2.0
|
||||
}
|
||||
}
|
||||
10
orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt
Normal file
10
orx-fx/src/commonMain/kotlin/transform/FlipVertically.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.openrndr.extra.fx.transform
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
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"))
|
||||
Reference in New Issue
Block a user