[orx-fx] Add MultiplyU, MultiplyV and Square filters
This commit is contained in:
19
orx-fx/src/commonMain/kotlin/math/MultiplyU.kt
Normal file
19
orx-fx/src/commonMain/kotlin/math/MultiplyU.kt
Normal 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
|
||||
}
|
||||
}
|
||||
22
orx-fx/src/commonMain/kotlin/math/MultiplyV.kt
Normal file
22
orx-fx/src/commonMain/kotlin/math/MultiplyV.kt
Normal 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
|
||||
}
|
||||
}
|
||||
10
orx-fx/src/commonMain/kotlin/math/Square.kt
Normal file
10
orx-fx/src/commonMain/kotlin/math/Square.kt
Normal 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")) {
|
||||
}
|
||||
27
orx-fx/src/shaders/glsl/math/multiply-u.frag
Normal file
27
orx-fx/src/shaders/glsl/math/multiply-u.frag
Normal 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
|
||||
}
|
||||
28
orx-fx/src/shaders/glsl/math/multiply-v.frag
Normal file
28
orx-fx/src/shaders/glsl/math/multiply-v.frag
Normal 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
|
||||
}
|
||||
26
orx-fx/src/shaders/glsl/math/square.frag
Normal file
26
orx-fx/src/shaders/glsl/math/square.frag
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user