Introduction
SkSL is the shading language of Skia, the 2D graphics library used by Chrome, Android, Flutter and other software. It is very similar to GLSL. Skia uses it internally and exposes it to programs as runtime effects, shaders whose source is compiled while the program runs and turned into code for the graphics interface in use.
The .sksl extension appears in Skia’s documentation as the file name of
a shader fed to its minifier. In most programs, SkSL source is a string in the code
rather than a file. Android’s AGSL, which shares much of its syntax with GLSL fragment
shaders and is used from Android 13 through RuntimeShader, is a variant of
the same idea; it is written in strings in app code.
Structure
A runtime shader is a plain-text program with a main function that
returns a colour. The coordinates passed to main are in local space.
Inputs from the program are declared as uniform variables, and a uniform
marked layout(color) is treated as a colour by the system.
uniform float2 iResolution;
half4 main(float2 fragCoord) {
float2 scaled = fragCoord / iResolution.xy;
return half4(scaled, 0, 1);
}
float2 and half4.Not described
Known, not yet covered
- Reference: this overview is the only page. The language has no reference pages: the types, the built-in functions, the differences from GLSL, the way child shaders and colour filters are declared, the runtime effect API (
SkRuntimeEffect) and the minifier. Skia’s SkSL documentation describes them. - Reference: AGSL, the Android variant, and how it differs from SkSL is not described.
- Viewer: there is no viewer for this format yet, and nothing is compiled or checked.
Links
Software
- Skia – the open-source 2D graphics library that compiles SkSL