Bump OPENRNDR to 0.3.40-rc.4

This commit is contained in:
Edwin Jakobs
2020-03-13 15:56:52 +01:00
parent cefc44fe7b
commit f0eb582ae5
5 changed files with 121 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ buildscript {
apply plugin: 'org.jetbrains.dokka'
project.ext {
openrndrVersion = "0.3.39"
openrndrVersion = "0.3.40-rc.4"
panelVersion = "0.3.21"
kotlinVersion = "1.3.70"
spekVersion = "2.0.9"

View File

@@ -1,6 +1,9 @@
package org.openrndr.extra.jumpfill
package org.openrndr.extra.jumpfill.fx
import org.openrndr.draw.*
import org.openrndr.extra.jumpfill.EncodeSubpixel
import org.openrndr.extra.jumpfill.JumpFlooder
import org.openrndr.extra.jumpfill.PixelDirection
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2

View File

@@ -0,0 +1,79 @@
package org.openrndr.extra.jumpfill.fx
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extra.jumpfill.EncodeSubpixel
import org.openrndr.extra.jumpfill.JumpFlooder
import org.openrndr.extra.jumpfill.PixelDirection
import org.openrndr.extra.parameters.ColorParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
import org.openrndr.math.Vector2
import org.openrndr.resourceUrl
private class InnerGlowFilter : Filter(filterShaderFromUrl(resourceUrl("/shaders/gl3/fx/inner-glow.frag"))) {
var angle: Double by parameters
var width: Double by parameters
var noise: Double by parameters
var color: ColorRGBa by parameters
var shape: Double by parameters
var imageOpacity: Double by parameters
init {
angle = 0.0
width = 5.0
noise = 0.0
shape = 1.0
imageOpacity = 1.0
}
}
@Description("Outer glow")
class InnerGlow : Filter() {
@DoubleParameter("width", 0.0, 50.0)
var width = 5.0
@DoubleParameter("noise", 0.0, 1.0)
var noise = 0.1
@DoubleParameter("shape", 0.0, 10.0)
var shape = 1.0
@DoubleParameter("opacity", 0.0, 1.0)
var opacity = 1.0
@DoubleParameter("image opacity", 0.0, 1.0)
var imageOpacity = 1.0
@ColorParameter("color")
var color = ColorRGBa.WHITE
private var jumpFlooder: JumpFlooder? = null
private val decodeFilter = PixelDirection()
private val glowFilter = InnerGlowFilter()
private var distance: ColorBuffer? = null
override fun apply(source: Array<ColorBuffer>, target: Array<ColorBuffer>) {
if (jumpFlooder == null) {
jumpFlooder = JumpFlooder(target[0].width, target[0].height, encodePoints = EncodeSubpixel())
}
if (distance == null) {
distance = colorBuffer(target[0].width, target[0].height, type = ColorType.FLOAT32)
}
val result = jumpFlooder!!.jumpFlood(source[0])
decodeFilter.originalSize = Vector2(target[0].width * 1.0, target[0].height * 1.0)
decodeFilter.distanceScale = 1.0
decodeFilter.apply(result, result)
result.copyTo(distance!!)
glowFilter.color = color.opacify(opacity)
glowFilter.width = width
glowFilter.noise = noise
glowFilter.shape = shape
glowFilter.imageOpacity = imageOpacity
glowFilter.apply(arrayOf(source[0], distance!!), target[0])
}
}

View File

@@ -1,7 +1,10 @@
package org.openrndr.extra.jumpfill
package org.openrndr.extra.jumpfill.fx
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.*
import org.openrndr.extra.jumpfill.EncodeSubpixel
import org.openrndr.extra.jumpfill.JumpFlooder
import org.openrndr.extra.jumpfill.PixelDirection
import org.openrndr.extra.parameters.ColorParameter
import org.openrndr.extra.parameters.Description
import org.openrndr.extra.parameters.DoubleParameter
@@ -50,7 +53,7 @@ class OuterGlow : Filter() {
private var jumpFlooder: JumpFlooder? = null
private val decodeFilter = PixelDirection()
private val glowFilter = OuterGlowFilter()
private val glowFilter = org.openrndr.extra.jumpfill.fx.OuterGlowFilter()
private var distance: ColorBuffer? = null

View File

@@ -0,0 +1,32 @@
#version 330 core
uniform sampler2D tex0; // image
uniform sampler2D tex1; // distance
uniform float width;
uniform float noise;
uniform vec4 color;
uniform float shape;
uniform float imageOpacity;
in vec2 v_texCoord0;
out vec4 o_color;
#define HASHSCALE 443.8975
vec2 hash22(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * HASHSCALE);
p3 += dot(p3, p3.yzx+19.19);
return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
}
void main() {
vec4 original = texture(tex0, v_texCoord0);
vec2 step = 1.0 / textureSize(tex0, 0);
vec2 distance = texture(tex1, v_texCoord0).rg;
float d = length(distance);
vec2 n = normalize(distance);
vec2 h = hash22(v_texCoord0)*10.0;
float e = exp(-( pow((d+h.x*noise)*1.0/width, shape)) );
o_color = original * imageOpacity + original.a* vec4(color.rgb, 1.0) * e * color.a;
o_color.a = max(o_color.a, 1.0);
}