Haishan - HLSL Material Functions — Turn .hlsl / .ush Files into Material Functions

Write real HLSL in .ush/.hlsl files and get one Material Function per function, with pins generated from the signature. Hot reload, #include, 14-function sample library. Editor-only.

Writing HLSL in Unreal's Custom node means pasting code into a small text box, adding every pin by hand, and, on many engine versions, fighting include paths.

HLSL Material Functions reads your .hlsl / .ush files and generates a standard Material Function for each exported function: Function Inputs, a Custom expression with your code, and Function Outputs. Keep your shader code in your own editor and source control; save the file and the Material Functions update in place.

The default Inline (self-contained) code mode embeds the code inside the generated asset, so you don't need any shader-folder mapping or C++ module — it works in Blueprint-only projects. In Inline mode you can use several Material Functions from the same HLSL library in one material without "redefinition" compile errors.

Ships with HaishanLib, a sample library of 14 public functions in 4 files (Noise, UV, Triplanar, Color Math).

Features
  • One file, many functions — every exported top-level function becomes its own Material Function; helpers are inlined automatically

  • Pins from the signature — scalar/vector types, default values, Texture2D / TextureCube / Texture2DArray / Texture3D inputs, bool → Static Bool, out/inout parameters → extra outputs

  • Default Inline (self-contained) mode — no shader directory mapping, no C++ module needed

  • Multiple Material Functions from the same library in one material — no redefinition errors in the default Inline mode (verified on UE 5.4 and 5.8)

  • #include support — relative paths, extra search directories, virtual path mappings; duplicate includes removed, cycles and missing files reported

  • Hot reload — save the file and the assets regenerate in place (Undo for hot reload is opt-in via Record Undo on Hot Reload)

  • Regenerate in place — existing Material Function assets are updated instead of recreated

  • Export control — /// comments become descriptions, // @category, // @private, // @export

  • Single-file generation — Tools → Haishan → Generate from HLSL File... (Ctrl+Z undoes it)

  • Dry-Run to preview what will be generated without writing assets

  • Name Conflict Policy — Overwrite Existing / Skip (Warn) / Prefix With Source File Name

  • Editor-only — nothing is added to your packaged game

Built-in Custom node vs HLSL Material Functions

Measured by us on UE 5.4.4 and 5.8 (Windows), October 2026.

  • Include a project .ush on UE 5.4 (Blueprint-only project)
    Built-in Custom node: Not possible without a C++ module that registers a shader directory mapping
    HLSL Material Functions: Default Inline mode embeds the code — no mapping, no C++

  • Several nodes in one material using the same HLSL library (UE 5.8)
    Built-in Custom node: Compile fails with redefinition errors (#pragma once does not help)
    HLSL Material Functions: No redefinition in default Inline mode (tested on 5.4 and 5.8)

  • Input / output pins
    Built-in Custom node: Added by hand, one by one
    HLSL Material Functions: Generated from the function signature

  • After you change the .ush signature
    Built-in Custom node: Recompile reads the new file, but pins/Code do not update; edit every node by hand
    HLSL Material Functions: Regenerate in place — FunctionInput/Output Ids kept, material wires stay connected

  • One file with many functions
    Built-in Custom node: One node per call, wired and configured manually
    HLSL Material Functions: One Material Function per exported function, generated in one step

Known limitations
  • Not a full HLSL compiler: macro expansion, templates and member functions are not handled.

  • Matrix (floatNxM) and array parameters are not supported; that function is reported and skipped.

  • A SamplerState parameter has no pin; it binds to the preceding texture parameter. Put the texture parameter first.

  • /Engine/... includes are not expanded.

  • Substrate materials: not yet verified.

  • The "no redefinition" result applies to the default Inline mode. The experimental Inline Flatten mode and the IncludeFilePaths mode have not been tested for this.

  • IncludeFilePaths mode references shader files by virtual path; every project that uses those assets needs the same mapping.

  • Hot-reload regeneration is not added to Undo unless Record Undo on Hot Reload is enabled.

Technical details
  • Type: Code plugin, one Editor module (no runtime module)

  • Engine versions: Targets UE 5.0–5.8. Functionally verified on UE 5.0, 5.3, 5.4, 5.6, 5.7, and 5.8. Build-verified on UE 5.1, 5.2, and 5.5.

  • Platform: Windows (Win64) editor

  • Settings: Edit → Project Settings → Plugins → HLSL Material Functions

  • Menus: Tools → Haishan → HLSL → Material Function: Generate All / Dry-Run / Refresh Watches; Tools → Haishan → Generate from HLSL File...

  • Included: HaishanLib sample library (14 public functions, 4 files)

  • Documentation: User Guide, Quick Start and FAQ in the plugin's Docs/User folder

  • Publisher: Haishan · Author: Christon Chan