<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>GAMES104 Game Engine on BoilTask's Blog</title><link>https://boiltask.com/en/tags/games104-game-engine/</link><description>Recent content in GAMES104 Game Engine on BoilTask's Blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Thu, 29 Jan 2026 12:26:47 +0800</lastBuildDate><atom:link href="https://boiltask.com/en/tags/games104-game-engine/index.xml" rel="self" type="application/rss+xml"/><item><title>GAMES104 Modern Game Engine - Rendering of Terrain, Atmosphere, and Clouds in Games (Part 1)</title><link>https://boiltask.com/en/note/games104-game-engine-6/</link><pubDate>Thu, 29 Jan 2026 12:26:47 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-6/</guid><description>&lt;blockquote&gt;
&lt;p&gt;There are quite a few things I didn&amp;rsquo;t fully understand here; I&amp;rsquo;ll need to go over them again later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="the-god-of-the-earth-and-the-god-of-the-sky"&gt;&lt;a href="#the-god-of-the-earth-and-the-god-of-the-sky" class="header-anchor"&gt;&lt;/a&gt;The God of the Earth and the God of the Sky
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Course positioning&lt;/strong&gt;: Lecture 6 of GAMES104 &lt;em&gt;Modern Game Engine: From Introduction to Practice&lt;/em&gt;, on the rendering of &amp;ldquo;Mother Nature&amp;rdquo; — how to express the magnificent natural world with 0s and 1s.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;ldquo;God of the Earth&amp;rdquo; and &amp;ldquo;God of the Sky&amp;rdquo;&lt;/strong&gt;: In a game engine team, the engineer responsible for the terrain system is called the &amp;ldquo;God of the Earth&amp;rdquo;, and the one responsible for sky, lighting, and clouds is called the &amp;ldquo;God of the Sky&amp;rdquo;. These titles arose spontaneously within teams and reflect a love for the technology of rendering nature.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Rendering the beauty of nature&lt;/strong&gt;: From Spanish cave paintings to Picasso, the human instinct to express nature continues to this day. The mission of game engine developers is to turn mountains, rivers, and skies into virtual worlds with mathematical formulas.&lt;/p&gt;
&lt;h2 id="terrain-rendering-basics"&gt;&lt;a href="#terrain-rendering-basics" class="header-anchor"&gt;&lt;/a&gt;Terrain Rendering Basics
&lt;/h2&gt;&lt;h3 id="core-concept-height-field"&gt;&lt;a href="#core-concept-height-field" class="header-anchor"&gt;&lt;/a&gt;Core Concept: Height Field
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Definition&lt;/strong&gt;: Terrain in a game engine is called &lt;strong&gt;Terrain&lt;/strong&gt;, a word rooted in the Old English meaning &amp;ldquo;mother of the earth&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Height Field&lt;/strong&gt; is the most basic way to represent terrain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use a 2D grayscale image to represent terrain height (similar to a contour map)&lt;/li&gt;
&lt;li&gt;Mathematical essence: $y = f(x,z)$, a single-valued function&lt;/li&gt;
&lt;li&gt;Long before computer games appeared, surveying already used contour lines (Counter) to represent terrain&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Geometry generation&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Generate a uniform grid (e.g., one vertex per meter)&lt;/li&gt;
&lt;li&gt;Displace vertices along the Y axis according to the Height Field&lt;/li&gt;
&lt;li&gt;The early approach is simple, but in an Open World the data volume explodes (1km×1km needs 1 million vertices)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="fractal-and-the-laws-of-nature"&gt;&lt;a href="#fractal-and-the-laws-of-nature" class="header-anchor"&gt;&lt;/a&gt;Fractal and the Laws of Nature
&lt;/h3&gt;&lt;p&gt;Natural terrain (mountain ranges, coastlines, erosion marks) follows the principle of &lt;strong&gt;fractals&lt;/strong&gt;: infinitely self-similar shapes. This mathematical law is the foundation of procedural terrain generation.&lt;/p&gt;
&lt;h2 id="terrain-lod-level-of-detail-techniques"&gt;&lt;a href="#terrain-lod-level-of-detail-techniques" class="header-anchor"&gt;&lt;/a&gt;Terrain LOD (Level of Detail) Techniques
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Core conflict&lt;/strong&gt;: up close you need detail, far away you need efficiency.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;LOD principles&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Distance-dependent&lt;/strong&gt;: dense nearby, sparse far away&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;FOV (Field of View)-dependent&lt;/strong&gt;: the narrower the view (e.g., when aiming down sights), the finer the triangles; the wider the view, the sparser they are
&lt;ul&gt;
&lt;li&gt;Rationale: at the same screen pixels, the smaller the FOV, the more pixels a single object occupies, so higher geometric precision is required&lt;/li&gt;
&lt;li&gt;Application: 3x and 8x scopes are implemented by shrinking the FOV&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="mesh-subdivision-algorithms"&gt;&lt;a href="#mesh-subdivision-algorithms" class="header-anchor"&gt;&lt;/a&gt;Mesh Subdivision Algorithms
&lt;/h3&gt;&lt;h4 id="binary-triangle-tree"&gt;&lt;a href="#binary-triangle-tree" class="header-anchor"&gt;&lt;/a&gt;Binary Triangle Tree
&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Method&lt;/strong&gt;: always split at the midpoint of the longest side (the hypotenuse) of an isosceles right triangle, producing two new isosceles right triangles&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Structure&lt;/strong&gt;: a binary tree&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Problem&lt;/strong&gt;: &lt;strong&gt;T Junction (T-shaped junction / crack)&lt;/strong&gt;
&lt;ul&gt;
&lt;li&gt;When adjacent triangles have different subdivision levels, the shared edge ends up with &amp;ldquo;a vertex on one side and no vertex on the other&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Result: cracks appear in the terrain (white edges showing the sky background)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Solution&lt;/strong&gt;: force-refine the coarser side until it matches its neighbor&amp;rsquo;s level&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="quadtree--the-mainstream-approach-in-modern-games"&gt;&lt;a href="#quadtree--the-mainstream-approach-in-modern-games" class="header-anchor"&gt;&lt;/a&gt;Quadtree — the mainstream approach in modern games
&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Idea&lt;/strong&gt;: cut the terrain into &amp;ldquo;tofu cubes&amp;rdquo;, which matches human intuition and computer storage conventions (textures and height maps are all block-shaped)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Hierarchy&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Block&lt;/strong&gt;: e.g., a 512m×512m on-disk data block (stores height map, textures, vegetation, and building information)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Patch&lt;/strong&gt;: further subdivided into e.g. 64m×64m pieces&lt;/li&gt;
&lt;li&gt;Stop merging once subdivided to the visual limit&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;T Junction solution: Stitching&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rather than changing the geometry topology, the extra vertices are &amp;ldquo;stitched&amp;rdquo; onto the neighbor&amp;rsquo;s edge&lt;/li&gt;
&lt;li&gt;This forms &lt;strong&gt;degenerate triangles&lt;/strong&gt; (triangles with zero area)&lt;/li&gt;
&lt;li&gt;Advantage: the mesh structure is unchanged, and the code is simpler than with a Binary Triangle Tree&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="gpu-driven-terrain-tessellation"&gt;&lt;a href="#gpu-driven-terrain-tessellation" class="header-anchor"&gt;&lt;/a&gt;GPU-Driven Terrain Tessellation
&lt;/h2&gt;&lt;h3 id="traditional-pipeline-dx11"&gt;&lt;a href="#traditional-pipeline-dx11" class="header-anchor"&gt;&lt;/a&gt;Traditional pipeline (DX11)
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hull Shader&lt;/strong&gt;: generates the patches (control points) used for tessellation&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Tessellator&lt;/strong&gt;: fixed-function hardware unit that subdivides edges a set number of times&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Domain Shader&lt;/strong&gt;: samples the height map at the tessellated vertices and displaces them&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Geometry Shader&lt;/strong&gt;: Post Processing; passes vertex data to the next stage&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="modern-approach-mesh-shader-dx12"&gt;&lt;a href="#modern-approach-mesh-shader-dx12" class="header-anchor"&gt;&lt;/a&gt;Modern approach: Mesh Shader (DX12+)
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Revolutionary change&lt;/strong&gt;: Hull, Domain, and Geometry shaders are merged, generating Meshlets (small geometry pieces) in one pass&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Programmers have full control over the subdivision algorithm&lt;/li&gt;
&lt;li&gt;More flexible geometry generation&lt;/li&gt;
&lt;li&gt;Provides a foundation for Deformable Terrain&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="dynamicdeformable-terrain"&gt;&lt;a href="#dynamicdeformable-terrain" class="header-anchor"&gt;&lt;/a&gt;Dynamic/Deformable Terrain
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Use cases&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A tractor leaving ruts in a rice field&lt;/li&gt;
&lt;li&gt;The deformable snow in &lt;em&gt;God of War&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Craters left by artillery explosions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Implementation logic&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate geometry in real time with GPU Tessellation&lt;/li&gt;
&lt;li&gt;Maintain a Deformation Texture at runtime&lt;/li&gt;
&lt;li&gt;Add the deformation offset in the Vertex Shader&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physics synchronization&lt;/strong&gt;: the Collision Mesh must be updated in sync, otherwise you get the &amp;ldquo;walking on the void&amp;rdquo; bug&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="complex-terrain-features-beyond-the-height-field"&gt;&lt;a href="#complex-terrain-features-beyond-the-height-field" class="header-anchor"&gt;&lt;/a&gt;Complex Terrain Features: Beyond the Height Field
&lt;/h2&gt;&lt;h3 id="limitations-of-the-height-field"&gt;&lt;a href="#limitations-of-the-height-field" class="header-anchor"&gt;&lt;/a&gt;Limitations of the Height Field
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Cannot express vertical Overhangs&lt;/li&gt;
&lt;li&gt;Cannot express Caves or tunnels&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="traditional-hack-solutions"&gt;&lt;a href="#traditional-hack-solutions" class="header-anchor"&gt;&lt;/a&gt;Traditional hack solutions
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hole-punching markers&lt;/strong&gt;: in the Vertex Shader, output NaN (invalid number) for vertices in the region to be punched out, and the GPU automatically culls the affected triangles&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Placing objects at seams&lt;/strong&gt;: manually place rock models at cliff edges to hide the seams&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="volumetric-terrain--marching-cubes"&gt;&lt;a href="#volumetric-terrain--marching-cubes" class="header-anchor"&gt;&lt;/a&gt;Volumetric Terrain + Marching Cubes
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Concept&lt;/strong&gt;: store a density value (Weight) in 3D voxels instead of a single height.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Marching Cubes algorithm&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Based on the density values at the 8 voxel corners, look up one of 15 (or more) predefined triangulation cases&lt;/li&gt;
&lt;li&gt;Produces a watertight triangle mesh&lt;/li&gt;
&lt;li&gt;Applications: CT scan visualization, digital humans, fluid simulation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Current state and outlook&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Currently used mainly in voxel games such as &lt;em&gt;Minecraft&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Challenges: LOD transitions, complex data management&lt;/li&gt;
&lt;li&gt;Potential: truly fully dynamic terrain (dig holes or excavate anywhere)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="terrain-material-system"&gt;&lt;a href="#terrain-material-system" class="header-anchor"&gt;&lt;/a&gt;Terrain Material System
&lt;/h2&gt;&lt;h3 id="texture-splatting"&gt;&lt;a href="#texture-splatting" class="header-anchor"&gt;&lt;/a&gt;Texture Splatting
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Basic approach&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Splat Map&lt;/strong&gt;: each channel represents the weight of one material&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Material properties&lt;/strong&gt;: Base Color, Normal, Roughness, Metallic, Height&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Height-Based Blending&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Problem: alpha blending makes sand &amp;ldquo;float&amp;rdquo; on the rock surface, which looks unreal&lt;/li&gt;
&lt;li&gt;Solution: compare heights using the Height Map — the higher one is kept, the lower one fades out&lt;/li&gt;
&lt;li&gt;Effect: sand fills the cracks in the rock and grass grows out of them, rather than covering the rock&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Reducing jitter&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add a &lt;strong&gt;Bias (offset, e.g. 0.2)&lt;/strong&gt; and &lt;strong&gt;Smoothstep&lt;/strong&gt; to avoid sharp boundaries when materials switch and flickering (aliasing) at a distance&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="multi-material-management-texture-array"&gt;&lt;a href="#multi-material-management-texture-array" class="header-anchor"&gt;&lt;/a&gt;Multi-Material Management: Texture Array
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Concept&lt;/strong&gt;: stack multiple unrelated 2D textures and access them by Index (rather than the trilinear interpolation of a 3D Texture)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Advantage&lt;/strong&gt;: supports blending dozens of materials with no interpolation cost between layers&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Data organization&lt;/strong&gt;: the Splat Map stores both the material Index and the blend weights&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="enhancing-surface-detail"&gt;&lt;a href="#enhancing-surface-detail" class="header-anchor"&gt;&lt;/a&gt;Enhancing Surface Detail
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parallax Mapping&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Simulates parallax via raymarching&lt;/li&gt;
&lt;li&gt;Produces a three-dimensional bump effect, though the geometric silhouette stays flat&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Displacement Mapping&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Actually displaces vertices together with Tessellation&lt;/li&gt;
&lt;li&gt;Higher cost, and the trend of the future&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="virtual-texture"&gt;&lt;a href="#virtual-texture" class="header-anchor"&gt;&lt;/a&gt;Virtual Texture
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Core idea&lt;/strong&gt;: load only the textures in the region visible inside the view frustum, similar to virtual memory management in an operating system.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Workflow&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Divide the large terrain into multi-level Tiles, forming a mipmap pyramid&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Physics Texture (physical texture / cache)&lt;/strong&gt;: stores only the currently visible Tiles&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Feedback/Indirection&lt;/strong&gt;: map UVs to positions in the physical texture via a lookup table (Page Table)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Asynchronous loading&lt;/strong&gt;: an &amp;ldquo;apprentice&amp;rdquo; (thread/IO system) loads Tiles on demand from disk/memory and unloads invisible ones&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Memory&lt;/strong&gt;: VRAM usage has a theoretical upper bound (a converging geometric series)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Performance&lt;/strong&gt;: material blending is precomputed (baked) at load time, so at runtime you sample a single texture directly, greatly reducing overdraw and texture sampling cost&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Hardware acceleration&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;DirectStorage&lt;/strong&gt;: disk → VRAM, transferred while still compressed and decompressed on the GPU&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;DMA (Direct Memory Access)&lt;/strong&gt;: a PS5 technology; data goes straight from the SSD to VRAM, bypassing the CPU and memory bus&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="floating-point-precision"&gt;&lt;a href="#floating-point-precision" class="header-anchor"&gt;&lt;/a&gt;Floating Point Precision
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;: when 32-bit floats represent a large-scale world (such as Earth to the Moon, or a large open world), the fractional part lacks precision (precision decreases as the value grows), causing distant objects to jitter.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom&lt;/strong&gt;: at 2-3 km out, where values reach tens of thousands, the fractional precision may exceed 1 cm, causing decals to z-fight with walls and objects to flicker.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solution: Camera Relative Rendering&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Set the camera position as the origin (0,0,0)&lt;/li&gt;
&lt;li&gt;Subtract the camera position from all world coordinates to get relative coordinates&lt;/li&gt;
&lt;li&gt;This preserves the high-precision fractional part and eliminates jitter&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Other approaches&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using Double (64-bit floats): too high a cost in data volume and bandwidth&lt;/li&gt;
&lt;li&gt;Sublevel relative coordinates: used by large engines such as UE5, where the coordinate system is reset for each Level&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="environment-element-systems"&gt;&lt;a href="#environment-element-systems" class="header-anchor"&gt;&lt;/a&gt;Environment Element Systems
&lt;/h2&gt;&lt;h3 id="foliage-rendering"&gt;&lt;a href="#foliage-rendering" class="header-anchor"&gt;&lt;/a&gt;Foliage Rendering
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;SpeedTree&lt;/strong&gt;: the industry-standard vegetation middleware&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LOD strategy&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Near: real meshes&lt;/li&gt;
&lt;li&gt;Mid distance: combinations of cards&lt;/li&gt;
&lt;li&gt;Far: billboards&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="decorator"&gt;&lt;a href="#decorator" class="header-anchor"&gt;&lt;/a&gt;Decorator
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: environment details such as small grass, pebbles, and small shrubs&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Techniques&lt;/strong&gt;: simple meshes, clustered billboard rendering&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="road-system"&gt;&lt;a href="#road-system" class="header-anchor"&gt;&lt;/a&gt;Road System
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Spline&lt;/strong&gt;: artists generate roads by dragging control points&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Erosion (carving)&lt;/strong&gt;: after a road is generated, the Height Field must be carved and flattened so that mountainous terrain is suitable for the road&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="decal"&gt;&lt;a href="#decal" class="header-anchor"&gt;&lt;/a&gt;Decal
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Definition&lt;/strong&gt;: a detail texture projected onto a surface (e.g., bullet holes, stains, road markings)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Application&lt;/strong&gt;: combined with Virtual Texture and baked into the terrain texture&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="procedural-generation"&gt;&lt;a href="#procedural-generation" class="header-anchor"&gt;&lt;/a&gt;Procedural Generation
&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Trend&lt;/strong&gt;: moving from manual editing to rule-based procedural generation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Capabilities&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Automatically generate vegetation based on slope, altitude, and material type (broadleaf forest → coniferous forest transition)&lt;/li&gt;
&lt;li&gt;Simulate water erosion to produce ridges and gullies&lt;/li&gt;
&lt;li&gt;Automatically generate road networks&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Requirement&lt;/strong&gt;: engine developers need some naturalist knowledge to understand geological and ecological laws.&lt;/p&gt;
&lt;h2 id="conclusion-the-technical-path-to-becoming-a-god-of-the-earth"&gt;&lt;a href="#conclusion-the-technical-path-to-becoming-a-god-of-the-earth" class="header-anchor"&gt;&lt;/a&gt;Conclusion: The Technical Path to Becoming a &amp;ldquo;God of the Earth&amp;rdquo;
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Basics&lt;/strong&gt;: master the Height Field and LOD principles&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Geometry&lt;/strong&gt;: implement Quadtree + GPU Tessellation and handle T Junctions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Materials&lt;/strong&gt;: Texture Splatting + Virtual Texture&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamics&lt;/strong&gt;: GPU Driven Deformable Terrain&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Precision&lt;/strong&gt;: Camera Relative Rendering to solve large-space problems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ecosystem&lt;/strong&gt;: integrate the SpeedTree, Decorator, Road, and Decal systems&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Future&lt;/strong&gt;: explore Volumetric Terrain and Marching Cubes&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="references"&gt;&lt;a href="#references" class="header-anchor"&gt;&lt;/a&gt;References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://www.bilibili.com/video/BV1au411y7Fq" target="_blank" rel="noopener"&gt;Rendering of Terrain, Atmosphere, and Clouds in Games (Part 1) | GAMES104 - Modern Game Engine: From Introduction to Practice&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GAMES104 Modern Game Engine - The Mathematical Magic of Light and Materials in Rendering</title><link>https://boiltask.com/en/note/games104-game-engine-5/</link><pubDate>Wed, 28 Jan 2026 13:19:37 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-5/</guid><description>&lt;blockquote&gt;
&lt;p&gt;There are quite a few things I didn&amp;rsquo;t fully understand; I&amp;rsquo;ll need to go through them again later.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="introduction-the-essential-challenge-of-rendering"&gt;&lt;a href="#introduction-the-essential-challenge-of-rendering" class="header-anchor"&gt;&lt;/a&gt;Introduction: The Essential Challenge of Rendering
&lt;/h2&gt;&lt;p&gt;This lecture explores the core of modern game engine rendering — &lt;strong&gt;the mathematical relationship between light, materials, and shaders (Shader)&lt;/strong&gt;. It is one of the most complex and intricate systems in a game engine.&lt;/p&gt;
&lt;p&gt;The essence of rendering is simulating the propagation of photons: photons are emitted from light sources, and after reflection, absorption, and refraction they enter the human eye. To solve this process in real time under limited hardware compute, graphics researchers and engineers around the world have spent the past decades proposing countless ingenious &amp;ldquo;hacks&amp;rdquo; (engineering compromises), collectively building today&amp;rsquo;s real-time rendering technology stack.&lt;/p&gt;
&lt;h3 id="the-rendering-equation"&gt;&lt;a href="#the-rendering-equation" class="header-anchor"&gt;&lt;/a&gt;The Rendering Equation
&lt;/h3&gt;&lt;p&gt;35 years ago, &lt;strong&gt;Kajiya&lt;/strong&gt; proposed the famous Rendering Equation, now regarded as the most fundamental theoretical framework in graphics:&lt;/p&gt;
&lt;blockquote&gt;
$$
L_o(x, \vec w) = L_e(x, \vec w) + \int_\Omega f_r(x, \vec w', \vec w) L_i(x, \vec w') (\vec w' \cdot \vec n) d\vec w'
$$&lt;p&gt;
Where:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;$L_o(x, \vec w)$ is the outgoing light at position $ x $ and direction $\vec w$.&lt;/li&gt;
&lt;li&gt;$L_e(x, \vec w)$ is the light emitted at the same position and direction.&lt;/li&gt;
&lt;li&gt;$\int_\Omega &amp;hellip; d\vec w&amp;rsquo;$ is the infinitesimal sum over the hemisphere of incident directions.&lt;/li&gt;
&lt;li&gt;$f_r(x, \vec w&amp;rsquo;, \vec w)$ is the fraction of light reflected at that point from the incident direction to the outgoing direction.&lt;/li&gt;
&lt;li&gt;$L_i(x, \vec w&amp;rsquo;)$ is the incident light at that point, at position and direction $ \vec w&amp;rsquo; $.&lt;/li&gt;
&lt;li&gt;$(\vec w&amp;rsquo; \cdot \vec n)$ is the attenuation of incident light caused by the incident angle.&lt;/li&gt;
&lt;/ul&gt;
&lt;p style='text-align:right'&gt;—— &lt;a href="https://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E6%96%B9%E7%A8%8B" target="_blank"&gt;Rendering Equation - Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Core contradiction&lt;/strong&gt;: this equation describes perfect physical truth, yet it is &lt;strong&gt;extremely difficult to solve in real time&lt;/strong&gt;. The work of game engine engineers over the past 30 years is essentially the search for various &lt;strong&gt;engineering approximate solutions&lt;/strong&gt; to this equation.&lt;/p&gt;
&lt;h2 id="the-three-major-challenges-of-real-time-rendering"&gt;&lt;a href="#the-three-major-challenges-of-real-time-rendering" class="header-anchor"&gt;&lt;/a&gt;The Three Major Challenges of Real-Time Rendering
&lt;/h2&gt;&lt;p&gt;Real-time rendering faces three core challenges:&lt;/p&gt;
&lt;h3 id="visibility-to-light"&gt;&lt;a href="#visibility-to-light" class="header-anchor"&gt;&lt;/a&gt;Visibility To Light
&lt;/h3&gt;&lt;p&gt;That is, the shadow problem. Determining whether a point in the scene can be directly lit by a light source seems simple, but it is in fact one of the thorniest problems in graphics.&lt;/p&gt;
&lt;h3 id="complexity-of-light"&gt;&lt;a href="#complexity-of-light" class="header-anchor"&gt;&lt;/a&gt;Complexity of Light
&lt;/h3&gt;&lt;p&gt;Real-world lighting comes from the spherical space (Sphere) in every direction, not from simple directional or point lights. How to handle area lights (Area Light), ambient light (Ambient Light), and the different frequency (high/low frequency) information of light is a huge challenge.&lt;/p&gt;
&lt;p&gt;Even if we know the incoming lighting from every direction (a spherical function), computing its integral (convolution) with the material BRDF is still enormously expensive. In real time, we cannot densely sample and integrate over the sphere.&lt;/p&gt;
&lt;h3 id="global-illumination"&gt;&lt;a href="#global-illumination" class="header-anchor"&gt;&lt;/a&gt;Global Illumination
&lt;/h3&gt;&lt;p&gt;In the real world, a surface that is lit becomes a new light source itself (Color Bleeding), and light bounces around the scene infinitely many times (Bouncing).&lt;/p&gt;
&lt;p&gt;This leads to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Infinitely many light sources in the scene&lt;/li&gt;
&lt;li&gt;Challenge three (indirect light) aggravates challenge one (visibility) and challenge two (complexity of light)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="the-basic-render-pipeline-early-engineering-compromises"&gt;&lt;a href="#the-basic-render-pipeline-early-engineering-compromises" class="header-anchor"&gt;&lt;/a&gt;The Basic Render Pipeline: Early Engineering Compromises
&lt;/h2&gt;&lt;p&gt;Faced with such complex mathematical theory, early graphics engineers resorted to extremely pragmatic &amp;ldquo;brute-force&amp;rdquo; tricks — and these simple hacks ended up laying the foundation of real-time rendering.&lt;/p&gt;
&lt;h3 id="simplified-lighting-models"&gt;&lt;a href="#simplified-lighting-models" class="header-anchor"&gt;&lt;/a&gt;Simplified Lighting Models
&lt;/h3&gt;&lt;p&gt;Complex spherical lighting is decomposed into three categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Dominant Light&lt;/strong&gt;: directional lights / point lights / spotlights&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ambient Light&lt;/strong&gt;: a constant standing in for indirect light from all directions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Environment Map&lt;/strong&gt;: a Cubemap (6 textures) capturing high-frequency reflection information of the surrounding environment&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="blinn-phong-material-model"&gt;&lt;a href="#blinn-phong-material-model" class="header-anchor"&gt;&lt;/a&gt;Blinn-Phong Material Model
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;A victory for the empiricists&lt;/strong&gt;. It does not pursue strict physical correctness, but is based on observation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Diffuse&lt;/strong&gt;: light scatters uniformly, computed with $\cos\theta$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Specular&lt;/strong&gt;: a power function controls the width of the reflection lobe (Lobe)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Flaw&lt;/strong&gt;: energy non-conservative; in ray-traced scenes light energy explodes (brightness grows without bound).&lt;/p&gt;
&lt;h3 id="shadow-map-technology"&gt;&lt;a href="#shadow-map-technology" class="header-anchor"&gt;&lt;/a&gt;Shadow Map Technology
&lt;/h3&gt;&lt;p&gt;The classic solution to the visibility problem, with the core idea of &lt;strong&gt;trading space for time&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Render a depth map (Depth Map) from the light&amp;rsquo;s point of view&lt;/li&gt;
&lt;li&gt;When rendering from the camera&amp;rsquo;s point of view, project each pixel back into light space and compare depths&lt;/li&gt;
&lt;li&gt;If the depth is greater than the value stored in the Shadow Map, the point is in shadow&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Key problems&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Self-occlusion&lt;/strong&gt;: aliasing caused by insufficient precision, solved by adding a bias, but this produces &amp;ldquo;floating shadows&amp;rdquo; (Peter Panning)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sampling rate mismatch&lt;/strong&gt;: the difference in sampling rate between the light&amp;rsquo;s view and the camera&amp;rsquo;s view causes various artifacts&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="global-illumination-gi-and-precomputation-techniques"&gt;&lt;a href="#global-illumination-gi-and-precomputation-techniques" class="header-anchor"&gt;&lt;/a&gt;Global Illumination (GI) and Precomputation Techniques
&lt;/h2&gt;&lt;p&gt;AAA games pursue realism and must solve indirect lighting. The core idea is &lt;strong&gt;precomputation&lt;/strong&gt;: store the results of offline computation and query them directly at runtime.&lt;/p&gt;
&lt;h3 id="spherical-harmonics-sh"&gt;&lt;a href="#spherical-harmonics-sh" class="header-anchor"&gt;&lt;/a&gt;Spherical Harmonics (SH)
&lt;/h3&gt;&lt;p&gt;The lighting function defined on the sphere (a spherical signal) is compressed using the idea of &lt;strong&gt;Fourier series&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Represent the spherical function with a set of orthogonal basis functions (similar to $\sin/\cos$ functions)&lt;/li&gt;
&lt;li&gt;Storing only the first $n$ orders of coefficients (e.g. 4 parameters for order 1, 9 parameters for order 2) is enough to reconstruct the approximate lighting direction&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Extremely high compression ratio&lt;/strong&gt;: 12 parameters (RGB×4) can express the ambient lighting at a point&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Simplified convolution&lt;/strong&gt;: the convolution (integral) of two functions on the sphere reduces to a dot product of SH coefficients&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Supports Diffuse and Specular&lt;/strong&gt;: choose different orders according to precision requirements&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="lightmap"&gt;&lt;a href="#lightmap" class="header-anchor"&gt;&lt;/a&gt;Lightmap
&lt;/h3&gt;&lt;p&gt;Bake the global illumination of static objects into 2D textures (Atlas):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parameterization&lt;/strong&gt;: unwrap 3D geometry into 2D UV space&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Baking&lt;/strong&gt;: perform offline ray-tracing computation on a Light Farm (render farm)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;At runtime&lt;/strong&gt;: sample the Lightmap directly for indirect light and add it to real-time lighting&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Drawbacks&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Only supports static objects and static light sources&lt;/li&gt;
&lt;li&gt;Baking takes a very long time (half an hour to an hour)&lt;/li&gt;
&lt;li&gt;Consumes a lot of memory (tens to hundreds of MB)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="light-probe"&gt;&lt;a href="#light-probe" class="header-anchor"&gt;&lt;/a&gt;Light Probe
&lt;/h3&gt;&lt;p&gt;Scatter sample points through space, each storing lighting information encoded as SH:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Automatic generation&lt;/strong&gt;: modern engines automatically generate Probe distributions (along player paths, expanding over geometric surfaces)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lighting for dynamic objects&lt;/strong&gt;: dynamic objects are shaded by interpolating the lighting of surrounding Probes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Reflection Probe&lt;/strong&gt;: dedicated to high-frequency reflections, storing high-resolution Cubemaps&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Trade-offs vs. Lightmap&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Lightmap: high precision, rich detail (soft shadows, Color Bleeding), but static only&lt;/li&gt;
&lt;li&gt;Light Probe: supports dynamic objects and runtime updates, but low precision and cannot express fine contact shadows&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="physically-based-rendering-pbr"&gt;&lt;a href="#physically-based-rendering-pbr" class="header-anchor"&gt;&lt;/a&gt;Physically Based Rendering (PBR)
&lt;/h2&gt;&lt;h3 id="microfacet-theory"&gt;&lt;a href="#microfacet-theory" class="header-anchor"&gt;&lt;/a&gt;Microfacet Theory
&lt;/h3&gt;&lt;p&gt;A rough surface is modeled as consisting of countless tiny mirrors (Microfacets):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Roughness&lt;/strong&gt;: controls how dispersed the distribution of microfacet normals is&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Metallic&lt;/strong&gt;: distinguishes metals (reflect colored light) from non-metals (dominated by diffuse reflection)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="the-cook-torrance-reflection-model"&gt;&lt;a href="#the-cook-torrance-reflection-model" class="header-anchor"&gt;&lt;/a&gt;The Cook-Torrance Reflection Model
&lt;/h3&gt;&lt;p&gt;The standard model for modern PBRSpecular; the BRDF is a product of three terms:&lt;/p&gt;
$$
f_r = \frac{D \cdot F \cdot G}{4(\omega_o \cdot n)(\omega_i \cdot n)}
$$&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;D (Normal Distribution Function, NDF)&lt;/strong&gt;: the distribution of microfacet normals, most commonly the &lt;strong&gt;GGX&lt;/strong&gt; (Trowbridge-Reitz) distribution&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Characteristics: sharp peak (good high-frequency behavior), long trailing tail (good low-frequency behavior) — like a good speaker with &amp;ldquo;crisp highs and deep lows&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;F (Fresnel Term)&lt;/strong&gt;: describes the increase in reflectance as the angle between the view direction and the surface approaches grazing angle (Grazing Angle)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Classic approximation: &lt;strong&gt;Schlick approximation&lt;/strong&gt; $F = F_0 + (1-F_0)(1-\cos\theta)^5$&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;G (Geometry Term)&lt;/strong&gt;: the geometric occlusion term, computing self-shadowing between microfacets (Shadowing-Masking)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Smith model: computes occlusion for the incoming and outgoing directions separately based on the same Roughness distribution&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="disney-principled-brdf"&gt;&lt;a href="#disney-principled-brdf" class="header-anchor"&gt;&lt;/a&gt;Disney Principled BRDF
&lt;/h3&gt;&lt;p&gt;The PBR design principles proposed by Disney, which deeply influenced the design philosophy of game engines:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Intuitive&lt;/strong&gt;: parameters must match artists&amp;rsquo; intuition (e.g. &amp;ldquo;metallic&amp;rdquo;, &amp;ldquo;roughness&amp;rdquo; rather than physical index of refraction)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Minimal parameters&lt;/strong&gt;: the fewer the better, usually kept to 2-3&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Normalized range&lt;/strong&gt;: parameters should preferably lie in $[0,1]$&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Robustness&lt;/strong&gt;: any combination of parameters should not produce invalid or bizarre results&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Creative flexibility&lt;/strong&gt;: a small number of out-of-range values are allowed for special artistic effects&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="mainstream-pbr-workflows"&gt;&lt;a href="#mainstream-pbr-workflows" class="header-anchor"&gt;&lt;/a&gt;Mainstream PBR Workflows
&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Specular-Glossiness (SG)&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parameters: Diffuse Map + Specular Map (RGB controls Fresnel color) + Glossiness Map&lt;/li&gt;
&lt;li&gt;Pros: flexible, good for expressing colored metals (e.g. gold, copper)&lt;/li&gt;
&lt;li&gt;Cons: easy to misconfigure, leading to energy non-conservation&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Metallic-Roughness (MR)&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Parameters: Base Color + Metallic Map + Roughness Map&lt;/li&gt;
&lt;li&gt;Mechanism: Metallic acts as a mask, interpolating between metal (using Base Color as Specular) and non-metal (Specular is gray)&lt;/li&gt;
&lt;li&gt;Pros: hard to get wrong, intuitive, the industry mainstream&lt;/li&gt;
&lt;li&gt;Cons: a white line artifact may appear at the transition between metal and non-metal&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="image-based-lighting-ibl"&gt;&lt;a href="#image-based-lighting-ibl" class="header-anchor"&gt;&lt;/a&gt;Image-Based Lighting (IBL)
&lt;/h2&gt;&lt;p&gt;A technique that combines environment lighting (Environment Map) with PBR materials, solving the integral problems of &lt;strong&gt;specular reflection&lt;/strong&gt; and &lt;strong&gt;diffuse reflection&lt;/strong&gt; from the environment.&lt;/p&gt;
&lt;h3 id="diffuse-irradiance-map"&gt;&lt;a href="#diffuse-irradiance-map" class="header-anchor"&gt;&lt;/a&gt;Diffuse Irradiance Map
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Precomputation&lt;/strong&gt;: convolve the environment map with the Lambertian BRDF (a constant) to produce a low-frequency diffuse lookup map&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;At runtime&lt;/strong&gt;: sample directly along the normal direction, no real-time integration needed&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="specular-prefiltered-mipmap"&gt;&lt;a href="#specular-prefiltered-mipmap" class="header-anchor"&gt;&lt;/a&gt;Specular Prefiltered Mipmap
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Roughness layering&lt;/strong&gt;: store prefiltered environment maps for different roughness values (0 to 1) in different mipmap levels of the Cubemap
&lt;ul&gt;
&lt;li&gt;Low roughness (smooth): high-frequency information, stored in high-precision mipmaps (low levels)&lt;/li&gt;
&lt;li&gt;High roughness (rough): low-frequency information, stored in low-precision mipmaps (high levels)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;BRDF LUT&lt;/strong&gt;: use a 2D lookup texture to precompute the integral of the Fresnel and geometry terms, parameterized by &lt;strong&gt;Roughness&lt;/strong&gt; and &lt;strong&gt;Cosine Theta&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Essence&lt;/strong&gt;: turning the integral computation of the rendering equation entirely into &lt;strong&gt;texture lookups&lt;/strong&gt;, enabling efficient dynamic environment lighting.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="advanced-shadow-techniques"&gt;&lt;a href="#advanced-shadow-techniques" class="header-anchor"&gt;&lt;/a&gt;Advanced Shadow Techniques
&lt;/h2&gt;&lt;h3 id="cascade-shadow-maps-csm"&gt;&lt;a href="#cascade-shadow-maps-csm" class="header-anchor"&gt;&lt;/a&gt;Cascade Shadow Maps (CSM)
&lt;/h3&gt;&lt;p&gt;Solves the problem of insufficient shadow resolution in large scenes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cascades&lt;/strong&gt;: divide the view frustum into several cascades by distance from the camera (e.g. 0-10m, 10-30m, 30-100m)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Multiple Shadow Maps&lt;/strong&gt;: generate a Shadow Map of different resolution for each cascade — high precision near, low precision far&lt;/li&gt;
&lt;li&gt;** blend between cascades**: smooth interpolation at cascade boundaries avoids hard edges&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Cost&lt;/strong&gt;: requires rendering the scene multiple times (usually 4), making it one of the most expensive modules in the render pipeline (typically 4-5 ms).&lt;/p&gt;
&lt;h3 id="soft-shadows"&gt;&lt;a href="#soft-shadows" class="header-anchor"&gt;&lt;/a&gt;Soft Shadows
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PCF (Percentage Closer Filtering)&lt;/strong&gt;: sample neighboring depths on the Shadow Map and blur with multiple samples to simulate the penumbra&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;PCSS (Percentage Closer Soft Shadows)&lt;/strong&gt;: dynamically adjust the sampling kernel size based on the distance from the object to the light (occluder distance), producing distance-dependent soft/hard shadows&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;VSSM (Variance Soft Shadow Map)&lt;/strong&gt;: uses Chebyshev&amp;rsquo;s inequality and a two-channel Shadow Map (storing depth and depth squared) to estimate the probability of visibility from variance, giving fast approximate soft shadows&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="virtual-shadow-map"&gt;&lt;a href="#virtual-shadow-map" class="header-anchor"&gt;&lt;/a&gt;Virtual Shadow Map
&lt;/h3&gt;&lt;p&gt;A new technique introduced by Unreal Engine 5, solving the low spatial utilization of CSM:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Virtual paging&lt;/strong&gt;: virtualize a huge shadow texture space, allocating and generating Shadow Map tiles only for the actually visible regions&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic allocation&lt;/strong&gt;: dynamically decide which regions need high-resolution shadows based on the camera view, achieving consistent high-precision shadows across the whole scene&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="modern-rendering-trends"&gt;&lt;a href="#modern-rendering-trends" class="header-anchor"&gt;&lt;/a&gt;Modern Rendering Trends
&lt;/h2&gt;&lt;h3 id="real-time-ray-tracing"&gt;&lt;a href="#real-time-ray-tracing" class="header-anchor"&gt;&lt;/a&gt;Real-Time Ray Tracing
&lt;/h3&gt;&lt;p&gt;Hardware acceleration (RTX/DRX) makes real-time ray tracing possible:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Current usage&lt;/strong&gt;: mainly used for &lt;strong&gt;reflection&lt;/strong&gt; and &lt;strong&gt;shadows&lt;/strong&gt;, rather than full GI&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Future direction&lt;/strong&gt;: combined with denoising to achieve real-time global illumination (e.g. UE5&amp;rsquo;s Lumen, which combines SDF, Voxel, Screen Space GI and other techniques)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="uber-shader-and-shader-variants"&gt;&lt;a href="#uber-shader-and-shader-variants" class="header-anchor"&gt;&lt;/a&gt;Uber Shader and Shader Variants
&lt;/h3&gt;&lt;p&gt;Modern engines face the problem of shader explosion:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Uber Shader&lt;/strong&gt;: write one giant shader containing all features, with branches controlled by macros (Macro)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shader Permutation (variants)&lt;/strong&gt;: at compile time, generate all possible shader combinations based on material properties, light types, platform, etc. (e.g. 165 templates can produce 70,000+ concrete shaders)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cross-platform compilation&lt;/strong&gt;: use intermediate formats such as SPIR-V and translate uniformly to each platform&amp;rsquo;s shader language — HLSL, GLSL, Metal, PSL, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="conclusion"&gt;&lt;a href="#conclusion" class="header-anchor"&gt;&lt;/a&gt;Conclusion
&lt;/h2&gt;&lt;p&gt;The history of real-time rendering technology is a history of engineering innovation that &lt;strong&gt;seeks a balance between physical truth and real-time performance&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;The foundational era&lt;/strong&gt;: through the combination of Blinn-Phong + Shadow Map + Environment Map, minimal hacks achieved acceptable real-time rendering&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The GI era&lt;/strong&gt;: through precomputation techniques such as Lightmap, Spherical Harmonics, and Light Probe, trading space for time to achieve static global illumination&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The PBR era&lt;/strong&gt;: based on Microfacet theory and the Cook-Torrance model, a unified material standard (Metallic-Roughness) was established, achieving physically correct lighting response&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The IBL era&lt;/strong&gt;: through prefiltered environment maps, complex integral computations became texture lookups, enabling efficient environment lighting&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Modern/future&lt;/strong&gt;: hardware ray tracing and real-time GI techniques (Lumen, etc.) are breaking the constraints of precomputation, moving toward a fully dynamic, fully realistic goal&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Key takeaway&lt;/strong&gt;: game engine development is not about chasing mathematical perfection, but about creating &lt;strong&gt;believable and beautiful&lt;/strong&gt; visuals under &lt;strong&gt;limited compute&lt;/strong&gt; through reasonable &lt;strong&gt;assumptions, simplifications, and precomputation&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="references"&gt;&lt;a href="#references" class="header-anchor"&gt;&lt;/a&gt;References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://www.bilibili.com/video/BV1J3411n7WT/" target="_blank" rel="noopener"&gt;The Mathematical Magic of Light and Materials in Rendering | GAMES104 - Modern Game Engine: From Beginner to Practice&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GAMES104 Modern Game Engine - Rendering Practices in Game Engines</title><link>https://boiltask.com/en/note/games104-game-engine-4/</link><pubDate>Tue, 27 Jan 2026 23:11:25 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-4/</guid><description>&lt;h2 id="course-overview"&gt;&lt;a href="#course-overview" class="header-anchor"&gt;&lt;/a&gt;Course Overview
&lt;/h2&gt;&lt;p&gt;In modern game engines, the rendering system occupies an extremely important position. It not only accounts for the largest portion of engine code but is also one of the most technically difficult and specialized fields. Although many people think &amp;ldquo;a game engine is just a drawing engine,&amp;rdquo; in reality rendering in game engines is fundamentally different from textbook computer graphics.&lt;/p&gt;
&lt;h3 id="game-rendering-vs-theoretical-graphics"&gt;&lt;a href="#game-rendering-vs-theoretical-graphics" class="header-anchor"&gt;&lt;/a&gt;Game Rendering vs Theoretical Graphics
&lt;/h3&gt;&lt;p&gt;Computer graphics theory focuses on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Correctness of specific effects (such as refraction of transparent objects, water rendering, hair algorithms, etc.)&lt;/li&gt;
&lt;li&gt;Mathematical precision of algorithms, without considering hardware implementation details&lt;/li&gt;
&lt;li&gt;A frame can take minutes or even days to render (offline rendering)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Four major challenges faced by game engine rendering:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All-in-One complexity: a scene must simultaneously handle thousands of objects with different effects such as water, vegetation, hair, skin, and clouds, and all algorithms must be integrated into one container and work together.&lt;/li&gt;
&lt;li&gt;Deep hardware adaptation: algorithms must run efficiently on contemporary hardware (PC, console, mobile devices), requiring an in-depth understanding of GPU architecture.&lt;/li&gt;
&lt;li&gt;Fixed budget constraints: must complete within a strict time budget (30fps ≈ 33ms/frame, 60fps ≈ 16ms/frame, esports requires 120fps+). Whether the scene is a small enclosed room or an open city, the frame rate must remain stable, and &amp;ldquo;frame drops when opening a door&amp;rdquo; must never happen.&lt;/li&gt;
&lt;li&gt;Limited resources: the rendering system usually can only use 10–20% of CPU resources, with the rest left for game logic, physics, networking, and other systems.
Therefore, the rendering system of a game engine is an engineering practice science, a heavily optimized software system iterated and optimized by the industry over the past 30 years, rather than a pure theoretical model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Therefore, the rendering system of a game engine is an engineering practice science, a heavily optimized software system iterated and optimized by the industry over the past 30 years, rather than a pure theoretical model.&lt;/p&gt;
&lt;h3 id="basic-render-pipeline"&gt;&lt;a href="#basic-render-pipeline" class="header-anchor"&gt;&lt;/a&gt;Basic Render Pipeline
&lt;/h3&gt;&lt;blockquote&gt;
&lt;p&gt;The process of turning data into a visible image:&lt;br&gt;
Vertex $\rightarrow$ Face $\rightarrow$ Projection Matrix $\rightarrow$ Rasterized Pixel $\rightarrow$ Material/Texture $\rightarrow$ Image&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;img src="https://r2.boiltask.com/2026/01/eede983c0252f5a3ec33b7d43ee85a0e.png"
loading="lazy"
alt="image-20260127164820371"
&gt;&lt;/p&gt;
&lt;p&gt;The entire rendering module is divided into four parts:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Fundamentals&lt;/strong&gt;: basic concepts such as GPU hardware architecture, rendering data management, and visibility culling&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lighting and Materials&lt;/strong&gt;: modern lighting models (IBL), PBR material systems, and the Shader model&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Subsystems&lt;/strong&gt;: terrain system, sky system, post-processing system, etc.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Render Pipeline&lt;/strong&gt;: advanced pipeline designs such as Deferred Shading&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="gpu-architecture-fundamentals-understanding-hardware-is-a-prerequisite-for-optimization"&gt;&lt;a href="#gpu-architecture-fundamentals-understanding-hardware-is-a-prerequisite-for-optimization" class="header-anchor"&gt;&lt;/a&gt;GPU Architecture Fundamentals: Understanding Hardware Is a Prerequisite for Optimization
&lt;/h2&gt;&lt;p&gt;To become an excellent graphics programmer, one must deeply understand GPU architecture. The design philosophies of modern GPUs and CPUs are completely different.&lt;/p&gt;
&lt;p&gt;CPU: Each core is powerful, and there are few cores; suitable for complex computational tasks such as game logic and physics simulation.&lt;br&gt;
GPU: Each core is weaker, and there are many cores; suitable for large-scale parallel computation such as pixel rendering.&lt;/p&gt;
&lt;h3 id="gpu-parallel-architecture-characteristics"&gt;&lt;a href="#gpu-parallel-architecture-characteristics" class="header-anchor"&gt;&lt;/a&gt;GPU Parallel Architecture Characteristics
&lt;/h3&gt;&lt;p&gt;The core characteristic of modern GPUs is &lt;strong&gt;large-scale parallel computing&lt;/strong&gt;, with a large number of small cores. This architecture determines the design philosophy of the rendering system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Data parallelism first&lt;/strong&gt;: decompose complex tasks into a large number of simple, uniform computational units&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Move computation forward&lt;/strong&gt;: shift operations from the CPU to the GPU as much as possible&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Batching mindset&lt;/strong&gt;: reduce Draw Calls and set up once for multiple reuses&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="simd-and-simt-architectures"&gt;&lt;a href="#simd-and-simt-architectures" class="header-anchor"&gt;&lt;/a&gt;SIMD and SIMT Architectures
&lt;/h3&gt;&lt;p&gt;SIMD (Single Instruction Multiple Data):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;One instruction processes multiple data items simultaneously (e.g., simultaneous operations on the XYZW of a 4D vector)&lt;/li&gt;
&lt;li&gt;Widely supported by modern CPUs as well (e.g., the SSE instruction set)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;SIMT (Single Instruction Multiple Threads):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The core idea of GPUs: make computational units very small but extremely numerous (thousands)&lt;/li&gt;
&lt;li&gt;One instruction can execute the same operation simultaneously on hundreds or thousands of cores&lt;/li&gt;
&lt;li&gt;Modern GPU compute power can reach 10+ TeraFLOPs, far exceeding CPUs (usually &amp;lt;1 TeraFLOP)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;TeraFLOP: one trillion floating-point operations per second, $10^{12}$ floating-point operations (FLOP), $10^{15}$ double-precision floating-point operations (DFLOP)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="modern-gpu-hardware-structure-using-nvidia-fermi-architecture-as-an-example"&gt;&lt;a href="#modern-gpu-hardware-structure-using-nvidia-fermi-architecture-as-an-example" class="header-anchor"&gt;&lt;/a&gt;Modern GPU Hardware Structure (Using NVIDIA Fermi Architecture as an Example)
&lt;/h3&gt;&lt;p&gt;A GPU consists of multiple GPCs (Graphics Processing Clusters), and each GPC contains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SM (Stream Multiprocessor): contains dozens of CUDA cores and performs mathematical operations&lt;/li&gt;
&lt;li&gt;Dedicated hardware units:
&lt;ul&gt;
&lt;li&gt;Texture Unit: dedicated to texture sampling (with filtering and Mipmap)&lt;/li&gt;
&lt;li&gt;SFU (Special Function Unit): handles complex mathematical operations such as trigonometric functions&lt;/li&gt;
&lt;li&gt;Tensor Core (after Ampere architecture): AI computation&lt;/li&gt;
&lt;li&gt;RT Core: ray tracing acceleration&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://r2.boiltask.com/2026/01/17ae9a58e54034d459c9dc77d0686ea4.png"
loading="lazy"
alt="image-20260127163232589"
&gt;&lt;/p&gt;
&lt;h3 id="memory-architecture-and-data-flow"&gt;&lt;a href="#memory-architecture-and-data-flow" class="header-anchor"&gt;&lt;/a&gt;Memory Architecture and Data Flow
&lt;/h3&gt;&lt;p&gt;Von Neumann architecture: computation and data are separated, resulting in relatively high data movement costs.&lt;/p&gt;
&lt;p&gt;Key concepts:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;VRAM and memory: transfer from CPU memory to GPU VRAM is a major bottleneck, and the one-way data transfer principle must be followed (CPU→GPU, avoid readback as much as possible)&lt;/li&gt;
&lt;li&gt;Cache: key to modern computing performance. Accessing main memory may require 100+ clock cycles, while accessing cache takes only a few cycles
&lt;ul&gt;
&lt;li&gt;Cache Hit: data is in the cache, fast access&lt;/li&gt;
&lt;li&gt;Cache Miss: data is not in the cache, requiring a wait&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Bandwidth: a common bottleneck in rendering, including texture bandwidth, vertex bandwidth, etc.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="render-data-organization-from-logical-objects-to-drawable-entities"&gt;&lt;a href="#render-data-organization-from-logical-objects-to-drawable-entities" class="header-anchor"&gt;&lt;/a&gt;Render Data Organization: From Logical Objects to Drawable Entities
&lt;/h2&gt;&lt;p&gt;A GameObject in a game (such as a car or a character) is a logical object and cannot be drawn directly. It must be expressed through a Renderable (drawable object).&lt;/p&gt;
&lt;h3 id="composition-of-a-renderable"&gt;&lt;a href="#composition-of-a-renderable" class="header-anchor"&gt;&lt;/a&gt;Composition of a Renderable
&lt;/h3&gt;&lt;p&gt;To draw an object (Renderable), you generally need:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Mesh&lt;/strong&gt;: vertex data, triangle indices
&lt;ol&gt;
&lt;li&gt;Vertex Data: vertex position, normal, UV coordinates, etc.&lt;/li&gt;
&lt;li&gt;Index Data: triangle indices, reusing vertices to save memory (typically the number of vertices is about half the number of triangles)&lt;/li&gt;
&lt;li&gt;Triangle Strip: an optimized vertex storage method that improves cache friendliness&lt;/li&gt;
&lt;li&gt;
&lt;blockquote&gt;
&lt;p&gt;Important note: vertex normals must be stored separately and cannot simply be averaged from triangle face normals. For example, at the edges/corners of a cube, vertices at the same position need to store multiple normals in different directions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Material&lt;/strong&gt;:
&lt;ol&gt;
&lt;li&gt;Expresses surface properties of objects (metal, plastic, stone, etc.)&lt;/li&gt;
&lt;li&gt;Modern engines use the PBR (Physically Based Rendering) model&lt;/li&gt;
&lt;li&gt;Note the distinction from Physics Material: the former is used for visuals, while the latter is used for physical properties such as friction coefficient and elasticity&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Texture&lt;/strong&gt;:
&lt;ol&gt;
&lt;li&gt;Materials reference textures for sampling; one material may reference multiple textures, and the same texture may be referenced by multiple materials&lt;/li&gt;
&lt;li&gt;Stores not only color (Albedo) but also roughness (Roughness), normal (Normal), metallic (Metallic), etc.&lt;/li&gt;
&lt;li&gt;Texture sampling is an expensive operation: a single sample requires accessing 8 pixels and performing 7 interpolations (considering Mipmap and bilinear filtering)&lt;/li&gt;
&lt;li&gt;
&lt;blockquote&gt;
&lt;p&gt;I already have a Texture, so why do I still need a Material?&lt;br&gt;
Because the GPU does not know:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is this image color? Normal? Or roughness?&lt;/li&gt;
&lt;li&gt;Should it participate in lighting?&lt;/li&gt;
&lt;li&gt;Is it transparent or opaque?&lt;/li&gt;
&lt;li&gt;How should Gamma / Linear be handled?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Material tells the GPU how to interpret this image and how it should participate in computation&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shader Code&lt;/strong&gt;:
&lt;ol&gt;
&lt;li&gt;A unique &amp;ldquo;code as data&amp;rdquo; existence: it is both source code and managed as a data asset&lt;/li&gt;
&lt;li&gt;Modern engines support Shader Graph, allowing artists to compose material logic like building blocks and automatically generate Shader code&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="submesh-the-key-to-resource-reuse"&gt;&lt;a href="#submesh-the-key-to-resource-reuse" class="header-anchor"&gt;&lt;/a&gt;SubMesh: The Key to Resource Reuse
&lt;/h3&gt;&lt;h4 id="submesh-concept"&gt;&lt;a href="#submesh-concept" class="header-anchor"&gt;&lt;/a&gt;SubMesh Concept
&lt;/h4&gt;&lt;p&gt;A face/patch may include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Vertices&lt;/li&gt;
&lt;li&gt;Orientation&lt;/li&gt;
&lt;li&gt;Color&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Different parts of a complex model (such as a soldier) (helmet, cloth, skin, weapon) require different materials.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://r2.boiltask.com/2026/01/9607113ef8ffab849070859b0c00e4c7.png"
loading="lazy"
alt="image-20260127182306364"
&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Why does every vertex need to store a normal instead of simply averaging the triangle face normals?&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The object surface is a continuous surface, not triangles; therefore, calculating from triangles will produce discontinuities.&lt;/li&gt;
&lt;li&gt;A pixel belongs to only one triangle and cannot know which surrounding faces exist.&lt;/li&gt;
&lt;li&gt;GPU interpolation is at the vertex level, so normals need to be recorded on vertices.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src="https://r2.boiltask.com/2026/01/510f23b535a6f2fdb71ee289aa4593be.png"
loading="lazy"
alt="image-20260127183531617"
&gt;&lt;/p&gt;
&lt;p&gt;Vertex normal = weighted average of adjacent triangle face normals (usually weighted by triangle area), then normalized&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Split a Mesh into multiple SubMeshes by material&lt;/li&gt;
&lt;li&gt;All SubMeshes share the same Vertex Buffer / Index Buffer, but each records its own Offset (&lt;strong&gt;offset&lt;/strong&gt;) range&lt;/li&gt;
&lt;li&gt;Each SubMesh corresponds to a specific material, texture, and Shader&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Memory efficiency: multiple objects share the same geometry data&lt;/li&gt;
&lt;li&gt;Rendering optimization: batch render after sorting by material, reducing state changes&lt;/li&gt;
&lt;li&gt;Industry standard: mainstream engines such as Unreal Engine use similar structures&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="resource-pool-design"&gt;&lt;a href="#resource-pool-design" class="header-anchor"&gt;&lt;/a&gt;Resource Pool Design
&lt;/h4&gt;&lt;p&gt;Modern engines solve data redundancy through resource pools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Mesh Pool&lt;/strong&gt;: centrally manages all mesh data&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Texture Pool&lt;/strong&gt;: textures are shared across objects (e.g., skins and clothing for multiplayer characters)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Material Pool&lt;/strong&gt;: material instancing system&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="rendering-optimization-strategies"&gt;&lt;a href="#rendering-optimization-strategies" class="header-anchor"&gt;&lt;/a&gt;Rendering Optimization Strategies
&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;Material sorting: group SubMeshes with the same material to reduce GPU state change overhead&lt;/li&gt;
&lt;li&gt;Instance: for identical geometry (such as minions or trees), store only one Definition and draw multiple copies through instance data (position, rotation, etc.)&lt;/li&gt;
&lt;li&gt;GPU-based Batch Rendering: modern engines use GPU compute shaders to handle the drawing of large numbers of identical objects at once, further reducing CPU submission overhead&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="gpu-based-batch-rendering"&gt;&lt;a href="#gpu-based-batch-rendering" class="header-anchor"&gt;&lt;/a&gt;GPU Based Batch Rendering
&lt;/h3&gt;&lt;p&gt;For large numbers of repeated objects (trees, grass, buildings), the traditional approach requires setting VBO/IBO once per object. Modern techniques use &lt;strong&gt;Computer Shader&lt;/strong&gt; to achieve:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Render hundreds of instances in a single Draw Call&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GPU-side instancing&lt;/strong&gt;: pass transform data as a buffer, and the GPU computes the final position of each instance in parallel&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Applicable scenarios&lt;/strong&gt;: large-scale vegetation, building clusters, particle systems&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="migrating-computation-from-cpu-to-gpu"&gt;&lt;a href="#migrating-computation-from-cpu-to-gpu" class="header-anchor"&gt;&lt;/a&gt;Migrating Computation from CPU to GPU
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Core idea&lt;/strong&gt;: migrate complex operations originally handled by the CPU to the GPU&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Animation system: GPU-based skeletal animation computation&lt;/li&gt;
&lt;li&gt;Physics simulation: particle and cloth simulation&lt;/li&gt;
&lt;li&gt;Visibility determination: Occlusion Query, Frustum Culling&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Performance advantage&lt;/strong&gt;: GPU parallel compute power is usually more than 10× that of the CPU, making it suitable for large-scale data.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="visibility-culling"&gt;&lt;a href="#visibility-culling" class="header-anchor"&gt;&lt;/a&gt;Visibility Culling
&lt;/h2&gt;&lt;p&gt;The highest level of rendering optimization: &lt;strong&gt;&amp;ldquo;Do Nothing&amp;rdquo;&lt;/strong&gt; — use algorithms to make the computer do as little work as possible.&lt;/p&gt;
&lt;h3 id="basic-culling-methods"&gt;&lt;a href="#basic-culling-methods" class="header-anchor"&gt;&lt;/a&gt;Basic Culling Methods
&lt;/h3&gt;&lt;h4 id="view-frustum-culling"&gt;&lt;a href="#view-frustum-culling" class="header-anchor"&gt;&lt;/a&gt;View Frustum Culling
&lt;/h4&gt;&lt;p&gt;Use a Bounding Volume to quickly determine whether an object is inside the camera frustum&lt;/p&gt;
&lt;p&gt;Bounding volume types:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bounding Sphere: fastest test, but loose bounds&lt;/li&gt;
&lt;li&gt;AABB (Axis-Aligned Bounding Box): axis-aligned bounding box; only two vertices need to be stored, and computation efficiency is extremely high&lt;/li&gt;
&lt;li&gt;OBB (Object-Oriented Bounding Box): object-aligned bounding box; fits more tightly but is more complex to compute&lt;/li&gt;
&lt;li&gt;Convex Hull: commonly used in physics computation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src="https://r2.boiltask.com/2026/01/7b44e02361e6880496fc935ac5b50877.png"
loading="lazy"
alt="image-20260128105845049"
&gt;&lt;/p&gt;
&lt;h4 id="spatial-acceleration-structures"&gt;&lt;a href="#spatial-acceleration-structures" class="header-anchor"&gt;&lt;/a&gt;Spatial Acceleration Structures
&lt;/h4&gt;&lt;ul&gt;
&lt;li&gt;Quadtree/Octree: suitable for large static scenes&lt;/li&gt;
&lt;li&gt;BVH (Bounding Volume Hierarchy): tree structure, suitable for dynamic scenes (FPS games with frequent object movement)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="bvh-bounding-volume-hierarchy"&gt;&lt;a href="#bvh-bounding-volume-hierarchy" class="header-anchor"&gt;&lt;/a&gt;BVH (Bounding Volume Hierarchy)
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Applicable scenarios&lt;/strong&gt;: scenes with many dynamic objects (such as large numbers of units in RTS games)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Principle&lt;/strong&gt;:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;
&lt;div class="highlight-body"&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;span class="lnt"&gt;4
&lt;/span&gt;&lt;span class="lnt"&gt;5
&lt;/span&gt;&lt;span class="lnt"&gt;6
&lt;/span&gt;&lt;span class="lnt"&gt;7
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;根节点（整个场景）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├── 子节点1（建筑区域）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├── 叶节点：建筑A
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ └── 叶节点：建筑B
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└── 子节点2（单位区域）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├── 叶节点：士兵1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; └── 叶节点：士兵2&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Hierarchical bounding boxes&lt;/strong&gt;: test from top to bottom; cull entire branches of invisible nodes&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Dynamic rebuild&lt;/strong&gt;: BVH has low rebuild cost when objects move, making it suitable for dynamic scenes&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="pvs-potential-visibility-set"&gt;&lt;a href="#pvs-potential-visibility-set" class="header-anchor"&gt;&lt;/a&gt;PVS (Potential Visibility Set)
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Origin of the idea&lt;/strong&gt;: John Carmack&amp;rsquo;s pioneering work in Doom/Quake&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Core principle&lt;/strong&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Divide space into &lt;strong&gt;Cells&lt;/strong&gt; (rooms) connected by &lt;strong&gt;Portals&lt;/strong&gt; (doors/windows)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Precomputation&lt;/strong&gt;: each Cell records which other Cells are visible from that position through Portals&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Runtime&lt;/strong&gt;: only render objects in the PVS of the current Cell&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Modern application extensions&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Level Streaming&lt;/strong&gt;: open worlds load by Zone&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Resource preloading&lt;/strong&gt;: use PVS to predict the area the player is about to enter and asynchronously load resources in advance&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Although pure PVS culling is rarely used now, its ideas guide resource scheduling&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="gpu-based-culling"&gt;&lt;a href="#gpu-based-culling" class="header-anchor"&gt;&lt;/a&gt;GPU Based Culling
&lt;/h3&gt;&lt;p&gt;Modern hardware performance allows some culling to be done directly on the GPU, using GPU parallel computing capability to parallelize bounding-box tests for thousands of objects.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Occlusion Query&lt;/strong&gt;: the GPU returns a visibility 0/1 array&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Early-Z / Hi-Z&lt;/strong&gt;: hardware-level depth testing; occluded pixels do not execute the Fragment Shader&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Compute Shader Hierarchy&lt;/strong&gt;: build BVH on the GPU and cull in parallel&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="texture-compression-technology"&gt;&lt;a href="#texture-compression-technology" class="header-anchor"&gt;&lt;/a&gt;Texture Compression Technology
&lt;/h2&gt;&lt;p&gt;Texture compression is an important module of the engine resource system and directly affects VRAM bandwidth and loading performance.&lt;/p&gt;
&lt;h3 id="texture-compression-formats"&gt;&lt;a href="#texture-compression-formats" class="header-anchor"&gt;&lt;/a&gt;Texture Compression Formats
&lt;/h3&gt;&lt;p&gt;The special requirements of game engines differ from ordinary image compression (JPEG); texture compression must support:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Random access&lt;/strong&gt;: quickly read any texel&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Real-time decompression&lt;/strong&gt;: extremely low decompression overhead&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Fixed compression ratio&lt;/strong&gt;: predictable VRAM usage&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="block-based-compression"&gt;&lt;a href="#block-based-compression" class="header-anchor"&gt;&lt;/a&gt;Block-based Compression
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Core idea&lt;/strong&gt;: split the texture into 4×4 or larger blocks and compress each block independently.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Split the texture into small 4×4 pixel blocks&lt;/li&gt;
&lt;li&gt;Record the maximum and minimum colors within the block; other pixels store interpolation ratios&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;DXT/BC series&lt;/strong&gt; (PC/console): DXT1/3/5, BC1-7, supporting real-time compression/decompression&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;ASTC (mobile devices)&lt;/strong&gt;: supports non-square blocks (such as 4×4, 6×6, 8×8), with higher compression ratios but more complex compression computation&lt;/p&gt;
&lt;h2 id="asset-production-pipeline"&gt;&lt;a href="#asset-production-pipeline" class="header-anchor"&gt;&lt;/a&gt;Asset Production Pipeline
&lt;/h2&gt;&lt;p&gt;Modern game assets come from diverse sources, driving advances in rendering technology:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Production Method&lt;/th&gt;
&lt;th&gt;Tools&lt;/th&gt;
&lt;th&gt;Advantages&lt;/th&gt;
&lt;th&gt;Disadvantages&lt;/th&gt;
&lt;th&gt;Applicable Scenarios&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Manual Modeling&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;3D Max, Maya, Blender&lt;/td&gt;
&lt;td&gt;Precise modeling based on points, lines, and faces; flexible and controllable&lt;/td&gt;
&lt;td&gt;Time-consuming and labor-intensive&lt;/td&gt;
&lt;td&gt;Machinery, architecture&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sculpting&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;ZBrush&lt;/td&gt;
&lt;td&gt;Freely add details like sculpting; highly unrestricted&lt;/td&gt;
&lt;td&gt;Difficult to parameterize&lt;/td&gt;
&lt;td&gt;Characters, creatures&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;3D Scanning&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;RealityCapture&lt;/td&gt;
&lt;td&gt;Acquired through photogrammetry; ultra-high precision&lt;/td&gt;
&lt;td&gt;Requires a physical prototype&lt;/td&gt;
&lt;td&gt;Artifacts, realistic props&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Procedural Generation&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Houdini, AI&lt;/td&gt;
&lt;td&gt;Automatically generated based on algorithms; efficient at scale&lt;/td&gt;
&lt;td&gt;Difficult to control&lt;/td&gt;
&lt;td&gt;Terrain, vegetation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Trend&lt;/strong&gt;: AI generation technology frees artists from tedious details so they can focus on creativity itself.&lt;/p&gt;
&lt;h2 id="development-directions-of-modern-render-pipelines"&gt;&lt;a href="#development-directions-of-modern-render-pipelines" class="header-anchor"&gt;&lt;/a&gt;Development Directions of Modern Render Pipelines
&lt;/h2&gt;&lt;p&gt;Technology keeps advancing, and render pipelines are also evolving, requiring developers to keep learning.&lt;/p&gt;
&lt;h3 id="cluster-based-mesh-pipeline"&gt;&lt;a href="#cluster-based-mesh-pipeline" class="header-anchor"&gt;&lt;/a&gt;Cluster Based Mesh Pipeline
&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;Driving force&lt;/strong&gt;: open worlds cause data volume to grow more than 10×, and traditional pipelines (CPU prepares vertex data → submits to GPU) cannot handle it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Core idea&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Split high-detail models into &lt;strong&gt;fixed-size Meshlets&lt;/strong&gt; (32–64 triangles)&lt;/li&gt;
&lt;li&gt;Mesh Shader: the GPU &amp;ldquo;conjures&amp;rdquo; geometric detail from algorithms and data, without the CPU pre-preparing vertex Buffers&lt;/li&gt;
&lt;li&gt;Amplification Shader: determines which Meshlets need subdivision (distance-based LOD) or culling&lt;/li&gt;
&lt;li&gt;GPU-driven: all culling, LOD selection, and rejection are completed entirely on the GPU, and the CPU only submits high-level commands&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Supports pixel-level geometric density (such as Nanite in Unreal Engine)&lt;/li&gt;
&lt;li&gt;Fine-grained culling: can cull just one hand of a monster instead of the entire model&lt;/li&gt;
&lt;li&gt;Artists do not need to consider the polygon budget and can freely use models with hundreds of millions of triangles&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Representative technologies&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ubisoft 2015&lt;/strong&gt;: &lt;em&gt;Assassin&amp;rsquo;s Creed Unity&lt;/em&gt; was the first to apply Cluster Based Mesh Pipeline at scale&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Unreal Engine 5&lt;/strong&gt;: Nanite virtual geometry technology, achieving &amp;ldquo;pixel-level mesh density&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Requirements for developers&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deeper understanding of GPU architecture&lt;/li&gt;
&lt;li&gt;More complex Shader programming models&lt;/li&gt;
&lt;li&gt;But in exchange for ultimate detail expressiveness&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="pipeline-evolution-summary"&gt;&lt;a href="#pipeline-evolution-summary" class="header-anchor"&gt;&lt;/a&gt;Pipeline Evolution Summary
&lt;/h3&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Characteristics&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Traditional Pipeline&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;VS+PS&lt;/td&gt;
&lt;td&gt;Prebuilt Vertex/Index Buffer&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Intermediate Pipeline&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hull/Domain/Geometry Shader&lt;/td&gt;
&lt;td&gt;GPU-side geometry subdivision&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Modern Pipeline&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Mesh Shader&lt;/td&gt;
&lt;td&gt;Fully GPU-driven, dynamically generates geometry&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="summary-of-the-core-cognitive-framework"&gt;&lt;a href="#summary-of-the-core-cognitive-framework" class="header-anchor"&gt;&lt;/a&gt;Summary of the Core Cognitive Framework
&lt;/h2&gt;&lt;h3 id="four-core-concepts"&gt;&lt;a href="#four-core-concepts" class="header-anchor"&gt;&lt;/a&gt;Four Core Concepts
&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Hardware-driven thinking&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Rendering is an engineering science that deeply depends on understanding GPU architecture&lt;/li&gt;
&lt;li&gt;Be familiar with the language of &amp;ldquo;performance bottlenecks&amp;rdquo;: bandwidth, fill rate, ALU utilization&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Data relationship thinking&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The core is resolving the relationships among Mesh, SubMesh, material, and Shader&lt;/li&gt;
&lt;li&gt;Instancing is a general pattern for resource management (sound, particles, vegetation)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Extreme culling thinking&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Optimization = making the computer do the least work (the Do Nothing philosophy)&lt;/li&gt;
&lt;li&gt;Visibility is the first factor in rendering performance&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;GPU Responsibility thinking&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;GPU Driven&lt;/strong&gt;: migrate CPU logic to the GPU&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Future trend&lt;/strong&gt;: animation, physics, and AI fully GPU-ified&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="advice-for-developers"&gt;&lt;a href="#advice-for-developers" class="header-anchor"&gt;&lt;/a&gt;Advice for Developers
&lt;/h3&gt;&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Render pipeline selection&lt;/strong&gt;: in-house engines should follow industry standards and avoid excessive innovation that makes maintenance difficult&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Debugging methodology&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Graphics debugging is extremely difficult (second only to server debugging)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Step-by-step verification&lt;/strong&gt;: split the algorithm into multiple steps and verify each step separately&lt;/li&gt;
&lt;li&gt;Use vendor tools: NVIDIA NSight, AMD Radeon GPU Profiler&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Learning path&lt;/strong&gt;: first read the code and set breakpoints to understand the flow, then start modifying it&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;The game engine rendering system is a bridge connecting hardware and art; it requires both solid engineering ability and a sense of aesthetics. Understand hardware, optimize data, cull to the extreme, and embrace the GPU—these four principles will run through the entire rendering module. The next lesson will dive into lighting models and the PBR material system, exploring how to make the image &amp;ldquo;look like the real deal.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The game engine rendering system is a highly practical engineering endeavor—it does not pursue theoretical optimality, but rather finds the best balance among hardware limitations, development efficiency, and image quality.&lt;/p&gt;
&lt;h2 id="reference-information"&gt;&lt;a href="#reference-information" class="header-anchor"&gt;&lt;/a&gt;Reference Information
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://www.bilibili.com/video/BV14r4y1p7tt" target="_blank" rel="noopener"&gt;Rendering in Game Engines | GAMES104-Modern Game Engine: From Beginner to Practice&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GAMES104 Modern Game Engine - How to Build a Game World</title><link>https://boiltask.com/en/note/games104-game-engine-3/</link><pubDate>Tue, 27 Jan 2026 12:24:19 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-3/</guid><description>&lt;h2 id="composition-of-the-game-world"&gt;&lt;a href="#composition-of-the-game-world" class="header-anchor"&gt;&lt;/a&gt;Composition of the Game World
&lt;/h2&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;th&gt;Abstraction in the Engine&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Dynamic objects&lt;/td&gt;
&lt;td&gt;Tanks, drones, NPCs&lt;/td&gt;
&lt;td&gt;GameObject (GO)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Static objects&lt;/td&gt;
&lt;td&gt;Houses, hangars, watchtowers&lt;/td&gt;
&lt;td&gt;GameObject&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Environment&lt;/td&gt;
&lt;td&gt;Terrain, sky, vegetation&lt;/td&gt;
&lt;td&gt;Separate systems (terrain system, TOD)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invisible objects&lt;/td&gt;
&lt;td&gt;Air walls, triggers, rules&lt;/td&gt;
&lt;td&gt;GameObject&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Conclusion: everything is a GameObject (abbreviated as GO).&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="component-based-architecture"&gt;&lt;a href="#component-based-architecture" class="header-anchor"&gt;&lt;/a&gt;Component-Based Architecture
&lt;/h2&gt;&lt;h3 id="why-not-deep-inheritance"&gt;&lt;a href="#why-not-deep-inheritance" class="header-anchor"&gt;&lt;/a&gt;Why Not Deep Inheritance
&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;Diamond problem of multiple inheritance (is an amphibious tank a “vehicle” or a “boat”?)&lt;/li&gt;
&lt;li&gt;Code bloat and maintenance difficulty&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="component-based-solution"&gt;&lt;a href="#component-based-solution" class="header-anchor"&gt;&lt;/a&gt;Component-Based Solution
&lt;/h3&gt;&lt;p&gt;Split “properties” and “behaviors” into independent &lt;strong&gt;Component&lt;/strong&gt;s and assemble them as needed:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Drone Example&lt;/th&gt;
&lt;th&gt;Corresponding Component&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Spatial position&lt;/td&gt;
&lt;td&gt;Transform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Appearance&lt;/td&gt;
&lt;td&gt;Model/Mesh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Movement capability&lt;/td&gt;
&lt;td&gt;Motor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Health&lt;/td&gt;
&lt;td&gt;Health&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AI patrol&lt;/td&gt;
&lt;td&gt;AI_Patrol&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Attack behavior&lt;/td&gt;
&lt;td&gt;Combat&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Advantages:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Composition &amp;gt; inheritance&lt;/li&gt;
&lt;li&gt;Dynamic add/remove at runtime (Unity/UE)&lt;/li&gt;
&lt;li&gt;Data and behavior are decoupled, which helps parallel and batch processing (ECS later)&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id="making-the-world-move-tick-mechanism"&gt;&lt;a href="#making-the-world-move-tick-mechanism" class="header-anchor"&gt;&lt;/a&gt;Making the World Move: Tick Mechanism
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Tick&lt;/strong&gt; = the engine advances the world by one step at every fixed frame interval (e.g., 33 ms)&lt;/li&gt;
&lt;li&gt;Every Component implements &lt;code&gt;Tick(float deltaTime)&lt;/code&gt;:
&lt;ol&gt;
&lt;li&gt;Motor updates position&lt;/li&gt;
&lt;li&gt;Animation updates bones&lt;/li&gt;
&lt;li&gt;Physics updates colliders&lt;/li&gt;
&lt;li&gt;Combat detects firing&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;li&gt;To improve cache hit rates, modern engines &lt;strong&gt;batch Tick by system&lt;/strong&gt; (first tick all Motors, then all Animations&amp;hellip;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="inter-object-communication-event-system"&gt;&lt;a href="#inter-object-communication-event-system" class="header-anchor"&gt;&lt;/a&gt;Inter-Object Communication: Event System
&lt;/h2&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Direct Call (Tight Coupling)&lt;/th&gt;
&lt;th&gt;Event Mail (Loose Coupling)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Shell explodes → call takeDamage() on each nearby object one by one&lt;/td&gt;
&lt;td&gt;Shell explodes → PostEvent(&amp;ldquo;Damage&amp;rdquo;, 100) → nearby objects check their mail on the next Tick and lose health&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;ul&gt;
&lt;li&gt;Mailbox model = &lt;strong&gt;determinism + extensibility&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Implementation details: string hashing / RTTI / reflection (UE Blueprint, Unity SendMessage)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="scene-management-from-brute-force-traversal-to-spatial-acceleration"&gt;&lt;a href="#scene-management-from-brute-force-traversal-to-spatial-acceleration" class="header-anchor"&gt;&lt;/a&gt;Scene Management: From Brute-Force Traversal to Spatial Acceleration
&lt;/h2&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Core Idea&lt;/th&gt;
&lt;th&gt;Suitable For&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Brute force O(n²)&lt;/td&gt;
&lt;td&gt;Traverse all objects every frame&lt;/td&gt;
&lt;td&gt;Small demos&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Uniform grid&lt;/td&gt;
&lt;td&gt;Divide the world into cells; check only neighboring cells&lt;/td&gt;
&lt;td&gt;Uniformly distributed objects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Quadtree / Octree&lt;/td&gt;
&lt;td&gt;Recursive subdivision; empty regions are no longer split&lt;/td&gt;
&lt;td&gt;2D/3D sparse worlds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BVH&lt;/td&gt;
&lt;td&gt;Merge bounding boxes bottom-up&lt;/td&gt;
&lt;td&gt;Many dynamic objects; fast updates&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Engines usually ship with multiple structures built in, so products can switch based on the characteristics of the scene.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="advanced-topics"&gt;&lt;a href="#advanced-topics" class="header-anchor"&gt;&lt;/a&gt;Advanced Topics
&lt;/h2&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;Common Strategy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Event ordering issue&lt;/td&gt;
&lt;td&gt;Introduce a post office concept, rather than having every component trigger or listen to events arbitrarily&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tick takes too long&lt;/td&gt;
&lt;td&gt;Time compensation / frame skipping / batched processing (deferred processing)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Render thread and logic thread synchronization&lt;/td&gt;
&lt;td&gt;Logic ticks first → writes a snapshot → render thread consumes it, with an extra 1~2 frames of latency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Drawbacks of the component pattern&lt;/td&gt;
&lt;td&gt;Query overhead, cache-unfriendly → the advanced course introduces ECS (SOA + System batching)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Physics and animation coupling&lt;/td&gt;
&lt;td&gt;Animation provides the initial pose → physics simulation → animation blends the interpolated result back, achieving “realistic, satisfying falls”&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Event debugging&lt;/td&gt;
&lt;td&gt;Visualized mail: 3D floating text, frame-by-frame Pause, Log flood&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;h2 id="one-sentence-summary"&gt;&lt;a href="#one-sentence-summary" class="header-anchor"&gt;&lt;/a&gt;One-Sentence Summary
&lt;/h2&gt;&lt;p&gt;The game world = a &lt;strong&gt;GameObject&lt;/strong&gt; container + &lt;strong&gt;Component&lt;/strong&gt; assembly + &lt;strong&gt;Tick&lt;/strong&gt; advancement + &lt;strong&gt;Event&lt;/strong&gt; communication + &lt;strong&gt;spatial index&lt;/strong&gt; acceleration.&lt;br&gt;
Understand these five steps, and you have the “map” for writing an engine by hand.&lt;/p&gt;
&lt;h2 id="reference-information"&gt;&lt;a href="#reference-information" class="header-anchor"&gt;&lt;/a&gt;Reference Information
&lt;/h2&gt;</description></item><item><title>GAMES104 Modern Game Engine - Engine Architecture Layers</title><link>https://boiltask.com/en/note/games104-game-engine-2/</link><pubDate>Mon, 26 Jan 2026 22:37:41 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-2/</guid><description>&lt;p&gt;Remember the “5+1” layer model and the two driving beasts.&lt;/p&gt;
&lt;hr&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;English&lt;/th&gt;
&lt;th&gt;Keywords&lt;/th&gt;
&lt;th&gt;Typical responsibilities&lt;/th&gt;
&lt;th&gt;Example code Xiaoming would write for “making the character move”&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;⑤&lt;/td&gt;
&lt;td&gt;Tool Layer&lt;/td&gt;
&lt;td&gt;Editor, productivity&lt;/td&gt;
&lt;td&gt;Level/Material/Blueprint/Particle/Sound&amp;hellip; all DCC import and visual editing&lt;/td&gt;
&lt;td&gt;Use Level Editor to drag the robot into the scene, adjust the camera and animation State Machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;④&lt;/td&gt;
&lt;td&gt;Function Layer&lt;/td&gt;
&lt;td&gt;Visible, animatable, playable&lt;/td&gt;
&lt;td&gt;Rendering (Render), Animation, Physics, AI/Scripting, UI (HUD)&lt;/td&gt;
&lt;td&gt;TickLogic: read input → update Skeletal Animation; TickRender: submit DrawCall&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;③&lt;/td&gt;
&lt;td&gt;Resource Layer&lt;/td&gt;
&lt;td&gt;Assets = efficient data + relationships&lt;/td&gt;
&lt;td&gt;Convert different asset types into efficient required formats 1. .max/.psd → engine Asset (DDS textures, compressed Mesh); 2. Manage GUID, Handle, lifecycle, lazy loading, GC&lt;/td&gt;
&lt;td&gt;Write Composite Asset: make “Robot.asset” point to Mesh/Texture/Anim&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;②&lt;/td&gt;
&lt;td&gt;Core Layer&lt;/td&gt;
&lt;td&gt;Swiss Army knife&lt;/td&gt;
&lt;td&gt;Math library (SIMD), containers (fragmentation-free), memory pool, thread/task system, RTTI/Reflection&lt;/td&gt;
&lt;td&gt;Provide Vec3/Quat math, efficient Queue, memory allocator for upper layers to call&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;①&lt;/td&gt;
&lt;td&gt;Platform Layer&lt;/td&gt;
&lt;td&gt;Write once, run everywhere&lt;/td&gt;
&lt;td&gt;Encapsulate OS, file paths, CPU/GPU differences, RHI (DX/Metal/Vulkan abstraction), input devices&lt;/td&gt;
&lt;td&gt;Implement RHI::CreateBuffer(): PC uses DX12, Mac uses Metal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Avoid logic where lower layers call upward into upper layers in reverse, which would cause a messy structure.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;The two “mythical beasts” — the game main loop
One Tick every 16.67ms (60 FPS):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;TickLogic:
&lt;ul&gt;
&lt;li&gt;Read input → AI decision → Skeletal Animation update → physics collision → memory GC → &amp;hellip;&lt;/li&gt;
&lt;li&gt;(Whether you can see it or not, the world state has advanced)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;TickRender:
&lt;ul&gt;
&lt;li&gt;Cull based on latest state → generate CommandBuffer → GPU execution → present frame&lt;/li&gt;
&lt;li&gt;(Presentation only; does not affect real physics/logic)
→ Logic and rendering are strictly separated, facilitating multithreading, replay recording, and network synchronization.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Resource → Asset lifecycle (key)&lt;/p&gt;
&lt;p&gt;Raw files (Resource)&lt;br&gt;
↓ Import/Convert (offline)&lt;br&gt;
Engine assets (Asset):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Compact data, GPU-friendly (e.g., DDS textures)&lt;/li&gt;
&lt;li&gt;Carry GUIDs; renaming/moving does not lose references&lt;/li&gt;
&lt;li&gt;Composite Asset describes associations (Mesh+Mat+Anim)&lt;br&gt;
↓&lt;br&gt;
Runtime Handle system + Asset Manager:&lt;/li&gt;
&lt;li&gt;Lazy loading, Reference Counting, asynchronous unloading&lt;/li&gt;
&lt;li&gt;Avoid “stutter” and “memory blow-up” during Level switching&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Evolution of multithreading and the Job system&lt;/p&gt;
&lt;p&gt;Single-threaded → Logic/Render two threads → function-module threads (Physics/Animation) → fully Job-based (Task Graph)&lt;br&gt;
Key: identify dependencies (Dependency), build a DAG, and split tasks into atomic Jobs to keep all cores fed.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Three golden rules of memory (Core Layer design mantra)&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Keep data together (Array-of-Struct → Struct-of-Array)&lt;/li&gt;
&lt;li&gt;Sequential access (Cache-line friendly)&lt;/li&gt;
&lt;li&gt;Batch reads/writes/frees (reduce malloc/free; use a Pool)&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;Easily overlooked pitfalls in the Platform Layer&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;File path separators, case sensitivity, encoding&lt;/li&gt;
&lt;li&gt;Different CPU architectures (x86/ARM, big.LITTLE cores, SPU)&lt;/li&gt;
&lt;li&gt;Graphics API differences → RHI abstraction&lt;/li&gt;
&lt;li&gt;Input devices (keyboard/mouse, gamepad, steering wheel, Kinect&amp;hellip;)&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Tool Layer = productivity&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In-house: Level Editor, Material Editor, Blueprint&amp;hellip;&lt;/li&gt;
&lt;li&gt;DCC chain: Max/Maya/PS/Houdini → Export Plugin → Asset Conditioning Pipeline → engine&lt;/li&gt;
&lt;li&gt;There is still no absolute standard for a unified data format (FBX→USD?); most engines build their own.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;p&gt;Engine = ⑤ Tool ④ Function ③ Resource ② Core ① Platform; Tick drives the layered stack, the lower, the steadier; the higher, the livelier.&lt;/p&gt;
&lt;p&gt;Video link: &lt;a class="link" href="https://www.bilibili.com/video/BV12Z4y1B7th" target="_blank" rel="noopener"&gt;Engine Architecture Layers | GAMES104 - Modern Game Engine: From Beginner to Practice&lt;/a&gt;&lt;/p&gt;</description></item><item><title>GAMES104 Modern Game Engine - Introduction to Game Engines</title><link>https://boiltask.com/en/note/games104-game-engine-1/</link><pubDate>Mon, 26 Jan 2026 21:05:27 +0800</pubDate><guid>https://boiltask.com/en/note/games104-game-engine-1/</guid><description>&lt;blockquote&gt;
&lt;p&gt;I still need to calm down and systematically organize my game engine knowledge, jotting down some notes as I go.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="engine-overview"&gt;&lt;a href="#engine-overview" class="header-anchor"&gt;&lt;/a&gt;Engine Overview
&lt;/h2&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Perspective&lt;/th&gt;
&lt;th&gt;One-line Definition&lt;/th&gt;
&lt;th&gt;Keywords&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Technical perspective&lt;/td&gt;
&lt;td&gt;The underlying framework for building &amp;ldquo;The Matrix&amp;rdquo;&lt;/td&gt;
&lt;td&gt;Matrix Foundation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Productivity perspective&lt;/td&gt;
&lt;td&gt;A toolchain that turns creativity/imagination into industrialized production&lt;/td&gt;
&lt;td&gt;Creative Pipeline&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Systems perspective&lt;/td&gt;
&lt;td&gt;The art of complex compromise under limited compute + real-time constraints&lt;/td&gt;
&lt;td&gt;Real-time Complexity&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="engine-history"&gt;&lt;a href="#engine-history" class="header-anchor"&gt;&lt;/a&gt;Engine History
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;1960-80s&lt;/strong&gt;: No engine concept; cartridges/arcade boards were burned directly; complete games were built within 40 KB.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1990&lt;/strong&gt;: John Carmack first extracted reusable modules from Wolf3D → Doom, and the term &amp;ldquo;Game Engine&amp;rdquo; was born.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;1996&lt;/strong&gt;: Graphics cards appeared; the Quake engine + OpenGL established the 3D + networked architecture.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2000-10&lt;/strong&gt;: Console generations iterated; compute increased 200,000x → code size grew from 10 K → 10 M lines; dedicated middleware emerged (Havok-Physics, FMOD-Sound, SpeedTree&amp;hellip;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2010-now&lt;/strong&gt;: Commercial engines formed a three-way rivalry (UE/Unity/in-house); engines became infrastructure, spilling over into film/TV, simulation, digital twins, and the metaverse.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="engine-architecture"&gt;&lt;a href="#engine-architecture" class="header-anchor"&gt;&lt;/a&gt;Engine Architecture
&lt;/h2&gt;
&lt;div class="highlight-wrapper"&gt;
&lt;div class="highlight-body"&gt;
&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1
&lt;/span&gt;&lt;span class="lnt"&gt; 2
&lt;/span&gt;&lt;span class="lnt"&gt; 3
&lt;/span&gt;&lt;span class="lnt"&gt; 4
&lt;/span&gt;&lt;span class="lnt"&gt; 5
&lt;/span&gt;&lt;span class="lnt"&gt; 6
&lt;/span&gt;&lt;span class="lnt"&gt; 7
&lt;/span&gt;&lt;span class="lnt"&gt; 8
&lt;/span&gt;&lt;span class="lnt"&gt; 9
&lt;/span&gt;&lt;span class="lnt"&gt;10
&lt;/span&gt;&lt;span class="lnt"&gt;11
&lt;/span&gt;&lt;span class="lnt"&gt;12
&lt;/span&gt;&lt;span class="lnt"&gt;13
&lt;/span&gt;&lt;span class="lnt"&gt;14
&lt;/span&gt;&lt;span class="lnt"&gt;15
&lt;/span&gt;&lt;span class="lnt"&gt;16
&lt;/span&gt;&lt;span class="lnt"&gt;17
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;┌─ 硬件/驱动抽象层（跨平台）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├─ 核心系统（内存、线程、IO、反射、序列化）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├─ 运行时“大三件”
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├─ Rendering 渲染（Forward/Deferred/Cluster/RTX）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├─ Animation 动画（骨骼、蒙皮、BlendTree、IK、Motion Matching）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ └─ Physics 物理（刚体→软体→流体；连续碰撞、约束求解）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├─ Gameplay 层
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├─ 世界对象模型（Entity/Component/Archetype）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├─ 脚本/可视化蓝图（事件→状态→行为）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ └─ AI + 寻路（NavMesh、行为树、感知系统）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;├─ 在线子系统
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ ├─ 网络同步模型（帧同步 vs 状态同步）
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;│ └─ 低延迟、丢包、预测、回滚
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;└─ 工具链与数据管线
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├─ 场景/关卡/动画/材质/特效 编辑器
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ├─ 反射+序列化保证“热更新+版本兼容”
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; └─ 构建、打包、分发、Crash 收集&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;blockquote&gt;
&lt;p&gt;Graphics is only a small part of it; the engine ≠ rendering.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="course-structure"&gt;&lt;a href="#course-structure" class="header-anchor"&gt;&lt;/a&gt;Course Structure
&lt;/h2&gt;&lt;ol&gt;
&lt;li&gt;Engine fundamentals and layered thinking (this section)&lt;/li&gt;
&lt;li&gt;Real-time Render Pipeline (Forward/Deferred/transparent sorting/mobile optimization)&lt;/li&gt;
&lt;li&gt;Animation system (Clip→Blend→IK→Motion Matching)&lt;/li&gt;
&lt;li&gt;Physics and collision (rigid body→particles→cloth→vehicles; performance budget)&lt;/li&gt;
&lt;li&gt;Gameplay architecture (Entity-Component, events, scripting, visual programming)&lt;/li&gt;
&lt;li&gt;VFX &amp;amp; particles (GPU Sprite, Niagara concepts)&lt;/li&gt;
&lt;li&gt;AI and Pathfinding (NavMesh, Behavior Tree, perception, Crowd)&lt;/li&gt;
&lt;li&gt;Camera/3C (Character-Camera-Control)&lt;/li&gt;
&lt;li&gt;Toolchain design (Reflection, Serialization, data compatibility, plugin mechanism)&lt;/li&gt;
&lt;li&gt;Multithreading and task systems (Job System, Data-Oriented)&lt;/li&gt;
&lt;li&gt;Network synchronization basics (Lockstep, State Synchronization, prediction, lag compensation)&lt;/li&gt;
&lt;li&gt;Open world and streaming (World Partition, HLOD, PCG)&lt;/li&gt;
&lt;li&gt;Global illumination and real-time ray tracing (SSGI, Lumen, RTX)&lt;/li&gt;
&lt;li&gt;Frontier topic 1: Motion Matching + machine learning animation&lt;/li&gt;
&lt;li&gt;Frontier topic 2: Procedural generation (PCG) + city/terrain&lt;/li&gt;
&lt;li&gt;Frontier topic 3: Data-oriented architecture (ECS) and the limits of engine performance&lt;/li&gt;
&lt;li&gt;Mini-engine practical course (code walkthrough: Update loop→module breakdown)&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="recommended-materials"&gt;&lt;a href="#recommended-materials" class="header-anchor"&gt;&lt;/a&gt;Recommended Materials
&lt;/h2&gt;&lt;p&gt;Main book: &amp;ldquo;Game Engine Architecture&amp;rdquo; 4th edition (English) / 3rd edition (Chinese)
Supplementary: Games101 (graphics), Games103 (physics), Games202 (advanced rendering)&lt;/p&gt;
&lt;h2 id="chapter-summary"&gt;&lt;a href="#chapter-summary" class="header-anchor"&gt;&lt;/a&gt;Chapter Summary
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;An engine is the art of compromise under real-time constraints.&lt;/li&gt;
&lt;li&gt;Algorithms account for only 10%; the remaining 90% is tools, data, collaboration, and compatibility.&lt;/li&gt;
&lt;li&gt;Update() is the engine&amp;rsquo;s &amp;ldquo;Big Bang&amp;rdquo; entry point—follow it to trace any engine.&lt;/li&gt;
&lt;li&gt;To build engines, learn to build tools first; the users are artists and designers first, programmers second.&lt;/li&gt;
&lt;li&gt;Changing the engine while the plane is flying—and not letting the plane fall—that&amp;rsquo;s live iteration.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="references"&gt;&lt;a href="#references" class="header-anchor"&gt;&lt;/a&gt;References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class="link" href="https://www.bilibili.com/video/BV1oU4y1R7Km" target="_blank" rel="noopener"&gt;Introduction to Game Engines | GAMES104 - Modern Game Engine: From Beginner to Practice&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>