Introduction
A .usf file, an Unreal Shader File, holds shader code for Epic Games’
Unreal Engine. The language is based on HLSL. The
engine first runs its own preprocessing pass, which is the same on every platform, and
then hands the result to the compiler of the target platform. A .usf file
should contain the shader entry points and private data.
A .ush file, an Unreal Shader Header, holds shared code. It is included
only by other .ush or .usf files, never used on its own.
Structure
Both kinds are plain text. A header begins with #pragma once so that it is
read only once. Includes name files by a path that starts at the engine’s shader
folder, as in #include "/Engine/Public/Platform.ush". Engine shaders live
under /Engine/Shaders/, and a plug-in can map its own folder to a virtual
path of its own. The engine needs a Platform.usf for every platform it
supports.
#include "/Engine/Public/Platform.ush"
float4 TintColour;
void MainPS(
float4 SvPosition : SV_POSITION,
out float4 OutColour : SV_Target0)
{
OutColour = TintColour;
}
TintColour is made up for this page.Not described
Known, not yet covered
- Reference: this overview is the only page. The format has no reference pages: how an entry point is tied to a shader class in C++, the engine’s shader parameter and macro conventions, the virtual shader paths, the preprocessing pass and what it adds to HLSL, and the platform compilers. Epic’s documentation describes some of it.
- Reference: Unreal’s material graphs, which generate shader code, are not described.
- Viewer: there is no viewer for these formats yet, and nothing is compiled or checked.
Links
Software
- Unreal Engine – game engine that compiles these shaders (Windows, macOS, Linux)
Reference
- Overview of shaders in plugins – Epic’s documentation on
.usfand.ushfiles