Global Illumination of non-Euclidean spaces
GGLOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES
TIAGO NOVELLO, VINICIUS DA SILVA, AND LUIZ VELHO
Abstract.
This paper presents a path tracer algorithm to compute the globalillumination of non-Euclidean manifolds. We use the 3D torus as an example. Introduction
Global illumination is a collection of algorithms in computer graphics that areemployed to mimic realist lighting in 3D scenes. The complexity of these algorithmsdepends on the indirect illumination , which comes not directly from the light sources( direct illumination ) but the light of these sources reflected by other surfaces atthe scene. Then computing reflections , refractions , and shadows are important tocompute the global illumination of a given scene.In photorealistic rendering a set of techniques are used to create an image from a3D scene that approximates from a photograph [4], thus enabling the visualizationof the global illumination of the underlying 3D scene. Path tracing is an algorithmcontained in this set. Informally, it consists of giving color for each point ( eye ) anddirection ( pixel ) by launching a path of rays through the scene based on reflections,refractions, and shadows. To write a ray tracer it is common to simulate cameras , ray–surface intersections , light sources , visibility , surface material , indirect lighttransport , and ray propagation .The above concepts used in global illumination of Euclidean spaces can be ex-tended to non-Euclidean spaces. These abstract spaces were developed avoidingEuclid’s fifth postulate, they do “not” exist in the real world. Therefore no real Date : June 24, 2019.
Key words and phrases.
Non-Euclidean geometry, path tracer. a r X i v : . [ c s . G R ] M a r TIAGO NOVELLO, VINICIUS DA SILVA, AND LUIZ VELHO camera can take a picture in such spaces, which makes exploring photorealisticrendering very challenging. Attempts to visualize non-Euclidean geometries haveproduced beautiful and inspiring images with no counterpart in the real world; muchof this is due to the non-trivial topology and geometry of such abstract spaces.Berger et al. [1] was the first to proposed an image-based algorithm to visualizenon-Euclidean spaces. Their rendering algorithm exploited programmable computeshaders and CUDA to implement ray-tracing on the GPU. However, the algorithmwas limited to render only scenes composed of Lambertian surfaces described asimplicit surfaces. Shadows and reflections were not simulated. In [6], we proposedthe first real-time visualization of such spaces using RTX GPUs. More complexesscenes were rendered, and shadows and reflections were introduced (Figure 1).
Figure 1.
Inside view of the 3D flat torus using ray tracing [6].We take the challenge of computing the global illumination in non-Euclideanspaces using a path tracer. In such spaces, the concept of photorealistic renderingis not well defined because there is no real camera there. However, the possibility ofdefining a global illumination equation in non-Euclidean geometry opens the doorfor a path tracing generalization. The images are inspiring.1.1.
Non-Euclidean Spaces.
In dealing with path tracing algorithms is required: (1) Space must be locallysimilar to a Euclidean space — a manifold . This allows us to model the cameraand scene objects; (2) For each point p we need tangent vectors pointing in alldirections. The inner product between two tangent vector is required to simulatelight effects; (3) For a point p and a vector v tangent at p , we need a ray , and itsintersections with objects in the scene. Geometric manifolds satisfies the above properties. Such objects are locallygeometrical similar to special spaces called model geometries . In dimension two,for example, there are exactly three models: Euclidean, hyperbolic, and sphericalspaces. In dimension three, there are five more model geometries, however, in thiswork, we focus on the (classical) first three spaces. We describe these topics inmore detail below. Great texts on this subject are Thurston [5] and Martelli [3].
LOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES 3
Definition 1.1 (Euclidean space) . The
Euclidean space E is R endowed with theclassical inner product (cid:104) u, v (cid:105) E = u x v x + u y v y + u z v z where u and v are vectors in R . The distance between two points p and q is d E ( p, q ) = (cid:112) (cid:104) p − q, p − q (cid:105) E . Thecurve γ ( t ) = p + tv describes a ray leaving a point p in a direction v . Analogously,for any n > E n is constructed. Definition 1.2 (Hyperbolic space) . The
Lorentzian inner product of the vectors v and u in R is (cid:104) u, v (cid:105) H = u x v x + u y v y + u z v z − u w v w . The Lorentzian space is R endowed with this product. The hyperbolic space H is the hyperboloid { p ∈ R | (cid:104) p, p (cid:105) H = − } endowed with a special metric d H ( p, q ) = cosh − ( −(cid:104) p, q (cid:105) H ).A tangent vector v to a point p in H satisfies (cid:104) p, v (cid:105) H = 0, then the tangent space T p H = { v ∈ R | (cid:104) p, v (cid:105) H = 0 } . Rays in H are the intersections between H and theplanes in R containing the origin. For instance, the ray leaving a point p ∈ H ina tangent direction v is the intersection between H and the plane spanned by thevectors v and p in E . Such ray can be parameterized as r ( t ) = cosh( t ) p + sinh( t ) v . H contains no straight line, thus its rays can not be straight. However, it ispossible to model H in the unit open ball in R — known as Klein model K —such that the rays are straight lines. More precisely, each point p ∈ H is projectedin the space { ( x, y, z, w ) ∈ R | w = 1 } by considering p/p w . Definition 1.3 (Elliptic Space) . The 3 -sphere S is the set { p ∈ E | (cid:104) p, p (cid:105) E = 1 } endowed with the metric d S ( p, q ) = cos − (cid:104) p, q (cid:105) E . A tangent vector v to a point in S satisfies (cid:104) p, v (cid:105) E = 0, then the tangent space T p S = { v ∈ E |(cid:104) p, v (cid:105) E = 0 } . The space T p S inherits the Euclidean inner product of E . A ray in S passing through apoint p in a tangent direction v is the intersection between S and the plane spannedby v , p , and the origin. Such ray can be parameterized as r ( t ) = cos( t ) p + sin( t ) v .A 3 -manifold M is a topological space which is locally identical to the Euclideanspace E : there is a neighborhood of every point in M mapped diffeomorphically tothe open ball of E n . These maps are called charts . The change of charts betweentwo neighborhoods in M must be differentiable. Examples of 3-manifolds includethe Euclidean, hyperbolic, and spherical spaces. Metric and rays are fundamental objects when working with path tracing, sincelight travels along with rays and are distributed in the scene surfaces by the metric.A manifold M endowed with a metric at each tangent space (in a smooth manner)is called Riemannian . This allows us to compute the length of vectors and distancesbetween points in M . A geodesic (ray) in M is a curve locally minimizing length.We remember an algebraic (very computational) way to construct manifolds fromsimple ones. Let M be a connected manifold and Γ be a discrete group of isometriesacting on M , the quotient M/ Γ is the set { Γ · p | p ∈ M } where Γ · p = { g ( p ) | g ∈ Γ } is the orbit of p . For example, the quotient of E by the group of translation givesrise to the flat torus T . A ray r leaving a point p ∈ T in a direction v is describedby considering the fractional part of the coordinates of r ( t ) = p + t · v .Interesting cases arise when M is a geometry model: Euclidean, hyperbolic, andspherical. The space M/ Γ inherits the geometric structure of M . For example, T has the geometric structure modeled by E . The fundamental domain ∆ plays animportant role in the above construction being the region of M containing exactlyone point for each orbit. The unit cube is the fundamental domain of T . TIAGO NOVELLO, VINICIUS DA SILVA, AND LUIZ VELHO Illumination of Non-Euclidean Spaces
This section focus on extending the local and global illumination equations to aRiemannian manifold (
M, g ), the next section presents a path tracer algorithm forthe class of geometric manifolds. We consider that light propagates along with raysin (
M, g ), and that it is constant in a vacuum. Then inside views of a scene inside M can be rendered by tracing rays: given a point (eye) and a direction (pixel),we trace a geodesic (first ray). When it reaches a point on a surface object, wecompute its Riemannian illumination by considering the direct and indirect lightcontributions. The direct illumination considers the rays coming directly from lightsources and the indirect gathers the light rays bounced by other surfaces.
Illumination is the process of simulating the light leaving a point in a givendirection. Classic approaches to perform such tasks are not suited for Riemannianmanifolds, so we propose a more general illumination definition.Let C be the space of RGB colors. The Riemannian illumination of a 3-manifold M , with a scene embedded on it, is a function L : M × S → C , where for each point p ∈ M and unit tangent direction v ∈ T p M we have a color L ( p, v ) representingthe light leaving this direction. Because we are considering the light constant alonggeodesics, the function L only needs to be computed on the scene surface objects.There are many approaches to compute the illumination function. We startwith a local model considering only the direct contributions of the light sourcesand surfaces composed of diffuse and specular materials. Then we incorporate theindirect light contribution generating a global model.2.1. Riemannian local illumination.
We start with the classical local illumination in a Euclidean scene. Let p be apoint in a surface object S , and N its normal vector. Let l be a point light, w i = ( l − p ) / | l − p | E is the incident vector and w r = − w i + 2 (cid:104) w i , N (cid:105) E N is the perfect reflection of w i . For a vector v leaving p , the local illumination function is:(2.1) L ( p, v ) = k a L a + k d n (cid:88) j =1 L i (cid:104) w ji , N (cid:105) E + k s n (cid:88) j =1 L i (cid:104) w jr , v (cid:105) k e E , where L a indicates the ambient light intensity, L i is the radiance emitted by thelight source l i , and the numbers k a , k d , k s , and k e represent the ambient , diffuse , specular , and roughness coefficients of the surface S at p .We now extend Equation 2.1 to a Riemannian manifold ( M, g ); g is the Riemann-ian metric. Here p is a point in a smooth surface S embedded in M , and N is thenormal vector at p . The direction w i is the unit tangent vector at time zero of thegeodesic running from p towards the light source l . Then w r = − w i + 2 g p ( w i , N ) N is the perfect reflection of w i . The metric (cid:104) , (cid:105) E used in Equation 2.1 is replaced bythe Riemannian metric g p of M restricted to p , this gives rise to the Riemannianlocal illumination for a unit direction v at T p M :(2.2) L ( p, v ) = k a L a + k d n (cid:88) j =1 L i g p ( w ji , N ) + k s n (cid:88) j =1 L i g p ( w jr , v ) k e , To render an image of a scene embedded in the Riemannian manifold M wedefine a Riemannian ray casting : it shoots rays through the pixels, if a ray inter-sects a surface, we compute its color using Riemannian local illumination function.Consider a 2-sphere S o centered in a point o (the observer) in M . We give a color LOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES 5 for each sphere point (ray direction) in the observer field of view V by tracing aray; In other words, V ⊂ S o carries the image. We call this procedure Riemannianray casting . Specifically, the unit sphere S o is centered at the origin of T o M . Foreach direction v in S o we attribute a color c by launching a ray γ from o in thedirection v . Each time γ intersects a scene object at a point p = γ ( t ) we computeits Riemannian local illumination L ( p, − γ (cid:48) ( t )).Before we go to a global illumination function we observe in Equation 2.2 that theambient term k a L a is a very rough approximation of the indirect light contribution.The other terms in Equation 2.2 is the direct light contribution when dealing withdiffuse/specular surfaces.2.2. Global illumination in non-Euclidean manifolds.
We remember the classical global illumination function of the Euclidean space E introduced by Kajiya [2]. For each point p , it computes the amount of light emittedin a direction v . It is modeled through the integral equation over the hemisphereΩ( p ) = { v ∈ S | (cid:104) v, N ( p ) } ≥ (cid:105) E :(2.3) L ( p, v ) = L e ( p, v ) + (cid:90) Ω f r ( p, v, w i ) L ( p, w i ) (cid:104) w i , N (cid:105) E dw i . The bidirectional reflectance distribution function (BRDF) f r ( p, v, w i ) defines howthe light reflects at p , and L e ( p, w ) is the light emitted at p in the direction v .Equation 2.3 generalizes Equation 2.1 because it integrates over all direction en-tering the hemisphere Ω while Equation 2.1 considers only the directions comingdirectly from the light points. The other indirect directions are roughly approxi-mated by the ambient term k a L a .Again, replacing the Euclidean metric with the Riemannian metric, we obtain aglobal illumination function for a Riemannian manifold ( M, g ),(2.4) L ( p, v ) = L e ( p, v ) + (cid:90) Ω f r ( p, v, w i ) L ( p, w i ) g p ( w i , N ) dw i . Taking into account the import contribution of the directions w i leaving the point p in the direction of the light points l i , we divide Equation 2.4 into the direct and indi-rect components L ( p, v ) = L e ( p, v )+ L dir ( p, v )+ L ind ( p, v ). The direct contribution L dir ( p, v ) is computed using Riemannian local illumination function (Equation 2.2).For the indirect contribution L ind ( p, v ), we use Monte Carlo integration to estimatea good approximation.Let { w i , . . . , w ni } be n vectors on the hemisphere Ω chosen using a distributiondensity d w , the Monte Carlo integration states that(2.5) L ind ( p, v ) ≈ n n (cid:88) k =1 f r ( p, v, w ki ) L ( p, w ki ) g p ( w ki , N ) d w ( w ki ) . If L ( p, w ki ) is known, the law of large number ensures the convergence when n → ∞ .Otherwise, computing these approximation for each L ( p, w ki ), and repeating suchprocedure for a finite number m of times, we obtain a version of the path tracing algorithm. It is well-known in compute graphics, since Kajiya [2], that the number m does not need to be large for computing realistic images. TIAGO NOVELLO, VINICIUS DA SILVA, AND LUIZ VELHO Path tracing in non-Euclidean spaces
We combine Riemannian ray casting and Riemannian global illumination to syn-thesize inside views of non-Euclidean spaces. This generalizes the classical pathtracing . We focus on a geometric manifold M/ Γ since it admits a well-behavedgeometry M and a combinatorial description of its topology in terms of Γ.Our method approximates the Riemannian global illumination of the visiblesurfaces inside a geometric manifold using the ray tracing capabilities of the RTXplatform. We will discuss first the basic principles of path tracing in Non-Euclideanspaces, as well as, the general algorithm in CPU. We will show how to map thecomputation to the RTX pipeline and present the details of GPU implementation.3.1. Overview of the Method.
The path tracing is the most natural method to produce photorealistic images ofEuclidean scenes. Thus extending the technique to non-Euclidean spaces wouldprovide a flavor of the photo-realism inside such abstract spaces. It is necessaryto take into account the geometry/topology of the non-Euclidean space. The firstaspect of this task is to simulate the ray path as it travels inside the space, startingfrom the point of observation until it intersects with a visible object — the Rie-mannian ray casting. The second aspect amounts to the illumination, evaluatingthe light scattered from the environment in the ray direction — the Riemannianglobal illumination. Because of the non-trivial topology, the ray path is updatedas it exits the fundamental domain.3.2.
Algorithm in CPU.
We present the basic path tracing algorithm for a geometric manifold M/ Γ, andcompare it with the traditional path tracing of Euclidean space.We start with an algorithm to trace rays inside M/ Γ. Let p be a point inside thefundamental domain ∆ of M/ Γ, and v be a direction at T p M , Algorithm 1 trace aray γ from p towards the direction v . If γ intersects a scene object in ∆, the pointand direction are updated. Algorithm 1:
Trace ray
Data: point p , direction v Result: bool hit
Trace a ray γ from ( p, v ) inside ∆; repeat Find closest intersection γ ( t ) with objects O in ∆; if γ ( t ) (cid:54) = ∅ then Update p = γ ( t ) and v = γ (cid:48) ( t ); return true; else Find intersection of γ with faces of ∆ ;Compute the new origin p (cid:48) and ray γ (cid:48) ;+ + i ; enduntil i ≤ maxlevel ; return false; LOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES 7
As it can be verified in Algorithm 1, the rays are intersected with visible objects(line 5) and if there is a hit (line 6), the ray point and direction is updated (line 7).The whole computation has the fundamental domain as a base, which is modeledby a polyhedron ∆. Therefore, as the ray hits a face F of ∆ (line 9), we transportit using the corresponding transformation of the discrete group Γ (line 10–11).This is the most important and critical step since it depends on the geometry andtopology of the space. As such, it is specific for each type of space. For practicalcomputational reasons, we cannot continue the ray indefinitely, thus a maximumlevel is set to stop the path (line 15).Algorithm 2 describes the path tracer. The rays are generated from the observer’spoint of view (lines 1–2). Using Algorithm 1 the visible points are computed andif there is a hit (line 3), shading is done using direct and indirect illumination (line4–5). Note that Algorithm 2 is computing the Riemannian ray casting. To computea good approximation of the image, it is common to accumulate the resulting imageof Algorithm 2 and line 2 chooses the direction associated with the pixel using adistribution density function. Algorithm 2:
Path Tracing in non-Euclidean spaces for each pixel σ ∈ I do Let p := 0 and v be the direction associated to σ ; if TraceRay ( p, v, d ) then Define a depth d and a color c = 0;Shade σ using L dir ( p, v ) + L ind ( p, v, d, c ); endend The direct illumination is computed using Equation 2.2. To add the shadows wemultiply the direct illumination by a factor 0 if tracing a ray from the hit point tothe light source a scene intersection occurs, and 1 otherwise.The indirect illumination is presented in Algorithm 3. An integer variable depth d is considered to control the number of ray light bounces of the path tracer. If d isgreater than zero and the ray launched from ( p, v ) intersect the scene (line 3), wesample a hemisphere direction and compute an approximation of the Riemannianglobal illumination (line 4–5). Clearly, in line 5 Algorithm 3, is called again. Thiscame from Equation 2.5 considering only one sample. Algorithm 3:
Indirect illumination
Data: point p , direction v , depth d , color c Result: color c if d ≥ and TraceRay ( p, v ) then Sample a direction w ∈ Ω( p ) using a distribution d w ;c+= L dir ( p, v ) + f r ( p, v, w ) L ind ( p, w, d − , c ) g p ( w, N ) d w ( w ) ; endreturn c; TIAGO NOVELLO, VINICIUS DA SILVA, AND LUIZ VELHO
RTX Pipeline.
NVidia RTX is a hardware/software platform with support for real time ray trac-ing. The ray tracing code of an application using this architecture consists of CPUhost code, GPU device code, and the memory to transfer data to the Accelera-tion Structures for fast geometry culling when intersecting rays with scene objects.Specifically, the CPU host code manages the memory flow between devices, setsup, controls and spawn GPU shaders and defines the Acceleration Structures.These shaders correspond to tasks in Algorithm 1, 2, and 3. The
Ray GenerationShader is responsible for creating the rays (line 1 in Algorithm 2), which are definedby their origins and directions (line 2). A call to TraceRay() launches a ray (line 3in Algorithm 1). The next stage is a fixed traversal of the Acceleration Structuredescribed only at a high level here. This traversal uses an
Intersection Shader tocalculate the intersections (line 5 in Algorithm 1). All hits found pass by tests toverify if they are the closest hit. After no additional hits are found, the
Closest-HitShader is called for the closest intersection point (line 7 in Algorithm 1). In caseno hits are found, Miss Shader is called as a fallback case. It is important to notethat additional rays can be launched in the Closest-Hit and Miss shaders.The scene objects and the boundary of the fundamental domain are treated differ-ently when mapping the algorithm to the RTX pipeline — while the scene objectsare tested and shaded in the regular way (lines 5 and 7 in Algorithm 1), the bound-ary of the fundamental domain is used to transport the rays by the discrete group(lines 9 and 10). This is implemented with a custom designed Miss Shader.3.4.
GPU Implementation.
The implementation of our visualization platform in GPU is built on top of Falcorusing DirectX 12 on Windows 10. The Falcor development framework consists ofa library with support for DXR at a high level and a built-in scene descriptionformat. We use the software Blender to create the scene objects.The core functionality of our system’s architecture consists of a set of shaders thatare mapped to the RTX GPU pipeline as described above. We developed genericshaders for each stage of the GPU path tracing pipeline that are independent ofthe geometric structure of the non-Euclidean space.
Ray Generation Shader : Creates camera rays using the isometries of thespace to transform the ray origin and direction to the camera coordinate system.
Intersection Shader : Computes the ray-object intersection using a parame-terization of the ray. Ray and objects are defined based on the model Geometry.
Closest Hit Shader : Performs the shading operation. This includes computingthe local and global illumination. The local illumination amounts to the directcontribution of light sources that are based on angles between the light directionand the surface normal, as well as, the distance to the light. The global illuminationis computed by launching indirect rays based on the surface BRDF.
Miss Shader : Deals with the transport of rays in the covering space, as theyleave the fundamental domain. For this, the rays are tested for intersection withthe boundary of the polyhedron ∆.
LOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES 9 Examples and Results
We present some expressive output images from our implementation of the al-gorithm in GPU using RTX. We focus on visualizing the 3D flat torus.
Flat Torus.
Probably the most famous and easiest example of a compact 3-manifold is the flattorus T . Topologically, it is obtained by gluing opposite faces of the unit cube[0 , × [0 , × [0 , ⊂ E . It is easy to check that the neighborhood of each pointin T is a 3-ball of the Euclidean space. Thus T is indeed a 3-manifold. T is modeled by E because it is the quotient of the Euclidean space by thegroup of translation spanned by ( x, y, z ) → ( x ± , y, z ), ( x, y, z ) → ( x, y ± , z ),and ( x, y, z ) → ( x, y, z ± T .Figure 2 presents the visualization of a scene inside the fundamental domainusing the path tracing algorithm. On its left, we do not use the indirect lightcontribution, on the right we add the indirect light contribution considering fivebounces. Note that we are using a cornel box with a additional window to setup our scene. The spheres inside the cube have specular, diffuse, and composedmaterials. The point light is above the box, close to the top window. Figure 2.
Cornell box inside the fundamental domain. Rendered con-sidering zero/five bounces.
We now identify the boundaries of the torus fundamental domain (the cube). Aray leaving a point p ∈ T in a direction v is parameterized as r ( t ) = p + t · v in E .For each intersection between r and a face F of the unit cube, we update p by itscorrespondent point p − n in the opposite face, where n is the unit vector normal to F . The ray direction v does not need to be updated. The rays in T can return tothe starting point, providing many copies of the scene. The immersive perceptionis E tessellated by unit cubes: each cube contains one copy of the scene.Figure 3 provides an immersive visualization of the 3-dimensional torus T usingthe path tracer algorithm. On its top, an outside view of the embedded cornel boxshowing how the fundamental domain tesselates the space. On its bottom, a closerview on the specular spheres embedded in the scene to show the tesselation beingreflected on their surface. Figure 3.
Immersive view in the 3D flat torus. The face pairing makesthe rays that leave a face return from its opposite face, giving rise tomany copies of the scene.
Mirrored Dodecahedron.
For an example of a space modeled by the hyperbolic space, consider the dodec-ahedron embedded in H . Let Γ be the group of reflections generated by thedodecahedral faces. With an appropriate scale, the dihedral angle of the dodeca-hedron reaches 90 degrees. The quotient H / Γ is the mirrored dodecahedral space .Γ tessellates H with dodecahedra, each edge has exactly 4 cells.Figure 4 illustrates an immersive visualization of the mirrored dodecahedronusing the reflection definition in the hyperbolic space. There are exactly threespheres, two red and a blue. We add the dodecahedron edges to highlight thehyperbolic space tessellation. The image is the inside view of the group of reflectionacting on the Hyperbolic space. LOBAL ILLUMINATION OF NON-EUCLIDEAN SPACES 11
Figure 4.
Immersive visualization of the mirrored dodecahedron.This space is obtained by considering the faces of a hyperbolic regu-lar dodecahedron to be perfect hyperbolic mirrors.
References
1. Pierre Berger, Alex Laier, and Luiz Velho,
An image-space algorithm for immersive views in3-manifolds and orbifolds , Visual Computer (2014).2. James T Kajiya,
The rendering equation , Proceedings of the 13th annual conference on Com-puter graphics and interactive techniques, 1986, pp. 143–150.3. Bruno Martelli,
An introduction to geometric topology , arXiv preprint arXiv:1610.02592 (2016).4. Matt Pharr, Wenzel Jakob, and Greg Humphreys,
Physically based rendering: From theory toimplementation , Morgan Kaufmann, 2016.5. W.P. Thurston,
The geometry and topology of three-manifolds , Princeton University, 1979.6. Luiz Velho, Tiago Novello, Vinicius Silva, and Djalma Lucio,
Visualization of non-euclideanspaces using ray tracing , Technical Report TR-09-2019, VISGRAF Lab - IMPA, 2019.
VISGRAF Laboratory,Rio de Janeiro,Brazil
E-mail address : [email protected] VISGRAF Laboratory,Rio de Janeiro,Brazil
E-mail address : [email protected] VISGRAF Laboratory,Rio de Janeiro,Brazil
E-mail address ::