SkSL Shader

Beta Feature. To enable, check Show Beta Features in Preferences.

SkSL ("Skia Shading Language") is a variant of GLSL which is used as Skia's internal shading language. With some minor modifications, GLSL code from sites like https://www.shadertoy.com/ can be converted for use in Cavalry.

For more detail on the differences between GLSL and SkSL see the Skia documentation.

UI

Blend Mode - see Blend Modes.

Shader Code - paste/edit SkSL code here.

Inputs - click the + Add button to to add a uniform.

Examples

Have a play with a selection of example .cv files. 👇

13KB
Open

Original source code:

Stars: https://www.shadertoy.com/view/XlfGRj Solar Wind: https://www.shadertoy.com/view/4lf3Rj Clouds: https://www.shadertoy.com/view/4tdSWr Simple: https://www.shadertoy.com/view/XsXXDn

Example usage:

  1. Create a Rectangle

  2. In the Attribute Editor, open the Fill tab.

  3. On the Shaders attribute, right click > Add Shader > SkSL Shader.

  4. Double click the SkSL Shader to load its Attribute Editor UI.

  5. Copy and paste the example code below into the Shader Code attribute.

  6. Rename the existing uniform n0 to Time. To do this, right click on the attribute and choose Rename.

  7. Click the + button to create a new uniform. Choose Add Double 2 (float2).

  8. Rename it Resolution.

  9. Ensure all values are > 0.

You should see a blue flame appear on the Rectangle. You can now start to play with connecting Behaviours (Noise, Sound etc) into each of the inputs. Try connecting a Frame Behaviour to the Time uniform.😎

Flat colour

  1. Delete the default n0 uniform. To do this, right click on the attribute and choose Delete Selected Attribute.

  2. Use the + button to add a Color (half4) uniform.

  3. Paste the code below into the Shader Code box.

  4. Adjust the color values on the uniform.

Cycling colour

  1. Rename the existing n0 uniform to Time. To do this, right click on the attribute and choose Rename.

  2. Paste the code below into the Shader Code box.

  3. Scrub the Time uniform.

Pixels

  1. Rename the existing n0 uniform to Time. To do this, right click on the attribute and choose Rename.

  2. Use the + button and choose Add Double 2 (float2) to add a new uniform.

  3. Rename the uniform to Resolution.

  4. Paste the code below into the Shader Code box.

  5. Increase the uniform's values.

Fractal Brownian motion

  1. Rename the existing n0 uniform to Time. To do this, right click on the attribute and choose Rename.

  2. Use the + button and choose Add Double 2 (float2) to add a new uniform.

  3. Rename the uniform to Resolution.

  4. Paste the code below into the Shader Code box.

  5. Increase the uniform's values.

Last updated

Was this helpful?