Exploring using Shaders with Compose Multiplatform...
# compose-desktop
d
Exploring using Shaders with Compose Multiplatform K: It's delightfully straightforward to share SKSL shader code between iOS and Desktop, since both platforms expose Skiko API's. ­čÄë Is it possible to use SKSL shader on Android platform in a similar way? I tried naively importing Skiko explicitly but this didn't help -
RuntimeEffect
doesn't resolve.
k
You can probably load the same shader with Android 13 APIs.
d
Thanks @Kirill Grouchnikov. Since I need to target Android 11 it looks like my only option is to maintain a GLSL Shader implementation for Android alongside SKSL for iOS/Desktop? I presume Skia underlying Jetpack Compose has most of the capabilities to share SKSL even pre-Android 13 (for Flutter) but there's an abstraction gap when it comes to exposing that to Kotlin.
k
I think it's an API gap to be able to plug in your shader in pre-13 Android pipeline
j
I presume Skia underlying Jetpack Compose has most of the capabilities to share SKSL even pre-Android 13 (for Flutter) but there's an abstraction gap when it comes to exposing that to Kotlin.
@darkmoon_uk Flutter bundles their own copy of Skia which allows them to use the latest Skia version (instead of the one bundled with the platform) and to access the Skia APIs directly (instead of needing a platform version which exposes the API). The downside of this approach is larger bundle size and worse interoperability (eg. embedding Android Views). We investigated doing the same, but decided using the Skia bundled in Android gave us a better mix of benefits. However, if you aren't using the interoperability APIs, and prefer to have the easy experience/API matching iOS/Desktop, bundling may be a reasonable option for you. Anyway, it would be some amount of work and is undocumented, so you'd need to figure out a bunch of things yourself (including doing a build of skiko/compose), not sure if it's worth it, but there is nothing preventing you from bundling Skia with your app to get SKSL on Android 11.
207 Views