Class ShaderRegistry
Namespace: ValveResourceFormat.Renderer.Shaders
Assembly: Renderer.dll
Registry of user provided shader directories and shader name mappings.
Directories added here are mounted in front of the shaders shipped with the renderer, similar to how search paths work in . Any file placed in a mounted directory overrides the built-in file with the same relative path, which applies to shader entry points (complex.vert.slang) as well as anything pulled in with #include (common/lighting.slang).
Mappings translate a Source 2 shader name (shader.vfx) to the renderer shader file that will be used to draw it, taking priority over the built-in mapping table.
Configure this before creating a . Changing the registry drops the parsed shader cache, but shader programs that have already been compiled by an existing loader keep running the old code.
public static class ShaderRegistryInheritance
Properties
Directories
Gets the mounted shader directories, highest priority first.
public static ImmutableArray<string> Directories { get; }Property Value
Mappings
Gets the registered shader name mappings, keyed by the Source 2 shader name (e.g. shader.vfx).
public static ImmutableDictionary<string, string> Mappings { get; }Property Value
ImmutableDictionary<string, string>
Methods
AddShaderDirectory(string)
Mounts a directory containing shader files. The most recently added directory has the highest priority, and all mounted directories take priority over the shaders shipped with the renderer.
public static bool AddShaderDirectory(string path)Parameters
path string
Path to the directory that mirrors the layout of the built-in Renderer/Shaders folder.
Returns
true if the directory was added, false if it was already mounted.
Exceptions
The directory does not exist.
AddShaderMapping(string, string)
Maps a Source 2 shader name to the renderer shader file used to draw it. Overrides the built-in mapping when the same name is already known to the renderer.
public static void AddShaderMapping(string shaderName, string shaderFileName)Parameters
shaderName string
The Source 2 shader name, including the extension (e.g. shader.vfx).
shaderFileName string
The renderer shader name without stage or extension (e.g. my_shader for my_shader.vert.slang).
Reset()
Removes all mounted directories and registered mappings.
public static void Reset()
