Shader Graph support
You can use the Unity Shader Graph to create custom materials for visionOS. These will previewed in their compiled form within Unity, but converted to MaterialX for display in simulator and on device. While MaterialX is very expressive, some Shader Graph nodes have no analog in materialX. Within the Shader Graph editor, unsupported nodes will be indicated by the presence of a #
symbol.
For technical, security, and privacy reasons, visionOS does not allow Metal-based shaders or other low level shading languages to run when using AR passthrough.
Debugging shader graphs
PolySpatial provides two methods useful for debugging shader graph conversion when using Play to Device to test your scenes on the visionOS simulator/device.
- First, shader graphs that are modified and saved while in play mode will be updated immediately and retransferred. Materials using them will reflect the saved changes automatically.
- Second, when connected to the Play to Device app, the shader graph editor will provide a
Preview Selection on Device
toggle in its menu bar. When that option is enabled and any single node or edge is selected, the value of that edge (or the first output of the node) will be rendered as the (unlit) output color in any materials that use the shader. Selecting a different node or edge will immediately update the result. This allows dynamic inspection of different intermediate values within the shader graph.
Texture limitations
When sampling textures in shader graphs, note that the sampler state (filter, wrap modes) associated with the texture itself is ignored. Instead, you must use the Sampler State
node to control how the texture is sampled if you want to use a mode other than the default (linear filtering, repeat wrap mode).
Coordinate space notes
There are two caveats to be aware of when converting between coordinate spaces in shader graphs. Because content is transformed according to the Volume Camera, the "world space" geometry returned within a shader graph will not match that of the simulation scene. Furthermore, visionOS is currently inconsistent with regards to the geometry it returns and the transformation matrices it supplies.
Retrieving the geometry of the source scene
To obtain positions, normals, tangents, or bitangents in the world space of the simulation scene, use the Position
, Normal Vector
, Tangent Vector
, or Bitangent Vector
nodes with Space
: World
, then transform them using the PolySpatial Volume to World
node with a Transform
appropriate to the type (typically Position
for positions and Direction
for the rest, which will be normalized after transformation).
Notes on Transform and Transformation Matrix nodes in VisionOS
The matrices returned by the Transformation Matrix
node and used by the Transform
node are obtained directly from visionOS and currently assume a world space that does not match either the simulation scene or the output of the Position
, Normal Vector
, Tangent Vector
, or Bitangent Vector
nodes. The "world space" output of those nodes is relative to the transform of the output volume--that is, it does not change when a bounded app volume is dragged around. The Transform
and Transformation Matrix
nodes, on the other hand, assume a world space that is shared between all app volumes. To get geometry in this world space, use the geometry (e.g., Position
) node with Space
: Object
and transform it with the Transform
node set to From
: Object
and To
: World
.
Global properties
Global values must be set in C# using the methods of PolySpatialShaderGlobals.
Time-based animation
Note that visionOS materials do not support global properties natively, and thus PolySpatial must apply global properties separately to all material instances, which may affect performance. For animation, consider using the PolySpatial Time
node rather than the standard Unity shader graph Time
. While PolySpatial Time
will not be exactly synchronized with Time.time (notably, it will not reflect changes to Time.timeScale), it is supported natively in visionOS and does not require per-frame property updates.
Supported targets
The Universal
and Built-In
targets are supported for conversion. For both targets, the Lit
and Unlit
materials are supported (Sprite Unlit
is treated the same as Unlit
), as well as the Opaque
and Transparent
surface types, the Alpha Clipping
setting, the Render Face
option, and the Depth Write
option (where Auto
is interpreted as Enabled
). The Depth Test
setting may be LEqual
or Always
. For Transparent
surfaces, the Alpha
, Premultiply
, and Additive
blending modes are supported. The Cast Shadows
setting is supported in the Universal
target. No other target settings are currently supported for conversion. All materials will have tangent space fragment normals.
Allow Material Override
The Allow Material Override
target setting is supported for the Render Face
, Depth Write
, Depth Test
, and Cast Shadows
settings (only), allowing you to change those settings via material properties (versus having to use a different shader), subject to the limitations described in the Supported targets
section (Depth Test
must be LEqual
or Always
). Switching between Opaque
and Transparent
surface types, between different blending modes, or toggling Alpha Clipping
via material overrides is not currently supported.
MaterialX keyword
The built-in MaterialX
keyword may be used to select different paths to use for Unity rendering (as used in editor play mode) versus MaterialX export (as used on visionOS). This is useful in cases where, for example, the Unity path requires Custom Function nodes that use HLSL beyond what is supported by the MaterialX exporter. Connect the Unity path to the Off
keyword input and the MaterialX path to the On
input.
MaterialX data extension
Additional options for MaterialX conversion may be configured in the Data Extension Settings
section, located under Target Settings
in the Graph Inspector
. Adding the MaterialX
data extension provides the following options:
Option | Description |
---|---|
Unlit Tone Mapping | If true, apply tone mapping to unlit targets. |
Shader Graph nodes
The following tables show the current support status for Shader Graph nodes in PolySpatial for visionOS including a list of supported nodes and their various caveats.
If a node doesn't appear here it means that it's not currently supported. Note that this list will be updated as we continue to add support for more nodes.
Artistic
Section | Node | Notes |
---|---|---|
Adjustment | Channel Mixer | ✓ Supported |
Contrast | ✓ Supported | |
Hue | ✓ Supported | |
Invert Colors | ✓ Supported | |
Replace Color | ✓ Supported | |
Saturation | ✓ Supported | |
White Balance | ✓ Supported | |
Blend | Blend | ✓ Supported |
Filter | Dither | Only default Screen Position is supported. |
Fade Transition | ✓ Supported | |
Mask | Channel Mask | ✓ Supported |
Color Mask | ✓ Supported | |
Normal | Normal Blend | ✓ Supported |
Normal From Height | ✓ Supported | |
Normal From Texture | ✓ Supported | |
Normal Reconstruct Z | ✓ Supported | |
Normal Strength | ✓ Supported | |
Normal Unpack | ✓ Supported | |
Utility | Colorspace Conversion | ✓ Supported |
Channel
Section | Node | Notes |
---|---|---|
Channel | Combine | ✓ Supported |
Flip | ✓ Supported | |
Split | ✓ Supported | |
Swizzle | ✓ Supported |
Input
Custom Interpolators
are limited to these specific/names types:
Color
: Vector4UV0
: Vector2UV1
: Vector2UserAttribute
: Vector4Section Node Notes Basic Boolean ✓ Supported Color ✓ Supported Constant ✓ Supported Integer ✓ Supported Slider ✓ Supported Time ✓ Supported Float ✓ Supported Vector2 ✓ Supported Vector3 ✓ Supported Vector4 ✓ Supported Geometry Bitangent Vector Tangent and View space options are not standard. Normal Vector Tangent and View space options are not standard. Position Tangent and View space options are not standard. Screen Position ✓ Supported Tangent Vector Tangent and View space options are not standard. UV ✓ Supported Vertex Color ✓ Supported Vertex ID ✓ Supported View Direction ✓ Supported View Vector ✓ Supported Gradient Blackbody ✓ Supported Gradient ✓ Supported Sample Gradient ✓ Supported Lighting Ambient ✓ Supported Baked GI Subject to limitations of PolySpatial Lighting Node Main Light Direction ✓ Supported Reflection Probe ✓ Supported Matrix Matrix 2x2 ✓ Supported Matrix 3x3 ✓ Supported Matrix 4x4 ✓ Supported Transformation Matrix Tangent and View space options are not standard. PBR Dielectric Specular ✓ Supported Metal Reflectance ✓ Supported Scene Camera Position
andDirection
outputs supported (non-standard).Eye Index ✓ Supported Fog ✓ Supported Object ✓ Supported Scene Depth Platform doesn't allow have access to the depth buffer, this is just the camera distance in either clip or view space. Screen ✓ Supported Texture Cubemap Asset ✓ Supported Gather Texture 2D ✓ Supported Sample Cubemap ✓ Supported Sample Reflected Cubemap ✓ Supported Sample Texture 2D ✓ Supported Sample Texture 2D Array ✓ Supported Sample Texture 2D LOD ✓ Supported Sample Texture 3D ✓ Supported Sampler State MirrorOnce
wrap mode not supported.Split Texture Transform ✓ Supported Texture 2D Array Asset ✓ Supported Texture 2D Asset ✓ Supported Texture 3D Asset ✓ Supported Texture Size ✓ Supported
Math
Section | Node | Notes |
---|---|---|
Advanced | Absolute | ✓ Supported |
Exponential | ✓ Supported | |
Length | ✓ Supported | |
Log | ✓ Supported | |
Modulo | ✓ Supported | |
Negate | ✓ Supported | |
Normalize | ✓ Supported | |
Posterize | ✓ Supported | |
Reciprocal | ✓ Supported | |
Reciprocal Square Root | ✓ Supported | |
Basic | Add | ✓ Supported |
Divide | ✓ Supported | |
Multiply | ✓ Supported | |
Power | ✓ Supported | |
Square Root | ✓ Supported | |
Subtract | ✓ Supported | |
Derivative | DDX | ✓ Supported |
DDXY | ✓ Supported | |
DDY | ✓ Supported | |
Interpolation | Inverse Lerp | ✓ Supported |
Lerp | ✓ Supported | |
Smoothstep | ✓ Supported | |
Matrix | Matrix Construction | ✓ Supported |
Matrix Determinant | ✓ Supported | |
Matrix Split | ✓ Supported | |
Matrix Transpose | ✓ Supported | |
Range | Clamp | ✓ Supported |
Fraction | ✓ Supported | |
Maximum | ✓ Supported | |
Minimum | ✓ Supported | |
One Minus | ✓ Supported | |
Random Range | ✓ Supported | |
Remap | ✓ Supported | |
Saturate | ✓ Supported | |
Round | Ceiling | ✓ Supported |
Floor | ✓ Supported | |
Round | ✓ Supported | |
Sign | ✓ Supported | |
Step | ✓ Supported | |
Truncate | ✓ Supported | |
Trigonometry | Arccosine | ✓ Supported |
Arcsine | ✓ Supported | |
Arctangent | ✓ Supported | |
Arctangent2 | ✓ Supported | |
Cosine | ✓ Supported | |
Degrees to Radians | ✓ Supported | |
Hyperbolic Cosine | ✓ Supported | |
Hyperbolic Sine | ✓ Supported | |
Hyperbolic Tangent | ✓ Supported | |
Radians to Degrees | ✓ Supported | |
Sine | ✓ Supported | |
Tangent | ✓ Supported | |
Vector | Cross Product | ✓ Supported |
Distance | ✓ Supported | |
Dot Product | ✓ Supported | |
Fresnel Effect | ✓ Supported | |
Projection | ✓ Supported | |
Reflection | ✓ Supported | |
Refract | ✓ Supported | |
Rejection | ✓ Supported | |
Rotate About Axis | ✓ Supported | |
Sphere Mask | ✓ Supported | |
Transform | ✓ Supported Refer to Coordinate Space Notes for information about using this node. | |
Wave | Noise Sine Wave | ✓ Supported |
Sawtooth Wave | ✓ Supported | |
Square Wave | ✓ Supported | |
Triangle Wave | ✓ Supported |
Procedural
Section | Node | Notes |
---|---|---|
Procedural | Checkerboard | ✓ Supported |
Noise | Gradient Noise | ✓ Supported |
Simple Noise | ✓ Supported | |
Voronoi | ✓ Supported | |
Shapes | Ellipse | ✓ Supported |
Polygon | ✓ Supported | |
Rectangle | ✓ Supported | |
Rounded Polygon | ✓ Supported | |
Rounded Rectangle | ✓ Supported |
Utility
Section | Node | Notes |
---|---|---|
Utility | Custom Function | See custom function node conversion notes. |
PolySpatial Background Blur | See below. | |
PolySpatial Environment Radiance | See lighting notes. | |
PolySpatial Hover State | See hover effect notes. | |
PolySpatial Lighting | See lighting notes. | |
PolySpatial Time | Non-standard shader graph node specific to PolySpatial. Implements the time function as described in the MaterialX Spec. | |
Preview | ✓ Supported | |
Split LR | Non-standard shader graph node specific to PolySpatial. Implements the splitlr function as described in the MaterialX Spec. | |
Logic | Branch | ✓ Supported |
Comparison | ✓ Supported | |
Is Infinite | ✓ Supported | |
Is NaN | ✓ Supported | |
Or | ✓ Supported |
UV
Section | Node | Notes |
---|---|---|
UV | Flipbook | ✓ Supported |
Parallax Mapping | ✓ Supported | |
Parallax Occlusion Mapping | Steps input must be constant (unconnected). |
|
Polar Coordinates | ✓ Supported | |
Radial Shear | ✓ Supported | |
Rotate | ✓ Supported | |
Spherize | ✓ Supported | |
Tiling and Offset | ✓ Supported | |
Triplanar | ✓ Supported | |
Twirl | ✓ Supported |
PolySpatial-specific nodes
PolySpatial provides several custom nodes that are not part of the standard shader graph node library in order to expose additional features of host platforms (such as visionOS) and the MaterialX standard. These include the PolySpatial Lighting and Environment Radiance nodes described in the lighting documentation, the PolySpatial Time and Split LR nodes from the MaterialX specification, and the following additional nodes.
PolySpatial Background Blur
This node provides a single color output that represents a blurred version of the color buffer at the current pixel position, useful for creating frosted glass effects.