Better Shaders is a system which targets the following goals:
- Write Lit Shaders in a simple format, akin to Unity’s Surface Shader system
- Shaders automatically compile to Standard, URP, and HDRP pipeline
- Shaders can be distributed and packaged for the asset store without Better Shaders
- Shader creation is more modular for developers and users of those shaders
If you’ve written a surface shader, Better Shaders will feel right at home to you, and surface shaders can be quickly ported to the system and immediately compile in URP, Standard, and HDRP. Better Shaders cleans up many of the quirks of the surface shader abstraction, massively improves what you can do with includes via it’s subshader system, and even lets users graphically stack existing shaders on top of each other to create new shaders.
For technical information about how this works, consult the online Documentation.
Stackable Shaders
Going beyond a surface shader replacement system, Better Shaders allows users to stack shaders together to create complex effects. For instance, this image was created by stacking these shaders on top of each other:
Let’s break down this example. At the top of the stack is the LitTessellation shader, which internally inherits from the Lit shader, and only implements a function to do the tessellation itself. Next we stack a moss effect onto it, which gives us moss based on the angle/height of the height texture. A puddles effect is applied after, followed by a UVShear modifier, which bends the UV coordinates for the two wind effects below it.
The same can be done via code:
BEGIN_SUBSHADER
"LitTessellation.surfshader"
"Stackable_Moss"
"Stackable_Puddles"
"Stackable_UVShear"
"Stackable_Wind"
"Stackable_Wind"
END_SUBSHADER
This lets you write and combine effects in a modular way, from multiple authors. Want to add Vegetation Studio support to your new shader? Simply subshader in its code, or stack it. Sub Shaders don’t just include code, but also properties, cbuffer entries, local keywords, etc. And you can even write them to allow multiple inclusion if you need to stack them more than once!
Better Shaders also includes custom Material Property Drawers to make your materials look better, and works with Shader Graph Markdown. You can even write Custom Editors for individual shaders, and they will be automatically combined into one editor for stacked shaders.