Add orx-fx, the new home for what was in openrndr-filter before
This commit is contained in:
11
orx-fx/src/main/kotlin/FilterTools.kt
Normal file
11
orx-fx/src/main/kotlin/FilterTools.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
package org.openrndr.extra.fx
|
||||
|
||||
import org.openrndr.resourceUrl
|
||||
import java.net.URL
|
||||
|
||||
internal class FilterTools
|
||||
|
||||
internal fun filterFragmentCode(resourceId: String): String {
|
||||
val urlString = resourceUrl("gl3/$resourceId", FilterTools::class.java)
|
||||
return URL(urlString).readText()
|
||||
}
|
||||
37
orx-fx/src/main/kotlin/antialias/FXAA.kt
Normal file
37
orx-fx/src/main/kotlin/antialias/FXAA.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
package org.openrndr.extra.fx.antialias
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
/**
|
||||
* FXAA approximate antialiasing filter. Only works on LDR inputs
|
||||
*/
|
||||
class FXAA : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("antialias/fxaa.frag"))) {
|
||||
/**
|
||||
* luma threshold, default value is 0.5
|
||||
*/
|
||||
var lumaThreshold: Double by parameters
|
||||
|
||||
/**
|
||||
* max search span, default value is 8.0
|
||||
*/
|
||||
var maxSpan: Double by parameters
|
||||
|
||||
/**
|
||||
* direction reduce multiplier, default value is 0.0
|
||||
*/
|
||||
var directionReduceMultiplier: Double by parameters
|
||||
|
||||
/**
|
||||
* direction reduce minimum, default value is 0.0
|
||||
*/
|
||||
var directionReduceMinimum: Double by parameters
|
||||
|
||||
init {
|
||||
lumaThreshold = 0.5
|
||||
maxSpan = 8.0
|
||||
directionReduceMinimum = 0.0
|
||||
directionReduceMultiplier = 0.0
|
||||
}
|
||||
}
|
||||
27
orx-fx/src/main/kotlin/blend/BlendFilters.kt
Normal file
27
orx-fx/src/main/kotlin/blend/BlendFilters.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.openrndr.extra.fx.blend
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
class ColorBurn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/color-burn.frag")))
|
||||
class ColorDodge : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/color-dodge.frag")))
|
||||
class Darken : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/darken.frag")))
|
||||
class HardLight : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/hard-light.frag")))
|
||||
class Lighten : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/lighten.frag")))
|
||||
class Multiply : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/multiply.frag")))
|
||||
class Normal : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/normal.frag")))
|
||||
class Overlay : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/overlay.frag")))
|
||||
class Screen : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/screen.frag")))
|
||||
|
||||
class SourceIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-in.frag")))
|
||||
class SourceOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/source-out.frag")))
|
||||
class DestinationIn : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-in.frag")))
|
||||
class DestinationOut : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/destination-out.frag")))
|
||||
class Xor : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/xor.frag")))
|
||||
|
||||
class MultiplyContrast : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/multiply-contrast.frag")))
|
||||
|
||||
class Passthrough : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/passthrough.frag")))
|
||||
class Add : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/add.frag")))
|
||||
class Subtract : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("blend/subtract.frag")))
|
||||
66
orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt
Normal file
66
orx-fx/src/main/kotlin/blur/ApproximateGaussianBlur.kt
Normal file
@@ -0,0 +1,66 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.ColorBuffer
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* Approximate separated Gaussian blur
|
||||
*/
|
||||
class ApproximateGaussianBlur : Filter(Shader.createFromCode(Filter.filterVertexCode,
|
||||
filterFragmentCode("blur/approximate-gaussian-blur.frag"))) {
|
||||
|
||||
/**
|
||||
* blur sample window, default value is 5
|
||||
*/
|
||||
var window: Int by parameters
|
||||
|
||||
/**
|
||||
* spread multiplier, default value is 1.0
|
||||
*/
|
||||
var spread: Double by parameters
|
||||
|
||||
/**
|
||||
* blur sigma, default value is 1.0
|
||||
*/
|
||||
var sigma: Double by parameters
|
||||
|
||||
/**
|
||||
* post blur gain, default value is 1.0
|
||||
*/
|
||||
var gain: Double by parameters
|
||||
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
|
||||
init {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
gain = 1.0
|
||||
sigma = 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
|
||||
}
|
||||
}
|
||||
|
||||
if (intermediate == null) {
|
||||
intermediate = 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
59
orx-fx/src/main/kotlin/blur/BoxBlur.kt
Normal file
59
orx-fx/src/main/kotlin/blur/BoxBlur.kt
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.ColorBuffer
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.draw.colorBuffer
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
import org.openrndr.math.Vector2
|
||||
|
||||
/**
|
||||
* BoxBlur implemented as a separable filter
|
||||
*/
|
||||
class BoxBlur : Filter(Shader.createFromCode(Filter.filterVertexCode,
|
||||
filterFragmentCode("blur/box-blur.frag"))) {
|
||||
|
||||
/**
|
||||
* The sample window, default is 5
|
||||
*/
|
||||
var window: Int by parameters
|
||||
|
||||
/**
|
||||
* Spread multiplier, default is 1.0
|
||||
*/
|
||||
var spread: Double by parameters
|
||||
|
||||
/**
|
||||
* Post-blur gain, default is 1.0
|
||||
*/
|
||||
var gain: Double by parameters
|
||||
|
||||
private var intermediate: ColorBuffer? = null
|
||||
|
||||
init {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if (intermediate == null) {
|
||||
intermediate = 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
39
orx-fx/src/main/kotlin/blur/GaussianBlur.kt
Normal file
39
orx-fx/src/main/kotlin/blur/GaussianBlur.kt
Normal file
@@ -0,0 +1,39 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
/**
|
||||
* Exact Gaussian blur, implemented as a single pass filter
|
||||
*/
|
||||
class GaussianBlur : Filter(Shader.createFromCode(Filter.filterVertexCode,
|
||||
filterFragmentCode("blur/gaussian-blur.frag"))) {
|
||||
|
||||
/**
|
||||
* The sample window, default value is 5
|
||||
*/
|
||||
var window: Int by parameters
|
||||
|
||||
/**
|
||||
* Spread multiplier, default value is 1.0
|
||||
*/
|
||||
var spread: Double by parameters
|
||||
|
||||
/**
|
||||
* Blur kernel sigma, default value is 1.0
|
||||
*/
|
||||
var sigma: Double by parameters
|
||||
|
||||
/**
|
||||
* Post-blur gain, default value is 1.0
|
||||
*/
|
||||
var gain: Double by parameters
|
||||
|
||||
init {
|
||||
window = 5
|
||||
spread = 1.0
|
||||
sigma = 1.0
|
||||
gain = 1.0
|
||||
}
|
||||
}
|
||||
35
orx-fx/src/main/kotlin/blur/HashBlur.kt
Normal file
35
orx-fx/src/main/kotlin/blur/HashBlur.kt
Normal file
@@ -0,0 +1,35 @@
|
||||
package org.openrndr.extra.fx.blur
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
class HashBlur : Filter(Shader.createFromCode(Filter.filterVertexCode,
|
||||
filterFragmentCode("blur/hash-blur.frag"))) {
|
||||
/**
|
||||
* Blur radius in pixels, default is 5.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
|
||||
*/
|
||||
var samples: Int by parameters
|
||||
|
||||
/**
|
||||
* Post-blur gain, default is 1.0
|
||||
*/
|
||||
var gain: Double by parameters
|
||||
|
||||
init {
|
||||
radius = 5.0
|
||||
time = 0.0
|
||||
samples = 30
|
||||
gain = 1.0
|
||||
}
|
||||
}
|
||||
30
orx-fx/src/main/kotlin/color/ColorLookup.kt
Normal file
30
orx-fx/src/main/kotlin/color/ColorLookup.kt
Normal file
@@ -0,0 +1,30 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
class ColorLookup(lookup: ColorBuffer) : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-lookup.frag"))) {
|
||||
/** 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)
|
||||
}
|
||||
}
|
||||
9
orx-fx/src/main/kotlin/color/ColorMix.kt
Normal file
9
orx-fx/src/main/kotlin/color/ColorMix.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.openrndr.extra.fx.color
|
||||
|
||||
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"))) {
|
||||
|
||||
}
|
||||
14
orx-fx/src/main/kotlin/color/SubtractConstant.kt
Normal file
14
orx-fx/src/main/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.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
class SubtractConstant : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/subtract-constant.frag"))) {
|
||||
var constant: ColorRGBa by parameters
|
||||
|
||||
init {
|
||||
constant = ColorRGBa(1.0, 1.0, 1.0, 0.0)
|
||||
}
|
||||
}
|
||||
25
orx-fx/src/main/kotlin/dither/ADither.kt
Normal file
25
orx-fx/src/main/kotlin/dither/ADither.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
package org.openrndr.extra.fx.dither
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
|
||||
class ADither: Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("dither/a-dither.frag"))) {
|
||||
var pattern: Int
|
||||
set(value) {
|
||||
parameters["pattern"] = value
|
||||
}
|
||||
get() = parameters["pattern"] as Int
|
||||
|
||||
var levels: Int
|
||||
set(value) {
|
||||
parameters["levels"] = value;
|
||||
}
|
||||
get() = parameters["levels"] as Int
|
||||
|
||||
init {
|
||||
levels = 4
|
||||
pattern = 3
|
||||
}
|
||||
}
|
||||
10
orx-fx/src/main/kotlin/transform/FlipVertically.kt
Normal file
10
orx-fx/src/main/kotlin/transform/FlipVertically.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
package org.openrndr.extra.fx.transform
|
||||
|
||||
import org.openrndr.draw.Filter
|
||||
import org.openrndr.draw.Shader
|
||||
import org.openrndr.extra.fx.filterFragmentCode
|
||||
|
||||
/**
|
||||
* Vertically flips in the input image
|
||||
*/
|
||||
class FlipVertically : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("transform/flip-vertically.frag")))
|
||||
Reference in New Issue
Block a user