Professional Documents
Culture Documents
Faculty of Informatics
Master’s Thesis
Daria Vasilenko
Master’s Thesis
Daria Vasilenko
Daria Vasilenko
i
Acknowledgements
I want to express my gratitude to my supervisor RNDr. Jan Byška,
Ph.D., for the valuable comments, important tips during the research,
and for the many reviews of the text of this thesis. I also want to thank
my consultant Mgr. Matúš Talčík for his valuable advice and many
ideas for improving the created framework.
iii
Abstract
In this thesis, we consider the applicability of the new raytracing
pipeline for visualizing signed distance fields using the example of the
NVIDIA OptiX 7 API. We considered the visualization tasks of both
discrete signed distance field (3d volume texture) and signed distance
field defined by the function. We have implemented our framework
based on NVIDIA OptiX 7. We also implemented visualization meth-
ods in OpenGL and CUDA for comparison with the implementation
on OptiX.
iv
Keywords
ray tracing, ray marching, signed distance field, OptiX, CUDA, OpenGL
v
Contents
1 Introduction 1
3 Implementation 23
3.1 Discrete signed distance field creation . . . . . . . . . . 24
3.2 Framework overview . . . . . . . . . . . . . . . . . . . . 26
3.2.1 Used tools . . . . . . . . . . . . . . . . . . . . . . 27
3.2.2 Framework design . . . . . . . . . . . . . . . . . 27
3.2.3 Usage . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3 Signed distance functions rendering using NVIDIA OptiX 32
3.3.1 Ray marching calculation in the intersection pro-
gram . . . . . . . . . . . . . . . . . . . . . . . . . 32
vii
3.3.2 Ray marching calculation in the closest hit pro-
gram . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.3.3 Ray marching calculation in the ray generation
program . . . . . . . . . . . . . . . . . . . . . . . 36
3.4 Signed distance functions rendering using OpenGL . . 37
3.5 Signed distance functions rendering using CUDA . . . 38
4 Results 39
4.1 Test setup . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.2 The impact of the CUDA block size on performance. . . 42
4.3 The impact of different types of CUDA mathematical
operations on performance and visual result. . . . . . . 42
4.4 Comparison of different methods of visualization of
SDF functions . . . . . . . . . . . . . . . . . . . . . . . . 45
4.5 Comparison of different methods of visualization of
discrete SDF functions . . . . . . . . . . . . . . . . . . . 50
5 Conclusion 55
Bibliography 63
viii
List of Tables
4.1 The dependence of the rendering speed (ms) of different
scenes on the size of the CUDA blocks. Less is better. 43
4.2 Performance (ms) speed up when using fast math for
Mandelbulb scene.The bottom line shows the acceleration as a
percentage. 43
4.3 Performance (ms) results of different methods of
visualization of SDF functions. 47
4.4 Performance (ms) results of different methods of
visualization of discete SDF functions. The number of
primitives in the accelerating structure is indicated in
parentheses. 54
ix
List of Figures
xi
3.4 Framework interface. 29
3.5 NVIDIA OptiX 7 pipeline. Image from [36]. 33
3.6 The OptiX pipeline. The traced ray intersects with the leaves
of the accelerating structure. Ray marching is calculated in
intersection program. 33
3.7 The OptiX pipeline. The traced ray intersects with the leaves
of the accelerating structure. Ray marching is calculated in
closest-hit program. 35
3.8 Artefacts in closest-hit method, if we compute ray marching
in one voxel. 37
4.1 Scenes that were used to compare the methods that use a
raymarching with a direct evaluation of SDFs for SDF
visualization. Top row from left to right: Sphere, DonutBox2,
SierpinskiTriangle, DonutBox4, Penguin. Bottom row from
left to right: DonutBox, MengerSponge, DonutBox3, Julia,
Mandelbulb. 40
4.2 Scenes that were used to compare the methods that are based
on a raymarching using precomputed 3d volumetric textures.
Top row from left to right: Cornell box, Sphere, Stanford
Bunny, Cow. Bottom row from left to right: Teapot, LPS
Head, Stanford Armadillo, Dragon. 41
4.3 Performance using default math and fast math (less is
better). (*) - uses fast math. 44
4.4 Visualization of Mandelbulb fractal using different math
types. 45
4.5 Visual results of different methods of visualization of SDF
functions. 46
4.6 Examples of SDFs AABBs using in OptiX. 46
4.7 The ratio of the four most frequently used instructions when
calculating the DonutBox4 SDF. FFMA - fp32 multiply and
add, FMUL - fp32 multiply, IMAD- integer multiply and
add, FADD - fp32 add. Charts are from the NVIDIA Nsight
Compute profiler. 47
4.8 Warp state for DonutBox4 scene. Charts are from the
NVIDIA Nsight Compute profiler. 48
xii
4.9 Number of ray marching steps for different visualisation
methods. Increasing the number of steps corresponds to a
color change from dark blue to light blue, white, and then red.
Dark red corresponds to the maximum number of steps (20
steps, in this case). A larger number of iterations leads to
lower performance. 49
4.10 Visual results for different grid sizes of discrete SDF. 50
4.11 Visual results of different methods of visualization of discrete
SDF functions. 51
4.12 Visual artifacts in OptiX IS method. 52
4.13 Performance (ms) results of different methods of
visualization of discete SDF functions. 53
xiii
1 Introduction
The signed distance function of a set defines the distance from any
point in space to the boundary of the set. It has negative values at
points inside the set, positive values outside the set, and it is equal to
zero at the set’s boundary. Instead of representing the geometry in a
traditional triangle-based way, signed distance fields can be used as
a more elegant and compact solution. So, for example, to visualize a
sphere, instead of rendering several hundred triangles, we can easily
calculate the elementary equation:
q
f ( p) = x2 + y2 + z2 − r, p ∈ R3 (1.1)
1
1. Introduction
the traced ray by the distance to the nearest scene object. Eventually,
the ray will get close enough to the surface that the point can be
considered as the intersection point with the object of the scene.
With a new ray tracing pipeline on the modern GPUs, we took
a step toward real-time ray tracing. The new pipeline is supported
by such APIs as Vulkan, DirectX 12 and Nvidia Optix 7. Though the
pipeline is oriented mostly on ray tracing triangle meshes (new ray
tracing cores are computing ray-triangle intersection and perform
BVH traversal on a hardware level), it still supports custom geometry
and can build an acceleration structure. Since sphere tracing is very
similar to ray tracing, we want to determine whether it makes sense
to implement sphere tracing on a new ray tracing pipeline. For the
evaluation we have chosen Optix 7.
2
2 Background and Related Works
This chapter provides background information for this thesis. It con-
sists of four parts. In the first part, the concept of the sign distance
functions is presented (see Chapter 2.1). And the mathematical prin-
ciples necessary for rendering geometry represented using signed
distance functions is described. In the second part, overview of dis-
crete signed distance fields is given (see Chapter 2.2). And methods
for constructing a discrete signed distance function is also described.
In the third part, the current state-of-the-art for rendering signed
distance functions and different signed distance function rendering
techniques is discussed (see Chapter 2.3). And in the last fourth part,
GPU real-time ray tracing pipeline is presented (see Chapter 2.4). And
all terms associated with NVIDIA OptiX 7, which will be used further
in this thesis, are presented and explained.
φ(−
→
x ) = min(d(−
→
x ,−
→
x I )) for all −
→
x I ∈ ∂Ω, (2.1)
where ∂Ω is a boundary of Ω.
The subset’s distance field φ(−
→x ) defines the distance from this point
to the boundary of the subset, for any point − →
x in a metric space X.
The distance can be signed to distinguish between the inside and out-
side of a subset (see Figure 2.1). The signed distance function has
negative values at points −→x inside Ω, it increases as −
→x approaches
the boundary of Ω, where the signed distance function is zero, and
takes positive values outside of Ω.
3
2. Background and Related Works
where ∂Ω− is the interior region of ∂Ω and ∂Ω+ is the exterior region
of ∂Ω.
Since in this thesis we render the sign distance functions only for
sets in three-dimensional Euclidean space, let’s give a definition of the
sign distance function specifically for our case.
4
2. Background and Related Works
q
f ( p) = x2 + y2 + z2 − r, p ∈ R3 (2.4)
5
2. Background and Related Works
If these conditions are met, we can easily determine which part of the
space is inside or outside the mesh, and we can build an SDF. Several
6
2. Background and Related Works
7
2. Background and Related Works
and his proposed algorithm runs in O(N) space and O(N log N) time,
where N is a number of elements in a polygonal interface.
We can estimate the distance value of a given voxel from the known
values of its neighbors using [10]:
• Chamfer DTs [13, 14, 15]. Voxels in which the mesh boundary
lies are initialized either by the minimum distance or zero,
8
2. Background and Related Works
m +1
where f i,j,k is the new value in the central voxel, f i,j,k
m is the
9
2. Background and Related Works
10
2. Background and Related Works
Figure 2.3: Visualization of basic ray marching. The red dots show all
the sampled points.
r (k ) = r0 + ∆t ∗ k ∗ rd , (2.6)
where r0 is the origin of the ray, rd is the unit direction vector of the ray,
∆t is the predefined step size and k ∈ 0, 1, 2, ..., n is the step number.
After completing the loop in the algorithm, the point that we get is
the intersection point of the constructed ray with the scene object.
In practice, the basic ray marching loop uses more exit conditions.
For example, in some implementations, the maximum possible dis-
tance that we can move along the ray is added. It means that we will
not visualize all objects that are further than this distance. This allows
us, for example, not to draw objects that occupy a tiny area of the
screen compared to the area of the entire screen. Also, some imple-
mentations use a predefined maximum number of loop iterations (i.e.,
the maximum number of steps along the ray). This is done to ensure,
that the loop ends, if the ray does not intersect with any object in the
scene. In basic ray marching algorithm parallelepiped, that bounds
the hypertexture volume [22], is used to generate the hypertexture
volume. If the ray does not intersect the bounding parallelepiped, then
the algorithm proceeds to process the next pixel. However, if the ray
11
2. Background and Related Works
12
2. Background and Related Works
ray marching step and march back on the ray until the sample point
exits the object. And then again, we can reduce the marching step and
continue sampling towards the object. We can continue this process
until we reach the desired accuracy of the result. Another possible
solution is to use the bisection method or binary search method. If the
sign of the SDF at the current sampling point is negative (that is, we
are inside an object), and the value at the previous point is positive
(outside the object), we use binary search to find the point where the
SDF is equal to zero. However, such solutions, although they help
find more precisely the intersection of the ray and the object, are very
time-consuming.
13
2. Background and Related Works
Figure 2.5: Visualization of ray marching. The red dots show all the
sampled points. The blue circles show areas that are guaranteed to
contain no objects. The dashed green lines show the shortest vectors
between each sampled point and the scene.
14
2. Background and Related Works
15
2. Background and Related Works
Figure 2.6: The ray in sphere tracing passes parallel to the object bound-
ary.
the value of the SDF at this point). If the SDF value is less than the
current radius, the cone is assumed to have crossed the object [26].
The most popular use of cone tracing is its use in the eponymous
real-time global illumination calculation algorithm [24, 25]. Voxel cone
tracing is used to create different global illumination effects such as
glossy reflections, ambient occlusion, indirect diffuse lighting trans-
parency, soft shadows. In this algorithm, we rasterize the entire scene
into a set of voxels containing material properties (such as color) and
surface normals. For voxels, the incoming or outgoing radiation from
lighting sources is calculated (i.e., direct lighting is calculated), and
the result is recorded in a 3D texture, which is linearly filtered using a
3D mipmapping scheme. Voxel cones are then traced throughout the
filtered mipmap in order to approximate indirect lighting. A group of
cones is created for each calculated surface pixel. And we march along
the centerline of the cone and use the voxel representation of direct
illumination to accumulate indirect illumination for the surface pixel.
This approach is similar to ray marching but is much more efficient
due to the use of larger (and variable) sampling steps.
16
2. Background and Related Works
Today if we want to use a GPU ray tracer utilizing new ray tracing cores,
we have several choices: DirectX Ray Tracing [27, 28], Vulkan Ray
Tracing [29, 30], or OptiX Ray Tracing [31, 32]. Ray tracing pipelines
are very similar for these three application programming interfaces
(APIs) [31], as they are based on the ray tracing technology offered
by NVIDIA and use Nvidia’s graphics products. But since our work is
written using OptiX 7 NVIDIA and for the sake of uniformity of used
terms and formulations, the explanation of the ray tracing pipeline in
this chapter is presented in terms of OptiX 7 NVIDIA.
The following terms will be used later in the text: The “host” is the
processor that begins the execution of an application. The “device” is
the GPU with which the host interacts. A “build” is the creation of an
acceleration structure on the device as initiated by the host [31].
NVIDIA OptiX (OptiX) is a graphics engine for real-time ray trac-
ing rendering using NVIDIA graphics processing units (GPUs). OptiX
uses CUDA technology to perform calculations on GPUs, which is
only supported on Nvidia’s graphics products. Although OptiX is a
graphics engine, it can be used in non-graphical computing. The scope
of use of OptiX is all computationally intensive tasks to which ray trac-
ing can be applied (here, "ray tracing" refers to a method for analyzing
17
2. Background and Related Works
2.4.1 Pipeline
The main idea of the OptiX engine is that most ray tracing algo-
rithms can be implemented using combinations of a small set of
programmable operations (which are called “programs” in OptiX)
[35]. The combination of user programs and hardcoded OptiX code
forms the ray tracing pipeline. The pipeline in OptiX consists of 8 pro-
grammable programs, each of which operates on a single ray at a time:
Ray generation, Intersection, Any-hit, Closest-hit, Miss, Exception,
Direct callables, Continuation callables (see Figure 2.8). Exception
programs can be called from any program or scene traversal (traversal,
i.e., search through the geometric data in the scene).
18
2. Background and Related Works
calls are asynchronous, so we need to use CUDA streams and events for
synchronization. When the ray generation program calls the optixTrace
function, a ray is generated, for which the intersection, any-hit, closest-
hit, and other functions are called, according to the pipeline.
19
2. Background and Related Works
ically computes material shading and passes the results back to the
ray generation program.
The shader binding table (SBT) binds geometric data to programs and
their parameters. The table stores information about which programs
need to be executed and with which arguments during the ray tracing
of the scene. The SBT mechanism is very flexible. It allows users to
perform many different settings depending on the needs of a partic-
ular application. For example, an application can specify different
programs and data to be used for different types of rays (for example,
shadow rays, camera rays, or ambient occlusion rays)[31, 36].
20
2. Background and Related Works
21
2. Background and Related Works
22
3 Implementation
In order to evaluate the suitability of the OptiX engine for rendering
signed distance functions, a framework based on the OptiX engine
and OpenGL was created. This framework supports two methods for
rendering geometry defined using the SDF:
1. a ray marching (sphere tracing proposed by Hart [8]) with a
direct evaluation of SDFs
2. a ray marching (sphere tracing) using precomputed volumetric
textures
Both of these methods use the standard raymarching algorithm de-
scribed in Chapter 2.3.2. But in the first method, the value of the SDF
at each step is calculated by evaluating the value of an explicitly spec-
ified SDF. And in the second method, the value of the SDF at each
step is read from the 3d volume texture, which stores a pre-calculated
discrete SDF of the scene.
In order to evaluate the effectiveness of using OptiX for SDF ren-
dering, both of these methods were implemented using:
• NVIDIA OptiX (see Chapter 3.3)
• OpenGL (see Chapter 3.4)
• CUDA (see Chapter 3.5)
Also, to create the SDF volumetric texture, a separate program
that calculates the discrete SDF for triangle meshes was implemented.
This chapter describes the implementation of the created framework.
It consists of five parts. The first part describes the implementation of
an algorithm for constructing a discrete SDF for triangle meshes. The
second part provides a general description of the framework. The third
part describes how to render the geometry of a given SDF using the
OptiX engine (see Chapter 3.3). The SDF rendering with raymarching
implementation in different parts of the OptiX pipeline (in the closest
hit program, intersection program, and ray generation program) is
described separately. The fourth part describes the implementation
using OpenGL (see Chapter 3.4). And the last fifth part describes
implementations using only CUDA (see Chapter 3.5).
23
3. Implementation
1. the path to the. obj file that stores the data of the triangle mesh
2. the path to the file where we want to save the calculated discrete
SDF
The output of this program is .bin file that contains in the following
order:
4. the calculated SDF values for each grid cell (each of 32 bit float
type)
24
3. Implementation
Figure 3.1: Computing the sign of the SDF at two points: 1 and 2. Before
intersecting with point 1, the ray intersects with the mesh three times,
so point one lies inside the mesh, and the sign of the SDF in it will be
negative. And before it intersects with point 2, the ray intersects with
the mesh six times, so point 2 lies outside the mesh, and the sign of
the SDF in it will be positive.
25
3. Implementation
26
3. Implementation
• NVIDIA OptiX 7.2 [32] graphics engine for ray tracing using
CUDA technology 11.2
27
3. Implementation
28
3. Implementation
3.2.3 Usage
All the requirements for running and compiling the framework are
specified in Appendix B. There is also additional instruction on how
to build the project (see Appendix C).
The framework has three windows (see Figure 3.4): the main win-
dow that displays the rendering result and two additional windows:
Rendering parameters and Stats. The Stats window displays the pa-
rameters of the used CPU and GPU, the rendering speed in frames
per seconds (fps) and in ms/ f rame.
To change the viewing angle of a scene user must click on the main
window and then use the following controls: WASD, Space, Left Shift
and mouse movement with the right mouse button held down.
29
3. Implementation
30
3. Implementation
31
3. Implementation
32
3. Implementation
Figure 3.6: The OptiX pipeline. The traced ray intersects with the leaves
of the accelerating structure. Ray marching is calculated in intersection
program.
33
3. Implementation
this ray intersected. In our case, the leaves of the accelerating structure
are voxels of the discrete SDF. This program is called for each inter-
sected leaf (see Figure 3.6). In each such program, we find two points
of intersection of the voxel and the ray: the point of entry of the ray
into the voxel and the point of exit of the ray from the voxel. After that,
we run the ray marching algorithm with a start point equal to the first
point of intersection of the ray and voxel and with an endpoint equal
to the second point of intersection of the ray and voxel. Suppose ray
marching has found the intersection point of the ray with the SDF. In
that case, we use the optixReportIntersection() function, which takes as
input the distance t from the beginning of the ray to the point where
the intersection occurred, to report an intersection. If tmin ≤ t ≤ tmax
(tmin starting ray parameter and tmax ending ray parameter are set
during ray generation in the ray generation program), then the any-hit
program is called after the intersection program ends. Otherwise, the
miss program is called.
The __anyhit __radiance() any-hit program consists of calling a sin-
gle optixTerminateRay() function, which records hit and stops traversal.
Based on the parameter t passed from the intersection program in
the optixReportIntersection() function, OptiX decides which of the in-
tersection points is the nearest and calls the closest hit program for
it.
The __closesthit __radiance() closest-hit program calculates the color
of the pixel that the intersection occurred with and returns it to the
ray generation program.
The __miss __radiance() miss program is called when we do not
intersect with the scene geometry and returns the background color
to the ray generation program.
The ray generation program in this method (see Figure 3.7) is the
same as the ray generation program in ray marching calculation in
the intersection program. Here we also start the tracer ray from the
program by calling optixTrace(). And after returning from the optix-
Trace() function, we read the resulting pixel color and save it to the
framebuffer.
34
3. Implementation
Figure 3.7: The OptiX pipeline. The traced ray intersects with the leaves
of the accelerating structure. Ray marching is calculated in closest-hit
program.
35
3. Implementation
program will be called for the closest voxel to the beginning of the ray
(i.e., closest to the camera).
In this method, ray marching is called in the closest-hit program.
As soon as this program has been called, we calculate the closest to
the camera intersection point of the voxel and the ray (i.e., point of
entry of the ray into the voxel). After that, we run the ray marching
algorithm from this intersection point to the end of the ray, which
we set in the ray generation program. If ray marching has found the
intersection point, we return to the ray generation program the color
of the scene object defined by the SDF. Otherwise, we return the
background color. It is important to note that in this method, we run
ray marching from the intersection point of the ray and voxel and to
the end of the traced ray, and not from one intersection point of the
ray and voxel and to the second intersection point, as in the previous
method. We do it because in this method the closest-hit program will
always be called for the closest voxel to the camera along the traced
ray. However, this voxel can be located far from the surface of the
object defined by the SDF. Suppose we compute ray marching only
in this voxel (as done in the previous method). In that case, we will
not find an intersection with the surface (since the SDF value in this
voxel will be very different from zero), and we will paint the pixel in
the background color, which will lead to the appearance of artifacts
(see Figure 3.8). For this reason, we restrict ray marching to the top
using ray length. This allows ray marching to go beyond the current
voxel further and continue searching for a point where the SDF value
will be close to zero.
The miss program is also called when we do not intersect with
the scene’s geometry and returns the background color to the ray
generation program.
36
3. Implementation
After that, in the same program, we run ray marching from the nearest
to the camera intersection point and to the far one. If ray marching has
found an intersection point with a scene object, we write the object’s
color to the framebuffer. And if the intersection point was not found,
then we write the background color in the framebuffer.
This method renders the SDF using OpenGL vertex and fragment
shaders, passing all the necessary data to them via uniforms. There is
no complex OptiX pipeline, and we do not use acceleration structures,
which are a significant part of all programs utilizing OptiX.
Rendering the SDF using OpenGL is very similar to rendering the
SDF using the OptiX generation program. We also launch a ray at each
pixel and compute ray marching. And if we find the intersection point
of the ray with the object of the scene, then we paint this pixel in the
object’s color. And if the intersection point is not found, then we paint
the pixel in the background color.
37
3. Implementation
38
4 Results
In this chapter we present the results of comparing OpenGL, CUDA,
OptiX intersection program (OptiX IS), OptiX closest-hit program
(OptiX CH), OptiX ray generation program (OptiX RG) methods for
visualizing SDF and discrete SDF on different scenes.
• Microsoft Windows 10 OS
5. Mandelbulb fractal
39
4. Results
Figure 4.1: Scenes that were used to compare the methods that use
a raymarching with a direct evaluation of SDFs for SDF visualiza-
tion. Top row from left to right: Sphere, DonutBox2, SierpinskiTrian-
gle, DonutBox4, Penguin. Bottom row from left to right: DonutBox,
MengerSponge, DonutBox3, Julia, Mandelbulb.
40
4. Results
Figure 4.2: Scenes that were used to compare the methods that are
based on a raymarching using precomputed 3d volumetric textures.
Top row from left to right: Cornell box, Sphere, Stanford Bunny, Cow.
Bottom row from left to right: Teapot, LPS Head, Stanford Armadillo,
Dragon.
41
4. Results
42
4. Results
Table 4.2: Performance (ms) speed up when using fast math for Man-
delbulb scene.The bottom line shows the acceleration as a percentage.
43
4. Results
Figure 4.3: Performance using default math and fast math (less is
better). (*) - uses fast math.
44
4. Results
45
4. Results
46
4. Results
Figure 4.7: The ratio of the four most frequently used instructions
when calculating the DonutBox4 SDF. FFMA - fp32 multiply and add,
FMUL - fp32 multiply, IMAD- integer multiply and add, FADD - fp32
add. Charts are from the NVIDIA Nsight Compute profiler.
47
4. Results
Figure 4.8: Warp state for DonutBox4 scene. Charts are from the
NVIDIA Nsight Compute profiler.
48
4. Results
more complex SDFs, OptiX IS is the fastest because using this method,
we very much limit the length of the ray, along which ray marching
needs to be calculated, to the boundaries of the AABB of the scene
object, which leads to a decrease in the number of ray marching steps.
And in OptiX CH, we restrict the traced ray to only one side of the
AABB side closest to the camera, and therefore we have to count more
ray marching steps (see Figure 4.9). And even though in OptiX RG we
also limit ray marching on both sides to the same values as in OptiX IS
(which means that the number of ray marching steps also matches),
OptiX IS for some internal implementation reason calculates complex
SDF much faster.
49
4. Results
Figure 4.10: Visual results for different grid sizes of discrete SDF.
50
4. Results
Table 4.4 and Figure 4.13 show the results of performance testing
on different scenes for different methods. As we can see, the slowest
of all methods is OpenGL. The performance for all other methods is
about the same. But the fastest ones are OptiX CH and CUDA. Also,
when using the OptiX IS method, there is a decrease in performance
as the number of elements in the accelerating structure increases. This
is because we count the ray marching for each voxel intersected by
the ray in this method. And then, we select the smallest value from
the obtained values. Therefore, as the number of voxels increases,
the number of mathematical operations performed increases, and
therefore the performance decreases.
51
4. Results
52
4. Results
53
4. Results
54
5 Conclusion
In order to evaluate the suitability of the OptiX engine for rendering
signed distance functions, a framework based on the OptiX engine and
OpenGL was created. This framework supports the visualization of
SDF and discrete SDF. To visualize both types of SDF functions, three
different methods based on OptiX were written : OptiX IS method with
ray marching implementation in the intersection program, OptiX CH
method with ray marching implementation in the closest hit program,
and OptiX RG method with ray marching implementation in the ray
generation program. Additionally, methods for visualizing SDF and
discrete SDF using "pure" CUDA were implemented. Moreover, a
separate program was written for calculating the discrete SDF for
triangular meshes.
Using created framework, all of the above methods were compared
in terms of their performance and the quality of the visual result.
All the proposed methods for visualizing SDF give the same visual
results, but the performance of the methods is very different. So for
visualization of simple SDF functions, CUDA or OpenGL are best
suited. And for visualizing more complex SDFs, OpenGL is best suited.
All methods based on OptiX have much lower performance, so they
are not suitable for visualizing SDF functions. Thus, it is best to use
OpenGL to visualize the SDF, which gives good results on all the
tested scenes, regardless of their complexity.
For the visualization of discrete SDF, "pure" CUDA is best suited.
Its performance is almost independent of the size of the visualized
SDF. OptiX-based methods are not suitable for visualizing discrete
SDF functions, even though on small discrete SDFs, their performance
is very close to that of CUDA. Because with an increase in the size of
discrete SDF, the performance of these methods drops significantly.
And OptiX becomes unsuitable for rendering large discrete SDFs.
Thus, OptiX is not suitable for visualizing geometry defined by
SDF.
55
A List of Electronic Attachments
Along with the thesis, the attachments are included in Application.zip
file consisting of:
57
B Requirements for running binaries and for
compiling
For running binaries:
• Windows 10 64-bit.
For compiling:
59
C Instruction for building the framework
1. Install everything required for compiling from Appendix B
2. Install vcpkg
4. Install cmake
6. Compile
61
Bibliography
1. Website [online]. Inigo Quilez [visited on 2021-04-23]. Available
from: https://www.iquilezles.org.
2. OSHER, Stanley; FEDKIW, Ronald. Signed Distance Functions.
In: Level Set Methods and Dynamic Implicit Surfaces. New York,
NY: Springer New York, 2003, pp. 17–22. isbn 978-0-387-22746-7.
Available from doi: 10.1007/0-387-22746-6_2.
3. FRISKEN, Sarah; PERRY, Ronald. Designing with Distance Fields.
In: 2005, vol. 2005, pp. 58–59. Available from doi: 10.1109/SMI.
2005.16.
4. HAUGO, Simen; STAHL, A.; BREKKE, E. Continuous Signed
Distance Functions for 3D Vision. 2017 International Conference on
3D Vision (3DV). 2017, pp. 116–125.
5. CRANE, Keenan. Ray Tracing Quaternion Julia Sets on the GPU
[online]. [N.d.] [visited on 2021-04-23]. Available from: https:
/ / www . cs . cmu . edu / ~kmcrane / Projects / QuaternionJulia /
paper.pdf.
6. Syntopia. Generative art, 3D fractals, creative computing [online].
Mikael Hvidtfeldt Christensen, 2018 [visited on 2021-04-23].
Available from: http://blog.hvidtfeldts.net.
7. Mandelbulb.com [online]. Matthew Haggett [visited on 2021-04-
23]. Available from: https://www.mandelbulb.com.
8. HART, John. Sphere Tracing: A Geometric Method for the An-
tialiased Ray Tracing of Implicit Surfaces. The Visual Computer.
1995, vol. 12. Available from doi: 10.1007/s003710050084.
9. KNOLL, A.; HIJAZI, Y.; KENSLER, A.; SCHOTT, Mathias;
HANSEN, C.; HAGEN, H. Fast Ray Tracing of Arbitrary Implicit
Surfaces with Interval and Affine Arithmetic. Computer Graphics
Forum. 2009, vol. 28.
10. JONES, M.W.; BAERENTZEN, J.A.; SRAMEK, M. 3D distance
fields: a survey of techniques and applications. IEEE Transactions
on Visualization and Computer Graphics. 2006, vol. 12, no. 4, pp. 581–
599. Available from doi: 10.1109/TVCG.2006.56.
63
BIBLIOGRAPHY
64
BIBLIOGRAPHY
65
BIBLIOGRAPHY
66
BIBLIOGRAPHY
67