Reader small image

You're reading from  The Modern Vulkan Cookbook

Product typeBook
Published inApr 2024
Reading LevelN/a
PublisherPackt
ISBN-139781803239989
Edition1st Edition
Languages
Concepts
Right arrow
Authors (2):
Preetish Kakkar
Preetish Kakkar
author image
Preetish Kakkar

Preetish Kakkar is a senior computer graphics engineer with Adobe and works on the rendering engine that powers products such as Aero, Stager, and After Effects. He has worked at Microsoft, MathWorks, and Stryker, where he co-authored various rendering engines as well as using other engines such as Unreal and Unity. He has more than 15 years of software development experience along with 10+ years in 3D graphics, scientific visualization, and medical imaging.
Read more about Preetish Kakkar

Mauricio Maurer
Mauricio Maurer
author image
Mauricio Maurer

Mauricio Maurer is a computer graphics engineer with nearly 20 years of experience working with 2D and 3D rendering, computational geometry, and rasterization in the fields of scientific visualization, CAD/CAM, and social networking. He is currently a graphics software engineer at Meta, helping to develop the next generation of AR/VR devices. Mauricio holds two master's degrees in computer science with a specialization in computer graphics from SUNY Stony Brook, NY, and the Federal University of Parana, Brazil.
Read more about Mauricio Maurer

View More author details
Right arrow

Deciphering Order-Independent Transparency

Rendering transparent objects isn’t always easy. While opaque objects can be rendered in any order, transparent objects need to be rendered from farthest to nearest relative to the camera, which implies an extra sorting step before performing the actual rendering. This depth sorting ensures that more distant objects are blended into the frame buffer first, followed by nearer objects, allowing for accurate composition of transparent layers.

Sorting can become computationally expensive and error-prone, especially when dealing with complex scenes, intersecting objects, or real-time rendering scenarios. Additionally, sorting fails to solve the problem of cyclic overlaps, where multiple objects interpenetrate in such a way that no single depth-sorting order can accurately represent their visual appearance.

Order-independent transparency techniques try to solve these problems by accumulating transparency information in a way that doesn...

Technical requirements

For this chapter, you will need to make sure you have VS 2022 installed along with the Vulkan SDK. Basic familiarity with the C++ programming language and an understanding of OpenGL or any other graphics API will be useful. Please revisit Chapter 1, Vulkan Core Concepts, under the Technical requirements section for details on setting up and building executables for this chapter. All recipes for this chapter are encapsulated in a single executable and can be launched using Chapter05_Transparency.exe executable.

Implementing Depth-Peeling

Depth Peeling was introduced in 2001 by Cass Everitt as a solution to render semi-transparent geometry without the need to sort the geometry from back-to-front. The technique consists of rendering the scene multiple times (passes). At each pass, only the nearest fragments to the camera are rendered and their depth is collected to be used on the next pass. On each pass, except for the first pass, fragments closer than the ones in the depth pass collected in the previous iteration are discarded. This process peels the scene into consecutive layers, from front to back. At the end of the process, all layers are blended into one final image, which is then blended once more with the background.

Getting ready

In the repository mentioned in Technical requirements, the Depth Peeling algorithm is implemented by the DepthPeeling class, located in source/enginecore/passes/DepthPeeling.hpp and cpp files. In this recipe, you will learn how to peel away or progressively...

Implementing Dual Depth-Peeling

One of the main drawbacks of the Depth Peeling algorithm is that it requires multiple passes, each of which may consist of rasterizing the entire scene. The Dual Depth-Peeling algorithm extends the original Depth Peeling algorithm by peeling two layers at the same time, almost effectively cutting the number of passes by half. In this recipe, we will focus on implementing the Dual Depth-Peeling algorithm. We will address one of the key limitations of the Depth Peeling algorithm, namely its requirement for multiple passes which may involve rasterizing the entire scene. You’ll learn how the Dual Depth-Peeling algorithm improves upon the original by peeling two layers concurrently, thus potentially reducing the number of passes by nearly half. This insight will empower you to handle complex scenes with greater efficiency and speed.

Getting ready

In the repository, the Depth Peeling algorithm is implemented by the DualDepthPeeling class, located...

Implementing Linked-List Order-Independent Transparency

Order Independent Transparency uses a per pixel linked list to handle transparency, it makes use of data structures, specifically linked lists, to store fragments for each pixel. Each node of the list contains information about a fragment’s color and depth value, and the nodes are connected in a way that follows the order of fragments arrival, thus making sorting unnecessary.

This approach effectively eliminates overdrawing, and artifacts associated with depth sorting. By focusing on the depth value of each fragment, the approach provides a more accurate, visually pleasing representation of transparent objects. In this recipe, we will delve into the detailed process of implementing the Linked-List Order-Independent Transparency (OIT) technique. You’ll learn how this technique leverages per pixel linked lists to efficiently manage transparency, eliminating the issues of overdrawing and depth sorting artifacts.

...

Implementing Weighted Order-Independent Transparency

Weighted Order-Independent Transparency (WOIT) uses a different idea to tackle transparency, by using the concept of weighted averages rather than using data structures like linked lists or layers like depth peeling.

This method doesn’t require sorting or linked lists or multiple passes, reducing the overhead associated with those operations. The final color is calculated by normalizing the color buffer with the weight buffer, which provides an aggregate view of the colors and their weights. Although it may not be as accurate as per-pixel linked lists in complex scenarios, WOIT offers a performance-efficient solution for handling transparency in scenes with lower depth complexity. In this recipe, you will gain an understanding of the WOIT technique. We will explore how this method employs weighted averages to handle transparency, eschewing the need for data structures like linked lists or multiple passes, thereby reducing...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Modern Vulkan Cookbook
Published in: Apr 2024Publisher: PacktISBN-13: 9781803239989
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Authors (2)

author image
Preetish Kakkar

Preetish Kakkar is a senior computer graphics engineer with Adobe and works on the rendering engine that powers products such as Aero, Stager, and After Effects. He has worked at Microsoft, MathWorks, and Stryker, where he co-authored various rendering engines as well as using other engines such as Unreal and Unity. He has more than 15 years of software development experience along with 10+ years in 3D graphics, scientific visualization, and medical imaging.
Read more about Preetish Kakkar

author image
Mauricio Maurer

Mauricio Maurer is a computer graphics engineer with nearly 20 years of experience working with 2D and 3D rendering, computational geometry, and rasterization in the fields of scientific visualization, CAD/CAM, and social networking. He is currently a graphics software engineer at Meta, helping to develop the next generation of AR/VR devices. Mauricio holds two master's degrees in computer science with a specialization in computer graphics from SUNY Stony Brook, NY, and the Federal University of Parana, Brazil.
Read more about Mauricio Maurer