< Return to Engineering Blog
Engine ArchitectureOCT 22, 2026 // 4 MIN READ

Unreal Engine Custom Shading Model for Anime Cel Shading

Architect a high-performance custom cel shading model in Unreal Engine's deferred pipeline for fast-paced anime stylized action combat.

The Architectural Failure of Screen-Space Post-Process Cel Shaders in Fast Combat

At Outlore, when engineering high-speed action combat pipelines, we reject hacky screen-space post-process wrappers for core gameplay rendering. In fast-paced action combat games, screen-space cel shading disintegrates under intense hit flashes, dynamic particle emitters, and rapid camera rotations. Sampling SceneColor and lighting buffers in screen space creates severe light bleeding, temporal anti-aliasing (TAA) ghosting, and stencil conflicts during rapid camera cuts. True anime stylized combat demands precise hardware-level control over the lighting pass: cleanly utilizing G-Buffer channels without introducing memory bus bottlenecks, computing deterministic discrete light bands in deferred passes, and preventing engine bloat from degrading our sub-millisecond frame budget. Read technical details on outlore game studio project ronin. Reference: Fixing Unreal Insights Game Thread Hitches in Combat. Reference: UE5 Swept Melee Collision: SweepMultiByChannel C++.

DIAGRAM // ARCHITECTURE
UE_PIPELINE // SHADING_MODEL_ANIME_COMBAT MODULE: DeferredShadingCommon.ush EXEC: RT_ASYNC [0.42ms] 01 // GBUFFER INPUT 8-BIT GBUFFER.A [RGB] BaseColor / Diffuse PBR Albedo Dynamic GBUFFER.B [ALPHA] Cel Threshold Mask Step Ramp 1D LUT CUSTOMDATA.R [UV] SDF Face Direction Shadow Map Rigged CUSTOMDATA.G [MASK] Combat Flash Buffer Hit Stop / Invert Mask CHAN_USAGE: 4/4 GBUFF VS_DATA 02 // CEL SHADING MODEL CORE.HLSL HALF-LAMBERT BTM NdotL = dot(N, L) * 0.5 + 0.5; Wrap shadow threshold bias BAND QUANTIZATION Cel = smoothstep(Thr-W, Thr, NdotL); Controlled 2-tone soft band SDF SHADOW MERGE Shadow = lerp(FaceSDF, Cel, IsBody); Anime head shadow fix COMBAT HIT MODULATOR Emit = HitInvColor * PulseAlpha; BRANCHING: DYNAMIC_INTRINSIC RAD_OUT 03 // COMBAT & RIM SPEC/RIM FRESNEL DEPTH RIM Depth-Weighted Rim Edge Breakout [Combat] ANISOTROPIC SPEC Stylized Angel Rings Hair Tangent Shifter SLASH / EMBER LIGHT Point Light Cel Clamping Non-Photorealistic Radius NORMAL BIAS DISCARD Self-Shadow Invalidate Clean Cheek Shadows SPEC_PASS: BLINN_CEL_HDR SCENE_HDR 04 // OUTLINE/PP FINAL INVERTED HULL Vertex Normal Push Constant Screen Px SOBEL POST-PROCESS Depth / Normal Edge Feature Silhouette TONE MAPPING LUT Anime Film Grading Vibrant Highlights OUTPUT FRAME SceneColor HDR R11G11B10_FLOAT ALPHA: COMPOSITED HLSL_HASH: #0xA9F42B | LIGHT_ATTEN: WARPED_STEP | FACE_SDF: BOUND RENDER_TARGET: HDR_POST_PASS [VRAM: 1.82 MB] // VALIDATED
// Figure 1: Architectural pipeline and execution flow for unreal engine custom shading model for anime stylized combat cel shading.

Relying on post-process edge detection and luminance-based thresholding assumes a static, predictable scene. When your combat loop involves frame-advantage pressure, multi-hit string combos, screen-space distortion waves, and dozens of overlapping point-light hit reactions, screen-space edge filters fail entirely. The thresholding calculations lose spatial coherence across frames, creating flickering outlines and muddy luminance bands that break the clean, intentional aesthetic of non-photorealistic rendering (NPR). Read technical details on project ronin action combat souls-like. Reference: Building Souls-Like Poise & Hyper Armor in UE5 C++.

Hardware G-Buffer Layout Optimization: Hijacking Clear Coat Channels

To achieve production-grade NPR without expanding Multiple Render Target (MRT) bandwidth or exhausting memory bus limits, we must integrate our shading model directly into Unreal Engine's deferred rendering pipeline. Modifying the G-Buffer structure to add dedicated custom textures introduces severe memory overhead and bandwidth penalties. Instead, a cleaner architectural approach is hijacking an existing, unused or repurposed shading model—such as Clear Coat—or defining a custom shading model enum value in EngineTypes.h that routes through CustomData channels. Read technical details on unity c++ engine garbage collection custom engine.

By repurposing the CustomData payload (such as CustomData.a or unused roughness bits), we pass artistic parameters like shadow thresholds, ramp selection indices, and specular sharpness flags directly into the deferred lighting pass. This avoids allocating extra render target textures and keeps our G-Buffer memory footprint tight. Read technical details on Custom HLSL Global Shaders in UE5: C++ & RDG Guide.

cpp
// Engine/Source/Runtime/Engine/Classes/Engine/EngineTypes.h
UENUM()
enum EMaterialShadingModel
{
    MSM_Unlit               UMETA(DisplayName = "Unlit"),
    MSM_DefaultLit          UMETA(DisplayName = "Default Lit"),
    MSM_SubSurface          UMETA(DisplayName = "Subsurface"),
    MSM_CustomToon          UMETA(DisplayName = "Custom Toon Shading"),
    MSM_MAX                 UMETA(Hidden),
};

Mathematical NdotL Warping and Discrete Tone Quantization in USF Shaders

Standard PBR lighting relies on smooth, continuous microfacet distributions (like GGX) that model physical light attenuation. Anime and cel-shaded aesthetics require discrete, stepped quantization of the dot product between the surface normal and the light direction ($N \cdot L$). Evaluating stepped half-Lambert lighting and tone ramps directly inside deferred lighting equations (specifically within DeferredLightPixelShader.usf or BDirectLighting.ush) preserves local point and spot light integrity without turning overlapping combat lights into muddy gradients.

hlsl
// DeferredLightPixelShader.usf / ToonLighting.ush snippet
float ComputeToonShading(float3 Normal, float3 LightDirection, float CustomThreshold, float CustomSmoothness)
{
    float NdotL = dot(Normal, LightDirection);
    // Half-Lambert transformation for stylized wrap-around lighting
    float halfLambert = NdotL * 0.5 + 0.5;
    
    // Discrete quantization step
    float shaded = smoothstep(CustomThreshold - CustomSmoothness, CustomThreshold + CustomSmoothness, halfLambert);
    return shaded;
}

Neutralizing Engine Tonemapper Conflicts for Saturated Anime Palettes

A common trap when implementing custom shading models in Unreal Engine is the default ACES filmic tonemapper. ACES is engineered to simulate physical film response curves, which naturally compress highlights, desaturate saturated primary colors, and introduce shoulder roll-off that destroys flat, vibrant anime color palettes. To achieve pure, saturated anime colors, developers must either bypass the tonemapper in specific shader permutations or normalize the G-Buffer output targets so that unclipped material colors retain their exact hue and saturation values.

As noted by graphics engineers exploring pipeline modifications, keeping the custom lighting calculations lightweight is entirely achievable. In well-structured implementations, the custom shading model adds as little as a single instruction per material pass, avoiding performance regressions while delivering a completely unique visual identity.

Decoupling Diffuse Quantization from Specular Breaks and Facial SDFs

True anime combat aesthetics—such as those seen in titles from Arc System Works—rely heavily on specialized styling rules that violate realistic optics. Specular highlights on hair and clothing should not follow microfacet roughness distribution; instead, they require hard-step geometric shapes or texture-driven specular masks. Furthermore, character faces require custom lighting solutions like camera-aligned vertex normal transfers and light-direction projected Signed Distance Field (SDF) face shadow masks to ensure noses and jaws cast clean, appealing shadow shapes regardless of where the actual scene light is positioned.

KEY ARCHITECTURAL TAKEAWAYS

  • 01.Avoid screen-space post-process cel shaders for fast action combat to eliminate TAA ghosting, light bleeding, and edge flickering.
  • 02.Hijack existing G-Buffer channels (such as Clear Coat CustomData) to pass custom toon thresholds and ramp indices without increasing MRT bandwidth.
  • 03.Implement NdotL warping and half-Lambert stepping directly inside DeferredLightPixelShader.usf for robust multi-light support.
  • 04.Neutralize or bypass ACES tonemapper curves to prevent desaturation and highlight compression on vibrant anime color palettes.

FREQUENTLY ASKED QUESTIONS

Do I need to recompile the Unreal Engine source code to add a custom cel-shading model?

Yes. Adding a first-class shading model requires modifying engine source files such as EngineTypes.h, MaterialShared.cpp, and DeferredLightPixelShader.usf. However, once integrated, artists can use the material graph freely without further engine recompilation.

How does cel shading affect performance in heavy combat scenes with multiple dynamic lights?

A well-implemented custom shading model evaluated in the deferred lighting pass is extremely lightweight—often adding only a single arithmetic instruction per material. Performance impact comes primarily from overdraw and outline post-processing, not the lighting calculation itself.

Can I combine cel shading with Unreal Engine's Substrate (Strata) materials?

Substrate replaces the traditional fixed shading model architecture with multi-scattering BSDF slabs. While extensible, custom cel shading in Substrate requires writing custom closures or modifying Strata evaluation shaders rather than relying on legacy MSM enums.

// CONNECTED_ENGINEERING_DOSSIERS

All Articles >