Shader Graph Create Custom Node

unity-technologies/skills/skills/shader-graph-create-custom-node

作者 unity-technologiescb1dccb8f5ad无许可证1K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Generates custom Shader Graph nodes from HLSL code. Use when the user wants a new Shader Graph node or to make existing HLSL work as a reflected function node.

AI 生成的概览

根据 HLSL 代码生成自定义 Unity Shader Graph 节点,并写入 .hlsl 资源文件。

功能
该技能指导如何从 HLSL 函数定义创建自定义 Shader Graph 节点。内容包括添加 UNITY_EXPORT_REFLECTION 预处理器定义、为函数添加必需的 Shader Graph 提示标签(如 sg:ProviderKey 和 sg:DisplayName),以及将生成的代码写入 ShaderInclude(.hlsl)资源。它还会检查项目中是否已有包含自定义节点的资源,并在追加前请求确认。
适用场景
当用户想要新建 Shader Graph 节点,或希望让现有 HLSL 代码作为反射函数节点使用时,可使用此技能。它面向使用 Shader Graph 包的 Unity 项目。
运行要求
需要 Unity Shader Graph 包(com.unity.shadergraph >= 17.5.0)以及包含 ShaderInclude 资源的 Unity 项目。该技能不附带脚本,依赖随附的 resources/all_hints.hlsl 参考文件。

Generating a custom Shader Graph node

Step 1: Generate an HLSL function definition

  • The function must be preceded by the preprocessor define UNITY_EXPORT_REFLECTION

Step 2: Decorate with Shader Graph hint tags

  • See resources/all_hints.hlsl for all valid hint tags and usage patterns
  • C#-style documentation tags are supported outside of funchints or paramhints blocks
  • Required function hints:
    • sg:ProviderKey
    • sg:SearchCategory
    • sg:SearchTerms
    • sg:DisplayName

Step 3: Write the code to an asset

  • Search the project for a ShaderInclude asset (.hlsl) that already contains custom Shader Graph nodes
  • If a matching asset exists, show the user its current contents and ask for confirmation before appending the new code
  • If no matching asset exists, create a new .hlsl asset
  • Ensure the file begins with #include "ShaderApiReflectionSupport.hlsl"

来源与署名

来源:unity-technologies/skills位于skills/shader-graph-create-custom-node提交cb1dccb

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架