[orx-integral-image] Pad source image for npot inputs. Add demo
This commit is contained in:
42
orx-integral-image/src/demo/kotlin/DemoFII01.kt
Normal file
42
orx-integral-image/src/demo/kotlin/DemoFII01.kt
Normal file
@@ -0,0 +1,42 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extra.integralimage.*
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
}
|
||||
program {
|
||||
val fii = FastIntegralImage()
|
||||
val target = colorBuffer(width, height, 1.0, ColorFormat.RGBa, ColorType.FLOAT32)
|
||||
val rt = renderTarget(width, height) {
|
||||
colorBuffer()
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.isolatedWithTarget(rt) {
|
||||
drawer.ortho(rt)
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
drawer.fill = ColorRGBa.PINK.shade(1.0)
|
||||
drawer.circle(mouse.position, 128.0)
|
||||
}
|
||||
fii.apply(rt.colorBuffer(0), target)
|
||||
|
||||
// -- here we sample from the integral image
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
float w = 64.0;
|
||||
vec2 step = 1.0 / vec2(textureSize(image, 0));
|
||||
vec4 t11 = texture(image, va_texCoord0 + step * vec2(w+1.0,w+1.0));
|
||||
vec4 t01 = texture(image, va_texCoord0 + step * vec2(-w,w+1.0));
|
||||
vec4 t00 = texture(image, va_texCoord0 + step * vec2(-w,-w));
|
||||
vec4 t10 = texture(image, va_texCoord0 + step * vec2(w+1.0,-w));
|
||||
x_fill = (t11 - t01 - t10 + t00) / ((2.0 * w +1.0) * (2.0 * w + 1.0));
|
||||
""".trimIndent()
|
||||
}
|
||||
drawer.image(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user