With the release of Spark AR Studio version 102, we’ve simplified shader authoring with the introduction of the Shader Code Asset, a new feature that lets you to write custom shaders and use them as materials or as visual shader patches. Additionally, the Shader Code Asset brings with it a brand new API that opens up a number of previously inaccessible functions, allowing you to explore more complex, custom-made materials in your Spark AR effects.
In Spark AR Studio, the Shader Code Assets represents a shader file in your project, much like a texture asset would represent a texture. Once you’ve created an asset, you simply write your shader using SparkSL, which is based on the GLSL shading language. You’ll find we’ve added several functions to SparkSL to make it more convenient for all creators, plus we’ve added new documentation that provides a basic guide and example of how to create the Shader Code Asset.
It’s easy to use the Shader Code Asset in the Patch Editor — simply drag the asset to the patch canvas and this action will create a new patch based on the Shader Code Asset. Thereafter, you can continue to edit your shader and any change you make will be reflected on the patch, once you save your shader. The patch acts just like any other visual shader, and it’s fully interoperable with existing visual shaders so you can easily update your previous projects.
We’re enabling you to use the Shader Code Asset directly as a material too. To do this, make sure your shader has a Color output value. A Color output is declared as “out vec4 Color,” you then just have to save your shader and select the shader on your material. And if you also want to modify the vertex position, just add “out vec4 Position,” and that should do the job. If you want to learn more about this, see our documentation on using the Shader Code Asset as a material.
Lastly, we’re releasing a new Shader API which allows you to access light data from your shader. The API contains light data about all of the lights in the scene, be it directional light, point light or ambient light. This means you have all the tools necessary to create your own full fledged custom material. To learn more about our Shader API, and other API functionality, check out our API documentation.
We hope you enjoy exploring the Shader Code Asset and all of the new functionalities it enables, we can’t wait to see what you create next!
Subscribe to the Spark AR Blog