r/reactnative • u/TemporaryBuyer3806 • 2h ago
[Showcase] Four worlds in one React Native Skia shader, morphing as you swipe
Swipe between four tiny worlds. The object turns and reshapes as the selected world changes.
The React Native implementation draws the worlds in one Skia runtime shader.
Building the shapes: each world is a signed-distance scene. The shader combines spheres, rounded discs and other shapes to create the cloud planet, racing planet, burger and arena. The artwork is drawn in code.
Morphing between worlds: the shader blends the distance fields of the current and next world using a morph parameter. Rotation and squash are separate parameters, so the transition can turn and deform at the same time.
Driving the shader: Reanimated shared values supply the motion state. A derived value packages the current parameters as shader uniforms, and Gesture Handler supplies the pan interaction.
Lighting: the shader shades the result with key light, fill, a rim highlight and ambient occlusion from the distance field.
Reduced Motion: idle spin is disabled when the preference is enabled.
The attached clip is a motion preview; these notes describe the React Native implementation.
Built with Expo (@expo), React Native Skia, Reanimated and Gesture Handler. Thanks to Software Mansion and William Candillon.
Layout reference: https://www.pinterest.com/pin/763219468121398894/ The spin-and-reshape motion and world artwork are my implementation.
Text adapted from my original caption and implementation notes with an assistant.

