WIP: HDR Rendering – ToneMapping using Compute Shader

chEngineToneMappingCS 2014-09-25 00-29-54-53

I worked on a basic naive implementation of HDR rendering few months back using old DX9 style pixel shaders. Actually I have a lot of old experimental shaders created in Nvidia FX Composer long back (tone-mapping, physically based BRDFs, etc) and I integrate them to the engine as required providing backend support in c++ code and improve on them as necessary using Direct3d11 features. So that old pixel shader based ToneMapping shader was one such example.  It was not so great either in quality or the performance but not so bad for first implementation. Here are the rendering stages involved in that implementation : –

  • First of all, the textures used were in linear space using SRGB texture in Direct3D11.
  • Render scene to R16G16B16A16 backbuffer
  •  RenderLuminance to a separate  RenderTarger R16_float
  • Calculate using AVG Luminance using pixel shader
  • Brightness Pass (based on luminance)
  • Blur the Brightness Luminance Texture
  • FinalPass – ToneMapping + Bloom
  • Automatic Gamma correction using SRGB rendertarget/backbuffer

I used Reinhard’s Tone-mapping operator.

My new implementation is more focused and based on computeshader wherever possible. Goal is both better performance and quality. This time I am using some HDR art assets (taken from Microsoft DirectX SDK examples and Nvidia DirectX Sample SDK) to test ToneMapping. It’s almost done (there’s no bloom yet). Here’s a list of steps involved right now –

  • Render scene to R16G16B16A16 render target
  • Render its log( luminance ) to 1024×1024 R32_Float rendertarget
  • Generate whole mipmap chain using Direct3D method GenerateMips which will store Avg log ( luminance ) in that last 1×1 mip
  • Tone-mapping using Reinhard’s method. (I am experimenting with some variations and other operators)


Currently Tonemapping of 720p scene takes 0.0014 ms and Rendering & Averaging Luminance takes 0.00087 ms on GTX 780.

(Will also post time values from my old GTS 450 soon)

I drafted this post in April when I was actively working on the engine but then I got busy with office work so development and this post were left incomplete. I am still not done with ToneMapping yet ther’s still some room for improvement and some other algorithms like those based on histograms, some other tone mapping operators , etc.

About chetanjags

Game Developer

Posted on September 25, 2014, in Graphics, JustAnotherGameEngine and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: