What It Means & How to Fix It in UE5
🧠 Why You’re Seeing This Error
This error means your shader is using a macro, function, or type that’s defined in Common.usf
, but you haven’t explicitly included that file in your shader source.
Unreal Engine 5 doesn’t automatically include Common.usf, so if you rely on things like:
TransformWorldToClip()
PI
,TwoPi
float3x3 CreateTangentToWorld()
- Math macros like
saturate()
,lerp()
, etc. (in some cases)
…you must include the file manually or compilation will fail.
💥 Example Error Message
error X3004: undeclared identifier 'TransformWorldToClip'
Missing #include of Common.usf
🛠️ Common Shader Scenarios That Trigger This
❌ Using Functions Without Including the Header
float4 position = TransformWorldToClip(input.WorldPosition); // ❌ Fails without Common.usf
❌ Using UE Math Constants Without Declaration
float angle = 2.0 * PI; // ❌ 'PI' not defined unless Common.usf is included
✅ How to Fix “Missing #include of Common.usf” in UE5 – Step-by-Step
✔️ 1. Add the Include at the Top of Your Shader File
Always include this near the top of your custom .usf
file:
#include "/Engine/Private/Common.ush"
Or:
#include "/Engine/Private/Common.usf"
✅ Use .ush
for smaller helper files
✅ Use .usf
for full shader programs
✔️ 2. Include Other Essential Shader Headers (Optional)
If you’re using Unreal’s rendering functions, you may also need:
#include "/Engine/Private/Definitions.usf"
#include "/Engine/Private/MaterialTemplate.ush"
#include "/Engine/Private/VertexFactory.ush"
✔️ 3. Don’t Copy Code That Depends on Common.usf Without the Include
If you’re building a shader by copying pieces from Unreal’s internal shaders (e.g. BasePassPixelShader.usf
), you must include all required headers, or macros and functions will be undefined.
✔️ 4. Check Your IDE or Shader Include Paths (if using custom build)
Make sure your build setup allows Unreal to find engine-level shader files from:
Engine/Shaders/Private/
✅ Summary: How to Fix “Missing #include of Common.usf” in UE5
Cause | Fix |
---|---|
Using engine functions/macros | Add #include "/Engine/Private/Common.ush" to your shader |
Math constants or transforms undefined | Common.usf provides built-in definitions like PI , TransformWorldToClip() |
Using internal shader fragments | Manually include required headers when copying from engine code |