Shader Script


Production depth HDRP material features: subsurface scattering, translucency, anisotropy, iridescence, clear ... Samples ... Platforms: tested on Windows with Direct3D 11 and Direct3D 12.


by Andrei Hilevich


Price History +

Write Unity shaders in C#. Shader Script turns C# classes into complete shaders for the Universal and the High Definition Render Pipelines. You write what the surface does; Shader Script generates every pass, keyword and material property each pipeline needs, and a Material Inspector like the pipeline's own. No node graphs, no #pragma or #include, and no new language to learn.

Shaders as easy as your other code

  • Your IDE, fully. Code completion, refactoring and navigation in Visual Studio, Rider or VS Code. Every function is documented right in the IDE, and Shader Script's own checks appear as regular compiler errors, each with a link to its explanation.
  • Commit, diff and merge shaders like any C# code, instead of a graph file nobody can merge.
  • Unit-test your shader math. Code shared between shaders also runs on the CPU, so regular C# tests can cover it.
  • Ask an AI assistant to write a shader. Shader Script ships with a reference that teaches AI assistants its API, and one menu command sets it up. Tested with Claude Code.
  • Readable generated HLSL. It keeps the structure and the names of your C#, so it's easy to debug with the Frame Debugger or RenderDoc.

One shader, both render pipelines

  • A single class produces a shader for every render pipeline installed in the project. You write pipeline-specific code only where the pipelines really differ.
  • Lit, Unlit and Fullscreen shaders. Lit shaders get the pipeline's full lighting, shadows and global illumination. Fullscreen shaders are post-processing effects.

Material Inspectors without the boilerplate

  • Attributes shape the Inspector: [Range] makes a slider, [Color] and [HDR] a color picker, [Toggle] a checkbox, a "Section/Label" name a collapsible section, and [KeywordSwitch] a compile-time switch.
  • Surface settings in code: fix transparency, blending, face culling or alpha clipping, or mark a setting Override to give every material the pipeline's own control for it.
  • A plugin API for the rest. A ShaderGuiPlugin lays out your properties your way, for example showing a field only when a map is assigned. The reproduced URP and HDRP Lit Inspectors are built with it.

Production depth

  • HDRP material features: subsurface scattering, translucency, anisotropy, iridescence, clear coat, refraction, distortion, depth offset, tessellation and ray tracing.
  • Shader functions matching Shader Graph nodes, plus Unity's shader library functions and HLSL math.

Samples

  • Reproduced URP and HDRP Shaders: URP's and HDRP's own Lit and Unlit shaders, rebuilt with Shader Script, with the same options and Inspectors. Use them as starting points for your own shaders.
  • Feature Examples: procedural bricks, grass and a flag in the wind, snow cover, water with rain and a fishing float, fractal marble, wood and granite, a stone that breaks apart, a matrix fountain and a live oil painting. Every example works on both URP and HDRP, with full source.

Technical details

  • Unity: 2022.3 or later; tested on 2022.3, 6000.0, 6000.3 and 6000.6.
  • Render pipelines: URP or HDRP, no other packages required. The Built-in Render Pipeline isn't supported.
  • How it works: a C# source generator translates classes marked [Shader] to HLSL in the Editor; in a build they are regular Unity shaders.
  • Platforms: tested on Windows with Direct3D 11 and Direct3D 12. Other platforms (Metal, Vulkan, mobile) haven't been tested yet. The generated shaders are built on the render pipelines' own shader code, so they're expected to work wherever URP's and HDRP's own shaders do.
  • Included: two sample sets with full source, a reference for AI assistants, and the manual as a PDF.

Documentation and support

Unity and Shader Graph are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere. Shader Script is not affiliated with, sponsored or endorsed by Unity Technologies.