SlideShare a Scribd company logo
HDR meets Black&White 2 Francesco Carucci Graphics Programmer/Lionhead Studios [email_address]
What’s HDR rendering? We all know…   …  rendering the scene to a format which can represent color luminance greater than 1.0 (usually floating point) Display devices are limited to LDR (8/10 bit): the HDR image must be converted to LDR (tonemapped) before it can be displayed
Why HDR? An HDR image can represent bright and dark areas in the scene ‘equally’ well Different scenes with drastically different lighting conditions can be handled the same way without saturating Does your game need it? No: Go To End. Pub. Yes: Go To Next Slide.
Black&White 2 by night (1) Day/night in BW2 cycle makes it difficult to find the right lighting set up for all cases Night scenes in BW2 are suffering from severe low dynamic range HDR rendering and auto exposure as a solution to improve visual quality in night scenes
Black&White 2 by night (2) More than 95% of the pixels have luminance smaller than 0.5
Color luminance Quick and simple: luminance is a color property defined in the HSL space and intuitively represents color brightness To compute luminance from RGB: luminance = dot(color,LUMINANCE_VECTOR) A typical LUMINANCE_VECTOR: (0.2125 0.7154 0.0721)
Tonemapping (1) Here’s the simplest tonemapping operator: if (luminance > 1.0) color = white Simple but not very interesting, let’s try another one: new_luminance = luminance / max_luminance new_color = color * new_luminance / luminance
Tone mapping (2) For a better operator give a look at: “ Photographic Tone Reproduction for Digital Images ” …  but it doesn’t matter how hard you try:  Tone mapping is an artistic process, and it does require input from an artist .
HDR in Games  Some games are now supporting HDR lighting or HDR rendering: Half Life 2 Lost Coast (HDRL) Far Cry and Splinter Cell (HDRR) Some XBOX 360 games
HDR “a la” Half Life 2 (1) Compute the light equation using high dynamic range values Tone map at the end of the lighting computation before writing the result to the framebuffer Render to a standard i8 (D3DFMT_A8R8G8B8) render target
HDR “a la” Half Life 2 (2) Pros: It doesn’t require HDR hardware support Compatible with MSAA on a broad range of hardware Relatively cheap
HDR “a la” Half Life 2 (3) Cons: Need to touch each and every single shader to include tone mapping Not easy to understand and control the overall dynamic range of the scene Can become expensive it there’s lots of overdraw (but a depth pass can save the day here!)
HDR: The “floating” way (1) Compute lighting at high dynamic range, write the result to a floating point (16, 32 bit per component) render target (D3DFMT_A16FG16FB16F) Compute average and maximum luminance from the HDR image Tone map the HDR image to a LDR render target
HDR: The “floating” way (2) Pros: Fixed and predictable cost per pixel High precision in representing the color (16bit per component) Easy to control exposure using average and maximum luminance directly computed from the scene
HDR: The “floating” way (3) Cons: It’s expensive! Lots of bandwidth required, lots of memory to store the fp16 render target It requires special hardware support available on latest hardware It doesn’t play well with MSAA (needs hardware support to resolve MSAA of a floating point render target)
Other ways to do HDR Use RGBE to represent HDR colors Blending must be done manually No MSAA Convert to HSL color space before writing to the frame buffer, allocate more bits for L for HDR expensive, hard to implement “right”
HDR: Fran’s way   But first, a word from the sponsor: <insert animation of a silly Black&White 2 creature here >
Average luminance and the GPU Computing the average luminance of a scene is a typical ‘gathering’ operation The GPU is not good at gathering data Where the CPU is very good at it
Average luminance on the CPU The HDR image data has to be transferred to the main memory SLOW! (not so slow on PCI-E) not a problem on next-gen consoles Why only average luminance? Compute the entire image histogram!
Image Histogram Find maximum and minimum absolute luminance (Lmax, Lmin) Divide the luminance range in a certain number of slots (e.g. 1024) For each slot, find the number of pixels with that particular luminance Divide each slot by the number of pixels to obtain its frequency
Histogram Equalisation (1) Once we got the image histogram we can equalise to cover the whole available dynamic range
Histogram Equalisation (2) From “Digital Image Processing”, page 91-93: map each slot with luminance level R in the input image, to a slot with level S where S is the sum of all frequencies less or equal than R The result a good approximation of an equalized histogram
Autoexposure (1) From the equalized histogram compute Lnew_min, Lnew_max, Lnew_avg: Lnew_min is the first slot where S is greater than Pmin Lnew_max is the first slot where S is greater than Pmax Lnew_avg is the first slot where S is greater than Pavg Typical Pmin, Pmax and Pavg are 0.01 (1%), 0.99 (50%), and 0.50 (50%)
Autoexposure (2) Minimum and maximum percentage can be chosen to ignore very small bright and dark areas and have a more uniform behaviour
Autoexposure (3) Auto exposure is implemented by tracking the actual minimum, maximum and average luminance to reach the values computed earlier: act_value += new_value * (1.0f - pow(1.0f - speed, 30.0f * elapsed_time));
Luminance mapping (1) Create a 1024x1 linear texture to store the luminance mapping: Luminance less than Lact_min is mapped to 0.0 Luminance greater than Lact_max is mapped to 1.0 (and then bloomed) The rest of the range could be mapped with a simple gamma ramp: float xp = 1.0f + (Lact_avg - Lact_min) / (Lact_max - Lact_min); gamma_ramp = powf(x, xp + bias);
Luminance mapping (2) The bias value is adjusted to increase or decrease contrast in the scene Higher contrast during the day Lower contrast at night
Luminance mapping (3) To reduce banding artefacts, the luminance map should be D3DFMT_R16F The pixel shader fragment in the tone mapper: float Li = dot(colorIn, LUMINANCE_VECTOR); float Ld = tex1D(LuminanceMapSampler, Li); colorOut.rgb = LuminanceScale * (colorIn.rgb / Li) * Ld;
Histogram based HDR Pros Trade bandwidth from GPU to CPU (usually spare but scarce) for GPU power More control over image characteristics Very flexible and simple pixel shader tone mapper Easy to plug into color correction techniques based on 3d textures
Histogram based HDR Cons Needs a lot of GPU to CPU bandwidth    but free on console Needs a lot of memory to double buffer the HDR image but downloading a scaled version will help Needs CPU cycles to analyze the HDR image what about that idle core there?
HDR in Black&White 2 (1) Plugging HDR into Black&White 2 required only localized changes to the post processing framework NO shader needed to be touched NO change to the art asset But to take full advantage of HDR the artists should take part in the process!
HDR in Black&White 2 (2) A fp16 render target is used to render the main rendering to have good color precision in input for the tone mapper A scaled down (4x) version of the HDR image is downloaded to system memory and analyzed every frame (at 30fps)
Performance analysis A scaled down version of a 1024x768 fp16 render target requires approximately 11mb/s of bandwidth It takes about 10ms to download the image and about 1ms to analyze it on a AMD64 3500mhz It’s bandwidth bound
Before
After
Before
After
BW2 HDR Patch The HDR Patch of Black&White 2 will be released soon (April) It will support MSAA where available
References “ Photographic Tone Reproduction for Digital Images ” Game Programming Gems 4 “ Digital Image Processing” – Gonzales, Woods  “ High Dynamic Range Rendering on the GeForce 6800” – Simon Green, Cem Cebenoyahn
Black&White 2 Engine Team Thanks to the Black&White 2 engine team who have made an amazingly looking game:  Ben, Dave and Mark
? [email_address]

More Related Content

PDF
Rendering AAA-Quality Characters of Project A1
Ki Hyunwoo
 
PPTX
Rendering Technologies from Crysis 3 (GDC 2013)
Tiago Sousa
 
PPTX
Parallel Futures of a Game Engine (v2.0)
repii
 
PPTX
High Dynamic Range color grading and display in Frostbite
Electronic Arts / DICE
 
PPTX
Future Directions for Compute-for-Graphics
Electronic Arts / DICE
 
PPTX
Cross platform app development with flutter
Hwan Jo
 
PPT
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
repii
 
PPTX
Dart and Flutter Basics.pptx
DSCVSSUT
 
Rendering AAA-Quality Characters of Project A1
Ki Hyunwoo
 
Rendering Technologies from Crysis 3 (GDC 2013)
Tiago Sousa
 
Parallel Futures of a Game Engine (v2.0)
repii
 
High Dynamic Range color grading and display in Frostbite
Electronic Arts / DICE
 
Future Directions for Compute-for-Graphics
Electronic Arts / DICE
 
Cross platform app development with flutter
Hwan Jo
 
Frostbite Rendering Architecture and Real-time Procedural Shading & Texturing...
repii
 
Dart and Flutter Basics.pptx
DSCVSSUT
 

What's hot (20)

PPTX
Physically Based and Unified Volumetric Rendering in Frostbite
Electronic Arts / DICE
 
PPTX
Lighting the City of Glass
Electronic Arts / DICE
 
PPTX
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Electronic Arts / DICE
 
PPTX
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
AMD Developer Central
 
PDF
Modern OpenGL Usage: Using Vertex Buffer Objects Well
Mark Kilgard
 
PDF
Deferred Rendering in Killzone 2
Guerrilla
 
PPTX
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
Electronic Arts / DICE
 
PPT
A Bit More Deferred Cry Engine3
guest11b095
 
PDF
OpenGL 4.4 - Scene Rendering Techniques
Narann29
 
PDF
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Philip Hammer
 
PPTX
Moving Frostbite to Physically Based Rendering
Electronic Arts / DICE
 
PPT
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Electronic Arts / DICE
 
PDF
Lighting of Killzone: Shadow Fall
Guerrilla
 
PDF
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
Codemotion
 
PDF
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
JP Lee
 
PPT
NVIDIA OpenGL and Vulkan Support for 2017
Mark Kilgard
 
PDF
Dissecting the Rendering of The Surge
Philip Hammer
 
PPT
Secrets of CryENGINE 3 Graphics Technology
Tiago Sousa
 
PDF
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Guerrilla
 
PPTX
Hable John Uncharted2 Hdr Lighting
ozlael ozlael
 
Physically Based and Unified Volumetric Rendering in Frostbite
Electronic Arts / DICE
 
Lighting the City of Glass
Electronic Arts / DICE
 
Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite
Electronic Arts / DICE
 
GS-4106 The AMD GCN Architecture - A Crash Course, by Layla Mah
AMD Developer Central
 
Modern OpenGL Usage: Using Vertex Buffer Objects Well
Mark Kilgard
 
Deferred Rendering in Killzone 2
Guerrilla
 
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
Electronic Arts / DICE
 
A Bit More Deferred Cry Engine3
guest11b095
 
OpenGL 4.4 - Scene Rendering Techniques
Narann29
 
The Rendering Technology of 'Lords of the Fallen' (Game Connection Europe 2014)
Philip Hammer
 
Moving Frostbite to Physically Based Rendering
Electronic Arts / DICE
 
Stable SSAO in Battlefield 3 with Selective Temporal Filtering
Electronic Arts / DICE
 
Lighting of Killzone: Shadow Fall
Guerrilla
 
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
Codemotion
 
Penner pre-integrated skin rendering (siggraph 2011 advances in real-time r...
JP Lee
 
NVIDIA OpenGL and Vulkan Support for 2017
Mark Kilgard
 
Dissecting the Rendering of The Surge
Philip Hammer
 
Secrets of CryENGINE 3 Graphics Technology
Tiago Sousa
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Guerrilla
 
Hable John Uncharted2 Hdr Lighting
ozlael ozlael
 
Ad

Viewers also liked (18)

PPT
HDR Tutorial
JoshNorthrup
 
PDF
High Dynamic Range Imaging- A Review
CSCJournals
 
PPS
Summer´s shots (hdr) in Argentina
Nikkitta M
 
PDF
New developments in image capture and delivery will affect entire entertainme...
Technicolor
 
PPTX
Hdr magic
SunRidge Photo
 
PPTX
Hdr Photography
Tom Mouat
 
KEY
HDR Workshop
Scott Wyden Kivowitz
 
PPT
2015 NAPIM Fall Tech Conference: Extended Gamut Guide Presentation
Buzz Apostol
 
PPTX
Towards 'inspirational HDR supervision': leading change in the HDR Supervisio...
Merilyn Childs @ Macquarie University
 
PPT
clinical applications of ldr and hdr brachytherapy
sugash
 
PPS
New York (hdr)
Nikkitta M
 
PDF
High-Dynamic Range (HDR) Demystified
Intel® Software
 
PPTX
HDR in Cinema: Achievable Contrast
Barco
 
PDF
Exploring HDR: Beyond the Single Exposure
ambientphoto
 
PPSX
Hdr Photo Collection 1 (Pp Tminimizer)
Marco Belzoni
 
PPT
Hdr Panoramic Photography
David Morris
 
PDF
Yanlu Dhtc Hdr Texture Compression
ozlael ozlael
 
HDR Tutorial
JoshNorthrup
 
High Dynamic Range Imaging- A Review
CSCJournals
 
Summer´s shots (hdr) in Argentina
Nikkitta M
 
New developments in image capture and delivery will affect entire entertainme...
Technicolor
 
Hdr magic
SunRidge Photo
 
Hdr Photography
Tom Mouat
 
HDR Workshop
Scott Wyden Kivowitz
 
2015 NAPIM Fall Tech Conference: Extended Gamut Guide Presentation
Buzz Apostol
 
Towards 'inspirational HDR supervision': leading change in the HDR Supervisio...
Merilyn Childs @ Macquarie University
 
clinical applications of ldr and hdr brachytherapy
sugash
 
New York (hdr)
Nikkitta M
 
High-Dynamic Range (HDR) Demystified
Intel® Software
 
HDR in Cinema: Achievable Contrast
Barco
 
Exploring HDR: Beyond the Single Exposure
ambientphoto
 
Hdr Photo Collection 1 (Pp Tminimizer)
Marco Belzoni
 
Hdr Panoramic Photography
David Morris
 
Yanlu Dhtc Hdr Texture Compression
ozlael ozlael
 
Ad

Similar to Hdr Meets Black And White 2 (20)

KEY
Cis660 primer hdr_eric_cheng
Eric Cheng
 
PPT
Paris Master Class 2011 - 05 Post-Processing Pipeline
Wolfgang Engel
 
PDF
An improved hdr image processing using fast global
eSAT Publishing House
 
PDF
An improved hdr image processing using fast global tone mapping
eSAT Journals
 
PDF
Deferred shading
ozlael ozlael
 
PDF
Practical Spherical Harmonics Based PRT Methods
Naughty Dog
 
PPTX
HDR
Ali A Jalil
 
PDF
Computer Graphics Part1
qpqpqp
 
PPT
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
mobius.cn
 
PPTX
A Bizarre Way to do Real-Time Lighting
Steven Tovey
 
PPTX
Real-time lightmap baking
Rosario Leonardi
 
PPT
Shooting High Dynamic Range
Jessica Young
 
PDF
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
Adam Hill
 
PPSX
Practical spherical harmonics based PRT methods.ppsx
MannyK4
 
PDF
Shader X³: Image Space - Color Grading
Ronny Burkersroda
 
PPTX
Around the World in 80 Shaders
stevemcauley
 
PPTX
Next generation mobile gp us and rendering techniques - niklas smedberg
Mary Chan
 
PDF
Shaders - Claudia Doppioslash - Unity With the Best
BeMyApp
 
PDF
Rendering Tech of Space Marine
Pope Kim
 
PPT
CS 354 Understanding Color
Mark Kilgard
 
Cis660 primer hdr_eric_cheng
Eric Cheng
 
Paris Master Class 2011 - 05 Post-Processing Pipeline
Wolfgang Engel
 
An improved hdr image processing using fast global
eSAT Publishing House
 
An improved hdr image processing using fast global tone mapping
eSAT Journals
 
Deferred shading
ozlael ozlael
 
Practical Spherical Harmonics Based PRT Methods
Naughty Dog
 
Computer Graphics Part1
qpqpqp
 
Advanced Lighting Techniques Dan Baker (Meltdown 2005)
mobius.cn
 
A Bizarre Way to do Real-Time Lighting
Steven Tovey
 
Real-time lightmap baking
Rosario Leonardi
 
Shooting High Dynamic Range
Jessica Young
 
PapersWeLove - Rendering Synthetic Objects Into Real Scenes - Paul Debevec.pdf
Adam Hill
 
Practical spherical harmonics based PRT methods.ppsx
MannyK4
 
Shader X³: Image Space - Color Grading
Ronny Burkersroda
 
Around the World in 80 Shaders
stevemcauley
 
Next generation mobile gp us and rendering techniques - niklas smedberg
Mary Chan
 
Shaders - Claudia Doppioslash - Unity With the Best
BeMyApp
 
Rendering Tech of Space Marine
Pope Kim
 
CS 354 Understanding Color
Mark Kilgard
 

Recently uploaded (20)

PPTX
奎斯特大学文凭办理|办理QUC毕业证学位证书2025年新版学位证书影本
1cz3lou8
 
PPTX
MtA文凭办理|办理蒙特埃里森大学毕业证成绩单复刻学分无法毕业怎么办?
ekwp9g1k
 
PPTX
design for presentation purpose can used
vishveshvarvms
 
PDF
Presentación San Patricio Ilustrativo Verde (1).pdf
andressuarezaraya912
 
PPTX
UCSP Quarter 1 Week 4 Powerpoint Presentation
EmyMaquiling1
 
PPTX
• Hinduism is not founded by any particular prophet. Buddhism was founded by ...
BeshoyGirgis2
 
PPT
2C Central and Eastern Europe - the flowering (Russia)
dolgalev
 
PDF
Malaria detection through machine learning and deep learning
BhaveshGoyal26
 
PPTX
Q1_Music and Arts_Week 3-4 [Autosaved].pptx
MelissaJeanBayobay1
 
PDF
Discover more pictures from Armoured One
Armoured One
 
PDF
Trapped Movie trailer (New Media Tools Presentation)
marebecams
 
PPTX
Thumbnail Sketch and The Golden Ratio.pptx
joyshehane
 
PPTX
ENGLISH 6 WEEK 6 DAY 2.pptxLFLLLLLLLLLLLLLLLLLLLLLLLLLL
DitaSIdnay
 
PDF
ARTIFICIAL intelligence ............,....
kasimnagori121
 
PDF
LLLLLLLLLLLLLLLLLLLLCABUTAN UNDIAN PELANCARAN ROKET.pdf
ABKARIMBINABDULRAHMA
 
PDF
Zero no Tsukaima 1 - Zero_s Familiar.pdf
WaldeckFlugelWallens
 
PPTX
Lecture 1b - Diagnostic Analytics Intro and Purpose ver 1.0 (1).pptx
guddipatel10
 
PDF
Why Should You Hire a Video Production Studio in 2025?
GXYZ Inc
 
PPTX
Human Efficiencknkjnhjbnhjbhjhjbnljy.pptx
hanhocpt13
 
PDF
gri-report-2023.nb hjjhbjhbjbmnmnmbbmbmbm
dsoham206
 
奎斯特大学文凭办理|办理QUC毕业证学位证书2025年新版学位证书影本
1cz3lou8
 
MtA文凭办理|办理蒙特埃里森大学毕业证成绩单复刻学分无法毕业怎么办?
ekwp9g1k
 
design for presentation purpose can used
vishveshvarvms
 
Presentación San Patricio Ilustrativo Verde (1).pdf
andressuarezaraya912
 
UCSP Quarter 1 Week 4 Powerpoint Presentation
EmyMaquiling1
 
• Hinduism is not founded by any particular prophet. Buddhism was founded by ...
BeshoyGirgis2
 
2C Central and Eastern Europe - the flowering (Russia)
dolgalev
 
Malaria detection through machine learning and deep learning
BhaveshGoyal26
 
Q1_Music and Arts_Week 3-4 [Autosaved].pptx
MelissaJeanBayobay1
 
Discover more pictures from Armoured One
Armoured One
 
Trapped Movie trailer (New Media Tools Presentation)
marebecams
 
Thumbnail Sketch and The Golden Ratio.pptx
joyshehane
 
ENGLISH 6 WEEK 6 DAY 2.pptxLFLLLLLLLLLLLLLLLLLLLLLLLLLL
DitaSIdnay
 
ARTIFICIAL intelligence ............,....
kasimnagori121
 
LLLLLLLLLLLLLLLLLLLLCABUTAN UNDIAN PELANCARAN ROKET.pdf
ABKARIMBINABDULRAHMA
 
Zero no Tsukaima 1 - Zero_s Familiar.pdf
WaldeckFlugelWallens
 
Lecture 1b - Diagnostic Analytics Intro and Purpose ver 1.0 (1).pptx
guddipatel10
 
Why Should You Hire a Video Production Studio in 2025?
GXYZ Inc
 
Human Efficiencknkjnhjbnhjbhjhjbnljy.pptx
hanhocpt13
 
gri-report-2023.nb hjjhbjhbjbmnmnmbbmbmbm
dsoham206
 

Hdr Meets Black And White 2

  • 1. HDR meets Black&White 2 Francesco Carucci Graphics Programmer/Lionhead Studios [email_address]
  • 2. What’s HDR rendering? We all know…  … rendering the scene to a format which can represent color luminance greater than 1.0 (usually floating point) Display devices are limited to LDR (8/10 bit): the HDR image must be converted to LDR (tonemapped) before it can be displayed
  • 3. Why HDR? An HDR image can represent bright and dark areas in the scene ‘equally’ well Different scenes with drastically different lighting conditions can be handled the same way without saturating Does your game need it? No: Go To End. Pub. Yes: Go To Next Slide.
  • 4. Black&White 2 by night (1) Day/night in BW2 cycle makes it difficult to find the right lighting set up for all cases Night scenes in BW2 are suffering from severe low dynamic range HDR rendering and auto exposure as a solution to improve visual quality in night scenes
  • 5. Black&White 2 by night (2) More than 95% of the pixels have luminance smaller than 0.5
  • 6. Color luminance Quick and simple: luminance is a color property defined in the HSL space and intuitively represents color brightness To compute luminance from RGB: luminance = dot(color,LUMINANCE_VECTOR) A typical LUMINANCE_VECTOR: (0.2125 0.7154 0.0721)
  • 7. Tonemapping (1) Here’s the simplest tonemapping operator: if (luminance > 1.0) color = white Simple but not very interesting, let’s try another one: new_luminance = luminance / max_luminance new_color = color * new_luminance / luminance
  • 8. Tone mapping (2) For a better operator give a look at: “ Photographic Tone Reproduction for Digital Images ” … but it doesn’t matter how hard you try: Tone mapping is an artistic process, and it does require input from an artist .
  • 9. HDR in Games Some games are now supporting HDR lighting or HDR rendering: Half Life 2 Lost Coast (HDRL) Far Cry and Splinter Cell (HDRR) Some XBOX 360 games
  • 10. HDR “a la” Half Life 2 (1) Compute the light equation using high dynamic range values Tone map at the end of the lighting computation before writing the result to the framebuffer Render to a standard i8 (D3DFMT_A8R8G8B8) render target
  • 11. HDR “a la” Half Life 2 (2) Pros: It doesn’t require HDR hardware support Compatible with MSAA on a broad range of hardware Relatively cheap
  • 12. HDR “a la” Half Life 2 (3) Cons: Need to touch each and every single shader to include tone mapping Not easy to understand and control the overall dynamic range of the scene Can become expensive it there’s lots of overdraw (but a depth pass can save the day here!)
  • 13. HDR: The “floating” way (1) Compute lighting at high dynamic range, write the result to a floating point (16, 32 bit per component) render target (D3DFMT_A16FG16FB16F) Compute average and maximum luminance from the HDR image Tone map the HDR image to a LDR render target
  • 14. HDR: The “floating” way (2) Pros: Fixed and predictable cost per pixel High precision in representing the color (16bit per component) Easy to control exposure using average and maximum luminance directly computed from the scene
  • 15. HDR: The “floating” way (3) Cons: It’s expensive! Lots of bandwidth required, lots of memory to store the fp16 render target It requires special hardware support available on latest hardware It doesn’t play well with MSAA (needs hardware support to resolve MSAA of a floating point render target)
  • 16. Other ways to do HDR Use RGBE to represent HDR colors Blending must be done manually No MSAA Convert to HSL color space before writing to the frame buffer, allocate more bits for L for HDR expensive, hard to implement “right”
  • 17. HDR: Fran’s way  But first, a word from the sponsor: <insert animation of a silly Black&White 2 creature here >
  • 18. Average luminance and the GPU Computing the average luminance of a scene is a typical ‘gathering’ operation The GPU is not good at gathering data Where the CPU is very good at it
  • 19. Average luminance on the CPU The HDR image data has to be transferred to the main memory SLOW! (not so slow on PCI-E) not a problem on next-gen consoles Why only average luminance? Compute the entire image histogram!
  • 20. Image Histogram Find maximum and minimum absolute luminance (Lmax, Lmin) Divide the luminance range in a certain number of slots (e.g. 1024) For each slot, find the number of pixels with that particular luminance Divide each slot by the number of pixels to obtain its frequency
  • 21. Histogram Equalisation (1) Once we got the image histogram we can equalise to cover the whole available dynamic range
  • 22. Histogram Equalisation (2) From “Digital Image Processing”, page 91-93: map each slot with luminance level R in the input image, to a slot with level S where S is the sum of all frequencies less or equal than R The result a good approximation of an equalized histogram
  • 23. Autoexposure (1) From the equalized histogram compute Lnew_min, Lnew_max, Lnew_avg: Lnew_min is the first slot where S is greater than Pmin Lnew_max is the first slot where S is greater than Pmax Lnew_avg is the first slot where S is greater than Pavg Typical Pmin, Pmax and Pavg are 0.01 (1%), 0.99 (50%), and 0.50 (50%)
  • 24. Autoexposure (2) Minimum and maximum percentage can be chosen to ignore very small bright and dark areas and have a more uniform behaviour
  • 25. Autoexposure (3) Auto exposure is implemented by tracking the actual minimum, maximum and average luminance to reach the values computed earlier: act_value += new_value * (1.0f - pow(1.0f - speed, 30.0f * elapsed_time));
  • 26. Luminance mapping (1) Create a 1024x1 linear texture to store the luminance mapping: Luminance less than Lact_min is mapped to 0.0 Luminance greater than Lact_max is mapped to 1.0 (and then bloomed) The rest of the range could be mapped with a simple gamma ramp: float xp = 1.0f + (Lact_avg - Lact_min) / (Lact_max - Lact_min); gamma_ramp = powf(x, xp + bias);
  • 27. Luminance mapping (2) The bias value is adjusted to increase or decrease contrast in the scene Higher contrast during the day Lower contrast at night
  • 28. Luminance mapping (3) To reduce banding artefacts, the luminance map should be D3DFMT_R16F The pixel shader fragment in the tone mapper: float Li = dot(colorIn, LUMINANCE_VECTOR); float Ld = tex1D(LuminanceMapSampler, Li); colorOut.rgb = LuminanceScale * (colorIn.rgb / Li) * Ld;
  • 29. Histogram based HDR Pros Trade bandwidth from GPU to CPU (usually spare but scarce) for GPU power More control over image characteristics Very flexible and simple pixel shader tone mapper Easy to plug into color correction techniques based on 3d textures
  • 30. Histogram based HDR Cons Needs a lot of GPU to CPU bandwidth but free on console Needs a lot of memory to double buffer the HDR image but downloading a scaled version will help Needs CPU cycles to analyze the HDR image what about that idle core there?
  • 31. HDR in Black&White 2 (1) Plugging HDR into Black&White 2 required only localized changes to the post processing framework NO shader needed to be touched NO change to the art asset But to take full advantage of HDR the artists should take part in the process!
  • 32. HDR in Black&White 2 (2) A fp16 render target is used to render the main rendering to have good color precision in input for the tone mapper A scaled down (4x) version of the HDR image is downloaded to system memory and analyzed every frame (at 30fps)
  • 33. Performance analysis A scaled down version of a 1024x768 fp16 render target requires approximately 11mb/s of bandwidth It takes about 10ms to download the image and about 1ms to analyze it on a AMD64 3500mhz It’s bandwidth bound
  • 35. After
  • 37. After
  • 38. BW2 HDR Patch The HDR Patch of Black&White 2 will be released soon (April) It will support MSAA where available
  • 39. References “ Photographic Tone Reproduction for Digital Images ” Game Programming Gems 4 “ Digital Image Processing” – Gonzales, Woods “ High Dynamic Range Rendering on the GeForce 6800” – Simon Green, Cem Cebenoyahn
  • 40. Black&White 2 Engine Team Thanks to the Black&White 2 engine team who have made an amazingly looking game: Ben, Dave and Mark