Patch Editor
Render Pass Patches
Shader Render Pass Patch

Shader Render Pass Patch

Render one or more visual shaders or textures, creating complex textures formed of multiple images.

This patch is particularly useful for:

  • Doing complex visual shader computations at a lower resolution to improve efficiency.
  • Storing data in a buffer (an intermediate stage of shader processing), ready be used at the Size specified in the patch.

Inputs

NameDescription

Size

Set this to edit the size of the texture output. For fixed sizing mode this is in pixels. For relative sizing mode this value is a factor relative to the screen, camera or background.

Sizing Mode

Set whether the size of the output texture is fixed or relative to the screen, camera or background.

Color Channel

The selected combination of color channels. Choose from RGBA, RGB, RG or A.

Data Type

Modify the texture’s data type depending on the precision level needed. Choose Unsigned Byte or Half Float.

Shader

Connect a visual shader or texture here.

Output

NameDescription

Image

The output is an image. It can be connected to another Shader Render Pass patch, a Scene Render Pass patch, visual shader network or the Screen Output patch.

Previewing the output

You can see a preview of the Shader Render Pass patch output at the bottom of the patch. The preview is closed by default. Open the preview by clicking on the arrow at the bottom right of the patch. In the example below we’re changing the color value in the Mix patch to adjust the output of the Shader Render Pass patch it’s connected to.

Example

This example uses the Shader Render Pass patch to add blur the camera texture and add a color filter:

A simple visual shader graph creates the colorful filter. It’s connected to the Shader input in the Shader Render Pass patch. The Shader Render Pass patch is then connected to a patch representing the Screen Output property of the Device scene object. In the Shader Render Pass the Size values are set to 0.1 and 0.05, rendering the camera texture at lower resolution to create the blurred effect.

Optimization

For efficiency it’s important to add Shader Render Pass patches intermittently in your patch graph. Usually it’s a good idea to add them after a particular stage in the graph. Too many will also impact the performance of your effect.

Use Spark AR Player to check the frame rate on different devices to get the balance right. You can also check the effect size in Spark AR Studio.

Cross-device compatibility

The effects you create are likely to be used on devices with a range of different specifications. This article will help you to ensure the shaders in your effects work well across as many different devices as possible.

Was this article helpful?