DirectX 12 Engine – Image Based Lighting (IBL) + Tone Mapping

In this post, I am going to tell you about the changes I did in my little engine.

Geometry Buffers

I am using the following geometry buffers

Untitle1d.png

Normal_Smoothness (DXGI_FORMAT_R10G10B10A2_UNORM): R and G components used to store normal in view space based on octahedron normal vector encoding. B component used to store material smoothness. A is unused.

BaseColor_MetalMask (DXGI_FORMAT_R8G8B8A8_UNORM): RGB used for base color. A used for metalness (0 non-metal, 1 metal)

Depth (DXGI_FORMAT_R32_FLOAT): Depth in View Space

DiffuseReflection (DXGI_FORMAT_R8G8B8A8_UNORM): RGBA used for the color sampled from diffuse irradiance cube map.

SpecularReflection (DXGI_FORMAT_R8G8B8A8_UNORM): RGBA used for the color sampled from the specular pre-convolved environment cube map.

Passes

If you read one of my previous posts, you should remember that I organized the recording of command lists in classes called CmdListRecorder’s. Now, I also decided to group similar recorders in Passes based on Deferred Shading & Screen Space Effects article. They are the following:

untitled123

Geometry pass reads geometry and material information and writes to geometry buffers. It supports several techniques (color, texture mapping, normal mapping, displacement mapping).

Lighting pass reads geometry buffers + light data and writes to the color buffer. Color buffer is a floating point format buffer that stores intermediate computations. It is important to mention that it is not the frame buffer. This pass supports punctual lights for now. It computes the BRDF for diffuse and specular terms only.

Ambient pass reads color buffer and adds to it ambient lighting.

Environment pass reads color buffer and adds to it diffuse & specular reflection geometry buffers (computed based on Image Based Rendering (IBL))

SkyBox pass reads color buffer and adds to it the sky box.

Tone Mapping pass reads color buffer, applies tone mapping and writes to the frame buffer.

Image Based Lighting 

Image Based Lighting technique (IBL) is one of rendering techniques that is based on the image from environment map for rendering the reflection, refraction and illumination lighting effect on the object surface. Since it is able to present excellent global illumination results for the surfaces in the scene by taking the full advantage and processing the environment map, it also plays a decisive influence on the material properties. Of course, the advantages of IBL are not just limited to its capability to present a good and almost realistic result, but what more it can do is to get rid of the biggest and the most common weakness in ray tracing of traditional global illumination. It is a problem of low speed to be caused by the tree structure of importance for stopping condition in ray tracing.

In local illumination, the most important components are ambient, diffuse and specular components. They depend on the properties of light sources, objects and viewer (position of light source, color, object normal, object position, and the viewer position, etc.in order to). Therefore even though the object and viewer properties are not changed after the local illumination is converted to the IBL global illumination, the light sources that are set in the real 3D environment are changed to an environment map that contains the light source image. In other words, we should consider all the lighting and shading information which compose all pixels in the environment map as a huge information dataset for the environment light sources. Thus we have to calculate the effects of each pixel in the environment map for a known cube map lookup to simulate the correspondent result under that pixel to the surface.

untitled

I learned about this topic from several presentations and blogs, and I used IBLBaker to generate the diffuse irradiance & specular pre-convolved environment cube maps. You can also use AMD CubeMapGen. You can see the result in the following video

Tone Mapping

Tone mapping is a technique used in image processing and computer graphics to map one set of colors to another to approximate the appearance of high-dynamic-range images in a medium that has a more limited dynamic range. Print-outs, CRT or LCD monitors, and projectors all have a limited dynamic range that is inadequate to reproduce the full range of light intensities present in natural scenes. Tone mapping addresses the problem of strong contrast reduction from the scene radiance to the displayable range while preserving the image details and color appearance important to appreciate the original scene content.

I learned about it in a John Hable’s presentation and after I understood its purpose, I tested several implementations.

You can check the result in the following video

Future Work

Source Code

https://github.com/nicolasbertoa/BRE12

References

Real Time Rendering

Game Graphics Programming

Introduction to 3D Game Programming with DirectX 12

Practical Rendering and Computation with Direct3D 11

Real-Time 3D Rendering with DirectX and HLSL: A Practical Guide to Graphics Programming

 

 

 

 

 

 

 

 

 

Advertisements

One thought on “DirectX 12 Engine – Image Based Lighting (IBL) + Tone Mapping

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s