diff --git a/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt b/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt new file mode 100644 index 00000000..e906e5de --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/math/MultiplyU.kt @@ -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 + } +} \ No newline at end of file diff --git a/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt b/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt new file mode 100644 index 00000000..2609bfd7 --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/math/MultiplyV.kt @@ -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 + } +} \ No newline at end of file diff --git a/orx-fx/src/commonMain/kotlin/math/Square.kt b/orx-fx/src/commonMain/kotlin/math/Square.kt new file mode 100644 index 00000000..3806e864 --- /dev/null +++ b/orx-fx/src/commonMain/kotlin/math/Square.kt @@ -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")) { +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/math/multiply-u.frag b/orx-fx/src/shaders/glsl/math/multiply-u.frag new file mode 100644 index 00000000..46b18ef5 --- /dev/null +++ b/orx-fx/src/shaders/glsl/math/multiply-u.frag @@ -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 +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/math/multiply-v.frag b/orx-fx/src/shaders/glsl/math/multiply-v.frag new file mode 100644 index 00000000..10b29d7c --- /dev/null +++ b/orx-fx/src/shaders/glsl/math/multiply-v.frag @@ -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 +} \ No newline at end of file diff --git a/orx-fx/src/shaders/glsl/math/square.frag b/orx-fx/src/shaders/glsl/math/square.frag new file mode 100644 index 00000000..c20b92f3 --- /dev/null +++ b/orx-fx/src/shaders/glsl/math/square.frag @@ -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 +} \ No newline at end of file