shader-graph-create-custom-node

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Generating a custom Shader Graph node

生成自定义Shader Graph节点

Step 1: Generate an HLSL function definition

步骤1:生成HLSL函数定义

  • The function must be preceded by the preprocessor define
    UNITY_EXPORT_REFLECTION
  • 函数前必须添加预处理器定义
    UNITY_EXPORT_REFLECTION

Step 2: Decorate with Shader Graph hint tags

步骤2:添加Shader Graph提示标签

  • 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
  • 查看
    resources/all_hints.hlsl
    获取所有有效提示标签及使用模式
  • funchints
    paramhints
    块外支持C#风格的文档标签
  • 必填函数提示:
    • sg:ProviderKey
    • sg:SearchCategory
    • sg:SearchTerms
    • sg:DisplayName

Step 3: Write the code to an asset

步骤3:将代码写入资源文件

  • 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"
  • 在项目中搜索已包含自定义Shader Graph节点的
    ShaderInclude
    资源(
    .hlsl
    格式)
  • 如果存在匹配的资源,先向用户展示其当前内容,在追加新代码前请求确认
  • 如果没有匹配的资源,创建新的
    .hlsl
    资源
  • 确保文件开头包含
    #include "ShaderApiReflectionSupport.hlsl"