ShaderGraph Editor
Description and Goals
This skill provides guidance for the Apple-documented Shader Graph workflow: author materials in Reality Composer Pro, load them with ShaderGraphMaterial, and update promoted inputs at runtime. It also covers how to inspect exported USD and MaterialX when you need advanced debugging or interoperability, but raw .usda editing is not the default authoring path.
Goals
- - Enable developers to create RealityKit materials with Shader Graph in Reality Composer Pro
- Guide loading and runtime control of INLINECODE2
- Help troubleshoot material graphs, promoted inputs, and exported assets
- Support advanced USD and MaterialX inspection without treating it as the primary workflow
- Point to repo samples when they provide a close starting point
What This Skill Should Do
When working with Shader Graph materials, this skill should:
- 1. Default to Reality Composer Pro - Treat the Shader Graph editor as the main authoring workflow.
- Guide node selection - Help choose the correct RealityKit surface, geometry, texture, and math nodes for the effect.
- Explain runtime integration - Show how promoted inputs map to
ShaderGraphMaterial parameters. - Troubleshoot exports - Inspect exported USD and MaterialX only when debugging, interop, or asset review requires it.
- Cross-link appropriately - Defer raw USD structure edits to
usd-editor when the task is really about prims, composition, or text-level USD authoring. - Prefer sample graphs when available - If the requested effect matches an example in
samples/, start from that file and point the user to it.
Load the appropriate reference file from the tables below for detailed usage, code examples, and best practices.
Quick Start Workflow
Before building a new effect from scratch, check samples/ for a close match and adapt it.
- 1. Create or open the material in Reality Composer Pro's Shader Graph editor.
- Choose the appropriate RealityKit surface node and add the graph nodes needed for the effect.
- Promote the inputs you expect to change at runtime.
- Save the material in the Reality Composer Pro asset package that ships with the app.
- Load the material with
ShaderGraphMaterial at runtime. - Update promoted inputs with runtime parameter APIs when the experience needs dynamic control.
- Inspect exported USD and MaterialX only when you need to debug the authored graph or interoperate with other asset tooling.
Information About the Skill
Core Concepts
Material Prim
Reality Composer Pro exports Shader Graph materials into USD-based assets, but the material should be authored in the Shader Graph editor rather than hand-written as text by default.
Shader Graph Authoring
Shader Graph materials are composed visually in Reality Composer Pro. Use RealityKit-specific nodes such as the surface and geometry modifier nodes that Apple documents for Shader Graph.
Promoted Inputs and Runtime Control
Promoted inputs let the app change material parameters after loading the material. This is the main Apple-supported workflow for runtime customization.
Exported USD and MaterialX
Exported assets may contain USD and MaterialX representations of the graph. Treat those files as implementation artifacts for debugging or interop, not as the primary authoring surface.
Samples and Interop Boundaries
The samples in this repo are useful starting points, but they are repo-owned examples. Do not treat raw exported info:id strings or USD graph structure as stable Apple API unless Apple documents them directly.
Reference Files
| Reference | When to Use |
|---|
REFERENCE.MD | When looking for ShaderGraph node and material reference guide. |
Samples (Common Effects)
This repo includes common ShaderGraph examples in samples/. When a user asks for a specific visual effect, start by selecting the closest sample and tell them to open it so you can align on the exact look and parameters.
Some samples reference external assets (for example ramp textures or a referenced .usdz). When copying a sample into your project, keep or update those asset paths as needed.
Implementation Patterns
Recommended Authoring Flow
- - Start with a Shader Graph material in Reality Composer Pro.
- Use Apple-documented RealityKit Shader Graph nodes such as the surface nodes and geometry modifier nodes for the effect you need.
- Promote any inputs that must change at runtime.
- Load the material in app code with
ShaderGraphMaterial. - Change promoted values at runtime rather than editing exported USD directly.
When Raw USD Review Is Appropriate
- - Inspect exported files when a material fails to load or render as expected.
- Compare repo samples to an exported asset when debugging a graph translation issue.
- Hand off prim-level edits to
usd-editor when the task is really about USD structure, paths, or composition.
Pitfalls and Checks
- - Do not present
UsdPreviewSurface networks as equivalent to Reality Composer Pro Shader Graph materials. - Do not rely on undocumented exported
info:id strings as stable Apple API. - Prefer promoted inputs and runtime parameter updates over raw text edits when the app needs dynamic control.
- Use
usd-editor for prim paths, composition arcs, or other text-level USD authoring tasks. - Treat the samples as repo examples, not as an exhaustive Apple-backed schema reference.
ShaderGraph 编辑器
描述与目标
本技能为 Apple 文档化的 Shader Graph 工作流程提供指导:在 Reality Composer Pro 中创作材质,使用 ShaderGraphMaterial 加载它们,并在运行时更新提升输入。它还涵盖了在需要高级调试或互操作性时如何检查导出的 USD 和 MaterialX,但原始的 .usda 编辑不是默认的创作路径。
目标
- - 使开发者能够在 Reality Composer Pro 中使用 Shader Graph 创建 RealityKit 材质
- 指导 ShaderGraphMaterial 的加载和运行时控制
- 帮助排查材质图、提升输入和导出资产的问题
- 支持高级 USD 和 MaterialX 检查,但不将其视为主要工作流程
- 在样本提供接近起点时指向仓库样本
本技能应执行的操作
在处理 Shader Graph 材质时,本技能应:
- 1. 默认使用 Reality Composer Pro - 将 Shader Graph 编辑器视为主创作工作流程。
- 指导节点选择 - 帮助为效果选择正确的 RealityKit 表面、几何体、纹理和数学节点。
- 解释运行时集成 - 展示提升输入如何映射到 ShaderGraphMaterial 参数。
- 排查导出问题 - 仅在调试、互操作或资产审查需要时检查导出的 USD 和 MaterialX。
- 适当交叉链接 - 当任务真正涉及图元、合成或文本级 USD 创作时,将原始 USD 结构编辑推迟到 usd-editor。
- 优先使用可用样本图 - 如果请求的效果与 samples/ 中的示例匹配,则从该文件开始并引导用户使用它。
从下表加载适当的参考文件以获取详细用法、代码示例和最佳实践。
快速入门工作流程
在从头开始构建新效果之前,检查 samples/ 中是否有接近的匹配并进行适配。
- 1. 在 Reality Composer Pro 的 Shader Graph 编辑器中创建或打开材质。
- 选择适当的 RealityKit 表面节点并添加效果所需的图节点。
- 提升预期在运行时更改的输入。
- 将材质保存在随应用一起提供的 Reality Composer Pro 资产包中。
- 在运行时使用 ShaderGraphMaterial 加载材质。
- 当体验需要动态控制时,使用运行时参数 API 更新提升输入。
- 仅在需要调试创作的图或与其他资产工具互操作时检查导出的 USD 和 MaterialX。
关于本技能的信息
核心概念
材质图元
Reality Composer Pro 将 Shader Graph 材质导出为基于 USD 的资产,但默认情况下材质应在 Shader Graph 编辑器中创作,而不是手动编写为文本。
Shader Graph 创作
Shader Graph 材质在 Reality Composer Pro 中以可视方式组合。使用 Apple 为 Shader Graph 记录的 RealityKit 特定节点,例如表面和几何体修改器节点。
提升输入和运行时控制
提升输入允许应用在加载材质后更改材质参数。这是 Apple 支持的主要运行时自定义工作流程。
导出的 USD 和 MaterialX
导出的资产可能包含图的 USD 和 MaterialX 表示。将这些文件视为用于调试或互操作的实现产物,而不是主要创作表面。
样本和互操作边界
此仓库中的样本是有用的起点,但它们是仓库拥有的示例。除非 Apple 直接记录,否则不要将原始导出的 info:id 字符串或 USD 图结构视为稳定的 Apple API。
参考文件
样本(常见效果)
此仓库在 samples/ 中包含常见的 ShaderGraph 示例。当用户请求特定视觉效果时,首先选择最接近的样本并告诉他们打开它,以便您可以对齐确切的外观和参数。
一些样本引用外部资产(例如渐变纹理或引用的 .usdz)。将样本复制到项目中时,根据需要保留或更新这些资产路径。
实现模式
推荐创作流程
- - 在 Reality Composer Pro 中以 Shader Graph 材质开始。
- 使用 Apple 记录的 RealityKit Shader Graph 节点,例如所需效果的表面节点和几何体修改器节点。
- 提升任何必须在运行时更改的输入。
- 在应用代码中使用 ShaderGraphMaterial 加载材质。
- 在运行时更改提升值,而不是直接编辑导出的 USD。
何时适合原始 USD 审查
- - 当材质无法按预期加载或渲染时检查导出的文件。
- 在调试图转换问题时将仓库样本与导出的资产进行比较。
- 当任务真正涉及 USD 结构、路径或合成时,将图元级编辑移交给 usd-editor。
陷阱和检查
- - 不要将 UsdPreviewSurface 网络呈现为与 Reality Composer Pro Shader Graph 材质等效。
- 不要依赖未记录的导出 info:id 字符串作为稳定的 Apple API。
- 当应用需要动态控制时,优先使用提升输入和运行时参数更新,而不是原始文本编辑。
- 对图元路径、合成弧或其他文本级 USD 创作任务使用 usd-editor。
- 将样本视为仓库示例,而不是详尽的 Apple 支持的模式参考。