Add ColorTint, LumaThreshold, HorizontalWave, VerticalWave, FrameBlur filters to orx-fx
This commit is contained in:
41
orx-fx/src/main/kotlin/blur/FrameBlur.kt
Normal file
41
orx-fx/src/main/kotlin/blur/FrameBlur.kt
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
package org.openrndr.extra.fx.blur
|
||||||
|
|
||||||
|
import org.openrndr.draw.*
|
||||||
|
import org.openrndr.extra.fx.filterFragmentCode
|
||||||
|
import org.openrndr.extra.parameters.Description
|
||||||
|
import org.openrndr.extra.parameters.DoubleParameter
|
||||||
|
import org.openrndr.extra.parameters.IntParameter
|
||||||
|
|
||||||
|
@Description("Frame blur")
|
||||||
|
class FrameBlur : Filter(Shader.createFromCode(Filter.filterVertexCode,
|
||||||
|
filterFragmentCode("blur/frame-blur.frag"))) {
|
||||||
|
|
||||||
|
@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)
|
||||||
|
}
|
||||||
|
|
||||||
|
super.apply(arrayOf(source[0], intermediate!!), arrayOf(intermediate!!))
|
||||||
|
intermediate!!.copyTo(target[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,21 @@
|
|||||||
package org.openrndr.extra.fx.color
|
package org.openrndr.extra.fx.color
|
||||||
|
|
||||||
|
import org.openrndr.color.ColorRGBa
|
||||||
import org.openrndr.draw.Filter
|
import org.openrndr.draw.Filter
|
||||||
import org.openrndr.draw.Shader
|
import org.openrndr.draw.Shader
|
||||||
import org.openrndr.extra.fx.filterFragmentCode
|
import org.openrndr.extra.fx.filterFragmentCode
|
||||||
|
import org.openrndr.extra.parameters.ColorParameter
|
||||||
|
import org.openrndr.extra.parameters.Description
|
||||||
|
|
||||||
class ColorMix : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-mix.frag")))
|
class ColorMix : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-mix.frag")))
|
||||||
|
|
||||||
|
@Description("Tint")
|
||||||
|
class ColorTint : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/color-tint.frag"))) {
|
||||||
|
@ColorParameter("tint")
|
||||||
|
var tint: ColorRGBa by parameters
|
||||||
|
|
||||||
|
init {
|
||||||
|
tint = ColorRGBa.PINK
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
38
orx-fx/src/main/kotlin/color/LumaThreshold.kt
Normal file
38
orx-fx/src/main/kotlin/color/LumaThreshold.kt
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
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
|
||||||
|
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("Luma threshold ")
|
||||||
|
class Threshold : Filter(Shader.createFromCode(Filter.filterVertexCode, filterFragmentCode("color/luma-threshold.frag"))) {
|
||||||
|
|
||||||
|
@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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
44
orx-fx/src/main/kotlin/distort/Wave.kt
Normal file
44
orx-fx/src/main/kotlin/distort/Wave.kt
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package org.openrndr.extra.fx.distort
|
||||||
|
|
||||||
|
import org.openrndr.draw.Filter
|
||||||
|
import org.openrndr.draw.Shader
|
||||||
|
import org.openrndr.extra.fx.filterFragmentCode
|
||||||
|
import org.openrndr.extra.parameters.Description
|
||||||
|
import org.openrndr.extra.parameters.DoubleParameter
|
||||||
|
|
||||||
|
@Description("Horizontal wave")
|
||||||
|
class HorizontalWave : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("distort/horizontal-wave.frag"))) {
|
||||||
|
@DoubleParameter("frequency", 0.0, 64.0)
|
||||||
|
var frequency: Double by parameters
|
||||||
|
|
||||||
|
@DoubleParameter("amplitude", 0.0, 1.0)
|
||||||
|
var amplitude: Double by parameters
|
||||||
|
|
||||||
|
@DoubleParameter("phase", -0.5, 0.5)
|
||||||
|
var phase: Double by parameters
|
||||||
|
|
||||||
|
init {
|
||||||
|
frequency = 1.0
|
||||||
|
amplitude = 0.1
|
||||||
|
phase = 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Description("Vertical wave")
|
||||||
|
class VerticalWave : Filter(Shader.createFromCode(filterVertexCode, filterFragmentCode("distort/vertical-wave.frag"))) {
|
||||||
|
@DoubleParameter("frequency", 0.0, 64.0)
|
||||||
|
var frequency: Double by parameters
|
||||||
|
|
||||||
|
@DoubleParameter("amplitude", 0.0, 1.0)
|
||||||
|
var amplitude: Double by parameters
|
||||||
|
|
||||||
|
@DoubleParameter("phase", -0.5, 0.5)
|
||||||
|
var phase: Double by parameters
|
||||||
|
|
||||||
|
init {
|
||||||
|
frequency = 1.0
|
||||||
|
amplitude = 0.1
|
||||||
|
phase = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// openrndr - gl3 - frame-blur
|
||||||
|
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0; // input image
|
||||||
|
uniform sampler2D tex1; // accumulator image
|
||||||
|
uniform float blend;
|
||||||
|
out vec4 o_color;
|
||||||
|
void main() {
|
||||||
|
|
||||||
|
vec4 inputColor = texture(tex0, v_texCoord0);
|
||||||
|
vec4 accumulator = texture(tex1, v_texCoord0);
|
||||||
|
o_color = accumulator * (1.0 - blend) + inputColor * blend;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#version 330
|
||||||
|
|
||||||
|
uniform vec4 tint;
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
void main() {
|
||||||
|
vec4 c = texture(tex0, v_texCoord0);
|
||||||
|
o_color = vec4(c.rgb * tint.rgb, c.a) * tint.a;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0; // input
|
||||||
|
uniform vec4 foreground;
|
||||||
|
uniform vec4 background;
|
||||||
|
uniform float foregroundOpacity;
|
||||||
|
uniform float backgroundOpacity;
|
||||||
|
uniform float threshold;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
void main() {
|
||||||
|
vec4 c = texture(tex0, v_texCoord0);
|
||||||
|
vec4 fgc = foreground * foregroundOpacity;
|
||||||
|
vec4 bgc = background * backgroundOpacity;
|
||||||
|
float luma = dot(c.rgb, vec3(1.0/3.0));
|
||||||
|
o_color = mix(bgc, fgc, step(threshold, luma ));
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0; // input
|
||||||
|
uniform float phase;
|
||||||
|
uniform float amplitude;
|
||||||
|
uniform float frequency;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
void main() {
|
||||||
|
vec2 uv = v_texCoord0;
|
||||||
|
uv.x += amplitude * cos(uv.y * 3.1415926535 * frequency + phase * 3.1415926535);
|
||||||
|
if (uv.x >= 0.0 && uv.x < 1.0) {
|
||||||
|
o_color = texture(tex0, uv);
|
||||||
|
} else {
|
||||||
|
o_color = vec4(0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
uniform sampler2D tex0; // input
|
||||||
|
uniform float phase;
|
||||||
|
uniform float amplitude;
|
||||||
|
uniform float frequency;
|
||||||
|
|
||||||
|
out vec4 o_color;
|
||||||
|
void main() {
|
||||||
|
vec2 uv = v_texCoord0;
|
||||||
|
uv.y += amplitude * sin(uv.x * 3.1415926535 * frequency + phase * 3.1415926535);
|
||||||
|
if (uv.y >= 0.0 && uv.y < 1.0) {
|
||||||
|
o_color = texture(tex0, uv);
|
||||||
|
} else {
|
||||||
|
o_color = vec4(0.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user