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
Shader graphs that are modified and saved while in play mode when using Play to Device will be updated immediately and retransferred. Materials using them will reflect the saved changes automatically.
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
.
Input properties
Shader graph properties must be set to Exposed
in order to be set on a per-instance basis. Globals must not be Exposed
, and 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, as well as the Opaque
and Transparent
surface types and the Alpha Clipping
setting. For Transparent
surfaces, the Alpha
, Premultiply
, and Additive
blending modes are supported. No other target settings are currently supported for conversion. Due to platform limitations, all materials will have Front
render face, depth writes enabled, LEqual
depth testing, and tangent space fragment normals.
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 Main Light Direction ✓ 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 Sample Cubemap ✓ Supported Sample Reflected Cubemap ✓ Supported Sample Texture 2D ✓ Supported Sample Texture 2D LOD ✓ Supported Sample Texture 3D ✓ Supported Sampler State MirrorOnce
wrap mode not supported.Split Texture Transform ✓ 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 | |
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 Environment Radiance | See lighting 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 | |
Polar Coordinates | ✓ Supported | |
Radial Shear | ✓ Supported | |
Rotate | ✓ Supported | |
Spherize | ✓ Supported | |
Tiling and Offset | ✓ Supported | |
Triplanar | ✓ Supported | |
Twirl | ✓ Supported |