Overview
SkSL (Skia Shading Language) lets you write custom shaders for unique visual effects. You can experiment with SkSL shaders in the online editor. If you’re familiar with GLSL or looking to convert GLSL shaders to SkSL, check out the differences between GLSL and SkSL.Creating a Runtime Effect
First, compile your shader code usingRuntimeEffect.Make:
Shader Component
Use theShader component to apply your custom shader:
Props
| Name | Type | Description |
|---|---|---|
| source | RuntimeEffect | Compiled shader from RuntimeEffect.Make |
| uniforms | { [name: string]: number | Vector | Vector[] | number[] | number[][] } | Uniform values to pass to the shader |
| children | Shader | Child shaders to use as uniforms |
Simple Shader Example
Using Uniforms
Uniforms are variables that allow you to pass parameters to your shaders. They’re perfect for creating dynamic, interactive effects.Supported Uniform Types
float,float2,float3,float4float2x2,float3x3,float4x4int,int2,int3,int4- Arrays:
uniform float3 colors[12]
Basic Uniforms Example
Animated Uniforms
Combine with React Native Reanimated for dynamic effects:Nested Shaders
Pass other shaders as inputs to your custom shader:Common Shader Patterns
Gradient Effect
Checkerboard Pattern
Circle Pattern
Ripple Effect
Advanced Techniques
Multiple Shader Inputs
Color Manipulation
Performance Tips
- Keep shader code simple and efficient
- Avoid complex branching (if/else) when possible
- Use built-in functions (sin, cos, etc.) efficiently
- Minimize uniform updates
- Cache compiled RuntimeEffects
- Test on target devices for performance
Debugging Shaders
Compilation Errors
Visual Debugging
Output debug values as colors:Built-in Functions
SkSL supports many built-in functions:- Math:
sin,cos,tan,pow,sqrt,abs,floor,ceil,fract,mod - Vector:
dot,cross,length,distance,normalize - Interpolation:
mix,clamp,smoothstep,step - Color:
mixfor blending colors
See Also
- Shader Editor - Online SkSL playground
- SkSL Documentation - Official SkSL docs
- Image Shaders - Using images in shaders
- Gradients - Built-in gradient shaders
- Perlin Noise - Procedural noise shaders