In Meta Spark Studio, patch asset materials are visual shaders created in the Patch Editor then set as a Shader Type for a material in the Inspector.
They can be saved and reused, which means they’re helpful for quickly creating and reusing visual shaders.
You can use any patch group with an RGBA Color output as a patch asset material. Meta Spark Studio also includes a premade patch asset material that can be customized through the Inspector and Patch Editor.
Patch asset materials can have multiple inputs. They must always have an RGBA Color output. They can also output a vector4 Position to set the vertex position in the material. For example, for vertex displacement.
To create a premade patch asset material:
Any patch groups you've added to your project with Color outputs will also be available to select from the dropdown list.
A material defined by the patch asset material will be visible in the scene:
A new patch group will be listed in the Assets panel:
To change the appearance of the material, either:
Use the options in the Inspector to make small changes to the material.
Under Parameters the premade patch asset material has one color Input that can be edited.
When more inputs have been added to a patch asset material in the Patch Editor they will also be listed here.
Any Color outputs the patch asset material has will be listed here.
Sets the blend mode of the material. Choose from:
Back - Discard pieces of the mesh that are facing away from the viewer. Most effects use this mode to improve performance.
Front - Discard pieces of the mesh that are facing the viewer.
Sets the transparency of the material on an individual map level.
Displays both sides of a face normal.
Advanced Render Options
Use the Write to Depth Buffer and Use Depth Test checkboxes to control certain order parameters for the object the material is applied to.
Drag the patch group into the Patch Editor to edit it:
The group has one Input port on the left of the patch. This is a color defined by connecting other patches to it to create a more complex visual shader, or by adjusting the Input value in the Inspector.
It has 2 output ports:
Expanding the patch asset
Expand the patch asset to edit and customize it. You’ll see it’s made of 2 graphs. One graph affects the Color output, and the other can be used to set a vertex position.
The color graph
This graph uses a Vertex Attribute and Swizzle patch to convert the local normal XYZ values to RGB color. A Mix patch combines this with the input color by the amount specified in the Alpha value:
The vertex position graph
This graph conforms the object's local vertex positions to the screen space of the camera, outputting a matrix signal that controls the object’s vertex positions:
Edit this by adding your own offsets to these signals either uniformly through vectors or through additional matrices.
To make patch asset materials customizable through the Inspector, add inputs to the patch asset.
To add an input or output:
The following options will appear:
To add inputs or outputs, either:
When you’ve added the inputs and outputs you need, create a new patch asset.
To create a new asset:
In this project we’ve added a second color and animation by editing the premade patch asset material:
We did this by editing both the color and position graphs. We added:
The Color 2 input adds a second color. We changed the Vertex Attribute patch to output Texture Coordinates.
The position graph
The Duration inputs allows us to set the Duration value in the Loop Animation patch to set the speed of the animation.
The Strength input lets us edit the strength of the vertex displacement by defining how much the normals should be multiplied by and adding this to the position.