What It Means & How to Fix It in UE5
🧠 Why You’re Seeing This Error
This error means Unreal’s shader compiler is trying to compile a shader and looking for a function named MainVS
, but it doesn’t exist in the shader file being compiled.
In UE5, this usually happens when:
- You didn’t define the
MainVS()
function in your.usf
file - You used a different name for the entry point
- There’s a typo in the
IMPLEMENT_SHADER_TYPE
macro - The function is hidden behind a
#define
or#if
block
In short: Unreal is told to compile
MainVS
, but it can’t find it anywhere in your shader code.
💥 Example Error Message
error X3501: 'MainVS': entrypoint not found
🛠️ Common Shader Scenarios That Cause This
❌ Missing the Function Altogether
// File has no MainVS() defined
// Unreal expected: void MainVS(...) { ... }
❌ Typo or Wrong Name
hlslCopyEditvoid mainVS() { } // ← Wrong case: should be MainVS
// Or maybe:
void MyCustomVertexShader() { } // ← Doesn’t match what C++ expects
❌ Hidden Behind a Preprocessor Directive
#ifdef USE_MY_SHADER
void MainVS(...) { ... }
#endif
// If USE_MY_SHADER is undefined → MainVS doesn't exist at compile time
❌ Wrong Shader Stage or Entry Name in C++ Macro
IMPLEMENT_SHADER_TYPE(, FMyShader, TEXT("/Shaders/MyShader.usf"), TEXT("MainVS"), SF_Vertex);
But your .usf
file only has:
void VertexMain(...) { ... }
Unreal is looking for MainVS
, but only finds VertexMain
.
✅ How to Fix X3501 in UE5 – Step-by-Step
✔️ 1. Define a Function Named Exactly as Expected
If your shader is registered with "MainVS"
as the entry point, make sure your .usf
file contains:
hlslCopyEditvoid MainVS(...) {
// shader logic
}
Match the spelling and casing exactly.
✔️ 2. Match Entry Name in C++ Shader Registration
In your shader registration macro:
IMPLEMENT_SHADER_TYPE(, FMyVertexShader, TEXT("/Shaders/MyShader.usf"), TEXT("MainVS"), SF_Vertex);
Make sure "MainVS"
matches the actual function in the shader file.
✔️ 3. Watch for Conditional Compilation Hiding the Entry Point
If your function is inside a macro block:
#if ENABLE_MY_SHADER
void MainVS(...) { ... }
#endif
Make sure ENABLE_MY_SHADER
is defined when compiling. Otherwise, MainVS
doesn’t exist during compile time.
✔️ 4. Rebuild Shader Cache and Flush If Needed
Sometimes even after you fix the code, Unreal may cache the old version.
basDelete DerivedDataCache/
Restart Editor
Or use:
Console Command: ShaderCompileWorker -clean
✅ Summary: How to Fix “error X3501: ‘MainVS’: entrypoint not found” in UE5
Cause | Fix Example |
---|---|
Function MainVS() missing | Define it in your shader file exactly as expected |
Mismatch in macro vs function name | Sync IMPLEMENT_SHADER_TYPE with your shader function |
Preprocessor hiding the function | Ensure relevant #defines are active during compile |
Wrong casing | Use exact name: MainVS , not mainvs or vertexMain |