/vault-game-dev:ue4-shader-debugfrom vault-game-dev
Systematically diagnose and fix Unreal Engine shader compiler errors (X3000 unrecognized identifier, X3003 redefinition, X3004 undeclared identifier, X3017 type mismatch) — include-guard, conditional-define, variable-scope, and C++ compilation-environment root causes. Use when UE4/UE5 shader compilation fails with `error X30xx`.
Ships in vault-game-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Handles shader compilation failures in Unreal Engine 4 by providing systematic diagnosis and fixes.
When shader compilation errors appear in the form:
error X3000: unrecognized identifiererror X3003: redefinition oferror X3004: undeclared identifiererror X3017: cannot implicitly convertSymptom: error X3003: redefinition of '<identifier>'
Root Cause: A .ush file is included multiple times (via different #if USE_X branches in the parent .usf), but the .ush file lacks a global include guard.
Diagnosis:
# Find all includes of the problematic file
grep -n "#include.*ShadowMomentFiltering.ush" Engine/Shaders/Private/*.usf
Fix: Add a global include guard at the top of the .ush file:
// At very top, after copyright header
#ifndef SHADOW_MOMENT_FILTERING_USH_INCLUDED
#define SHADOW_MOMENT_FILTERING_USH_INCLUDED
// ... all content ...
#endif // SHADOW_MOMENT_FILTERING_USH_INCLUDED
Symptom: error X3004: undeclared identifier '<function>'
Root Cause: #ifndef USE_X that sets a default is nested inside #if USE_Y, so when USE_Y=0, USE_X never gets its default value.
Diagnosis: Check structure:
#if USE_Y // Line 100
#ifndef USE_X // Line 101 - nested INSIDE USE_Y block!
#define USE_X 0
#endif
struct X { ... }; // Defined only when USE_Y=1
#endif
Fix: Move #ifndef USE_X before the #if USE_Y block:
#ifndef USE_X
#define USE_X 0
#endif
#if USE_Y
// Now USE_X is guaranteed to be defined regardless of USE_Y
#endif
Symptom: error X3004: undeclared identifier '<variable>'
Root Cause: Variable declared inside #if X block but used outside it.
void MainPS(...) {
#if USE_M4
float Shadow; // Only declared when USE_M4=1
#endif
Shadow = 1.0; // Error when USE_M4=0
}
Fix: Declare variable before the conditional:
void MainPS(...) {
float Shadow = 0; // Always declared
#if USE_M4
Shadow = CalculateM4Shadow(...);
#endif
}
Symptom: error X3017: cannot implicitly convert from 'float2' to 'float3'
Fix: Use correct vector construction:
// Wrong
M4Settings.SvPosition = SVPos.xy;
// Correct
M4Settings.SvPosition = SVPos.xyx;
Symptom: USE_X is always 0 despite shader having #if USE_X blocks
Root Cause: C++ ModifyCompilationEnvironment doesn't set the USE_X define.
Diagnosis: Check ShadowRendering.h or equivalent:
static void ModifyCompilationEnvironment(...) {
OutEnvironment.SetDefine(TEXT("USE_M4_POINT_LIGHT"), 1);
OutEnvironment.SetDefine(TEXT("USE_M4"), 1);
}
From the log line:
error X3003: redefinition of 'quant1_m'
at ShadowMomentFiltering.ush(334,23-30)
Extract:
X3003 = redefinitionquant1_mShadowMomentFiltering.ushgrep -n "quant1_m" Engine/Shaders/Private/ShadowMomentFiltering.ush
# Which files include this .ush?
grep -rn "#include.*ShadowMomentFiltering.ush" Engine/Shaders/
# Check the including file's conditional structure
grep -n "#if USE_M4" Engine/Shaders/Private/ShadowProjectionPixelShader.usf
For each .ush file that's included multiple times:
#ifndef X_INCLUDED guard at top?#endif at bottom?When a file is included twice:
1st include: USE_M4=1, USE_M4_POINT_LIGHT=0
2nd include: USE_M4=1 (already defined!), USE_M4_POINT_LIGHT=1
If the file has no global guard, all code runs twice → redefinition.
# Find all includes of a problematic .ush
grep -rn "#include.*<filename.ush>" Engine/Shaders/Private/
# Find all #ifndef guards in a file
grep -n "#ifndef\|#define.*_INCLUDED\|#endif" Engine/Shaders/Private/problematic.ush
# Find all definitions of an identifier
grep -rn "static const.*identifier\|identifier =" Engine/Shaders/Private/
# Check C++ defines for shader
grep -rn "SetDefine.*USE_M4" Engine/Source/Runtime/Renderer/Private/
| Priority | Issue | Fix Complexity |
|---|---|---|
| 1 | Missing global include guard | Low - add #ifndef X_INCLUDED wrapper |
| 2 | Define inside conditional | Low - move #ifndef before outer #if |
| 3 | Variable scope | Low - declare before #if block |
| 4 | Type mismatch | Low - correct vector construction |
| 5 | Missing C++ define | Medium - add to ModifyCompilationEnvironment |
#if 0 to "disable" code - Doesn't work if other includes path to it#ifndef for defaults - These don't prevent re-processing, only set defaults once#if X is a guard - It's conditional compilation, not include protection#ifndef inside #if - The outer #if may skip the inner #ifndef, leaving defines unsetAll shader compilers complete with zero errors:
[0]LogShaderCompilers: Warning: 0 Shader compiler errors
| File | Purpose |
|---|---|
ShadowProjectionPixelShader.usf | Main shadow projection - includes M4 conditionally |
ShadowMomentFiltering.ush | M4 functions - must have global guard |
ShadowRendering.h | C++ sets USE_M4_POINT_LIGHT, USE_M4 defines |
ShadowDepthVertexShader.usf | Depth pass for shadows |
ShadowDepthPixelShader.usf | Pixel shader for shadow depth |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub yhyu13/agentskillsvault --plugin vault-game-dev31 skills in this plugin
/ai-3d-scene-pipeline用 AI 生产 3D 场景/关卡的完整链路:概念多视角参考图 → 资产拆解分流(Tripo 生成 vs Blender 代码搭建)→ Tripo 出高精度道具 → Opus 级模型驱动 Blender + Unity 组装 → 独立审查 Agent 多机位盲审迭代。Use when the user wants to build or replicate a 3D scene with AI(3D 场景搭建 / 关卡复刻 / Tripo 资产生成 / 参考图还原 / 多机位验收)。/animationGame-ready animation in Blender including walk/run/idle cycles, combat, mechanical animation, camera animation, constraints, Graph Editor, and NLA workflows via MCP./blender-directorUse when starting any Blender asset task, planning a production pipeline, coordinating multiple disciplines, or matching a reference photo/concept art. Invoke for game-ready assets, hard surface, environment, character, creature, export, or any multi-skill Blender workflow.