Patches in AR Studio

A patch is a building block. You can build a full effect by connecting patches together in what's known as a graph. Each individual patch will control part of your effect.

AR Studio has several different types of patches. This is what a patch looks like in AR Studio:

Name

When you create a patch, it will have a name. In the example above, the patch is called Loop Animation. You can rename some patches by double-clicking their name.

Ports

Patches have 'ports' - the small circles along the side of each patch.

Ports are labelled to show the behavior they can drive in the effect you're building. Ports can accept associated data types. You can set the data type in some patches by right-clicking the port and selecting an option from the Type menu.

You can adjust the values in some ports, but you can't change which ports a patch has.

Connections made between patches are read from left to right. This means the port on the right side of a patch is known as an output port, and the port on the left side is known as an input port.

For example, Loop Animation has 4 inputs:

  1. Enable - this port accepts a data type called a boolean signal, that turns an animation on or off.
  2. Duration - you'd adjust the value of this port to reflect the length of the animation, in seconds.
  3. Reset - this port also accepts a boolean signal, to reset the animation.
  4. Mirrored - a boolean signal that makes the animation move back and forth between zero and one. If the boolean is false, the animation will reset immediately to zero when it reaches one.

It has 1 output port, Progress. This is a progress data type, which is a number with values 0 to 1, where 0 is the initial state and 1 is the completed state.

Producers, Consumers and Intermediary patches

This graph uses producer, consumer and intermediary patches to create an effect that responds to the user's interaction. When a face with an open mouth is detected, the objects will appear in the effect.

Producers

Producers represent an object or material. You'll usually start building your graph with a producer patch. If you're not using the Patch Editor, you'll find these elements in the Scene tab.

Producer patches are purple in color. The Face Tracker patch - facetracker0 in this example - is a producer patch.

Change the name of producer patches by double-clicking their default name.

Intermediaries

These patches take the information from the producer patch and manipulate it - depending on the type of intermediary patch you choose. They're grey in color.

In this example, Mouth Open is the intermediary patch.

In the example below we've connected the Face output port on the facetracker1 patch to the Face input port on the Mouth Open patch. As a result, the Mouth Open patch will take information from facetracker0 to understand when the mouth is open.

Consumers

Consumer patches represent the properties of an object. They're blue in color, and will generally be the final patches in a graph.

If you weren't using the Patch Editor, you'd use the Inspector panel to apply these properties to your object.

In this example, pizzas_789, pizzas_456 and pizzas_123 are consumer patches. These patches control whether the objects are visible, because they represent the Visibility property for each object.

Because they're connected to the Mouth Open port in the Mouth Open patch, the objects will become visible when the mouth is open.

Change the name of consumer patches by double-clicking their default name.

Asset Patches

Asset patches represent an asset you've added to your effect, for example an audio file or a texture. They're orange in color.

Asset patches can be inserted multiple times.

Change the name of asset patches by double-clicking their default name.

Grouping patches

You can group patches to help organize your graph. Select the patches you want to group, right-click and select Group.

The input and output ports of a Group patch define the input and output for the whole group. You can create them by:

  1. Right-clicking the Group patch.
  2. Selecting Group Info, the Port Setup.
  3. Adding Input or Output ports.

List of Intermediary Patches

Name Description

Screen Tap

Capture a tap anywhere on the screen.

Object Tap

Capture a tap on an object in the scene.

Head Rotation

Capture head rotation, using data from a face tracker in the scene.

Head Nod

Capture a head nod, using data from a face tracker in the scene.

Head Shake

Capture a head shake, using data from a face tracker in the scene.

Mouth Open

Capture an opened mouth, using data from a face tracker in the scene.

Blink

Capture blinked eyes, using data from a face tracker in the scene.

Eyebrows Raised

Capture raised eyebrows, using data from a face tracker in the scene.

Eyebrows Lowered

Capture lowered eyebrows, using data from a face tracker in the scene.

Left Eye Closed

Determine when the left eye is closed, using data from a face tracker in the scene.

Right Eye Closed

Determine when the right eye is closed, using data from a face tracker in the scene.

Smile

Detect a smile, using data from a face tracker in the scene.

Animation

Animate an element in your scene.

Loop Animation

Animate an element in your scene repeatedly.

Transition

Convert a progress value to a value between a new range defined by the start and end values.

Keyframe Transition

Convert a progress value to a value between a new range defined by the start and end values. Progress output is used to chain multiple transitions.

Value Progress

Map scalar values to progress values.

Not

Flip a boolean from true to false, or from false to true.

And

Check if 2 booleans are true together.

Or

Check if either one of 2 booleans are true.

Equals

Check if 2 numbers are equal.

Greater Than or Equal To

Check if one input value is greater than or equal to another.

Greater Than

Check if one value is greater than another.

Less Than or Equal To

Check if one value is less than or equal to another.

Less Than

Check if one value is less than another.

Pack

Create a point with 3 dimensions (X, Y and Z).

Unpack

Turn a point into its individual X, Y and Z values.

Pulse

Trigger a pulse whenever a state changes from on to off or vice versa.

Option Switch

Control up to 5 states using an index (0, 1, 2...). This is useful for tracking a state that is one of many options. By default, the output is 0.

Counter

Create a counter that starts at 0, where the value can be increased or decreased gradually, or set to a specific number.

Math patches

Math patches can be used to perform a math operation on their input.

Name Description

Add

Adds 2 values.

Multiply

Multiplies 2 values.

Subtract

Subtracts 2 values.

Divide

Divides 2 values.

Negate

Negates the value.

Floor

Rounds down the value.

Ceiling

Rounds up the value.

Sine

Calculates the sine of the given argument.

Cosine

Calculates the cosine of the given argument.

Tangent

Calculates the tangent of the given argument.

Arcsine

Calculates the arcsine of the given argument.

Arccosine

Calculates the arccosine of the given argument.

Arctangent

Calculates the arctangent of the given arguments.

Exponential

Calculates the natural exponentiation of the given argument.

Logarithm

Calculates the natural logarithmn of the given argument.

Power

Calculates the value of the first parameter raised to the power of the second.

Modulo

Calculates division remainder for the given values.

Round

Rounds the value according to the specified rounding mode.

Absolute

Returns the absolute value of the argument.

Sign

Extracts the sign of the value.

Minimum

Returns the lesser of two values.

Maximum

Returns the greater of two values.

Clamp

Constrains a value to lie between two given bounds.

Mix

Linearly interpolates between two values modulated by Alpha.

Step

Generates a step function by comparing two values.

Smooth Step

Performs Hermite interpolation between two values.

Square Root

Calculates the square root of the value.

From Range

Maps the given value from the specified range to the [0, 1] range.

To Range

Maps the given value from the [0, 1] range to the specified range.

The patches in the table above will apply the operation separately on each component of the input.

So, if the input is Vector2 with the values (3.1,4.7), and we used the Round patch, the outputs will be (3, 5).

This also applies if there are two inputs. If you have an input of (5,7) and (1,6) and we use the Add patch, the outputs will be (6,13).

The input types must be compatible, for example you can't have an input of Vector2 and input of Vector3 connected to the same Add patch. If you want to use a number and another input, for example Vector2, AR Studio will automatically expand the number to the corresponding input. So, if you have an input of (5,7) and the number 2 in an Add patch, the output would be (7,9).

Name Description

Dot Product

Calculates the dot product of two vectors.

Cross Product

Calculates the cross product of two vectors.

Distance

Calculates the distance between two points.

Length

Calculates the length of a Vector.

Normalize

Calculates the unit vector in the same direction as the original vector.

Reflect

Calculates the reflection direction for an incident vector.