[orx-fx] Add MultiplyU, MultiplyV and Square filters

This commit is contained in:
Edwin Jakobs
2022-01-06 23:20:13 +01:00
parent f5b2980d8d
commit 5332d8bcf4
6 changed files with 132 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import org.openrndr.draw.Filter
import org.openrndr.draw.filterShaderFromCode
import org.openrndr.extra.fx.fx_film_grain
import org.openrndr.extra.fx.fx_multiply_u
import org.openrndr.extra.fx.mppFilterShader
import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
/**
* Multiply by u coordinate
*/
@Description("multiply u")
class MultiplyU : Filter(filterShaderFromCode(fx_multiply_u, "multiply-u")) {
@DoubleParameter("multiplication bias", 0.0, 2.0)
var bias: Double by parameters
init {
bias = 0.0
}
}

View File

@@ -0,0 +1,22 @@
import org.openrndr.draw.Filter
import org.openrndr.draw.filterShaderFromCode
import org.openrndr.extra.fx.fx_multiply_v
import org.openrndr.extra.parameters.BooleanParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
/**
* Multiply by v coordinate
*/
@Description("multiply v")
class MultiplyV : Filter(filterShaderFromCode(fx_multiply_v, "multiply-v")) {
@DoubleParameter("multiplication bias", 0.0, 2.0)
var bias: Double by parameters
@BooleanParameter("invert v")
var invertV: Boolean by parameters
init {
bias = 0.0
invertV = false
}
}

View File

@@ -0,0 +1,10 @@
import org.openrndr.draw.Filter
import org.openrndr.draw.filterShaderFromCode
import org.openrndr.extra.fx.fx_square
import org.openrndr.extra.parameters.Description
/**
* Square input texture values
*/
@Description("square")
class Square : Filter(filterShaderFromCode(fx_square, "square")) {
}

View File

@@ -0,0 +1,27 @@
#ifdef OR_IN_OUT
in vec2 v_texCoord0;
#else
varying vec2 v_texCoord0;
#endif
uniform sampler2D tex0;
uniform float bias;
#ifndef OR_GL_FRAGCOLOR
out vec4 o_color;
#endif
void main() {
#ifndef OR_GL_TEXTURE2D
vec4 a = texture(tex0, v_texCoord0);
#else
vec4 a = texture2D(tex0, v_texCoord0);
#endif
vec4 result = a * (v_texCoord0.x + bias);
#ifdef OR_GL_FRAGCOLOR
gl_FragColor = result;
#else
o_color = result;
#endif
}

View File

@@ -0,0 +1,28 @@
#ifdef OR_IN_OUT
in vec2 v_texCoord0;
#else
varying vec2 v_texCoord0;
#endif
uniform sampler2D tex0;
uniform float bias;
uniform bool invertV;
#ifndef OR_GL_FRAGCOLOR
out vec4 o_color;
#endif
void main() {
#ifndef OR_GL_TEXTURE2D
vec4 a = texture(tex0, v_texCoord0);
#else
vec4 a = texture2D(tex0, v_texCoord0);
#endif
float v = invertV ? (1.0 - v_texCoord0.y) : v_texCoord0.y;
vec4 result = a * (v + bias);
#ifdef OR_GL_FRAGCOLOR
gl_FragColor = result;
#else
o_color = result;
#endif
}

View File

@@ -0,0 +1,26 @@
#ifdef OR_IN_OUT
in vec2 v_texCoord0;
#else
varying vec2 v_texCoord0;
#endif
uniform sampler2D tex0;
uniform float bias;
uniform float invertV;
#ifndef OR_GL_FRAGCOLOR
out vec4 o_color;
#endif
void main() {
#ifndef OR_GL_TEXTURE2D
vec4 a = texture(tex0, v_texCoord0);
#else
vec4 a = texture2D(tex0, v_texCoord0);
#endif
vec4 result = a * a;
#ifdef OR_GL_FRAGCOLOR
gl_FragColor = result;
#else
o_color = result;
#endif
}