程序代写代做代考 AI GPU 10: The OpenGL Pipeline

10: The OpenGL Pipeline

17: Deferred
Rendering

COMP5822M: High Performance Graphics
Forward Rendering
The standard form of projective rendering
Every fragment does lighting calculation
Expensive bottleneck in practice

COMP5822M: High Performance Graphics
Deferred Rendering
Reduces bottleneck of lighting
Single lighting computation per pixel

COMP5822M: High Performance Graphics
Deferring Pass
First pass doesn’t compute lighting
It just computes visibility
Stores all of the lighting inputs
Typically, in multiple buffers
Triangle/Surface ID
Position, Normal
Materials & Texture Coords

COMP5822M: High Performance Graphics
Deferred Pass
Second pass computes lighting
Single quad for the entire image
One fragment per pixel
One lighting calculation per pixel
Accessing the data in the buffers

COMP5822M: High Performance Graphics
Pros & Cons
Reduces number of lighting calculations
Multiple / dynamic light sources are cheaper
Increases interim storage requirements
Trades off storage vs. compute cost
Not actually guaranteed to be faster
But typically faster given the pipeline
Separates geometry from lighting

COMP5822M: High Performance Graphics
Deferred Problems
Material transparency is hard to do
Usually takes an extra forward pass
Hardware anti-aliasing can’t be used

COMP5822M: High Performance Graphics
Example: Tabula Rasa (2007)
MMO RPG/Shooter with deferred lighting

COMP5822M: High Performance Graphics
Render Issues
MMO means little control over environment
Many players can be in sight at once
Many visual effects &/or lights as well
Deferred rendering => one lighting pass

COMP5822M: High Performance Graphics
Deferred Shading Engine
Supported forward shading as well
Limited feature set
Multiple techniques per effect
Light prioritization
Deferred shading for advanced techniques

https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch19.html

COMP5822M: High Performance Graphics
Forward Shading
Used for translucent geometry
But also the fallback on low-end GPUs
Supported:
Hemispheric, directional & point lights only
Per-vertex and per-pixel lighting
Annotations for which pipeline to use
Strict limit on # of active lights

COMP5822M: High Performance Graphics
Deferred Shading
Up to 50 active dynamic lights per frame
Bidirectional lighting
Globe mapping
Box Lights
Shadow maps (local & global)

COMP5822M: High Performance Graphics
Using Depth/Normal Buffers
Fragment shaders could read from buffers
Allowed water shading in a single pass
Using caustic maps

COMP5822M: High Performance Graphics
More Recent (2016)
Uncharted 4 (see SIGGRAPH 2016 notes)
Storing more information in the buffers
Which drives cost back up

COMP5822M: High Performance Graphics
A Vulkan Example
Sascha Willems
https://github.com/SaschaWillems/Vulkan/tree/master/examples/deferred

COMP5822M: High Performance Graphics
Real Time Full Illumination
Raytraced rendering uses multiple bounces
Allows interreflections & colour bleeding

COMP5822M: High Performance Graphics
Radiosity for Ambient
Do multiple passes
Every surface becomes a light source
So render lighting to texture in each pass

COMP5822M: High Performance Graphics
Practical Radiosity
Subdivide each surface into patches
For example, texels with area-correction
In each pass, calculate re-reflection
Iterate until the result stabilises

COMP5822M: High Performance Graphics
Form Factors
Biggest problem in radiosity
How much light from A strikes B?
Based on distance, angle, patch size

COMP5822M: High Performance Graphics
Nusselt Analog Shortcut
Project surface B onto hemisphere
Drop patch down to ground plane
Take ratio to area of circular base

COMP5822M: High Performance Graphics
Radiosity Equilibrium
Light patches are emitters
Energy travels through the system
Treat as a heat transfer problem
%age heat transfer between surfaces
Or solve for eigenvectors

COMP5822M: High Performance Graphics
Progressive Radiosity
Radiosity is O(N2) in number of surfaces
Alternately, do one surface at a time
Usually the surface with the most energy
When done, set that surfaces’ emission to 0
Converges more rapidly with less storage

COMP5822M: High Performance Graphics
Real-Time Ray Tracing
Raytracing follows rays through space
Monte Carlo randomizes bounces
So adjacent rays are not in fact parallel

COMP5822M: High Performance Graphics
Interactive Ray-Tracing
Common in scientific/industrial visualization
# of primitives >> # of pixels
But each pixel is largely independent of next
Result: embarrassingly parallel branchy code
Often runs faster on CPU than GPU
Eg. Intel’s Osprey raytracer
And now NVIDIA’s RTX

COMP5822M: High Performance Graphics
PowerVR Example

COMP5822M: High Performance Graphics
RTX Example

COMP5822M: High Performance Graphics
Accelerating Raytracing
Most expensive operation is intersection
Not finding the point of intersection
But finding the surfaces to test
Good acceleration structures cost O(log n)
But O(n log n) set up cost
Work best for static scenes
Octrees, kd-trees, BSP trees, BVH

COMP5822M: High Performance Graphics
Downsides
At present, you have to use their engine
Many of the accelerations are baked in
E.g. progressive rendering
Optimises for rays in regions of high change
Or close to the centre of view
AI optimisations for early termination
Little option to customise

COMP5822M: High Performance Graphics