Hello, I'm trying to use ShaderBrush on iOS. It wo...
# compose
o
Hello, I'm trying to use ShaderBrush on iOS. It works perfectly in the simulator, but something goes wrong on a physical device
Copy code
const val SIMPLE_SHADER =
    """
    uniform float2 iResolution;
    uniform float iTime;
    const float3 colorBlend = vec3(0.0,2.0,4.0);
    half4 main(float2 fragCoord) {
        float2 uv = fragCoord/iResolution.xy;
        vec3 prod = uv.xyx + colorBlend;
        vec3 bias = prod + iTime;
        vec3 col = 0.5 + 0.5*cos(bias);
    
        return half4(col,1.0);
    }
    """

fun MainViewController(): UIViewController{
    return ComposeUIViewController {
        ShaderIosCheck()
    }
}

val compositeRuntimeEffect = RuntimeEffect.makeForShader(SIMPLE_SHADER)
val compositeShaderBuilder = RuntimeShaderBuilder(compositeRuntimeEffect)

@Composable
fun ShaderIosCheck(){
    val time by produceState(0f) {
        while (true) {
            withInfiniteAnimationFrameMillis { frameTimeMillis ->
                value = frameTimeMillis / 1000f
            }
        }
    }
    Box(
        modifier = Modifier.drawWithCache {
                compositeShaderBuilder.uniform("iResolution", size.width, size.height)
                onDrawBehind {
                    compositeShaderBuilder.uniform("iTime", time)
                    drawRect(brush = ShaderBrush(compositeShaderBuilder.makeShader()))
                }
            }
            .fillMaxSize()
    )
}
does anyone know why it is happening?🙏
s
You might wanna ask about this in #C0346LWVBJ4
🙌 1