Source Code for "Ray Tracing Gems: High-Quality and Real-Time Rendering with DXR and Other APIs" by Eric Haines and Tomas Akenine-Möller

Overview

Apress Source Code

This repository accompanies Ray Tracing Gems: High-Quality and Real-Time Rendering with DXR and Other APIs by Eric Haines and Tomas Akenine-M�ller (Apress, 2019).

See http://raytracinggems.com for further information about the book.

Cover image

Download or clone the files as a zip using the green button in the upper right, or clone the repository to your machine using Git with https://github.com/Apress/ray-tracing-gems.git

Note that code with a *.cu or *.cuh suffix is written in CUDA. The various CUDA functions can be found in this set of reference pages. Code with an *.hlsl suffix is in the High Level Shading Language, with its function reference here.

Releases

Errata for the book is available.

Release v1.0 corresponds to the code in the published book, with three corrections to Chapter 16:

Page 226: "float SampleLinear( float a, float b ) {" should have a "float u" parameter for the random variable, i.e., "float SampleLinear( float u, float a, float b ) {"

Page 235, file ConcentricSquareMapping.cpp: The case "a == 0 && b == 0" is not handled and can result in division by 0; above line 3 add "if (b == 0) b = 1;"

Page 242, file PhongDistribution.cpp: Line 1 of the code at the top, change "1+s" to "2+s"

Contributions

See the file Contributing.md for more information on how you can contribute to this repository.

License

All code here is released under the MIT License, copyright 2019 NVIDIA Corporation, unless otherwise noted within an individual chapter's files. This license reads as follows:

Copyright 2019 NVIDIA Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Source missing?

    Source missing?

    Greetings I am interested in the implementation of Ch. 14 (Ch_14_Ray-Guided_Volumetric_Water_Caustics_in_Single_Scattering_Media_with_DXR), but it seems that the source code is missing. I can only find dll, exe & media files.

    opened by no-materials 8
  • chapter 27, the introduction of Listing 27-2 is wrong

    chapter 27, the introduction of Listing 27-2 is wrong

    The introduction of Listing 27-2:

    Listing 27-2.This closest-hit shader code snippet skips shading of transparent surfaces when the incident ray has crossed through a user-defined maximum number of transparent surfaces, proceeding instead by shooting a transmission ray and continuing as though there had been no ray/surface intersection

    is same as that of Listing 27-4:

    Listing 27-4. This closest-hit shader code snippet skips the shading of transparent surfaces when the incident ray has crossed through a user-defned maximum number of transparent surfaces, proceeding instead by shooting a transmission ray and continuing as though there had been no ray/surface intersection.

    and I believe the former is wrong. I didn't see this mistake in the errata and I have checked version 1.5, 4/29/2019, it's still there.

    opened by Zieng 4
  • GL Texture memory leak in Chapter 28: Ray Tracing Inhomogeneous Volumes

    GL Texture memory leak in Chapter 28: Ray Tracing Inhomogeneous Volumes

    There is a potential GL texture memory leak in the code. It generates a new texture object each frame (line 459-462).

    Solution: Two additions in the code should do it :)

    1. Add the following code after line 431
    kernel_params.iteration = 0;
    
    //allocate texture once
    glBindTexture(GL_TEXTURE_2D, display_tex);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    }
    
    1. Replace glTexImage2D and parameter setting calls (lines 459-462) with the following glTexSubImage2D call, glTexSubImage2D(GL_TEXTURE_2D, 0, 0,0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
    opened by mmmovania 2
  • Chapter 15.3 code for sample variance equation - possible bug

    Chapter 15.3 code for sample variance equation - possible bug

    Hi, very minor thing but I'm looking at http://raytracinggems.com/unofficial_RayTracingGems_v1.7.pdf and the last line code for estimate_sample_variance() seems incorrect.

    The code is:

    1 float estimate_sample_variance(float samples[], int n) {
    2     float sum = 0, sum_sq = 0;
    3     for (int i = 0; i < n; ++i) {
    4         sum += samples[i];
    5         sum_sq += samples[i] * samples[i];
    6     }
    7     return sum_sq / (n * (n - 1))) -
    8     sum * sum / ((n - 1) * n * n);
    9 }
    

    in lines 7 & 8 there is an additional ')' but the formula also appears wrong - it should be return sum_sq / (n - 1) - sum * sum / ((n - 1) * n); ( or return (sum_sq - sum * sum / n) / (n - 1); )? (or I might be missing something :) )

    opened by fstrugar 1
  • May be mistake in codes

    May be mistake in codes

    I found that in the source file which addressed at ray-tracing-gems/Ch_11_Automatic_Handling_of_Materials_in_Nested_Volumes/push.cpp may have a mistake. The index variable used at line 14 as prev_same is an index of the stack, not an index of the scene materials. So, I think the variable prev_same should be change to stack[prev_same].material_idx.Just like the following codes:

    line 14 if (material[material_idx] == material[prev_same]) { => if (material[material_idx] == material[stack[prev_same].material_idx]) {

    It was also used at line 26 but in right form: line 26 if ((material[stack[idx].material_idx] != material[material_idx]) &&

    opened by Nicholas10128 1
  • Link to the existing code for Chapter 18

    Link to the existing code for Chapter 18

    Falcor 4.0 was released back in March but the README never got updated. While at it, add some pointers on where inside Falcor to find the files related to this article and how to use the code.

    opened by pierremoreau 0
  • Minor mistake in code sample

    Minor mistake in code sample

    In section 16.4.2.3 Hierarchical Transformation (p233), the first code sample is missing a curly braces between line 8 and 9 to close off the else statement:

     1 node = root;
     2 while (!node.isLeaf) {
     3     if (u < node.probLeft) {
     4         u /= node.probLeft;
     5         node = node.left;
     6     } else {
     7         u /= (1.0 - node.probLeft);
     8         node = node.right;
     9 }
    10 // Ok. We have found a leaf with the correct probability!
    

    Should be:

     1 node = root;
     2 while (!node.isLeaf) {
     3     if (u < node.probLeft) {
     4         u /= node.probLeft;
     5         node = node.left;
     6     } else {
     7         u /= (1.0 - node.probLeft);
     8         node = node.right;
     9     }                                 <<<<<<<<<<<<<<<<<<<<< Missing this
    10 }
    11 // Ok. We have found a leaf with the correct probability!
    
    opened by GaryHuan9 0
Releases(v1.0)
Owner
Apress
Source code for books published by Apress. For more information go to www.apress.com/source-code.
Apress
ZBar Bar Code Reader is an open source software suite for reading bar codes from various sources

ZBar Bar Code Reader is an open source software suite for reading bar codes from various sources

null 2.3k Sep 25, 2022
StereoKit is an easy-to-use open source mixed reality library for building HoloLens and VR applications with C# and OpenXR!

StereoKit is an easy-to-use open source mixed reality library for building HoloLens and VR applications with C# and OpenXR! Inspired by libraries like XNA and Processing, StereoKit is meant to be fun to use and easy to develop with, yet still quite capable of creating professional and business ready software.

Nick Klingensmith 693 Sep 29, 2022
OpenCorr is an open source C++ library for development of 2D, 3D/stereo, and volumetric digital image correlation

OpenCorr OpenCorr is an open source C++ library for development of 2D, 3D/stereo, and volumetric digital image correlation. It aims to provide a devel

Zhenyu Jiang 59 Sep 26, 2022
Open source Altium Database Library with over 147,000 high quality components and full 3d models.

Open source Altium Database Library with over 147,000 high quality components and full 3d models.

Mark 1.3k Sep 27, 2022
Vizzu is a free, open-source Javascript/C++ library for animated data visualizations and data stories.

Vizzu is a free, open-source Javascript/C++ library utilizing a generic dataviz engine that generates many types of charts and seamlessly animates between them

Vizzu 1.6k Sep 29, 2022
appleseed is an open source, physically-based global illumination rendering engine primarily designed for animation and visual effects.

appleseed is an open source, physically-based global illumination rendering engine primarily designed for animation and visual effects.

appleseedhq 1.9k Oct 4, 2022
An Open-Source subdivision surface library.

OpenSubdiv OpenSubdiv is a set of open source libraries that implement high performance subdivision surface (subdiv) evaluation on massively parallel

Pixar Animation Studios 2.7k Sep 29, 2022
Quake GPL Source Release

This is the complete source code for winquake, glquake, quakeworld, and glquakeworld. The projects have been tested with visual C++ 6.0, but masm is

id Software 3.8k Sep 26, 2022
Quake 2 GPL Source Release

This is the complete source code for Quake 2, version 3.19, buildable with visual C++ 6.0. The linux version should be buildable, but we haven't test

id Software 2.2k Oct 4, 2022
An open-source implementation of Autodesk's FBX

SmallFBX An open-source implementation of Autodesk's FBX that is capable of import & export mesh, blend shape, skin, and animations. Mainly intended t

Seiya Ishibashi 41 Jun 30, 2022
The open-source tool for creating of 3D models

The open-source tool for creating of 3D models

3D geoinformation research group at TU Delft 416 Sep 23, 2022
Source Codes for Codimensional Incremental Potential Contact (C-IPC)

Source Codes for Codimensional Incremental Potential Contact (C-IPC) Reference This repository provides source code for: Minchen Li, Danny M. Kaufman,

null 108 Sep 28, 2022
Source Codes for Injective Deformation Processing (IDP) with Incremental Potential Contact (IPC)

Source Codes for Injective Deformation Processing Reference This repository provides source code for: Yu Fang*, Minchen Li* (equal contribution), Chen

null 37 Sep 15, 2022
Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

Cocos2d-x is a suite of open-source, cross-platform, game-development tools used by millions of developers all over the world.

cocos2d 16.5k Sep 28, 2022
Tesseract Open Source OCR Engine (main repository)

Tesseract OCR Table of Contents Tesseract OCR About Brief history Installing Tesseract Running Tesseract For developers Support License Dependencies L

null 46.9k Oct 3, 2022
A completely free, open-source, 2D game engine built on proven torque technology.

Torque2D 4.0 Early Access 1 MIT Licensed Open Source version of Torque2D from GarageGames. Maintained by the Torque Game Engines team and contribution

Torque Game Engines 606 Oct 5, 2022
Open-Source Vulkan C++ API

Vulkan-Hpp: C++ Bindings for Vulkan The goal of the Vulkan-Hpp is to provide header only C++ bindings for the Vulkan C API to improve the developers V

The Khronos Group 2.4k Sep 30, 2022
Open-source, cross-platform, C++ game engine for creating 2D/3D games.

GamePlay v3.0.0 GamePlay is an open-source, cross-platform, C++ game framework/engine for creating 2D/3D mobile and desktop games. Website Wiki API De

gameplay3d 3.8k Sep 30, 2022
Dust3D is a cross-platform open-source 3D modeling software

Dust3D is a cross-platform open-source 3D modeling software. Auto UV unwrapping, auto rigging with PBR Material support, pose and motion authoring all in one.

Jeremy HU 2.5k Sep 28, 2022