Is there any example on how to implement a `floatU...
# compose-desktop
a
Is there any example on how to implement a
floatUniform
effect for a runtime shader in desktop?
I'm looking how to adjust this parts of code using Compose Multiplatform
t
I am not sure if it is possible to use custom shaders in graphicsLayer yet. But you could use this code which is working:
Copy code
fun Modifier.skslBackground(
    effect: RuntimeEffect,
    uniforms: (RuntimeShaderBuilder) -> Unit = {}
): Modifier = composed {
    val density = LocalDensity.current
    this.drawWithCache {
        val builder = RuntimeShaderBuilder(effect)
        println("size: ${size.width}x${size.height}")
        builder.uniform("iResolution", size.width, size.height, 1f)
        builder.uniform("iDensity", density.density)
        uniforms(builder)
        val shader = builder.makeShader()
        val brush = ShaderBrush(shader)
        onDrawBehind {
            drawRect(brush = brush, topLeft = Offset.Zero, size = size)
        }
    }
}