3D Graphics Rendering Cookbook

Book description

Build a 3D rendering engine from scratch while solving problems in a step-by-step way with the help of useful recipes

Key Features

  • Learn to integrate modern rendering techniques into a single performant 3D rendering engine
  • Leverage Vulkan to render 3D content, use AZDO in OpenGL applications, and understand modern real-time rendering methods
  • Implement a physically based rendering pipeline from scratch in Vulkan and OpenGL

Book Description

OpenGL is a popular cross-language, cross-platform application programming interface (API) used for rendering 2D and 3D graphics, while Vulkan is a low-overhead, cross-platform 3D graphics API that targets high-performance applications. 3D Graphics Rendering Cookbook helps you learn about modern graphics rendering algorithms and techniques using C++ programming along with OpenGL and Vulkan APIs.

The book begins by setting up a development environment and takes you through the steps involved in building a 3D rendering engine with the help of basic, yet self-contained, recipes. Each recipe will enable you to incrementally add features to your codebase and show you how to integrate different 3D rendering techniques and algorithms into one large project. You'll also get to grips with core techniques such as physically based rendering, image-based rendering, and CPU/GPU geometry culling, to name a few. As you advance, you'll explore common techniques and solutions that will help you to work with large datasets for 2D and 3D rendering. Finally, you'll discover how to apply optimization techniques to build performant and feature-rich graphics applications.

By the end of this 3D rendering book, you'll have gained an improved understanding of best practices used in modern graphics APIs and be able to create fast and versatile 3D rendering frameworks.

What you will learn

  • Improve the performance of legacy OpenGL applications
  • Manage a substantial amount of content in real-time 3D rendering engines
  • Discover how to debug and profile graphics applications
  • Understand how to use the Approaching Zero Driver Overhead (AZDO) philosophy in OpenGL
  • Integrate various rendering techniques into a single application
  • Find out how to develop Vulkan applications
  • Implement a physically based rendering pipeline from scratch
  • Integrate a physics library with your rendering engine

Who this book is for

This book is for 3D graphics developers who are familiar with the mathematical fundamentals of 3D rendering and want to gain expertise in writing fast rendering engines with advanced techniques using C++ libraries and APIs. A solid understanding of C++ and basic linear algebra, as well as experience in creating custom 3D applications without using premade rendering engines is required.

Table of contents

  1. 3D Graphics Rendering Cookbook
  2. Contributors
  3. About the authors
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
    4. Download the color images
    5. Conventions used
    6. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    7. Get in touch
    8. Share Your Thoughts
  6. Chapter 1: Establishing a Build Environment
    1. Technical requirements
    2. OpenGL 4.6 with AZDO and Vulkan
      1. What is the essence of modern OpenGL?
    3. Setting up our development environment on Windows
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Setting up our development environment on Linux
      1. Getting ready
      2. How to do it...
    5. Installing the Vulkan SDK for Windows and Linux
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Managing dependencies
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Getting the demo data 
      1. How to do it
      2. There's more...
    8. Creating utilities for CMake projects
      1. Getting ready
      2. How to do it...
      3. There's more...
  7. Chapter 2: Using Essential Libraries
    1. Technical requirements
    2. Using the GLFW library
      1. Getting ready
      2. How to do it...
      3. There's more...
    3. Doing math with GLM
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Loading images with STB
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Rendering a basic UI with Dear ImGui
      1. Getting ready
      2. How to do it...
      3. There's more…
    6. Integrating EasyProfiler 
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Integrating Optick
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more…
    8. Using the Assimp library
      1. Getting ready
      2. How to do it...
    9. Getting started with Etc2Comp 
      1. Getting ready
      2. How to do it...
      3. There's more...
    10. Multithreading with Taskflow
      1. Getting ready
      2. How to do it...
      3. There's more...
    11. Introducing MeshOptimizer 
      1. Getting ready
      2. How to do it...
      3. There's more...
  8. Chapter 3: Getting Started with OpenGL and Vulkan
    1. Technical requirements
    2. Intercepting OpenGL API calls
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Working with Direct State Access (DSA)
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Loading and compiling shaders in OpenGL
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Implementing programmable vertex pulling (PVP) in OpenGL
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Working with cube map textures
      1. Getting ready
      2. How to do it...
      3. There's more...
    7. Compiling Vulkan shaders at runtime
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    8. Initializing Vulkan instances and graphical devices
      1. Getting ready
      2. How to do it...
    9. Initializing the Vulkan swap chain
      1. Getting ready
      2. How to do it...
    10. Setting up Vulkan's debugging capabilities
      1. How to do it...
      2. There's more…
    11. Tracking and cleaning up Vulkan objects
      1. Getting ready
      2. How to do it...
    12. Using Vulkan command buffers
      1. How to do it...
      2. See also
    13. Dealing with buffers in Vulkan
      1. Getting ready
      2. How to do it...
      3. How it works...
    14. Using texture data in Vulkan
      1. Getting ready
      2. How to do it...
    15. Using mesh geometry data in Vulkan
      1. Getting ready
      2. How to do it...
    16. Using Vulkan descriptor sets
      1. How to do it...
      2. There's more…
    17. Initializing Vulkan shader modules
      1. Getting ready
      2. How to do it...
    18. Initializing the Vulkan pipeline
      1. Getting ready...
      2. How to do it...
      3. There's more…
      4. See also
    19. Putting it all together into a Vulkan application
      1. Getting ready
      2. How to do it...
  9. Chapter 4: Adding User Interaction and Productivity Tools
    1. Technical requirements
    2. Organizing Vulkan frame rendering code
      1. Getting ready
      2. How to do it...
      3. There's more…
    3. Organizing mesh rendering in Vulkan
      1. Getting ready
      2. How to do it...
    4. Implementing an immediate mode drawing canvas
      1. Getting ready
      2. How to do it...
    5. Rendering a Dear ImGui user interface with Vulkan
      1. Getting ready
      2. How to do it...
    6. Working with a 3D camera and basic user interaction
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Adding a frames-per-second counter
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Adding camera animations and motion
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Integrating EasyProfiler and Optick into C++ applications
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Using cube map textures in Vulkan
      1. Getting ready
      2. How to do it...
    11. Rendering onscreen charts
      1. Getting ready
      2. How to do it...
      3. How it works...
    12. Putting it all together into a Vulkan application
      1. Getting ready
      2. How to do it...
  10. Chapter 5: Working with Geometry Data
    1. Technical requirements
    2. Organizing the storage of mesh data
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Implementing a geometry conversion tool
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Indirect rendering in Vulkan
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Implementing an infinite grid GLSL shader
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Rendering multiple meshes with OpenGL
      1. Getting ready
      2. How to do it…
    7. Generating LODs using MeshOptimizer
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Integrating tessellation into the OpenGL graphics pipeline
      1. Getting ready
      2. How to do it...
      3. There's more...
  11. Chapter 6: Physically Based Rendering Using the glTF2 Shading Model
    1. Technical requirements
    2. Simplifying Vulkan initialization and frame composition
      1. How to do it...
    3. Initializing compute shaders in Vulkan
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Using descriptor indexing and texture arrays in Vulkan
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Using descriptor indexing in Vulkan to render an ImGui
      1. Getting ready
      2. How to do it...
    6. Generating textures in Vulkan using compute shaders
      1. Getting ready
      2. How to do it...
    7. Implementing computed meshes in Vulkan
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Precomputing BRDF LUTs
      1. Getting ready
      2. How to do it...
      3. There's more...
    9. Precomputing irradiance maps and diffuse convolution
      1. Getting ready
      2. How to do it...
      3. There's more...
    10. Implementing the glTF2 shading model
      1. Getting ready
      2. How to do it...
      3. There's more...
  12. Chapter 7: Graphics Rendering Pipeline
    1. Technical requirements
    2. How not to do a scene graph
    3. Using data-oriented design for a scene graph
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Loading and saving a scene graph
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Implementing transformation trees
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Implementing a material system
      1. Getting ready
      2. How to do it...
    7. Importing materials from Assimp
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Implementing a scene conversion tool
      1. Getting ready
      2. How to do it...
      3. There's more...
    9. Managing Vulkan resources
      1. Getting ready
      2. How to do it...
      3. There's more...
    10. Refactoring Vulkan initialization and the main loop
      1. Getting ready
      2. How to do it...
    11. Working with rendering passes
      1. Getting ready
      2. How to do it...
      3. There's more...
    12. Unifying descriptor set creation routines
      1. Getting ready
      2. How to do it...
      3. There's more...
    13. Putting it all together into a Vulkan application
      1. Getting ready
      2. How to do it...
      3. How it works…
      4. There's more...
  13. Chapter 8: Image-Based Techniques
    1. Technical requirements
    2. Implementing offscreen rendering in OpenGL
      1. Getting ready
      2. How to do it…
    3. Implementing fullscreen quad rendering
      1. Getting ready
      2. How to do it…
      3. There's more...
    4. Implementing shadow maps in OpenGL
      1. Getting ready
      2. How to do it…
      3. There's more…
    5. Implementing SSAO in OpenGL
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Implementing HDR rendering and tone mapping
      1. Getting ready
      2. How to do it...
      3. There's more...
    7. Implementing HDR light adaptation
      1. Getting ready
      2. How to do it...
      3. There's more...
    8. Writing postprocessing effects in Vulkan
      1. Getting ready...
      2. How to do it...
    9. Implementing SSAO in Vulkan
      1. Getting ready...
      2. How to do it...
    10. Implementing HDR rendering in Vulkan
      1. Getting ready…
      2. How to do it...
      3. There's more…
  14. Chapter 9: Working with Scene Graphs
    1. Technical requirements
    2. Deleting nodes and merging scene graphs
      1. How to do it...
    3. Finalizing the scene-converter tool
      1. Getting ready
      2. How to do it...
      3. There's more...
    4. Implementing lightweight rendering queues in OpenGL
      1. Getting ready
      2. How to do it...
      3. There's more...
    5. Working with shape lists in Vulkan
      1. Getting ready
      2. How to do it...
    6. Adding Bullet physics to a graphics application
      1. Getting ready
      2. How to do it...
      3. There's more...
  15. Chapter 10: Advanced Rendering Techniques and Optimizations
    1. Technical requirements
    2. Doing frustum culling on the CPU
      1. Getting ready
      2. How to do it…
      3. There's more...
    3. Doing frustum culling on the GPU with compute shaders
      1. Getting ready
      2. How to do it…
      3. There's more...
    4. Implementing order-independent transparency
      1. Getting ready
      2. How to do it…
    5. Loading texture assets asynchronously
      1. Getting ready
      2. How to do it...
      3. There's more...
    6. Implementing projective shadows for directional lights
      1. Getting ready
      2. How to do it...
      3. There's more...
    7. Using GPU atomic counters in Vulkan
      1. Getting ready
      2. How to do it...
      3. There's more…
    8. Putting it all together into an OpenGL demo
      1. Getting ready
      2. How to do it...
      3. There's more…
    9. Why subscribe?
  16. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: 3D Graphics Rendering Cookbook
  • Author(s): Sergey Kosarevsky, Viktor Latypov
  • Release date: August 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781838986193