Rendering GAMES104 Lecture07
Rendering GAMES104 Lecture07
Lecture 07
Ambient Occlusion
• Approximation of attenuation of ambient light due to occlusion
Precomputed AO
Using ray tracing to compute the AO offline and store the result into texture, which is widely
used in object modeling process
• Extra storage cost
• Only apply to static object
Modern Game Engine - Theory and Practice
SSAO+
• Recall the AO equation is acutally done on the normal-oriented hemisphere
SSAO+ Off
SSAO+ ON
Modern Game Engine - Theory and Practice
Occluded Area
attenuation function
Slice
N
Modern Game Engine - Theory and Practice
HBAO Implementation
• Use the depth buffer as a heightfield on 2D surface
• Trace rays directly in 2D and approximate AO from horizon angle
P
Randomly jitter the step size and randomly Find the max horizon angle
rotate the directions per pixel
Modern Game Engine - Theory and Practice
cosine factor
Modern Game Engine - Theory and Practice
Fog Everything
Modern Game Engine - Theory and Practice
Depth Fog
Linear fog:
factor = (end-z)/(end-start)
Exp fog:
factor = exp(- density*z)
Exp Squared fog:
factor = exp(- (density*z)^2)
Height Fog
• Height Fog integration along view diretion
Reason of Aliasing
• Aliasing is a series of rendering artifact which is caused by high-frequency signal vs.
insufficient sampling of limited rendering resolutions
Anti-aliasing
• The general strategy of screen-based antialiasing schemes is using a sampling pattern to
get more samples and then weight and sum samples to produce a pixel color
Modern Game Engine - Theory and Practice
Horizontal = abs(1*0.25+1*1-2*0.1)
+abs(2*0.15+2*1-4*0.2)
+abs(1*0.35+1*1-2*0.3) = 3.3
Vertical = abs(1*0.25+1*0.35-2*0.15)
+abs(2*0.1+2*0.3-4*0.2)
+abs(1*1+1*1-2*1) = 0.3
Modern Game Engine - Theory and Practice
FXAA Result
Origin FXAA
Modern Game Engine - Theory and Practice
history
history N-1 blend history N
rectification
neighborhood
reproject with
color
motion vector
boundingbox
input frame N
(jittered) output
Modern Game Engine - Theory and Practice
TAA On/Off
Modern Game Engine - Theory and Practice
Post-process
Post-process in 3D Graphics refers to any algorithm that will be applied to the
final image. It can be done for stylistic reasons (color correction, contrast, etc.)
or for realistic reasons (tone mapping, depth of field, etc.)
What is Bloom
• The physical basis of bloom is that, in the
real world, lenses can never focus
perfectly
• Even a perfect lens will convolve the
incoming image with an Airy disk
Airy Disk
Modern Game Engine - Theory and Practice
Threshold
Gaussian Blur
Blur
Bloom Composite
Tone Mapping
Modern Game Engine - Theory and Practice
Tone Mapping
• No way to directly display HDR image in a SDR device
• The purpose of the Tone Mapping function is to map the wide range of high dynamic
range (HDR) colors into standard dynamic range (SDR) that a display can output
Modern Game Engine - Theory and Practice
ACES
• Academy Color Encoding System
• Primarily for Film & Animation
• Interesting paradigms and transformations
LUT 3D or 2D
3D 2D Slices
Modern Game Engine - Theory and Practice
Rendering Pipeline
• Rendering pipeline is the management order of all rendering operation execution and
resource allocation
drawCall skybox
drawCall
Modern Game Engine - Theory and Practice
Forward Rendering
for n meshes
for m lights
color += shading(mesh, light)
Modern Game Engine - Theory and Practice
Forward Rendering
Deferred Rendering
Pass 1
Pass 2
Deferred Rendering
Pros
• Lighting is only computed for visible fragments
• The data from the G-Buffer can be used for post-
processing
Cons
• High memory and bandwidth cost
• Not supporting transparent object
• Not friendly to MSAA
Tile-based Rendering
Modern Game Engine - Theory and Practice
Battlefield 4 Ryse
Modern Game Engine - Theory and Practice
DIRT GRID
Modern Game Engine - Theory and Practice
Cluster-based Rendering
Doom 2016
Modern Game Engine - Theory and Practice
Visibility Buffer
G-Buffer V-Buffer
Real Rendering Pipeline
Modern Game Engine - Theory and Practice
Challenges
• Complex parallel work needs to synchronize with complex resource dependency
• Large amount of transient resource whose lifetime is shorter than one frame
• Complex resource state management
• Exploit newly exposed GPU features without extensive user low level knowledge
Modern Game Engine - Theory and Practice
Frame Graph
A Directed Acyclic Graph (DAG) of pass and
resource dependency in a frame, not a real
visual graph
Modern Game Engine - Theory and Practice
Render to Monitor
Modern Game Engine - Theory and Practice
Screen Tearing
Modern Game Engine - Theory and Practice
Screen Tearing
V-Sync Technology
Synchronizing buffer swaps with the Vertical refresh is called V-sync
V-Sync can be used to prevent tearing but framerates are reduced, the mouse is lagging & stuttering
ruins gameplay
Modern Game Engine - Theory and Practice
Homework 2
• You are supposed to...
• Implement ColorGrading shader code
• Generate own style ColorGrading result
• Add a new post-process pass that you want (advanced)
• Write a report document that contains screenshots of
your results
• Download at
• Course-site:
https://games104.boomingtech.com/sc/course-list
• Github:
https://github.com/BoomingTech/Pilot/tree/games104/homewor
k02-rendering
Modern Game Engine - Theory and Practice
Bugfixes
• Fixed image layout transition in “pick” pass
• Fixed overlapped button and cursor twinkling
Optimizations
• Optimized display of rotation as Euler angles
• Optimized AMD and NVIDIA graphic device race when initializing
Vulkan
• Optimized editor camera controlling
Contributors
Modern Game Engine - Theory and Practice
Q&A
Modern Game Engine - Theory and Practice
Lecture 07 Contributor
• 一将 • 爵爷 • 沛楠 • QIUU
• 光哥 • Jason • Leon • C佬
• 炯哥 • 坤哥 • 虎哥 • 阿乐
• 玉林 • BOOK • Shine • 阿熊
• 小老弟 • MANDY • 晨晨 • CC
• 建辉 • 婷姐 • Judy • 大喷
Modern Game Engine - Theory and Practice
Enjoy ;)
Coding
Course Wechat