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 從公開儲存庫中收錄這些內容。

檢舉或申請下架