Andy Luedke Halo Development Team Microsoft Game Studios Why do Histogram Analysis Dynamically adjust postprocessing settings based on rendered scene content Drive tone adjustments by discovering intensity levels and adjusting ID: 617018
Download Presentation The PPT/PDF document "Fast GPU Histogram Analysis for Scene Po..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
Fast GPU Histogram Analysis for Scene Post-Processing
Andy Luedke
Halo Development Team
Microsoft Game StudiosSlide3
Why do Histogram Analysis?
Dynamically adjust post-processing settings based on rendered scene content
Drive tone adjustments by discovering intensity levels and adjusting
tonemapper
settings
Make environments feel consistent with a wide range of illumination
Mimic eye’s natural adaptation to exposure and focal rangesSlide4
Existing Techniques
Average Scene Luminance
Varies significantly with small perceived changes in HDR scenes
Luminance Histogram
Provides more useful exposure data
Limited by fixed number of bins
CPU generated from locked texture
Adjustable granularity, poor performance
GPU queries to update histogram bins
Low granularity, delayed scene responseSlide5
Luminance Histogram
Used to find interesting exposure control points
Median luminance (50
th
percentile)
Bright point (90
th
– 95
th
percentile)
Search histogram for each point
Only contains luminance data from previously rendered frames
Expensive to generate and search
Histograms are not great for exposure controlSlide6
Sorted Luminance Buffer
Sorting the luminance fixes many problems with histogram method
Expensive to sort on the CPU
Sort on the GPU instead
Parallel sorts are quite fast on GPUs
Works on current frame’s data
Easy to find percentiles in a sorted luminance buffer
Sample center of buffer for median value, or at X*N/100 for
X
th
percentileSlide7
GPU Sorting
Avoids histogram range clamping and bin granularity problems
Works on current frame’s values
Sorts multiple channels at once
Sort luminance and depth in a two channel buffer, or more in 4 channels
Sorted buffer remains on GPU
CPU processing of exposure control can be moved to the GPU exclusivelySlide8
GPU Sorting (continued)
Bitonic
sort works well on the GPU
Well suited for shader implementation
Exactly ½*(log
2
n * (log
2
n+1)) passes
Scale to slower hardware by reducing size of sorting buffer
Exposure control point lookups are still direct, but have less resolution
Bitonic
sort works best on power of 2 textures, but can be tweaked to work on other sizesSlide9
Bitonic Sort Demo
Red = Average luminance
Green = Maximum luminanceSlide10
GPU Exposure Processing
Shader samples sorted luminance buffer and outputs updated exposure control values
Use GPU to sample many points and do complex adjustments (curves, etc)
Blend new exposure control values with previous values over time
Another shader generates further
tonemapping
settings
Bloom settings, saturation, tone, etc.Slide11
Local Exposure Control
Use one channel of sort buffer as a key for another channel’s sort
Sort regions of the screen in addition to the full frame’s values
Still direct access as long as each region has a known number of pixels
RGBA=[
Lum
, Depth, Local
Lum
, Key]
Allows you to divide the screen into multiple exposure zones and mix local and global adjustmentsSlide12
Keyed Luminance Sort
Red/Green =
Avg
/Max Luminance
Blue = Regional
Avg
LuminanceSlide13
Local Exposure Control
Use different region masks to customize to your game’s needs
Must know how many pixels in each region for direct value accessSlide14
Focal Range Control
Sorted depth gives useful information for DOF ranges
Detect changes in depth range, adjusting DOF settings to simulate eye’s adjustment of focal range
Extracting depth has sampling cost, but no additional sorting
cost
May not need to filter on
downsampleSlide15
CPU Exposure PipelineSlide16
GPU Exposure PipelineSlide17
Questions?
aluedke@microsoft.com
Please fill out your surveys
References
GPU Gems
, Chapter 37
GPU Gems 2, Chapter 46
UberFlow
: A
GPU-based particle engine [
Kipfer
, et al.]
Wikipedia, Sorting
Algoritms