Intro and Philosophy

History

  • rendering has always been focus point
  • best visual at the best performance
  • all-compatible set of tools for any renderer or platform

UE1 (1997)

  • blended colored light
  • dynamic, static light
  • volumetric light, lensflare, perfect mirrors, procedural texture effects
  • 1k, 2k supported, detailed texture in 256mb memory

UE2 (2002)

  • DirectX 7 support
  • mesh, terrains, larger outdoor environments, vehicles
  • foliage and particle
  • basic material
  • vertex lighting

UE3 (2006)

  • DirectX 9 support
  • forward rendering
  • even larger outdoor environments
  • full lightmapping, dynamic shadows

UE4 (2014)

  • handle any style (not only high realism)
  • scalabiliy, from indipendable to AAA
  • over game egine
    • better fidelity, architecture, pipeline, flexibility

UE5 (2022)

  • Nanite
  • Lumen
  • Niagara

Schematic Schematic

  1. Ahead of Rendering
  2. Visibility Features
  3. Start of Rendering
  4. BasePass
    • BasePass Material
      • Geometry
      • Precomputed Lighting
  5. GBuffer
  6. Dynamic Light & Shadow
  7. Reflections
  8. Additional
    • Translucency
    • Atmospherics
    • Etc
  9. Post Processing
  10. Final Frame
    • Scalability and Performance

Schematic Overview

image
Full size (4MB)

Ahead of Rendering (Frame 0, CPU)

All Logic

deciding what to render

  • Gameplay
  • Animation
  • Physics
  • etc..

Visibility (Frame 1, CPU)

check what can be seen by camera.
process lighter tasks first to reduce calcuration candidates

  • Occlusion/Visibility Processes
    1. Distance Culling (Lightest)
      • not enabled by default (recommended)
      • by CullDistanceVolume
        • or you have to set Desired Max Draw Distance for every actors (annoying)
    2. Frustum Culling
      • standard enabled
      • why you have to disable this?
    3. Precomputed Visibility
      • not enabled by default (optional)
      • enable with World Setting property
      • Good for space-time tradeoff
        • use memmory to reduce cpu cost
      • by PrecomputedVisibilityVolume
    4. Visibility Culling (Heaviest)
      • standard enabled
      • heavy
      • check with freezerendering
      • Hardware Occlusion
        • use every mesh as occluder
        • not work in every devices (so engine need Software Occlusion)
      • Software Occlusion
        • uses Mesh LODs as occluder

Start of Rendering (Frame 2, GPU)

Early Z Pass

  • Scene Depth
  • used for deferred rendering pipeline

Basepass

Act of rendering all geometries
can check with GPU compiler

  • Drawcalls
    • HLOD
    • Static Meshes
    • Instanced Meshes
    • Skeletal Meshes
    • Landscapes
    • Procedural Meshes
    • Geometry Collection
    • … etc (Geometry, 3D to render)
  • Dynamic Instancing

    automatically batch drawcalls

    • enabled by default
    • same mesh, same material in one drawcall
  • Basspass Materials

    unreal’s deferred rendering do not render every materials at once.
    first, basic materials are rendered here (without shadow, blending, etc)

    • Lightmaps
      • need for initial shading
      • Generated by Lightmass

Static Lighting/Shadows

  • Lightmass

    Separeted application run by Swarm agent
    manage building and baking lights

    • what
      • Static Light Actors placed in the world
      • Lightmass Importance Volume
      • Global Illumination/Radiosity
    • how
      • Volumetric Lightmaps
        • default setting for current version
        • saves multiple lighting data since lightmap doesn’t provide dynamic lighitng data
      • Volume Lighting Samples
        • used for older version
        • less memory, less gpu time, less accuracy
        • saves single color only for dynamic lighting data

GBuffer

  • Buffer A : World Normals
  • Buffer B : Specular / Roughness / Metalic
  • Buffer C : Base Color / Lighting
  • Buffer D : Additional
  • Buffer E : Additional

Dyanmic Lighting/Shadows

Direct-Light

  • IES Profiles
    • customize light projection and intensity
    • can be static
  • Light Functions
    • Material -> Material Domain -> Light Function
    • e.g. fire flickering, water caustics, cloud shadow
    • kinda heavy work, so set Fade Distance in proper value

Direct-Shadow

  • Dynamic Shadows
    • optionally use Mesh Distance Field
    • cached (performance dip when invalidated)
    • r.Shadow.CacheWholeSceneShadows
  • Cascaded Shadow Maps
    • for gradually disappearing shadows
    • low, medium, high quality (3 by default)
    • commonly used in directional light, outdoor environments
    • still heavy, ugly when shadow disappear -> Distance Field Shadows
  • Distance Field Shadow
    • not enabled by default
    • uses Mesh Distance Field
    • need more memory and imprecise
  • Raytraced Shadows
  • Per Object Shdows & Inset Shadows
    • used for often-seen shadows (like character mesh)
    • can show more precise shadow
  • Contact Shadows
    • shadow over close obejcts
    • kind of post processing
    • for tiny detail

Indirect-Light

both are not commonly used for nowdays

  • Light Propagation
    • older realtime GI
    • outdated; not recommended
  • Raytraced GI
    • complication of raytracing feature
    • complex works

Indirect-Shadow

  • Raycast AO
    • raycast feature
    • Accurate raytraced Ambient Occlusion (a.k.a. its name)
  • Capsule Shadow
    • simplicating skeletal mesh’s shadow
    • commonly used for tiny creatures or swarming characters
    • can be used for vague light art style
  • DFAO
    • Distance Field Ambient Occlusion
    • uses Mesh Distance Field
    • used for moveable. stationary Skylight (in detail panel)
    • let actor scale stay close to 1, or Distance Field will look weird

Reflections

  • Reflection Process
    1. Reflection Captures
      • Placed in world, statically captures blend cubemap
      • fast, not precise
    2. Planar Reflections
      • Placed in world, dynamically capture everytime
      • precise, but only for flat surface
      • realtime; not good for performance
    3. Screen Space Reflections
      • reuse already-rendered result
      • replaces previous reflections if it possible (per-pixel)
      • can tweak with poss-process volume and cvar (e.g. SSR.Quality)
    4. Raytraced Reflections (optional)

Additional

  • Atmospherics
    • In Editor,
      • Exponential Height Fog
        • Distance Fog
      • Atmospheric Fog
      • Sky Atmosphere
    • Volumetric Fog
      • with Exponential Height Fog
      • reads Volumetric Lightmaps and adjust color on fog
      • renders dynamic light/shadows on top (e.g. god rays, light illumination)
      • can be tied into particle
      • Volumetric Materials
      • Distance Fog
    • Physically Based Sky Atmosphere
  • Translucency
    • Refraction
      • material detail panel -> Refraction Mode
        • Pixel Normal Offset : for flat surface
        • Index Of Refraction : for complex 3d objects
    • if you set Shading Mode as unlit, it’s good for performance
    • Lighting Mode
      • Volumetric NonDirectional
        • cheapest
      • Volumetric Directional
      • Translucency Volume
      • Volumetric PerVertex NonDirectional
        • almost cheapest
      • Volumetric PerVertex Directional
      • Surface ForwardShading
        • heaviest, nice looking
      • Raytraced

Post Processing

Unrea;’s almost postprocessings are enabled by default
Highlight with Volume, Camera, Component, Project Setting
turning checkbox off doesn’t mean feature is off
set Cvar into 0 or modify project setting to turn feature off

  • Tonemapper
    • r.Tonemapper.Sharpen
  • Bloom

    multi-stage; layered resulting
    supports reflection, 6 of size scale and tint

    • Standard
    • Convolution
      • high quality, expensive, not for realtime rendering
  • SSAO (Screen Space Ambient Occlusion)
  • SSSSS (Screen Space SubSurface Scattering)

    for skin, wax on candle. leaves

    • Burley SSSSS
  • SSGI (Screen Space Global Illuminaion)
    • disabled by default
    • approximate GI in screen space (like photoshop)
  • Depth Of Field
    • Gaussian
      • low quality, cheapest
    • Bokeh
      • expensive, high quality
      • but Circle/Cinematic is better in performance
      • deprecated; will be removed
    • Circle/Cinematic
      • high quality, acceptable performance
  • Exposure
    • uses setting in game setting
  • Blendables
    • allows PP Material to modify how screen looks like
    • e.g. underwater
  • Camera Effects
    • Grain
    • Vignette
    • Chromatic Abberation
    • Lensflares
    • Dirt Mask

Final Frame (Frame N, done)

Performance

check for world building chepter since it’s closely related

  • GPU Profiler
  • Stats
  • View Modes
  • Scalability
    • CVars
      • CVars are not saved; reset when you turn editor o
      • r.* : rendering, performance critial
      • help : generate HTML page that lists command and description
    • Scalability Example
      • Device Profile

        CVars are automatically called in distinct device

        • can type in text inside DefaultDeviceProfile.ini
        • can set layer by power to make engine estimate device power and adjust them

Advice

  • Managing tris and draw calls
    • do not forget using statistic panel
    • Merge Actors
      • grouping by materials
      • into single mesh
      • into an actor with multiple instanced static mesh components
    • Hitting the right balance (check rendering course)
    • LOD
      • Forced LOD Model
      • LOD Reduction
      • Detail Mode
  • Shadow rendering
    • Balance Cascaded Shadow Map / Distant Field
    • Far Shadows
      • set number of cascade cases and distance in directional light
      • set whether makes far shadow or not in model
      • kinda outdated by distance field
    • Toggling/Light Range
      • Max draw distnace in Light detail panel
    • Polycount/LODs
    • Large Meshes/Foliage Shadows
    • Toggling Shadows on detail meshes (DF+Regular)
      • Distance Field Shadow is useless for small meshes
  • Material cost
    • Noise is expensive
    • Instruction counts / Shader complexity
    • Balance between permutations/Instruction and Materials/Instances
    • Quality Switch
  • Translucency
    • use Unlit if you can
    • Instruction counts important
    • if lit - use the volume mode + CVars
      • e.g. r.TranslucencyLightingVolumeDim
    • Forward + Reflection is very expensive
    • Dithered translucency
  • Baking lighting
    • baking light needs all levels loaded
    • Lightmass Importance Volume
    • Volumetric Lightmaps tips
      • cell size in world property
      • Volumetric Lightmap Density Volume
    • override Lightmap size
    • can mass manipulate LM + Statics
    • Build time = LM Res + # lighta + # Meshes + Source Radius + Radius
  • Reflections
    • Base layer with Sphere Reflection Captures
    • Placement, tactic, cost and limits
    • Screen Space Reflection settings
    • Planar is rare, careful with real time
  • Forward/Mobile
    • Other renderers and where to find them
    • Previewing
    • Material settngs
  • Scalability Cvars/Shows
    • CVar tweaking and experimentation workflow
    • Help HTML Export
    • Setting defaults
    • Performance assessments with CVar toggling and Show/Hide commands
  • use Light Fallout Exponent for sizing light with less cost
  • try to use RenderDoc