Custom Filter
package basics
import kotlin.browser.document
fun main(args: Array<String>) {
val app = PIXI.Application()
document.body!!.appendChild(app.view)
val background = PIXI.Sprite.fromImage("../assets/bkg-grass.jpg")
background.width = app.screen.width
background.height = app.screen.height
app.stage.addChild(background)
app.stop()
var filter: PIXI.Filter? = null
fun onLoaded(res: PIXI.loaders.Resources) {
filter = PIXI.Filter(null, res.asDynamic().shader.data as String)
background.filters = arrayOf(filter!!)
app.start()
}
PIXI.loader.add("shader", "../assets/basics/shader.frag")
.load({ _, res -> onLoaded(res) })
app.ticker.add({ delta ->
filter!!.uniforms.customUniform += 0.04 * delta.toDouble()
})
}