Add SDFBlend filter to orx-jumpflood
This commit is contained in:
@@ -84,3 +84,19 @@ class SDFOnion : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/ops/sdf-on
|
|||||||
super.apply(source, target)
|
super.apply(source, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SDFBlend : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/ops/sdf-blend.frag"))) {
|
||||||
|
var factor: Double by parameters
|
||||||
|
|
||||||
|
init {
|
||||||
|
factor = 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
|
||||||
|
require(target[0].type == ColorType.FLOAT16 || target[0].type == ColorType.FLOAT32) {
|
||||||
|
"needs a floating point target"
|
||||||
|
}
|
||||||
|
super.apply(source, target)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#version 330 core
|
||||||
|
|
||||||
|
uniform sampler2D tex0;// signed distance
|
||||||
|
uniform sampler2D tex1;// signed distance
|
||||||
|
uniform float factor;
|
||||||
|
|
||||||
|
in vec2 v_texCoord0;
|
||||||
|
out vec4 o_color;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
float d0 = texture(tex0, v_texCoord0).r;
|
||||||
|
float d1 = texture(tex1, v_texCoord0).r;
|
||||||
|
float d = mix(d0, d1, factor);
|
||||||
|
o_color = vec4(d, 0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user