shadergraph-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShaderGraph Editor
ShaderGraph编辑器
Description and Goals
说明与目标
This skill provides guidance for manually editing USD ASCII (.usda) files to create and modify RealityKit materials and ShaderGraph networks. It covers material prims, shader nodes, connections, and material binding patterns.
本技能为手动编辑USD ASCII(.usda)文件以创建和修改RealityKit材质及ShaderGraph网络提供指导。内容涵盖材质prim、着色器节点、连接以及材质绑定模式。
Goals
目标
- Enable developers to create custom materials in USD format
- Guide manual editing of .usda files for ShaderGraph networks
- Help troubleshoot material and shader node issues
- Support creation of complex material networks
- Ensure proper material binding to geometry
- 帮助开发者创建USD格式的自定义材质
- 指导手动编辑.usda文件以构建ShaderGraph网络
- 协助排查材质与着色器节点相关问题
- 支持创建复杂的材质网络
- 确保材质与几何体正确绑定
What This Skill Should Do
本技能的功能
When editing ShaderGraph materials in .usda files, this skill should:
- Guide material creation - Show how to define material prims and surface shaders
- Explain shader nodes - Demonstrate how to add and configure shader node prims
- Show connections - Explain how to connect node outputs to shader inputs
- Handle material binding - Show how to bind materials to geometry
- Troubleshoot issues - Help identify and fix common material problems
- Prefer sample graphs when available - If the requested effect matches an example in , start from that file and point the user to it.
samples/
Load the appropriate reference file from the tables below for detailed usage, code examples, and best practices.
在.usda文件中编辑ShaderGraph材质时,本技能可:
- 指导材质创建 - 展示如何定义材质prim和表面着色器
- 解释着色器节点 - 演示如何添加和配置着色器节点prim
- 展示连接方式 - 说明如何将节点输出连接到着色器输入
- 处理材质绑定 - 展示如何将材质绑定到几何体
- 排查问题 - 帮助识别并修复常见的材质问题
- 优先使用示例图 - 如果所需效果与中的示例匹配,请以该文件为基础,并指引用户查看。
samples/
请从下方表格中加载对应的参考文件,以获取详细用法、代码示例及最佳实践。
Quick Start Workflow
快速开始流程
Before building a new effect from scratch, check for a close match and adapt it.
samples/- Open the file in a text editor.
.usda - Find or create a block in the correct scope.
def Material "MaterialName" - Define a prim and connect
def Shader "Surface"to the material output.outputs:surface - Add shader node prims () for textures and math operations.
def Shader - Connect node outputs to shader inputs with the syntax.
.connect - Set constant values on inputs that are not connected.
- Bind the material to geometry with .
rel material:binding
在从头构建新效果之前,请先检查目录中是否有相近的示例并进行适配。
samples/- 在文本编辑器中打开.usda文件。
- 在正确的作用域中找到或创建块。
def Material "MaterialName" - 定义prim,并将
def Shader "Surface"连接到材质输出。outputs:surface - 添加用于纹理和数学运算的着色器节点prim()。
def Shader - 使用语法将节点输出连接到着色器输入。
.connect - 为未连接的输入设置常量值。
- 使用将材质绑定到几何体。
rel material:binding
Information About the Skill
技能相关信息
Core Concepts
核心概念
Material Prim
材质Prim
The root of a material definition in USD. Contains the material structure and connects to a surface shader.
USD中材质定义的根节点,包含材质结构并连接到表面着色器。
Surface Shader
表面着色器
A prim that drives . Typically uses or RealityKit-specific shader identifiers.
Shaderoutputs:surfaceUsdPreviewSurface驱动的prim。通常使用或RealityKit专用的着色器标识符。
outputs:surfaceShaderUsdPreviewSurfaceShader Nodes
着色器节点
Additional prims for textures, transforms, and math operations. Each node has an that identifies its type.
Shaderinfo:id用于纹理、变换和数学运算的额外prim。每个节点都有一个用于标识其类型。
Shaderinfo:idConnections
连接
.connect使用语法链接节点输出与着色器输入,构建材质网络图形。
.connectMaterial Binding
材质绑定
rel material:binding网格prim上的用于将材质与几何体关联。
rel material:bindinginfo:id
info:id
The shader node identifier used by USD and RealityKit to determine the node's behavior.
USD和RealityKit用于确定节点行为的着色器节点标识符。
Reference Files
参考文件
| Reference | When to Use |
|---|---|
| When looking for ShaderGraph node and material reference guide. |
| 参考文件 | 使用场景 |
|---|---|
| 查找ShaderGraph节点和材质参考指南时使用。 |
Samples (Common Effects)
示例(常见效果)
This repo includes common ShaderGraph examples in . 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.
samples/- — A single scene that references the other samples for quick preview/inspection.
samples/ShaderSamplesScene.usda - — Mesh outline via duplicated mesh + vertex expansion (geometry modifier) and
samples/OutlineShader.usda.cullMode = "front" - — Fresnel/rim glow (emissive) with tunable color and falloff.
samples/FresnelShader.usda - — Near/far color gradient driven by camera distance.
samples/GradientShader.usda - — Animated lava emissive using 3D noise + time.
samples/LavaShader.usda - — Animated dissolve with noise threshold and emissive edge.
samples/DissolveShader.usda - — Animated vertex displacement using
samples/VertexDisplacementShader.usda(geometry modifier).outputs:realitykit:vertex - — Vertex displacement with corrected normals for cleaner lighting.
samples/NormalCorrectionShader.usda - — Toon shading using diffuse/specular ramp textures.
samples/ToonShader.usda - — PBR-to-toon node graph (banding/quantization) applied to an existing material graph.
samples/PBRToonShader.usda
Some samples reference external assets (for example ramp textures or a referenced ). When copying a sample into your project, keep or update those asset paths as needed.
.usdz本仓库在目录中包含常见的ShaderGraph示例。当用户询问特定视觉效果时,请优先选择最接近的示例,并告知用户打开该文件,以便确认具体的外观和参数。
samples/- — 一个包含其他所有示例引用的场景文件,用于快速预览/检查。
samples/ShaderSamplesScene.usda - — 通过复制网格+顶点扩展(几何体修改器)和
samples/OutlineShader.usda实现的网格轮廓效果。cullMode = "front" - — 具有可调颜色和衰减效果的菲涅尔/边缘发光(自发光)。
samples/FresnelShader.usda - — 由相机距离驱动的近/远颜色渐变。
samples/GradientShader.usda - — 使用3D噪声+时间实现的动画熔岩自发光效果。
samples/LavaShader.usda - — 带有噪声阈值和自发光边缘的动画溶解效果。
samples/DissolveShader.usda - — 使用
samples/VertexDisplacementShader.usda(几何体修改器)实现的动画顶点位移。outputs:realitykit:vertex - — 带有法线校正的顶点位移,以获得更清晰的光照效果。
samples/NormalCorrectionShader.usda - — 使用漫反射/高光渐变纹理实现的卡通着色效果。
samples/ToonShader.usda - — 应用于现有材质图的PBR转卡通节点图(带色阶/量化效果)。
samples/PBRToonShader.usda
部分示例引用了外部资源(例如渐变纹理或引用的.usdz文件)。将示例复制到项目中时,请根据需要保留或更新这些资源路径。
Implementation Patterns
实现模式
Basic Red PBR Material (UsdPreviewSurface)
基础红色PBR材质(UsdPreviewSurface)
usda
def Material "RedMaterial"
{
token outputs:surface.connect = <./Surface.outputs:surface>
def Shader "Surface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (1, 0, 0) # Red
float inputs:roughness = 0.2
float inputs:metallic = 0.0
token outputs:surface
}
}usda
def Material "RedMaterial"
{
token outputs:surface.connect = <./Surface.outputs:surface>
def Shader "Surface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (1, 0, 0) # Red
float inputs:roughness = 0.2
float inputs:metallic = 0.0
token outputs:surface
}
}Texture-Mapped Material
纹理映射材质
usda
def Material "TexturedMaterial"
{
token outputs:surface.connect = <./Surface.outputs:surface>
def Shader "Surface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor.connect = <../DiffuseTexture.outputs:rgb>
token outputs:surface
}
def Shader "DiffuseTexture"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textures/wood_albedo.png@
float2 inputs:st.connect = <../PrimvarReader.outputs:result>
float3 outputs:rgb
}
def Shader "PrimvarReader"
{
uniform token info:id = "UsdPrimvarReader_float2"
string inputs:varname = "st" # Name of UV set on mesh
float2 outputs:result
}
}usda
def Material "TexturedMaterial"
{
token outputs:surface.connect = <./Surface.outputs:surface>
def Shader "Surface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor.connect = <../DiffuseTexture.outputs:rgb>
token outputs:surface
}
def Shader "DiffuseTexture"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file = @textures/wood_albedo.png@
float2 inputs:st.connect = <../PrimvarReader.outputs:result>
float3 outputs:rgb
}
def Shader "PrimvarReader"
{
uniform token info:id = "UsdPrimvarReader_float2"
string inputs:varname = "st" # Name of UV set on mesh
float2 outputs:result
}
}RealityKit-Specific Nodes
RealityKit专用节点
usda
def Material "UnlitMaterial"
{
token outputs:surface.connect = <./UnlitSurface.outputs:surface>
def Shader "UnlitSurface"
{
# Identifier may vary based on RealityKit version/export
uniform token info:id = "ND_realitykit_unlit_surfaceshader"
color3f inputs:color = (0, 1, 0)
token outputs:surface
}
}usda
def Material "UnlitMaterial"
{
token outputs:surface.connect = <./UnlitSurface.outputs:surface>
def Shader "UnlitSurface"
{
# Identifier may vary based on RealityKit version/export
uniform token info:id = "ND_realitykit_unlit_surfaceshader"
color3f inputs:color = (0, 1, 0)
token outputs:surface
}
}Pitfalls and Checks
注意事项与检查项
- Ensure is present on the material.
outputs:surface.connect - Verify values match the expected node identifiers.
info:id - Confirm all paths point to valid outputs.
.connect - Provide a when using UV textures.
PrimvarReader - Bind materials to geometry with .
rel material:binding
- 确保材质上存在。
outputs:surface.connect - 验证值与预期的节点标识符匹配。
info:id - 确认所有路径指向有效的输出。
.connect - 使用UV纹理时需提供。
PrimvarReader - 使用将材质绑定到几何体。
rel material:binding