Introduction

The notion of creating a deductive formalization of mathematical properties through visualizations and intuitions of geometry dates back to ancient Greece. Notably, in his 299 B.C. book, The Elements, Euclid posited as an axiom that parallel lines do not meet. In a painitng, lines that might be parallel in the real world appear to meet at a vanishing point.

Projective geometry provides a natural and conceptually complete setting for many geometric theorems. Statements about parallel lines, conic sections, and algebraic varieties often become simpler and more unified when expressed projectively. However, standard visualizations often treat points at infinity as artifacts rather than intrinsic components of the geometry.

To an observer living inside projective space, no point would be distinguished as infinite. The geometry is homogeneous, as every point admits identical local structure, and there is no intrinsic notion of boundary. The apparent singularity of infinity arises only from extrinsic representations. In this work, we develop a rendering framework that allows the viewer to inhabit RP3\mathbb{RP}^3 directly, removing the artificial distinction between finite and infinite points. To accomplish this, we use the identification RP3S3/{±1},\mathbb{RP}^3 \cong S^3 / \{\pm 1\}, and view real projective 3-space as the antipodal quotient of the 3-sphere. Rather than projecting projective space into Euclidean coordinates, we perform ray marching directly along geodesics of S3S^3 and preserve the intrinsic geometry. Surfaces defined by homogeneous equations are evaluated on the sphere, and antipodal symmetry ensures the correct projective identification.

This work is heavily inspired by (Coulon et al. 2022) which produced a set of flexible software for ray marching the Thurstonian geometries and their quotients, including S3S^3 and the quotient RP3\mathbb{RP}^3. Our techniques are also influenced by discussion from (Quilez 2011) on approximating distance to implicit surfaces and this proof of concept (“Raycasting Implicit Surfaces” 2017) using Descarte’s method in the Bernstein Basis to solve for real ray intersections.

In Sec. 2, we review the structure of RP3\mathbb{RP}^3 and its realization as the antipodal quotient of S3S^3. Sec. 3 describes our intrinsic ray-marching framework and numerical methods. Our implementation is outlined in 4. In Sec. 5 we present examples of projective varieties visualized using this approach. We conclude with a discussion of implications and future directions.

Mathematical Background

Real Projective 3-Space

The geometric space under consideration in this work is real projective 3-space, denoted RP3\mathbb{RP}^3. Formally, it is defined as the space of all one-dimensional linear subspaces of R4\mathbb{R}^4, or, equivalently,

RP3=(R4{0})/,\mathbb{RP}^3 = (\mathbb{R}^4 \setminus \{0\}) / \sim,

where xλxx \sim \lambda x for every nonzero scalar λR\lambda \in \mathbb{R}. A point in RP3\mathbb{RP}^3 therefore represents an entire line through the origin in R4\mathbb{R}^4. Using homogeneous coordinates, we write such a point as

[x0:x1:x2:x3]:=[λx0:λx1:λx2:λx3]for all λ0.[x_0 : x_1 : x_2 : x_3] := [\lambda x_0 : \lambda x_1 : \lambda x_2 : \lambda x_3] \quad \text{for all } \lambda \neq 0.

Projective space may additionally be understood as a completion of Euclidean space. In fact, we recover standard Euclidean coordinates via

[x0:x1:x2:x3](x1x0,x2x0,x3x0),[x_0 : x_1 : x_2 : x_3] \mapsto\left(\frac{x_1}{x_0},\, \frac{x_2}{x_0},\, \frac{x_3}{x_0}\right),

where we have identified R3\mathbb{R}^3 with the affine chart [x0:x1:x2:x3][x_0 : x_1 : x_2 : x_3], such that x00x_0 \neq 0. The remaining points, i.e., those with x0=0x_0 = 0, are often described as “points at infinity." In this interpretation, parallel lines in R3\mathbb{R}^3 intersect at a unique point at infinity determined by their direction, similar to how railroad tracks vanish at a different point in the horizon depending on what angle they take with your vision.

This language of infinity can be misleading. The distinction between finite and infinite points depends entirely on the choice of affine chart. Changing coordinates moves the hyperplane x0=0x_0 = 0 to another location, altering which points are labeled infinite. From the intrinsic perspective of RP3\mathbb{RP}^3, there is no preferred hyperplane and therefore no distinguished set of infinite points. Every point possesses identical local geometric structure.

Consider the identification

RP3S3/{±1},where S3={xR4:x=1}.\mathbb{RP}^3 \cong S^3 / \{\pm 1\},\quad\text{where }S^3 = \{ x \in \mathbb{R}^4 : \|x\| = 1 \}.

Here, S3S^3 is the unit 3-sphere. Note that each line through the origin intersects S3S^3 in exactly two antipodal points. Identifying these antipodal pairs of intersection points produces RP3\mathbb{RP}^3. Thus, projective space inherits the smooth compact structure of the sphere modulo symmetry.

Rather than embedding RP3\mathbb{RP}^3 into Euclidean space and treating infinity as limiting, we perform geometric computations directly on S3S^3 and enforce antipodal identification. Thus, surfaces and intersections that would appear to escape to infinity in Euclidean coordinates remain entirely visible and continuous within the projective model, and the geometry becomes globally coherent.

Spherical Geometry

In Euclidean space, the paths that minimize distance, or the geodesics, are the straight ones: straight lines extend infinitely and distances are measured with respect to a flat metric. On the sphere, however, the natural notion of a straight line is a great circle geodesic, a curve that locally minimizes distance while remaining on the surface. These great circles are compact and obtained by intersecting the sphere with two-dimensional places through the origin in R4\mathbb{R}^4.

To an observer living in S3S^3, these geodesics would appear to be the straightest possible paths available, even though they appear curved when viewed extrinsically. Were they to ride a bike on this surface, traveling along a great circle would not require any turning of the handle bars. This distinction is essential to our visualizations, as we do not treat the sphere as a curved object sitting inside a higher-dimensional flat space. Instead, we treat the sphere as the ambient space itself.

Geometrically, S3S^3 has constant positive curvature. This curvature explains several features, including the tendency for geodesics to bend towards one another, that triangles have angle sums greater than pi, and the compactness of the global topology. This compactness gives us a powerful result about the space: rays [JS: (specify that they follow geodesics?)]{style=“color: blue”} never diverge or escape. Projective phenomena that appear unbounded in Euclidean coordinates become fully contained when viewed on S3S^3.

Because S3S^3 is compact and geodesics are periodic, rays don’t escape to infinity.

After identifying antipodal points to obtain RP3\mathbb{RP}^3, the space remains compact but becomes non-simply connected.

Rendering Framework

Ray Marching on S3S^3

In Euclidean ray tracing, rays follow the straight line geodesics which originate at a camera position and travel outward until they intersect a surface. Implicitly, the trajectory of these rays is governed by the flat Euclidean metric. In our setting, we treat S3S^3 as the ambient space itself, and thus the rays should instead follow geodesics of S3S^3.

Given a point pS3p \in S^3 and a unit tangent vector vTpS3v \in T_p S^3 with p,v=0\langle p, v \rangle = 0, the geodesic through pp in direction vv is given by

γ(t)=cos(t)p+sin(t)v.\gamma(t) = \cos(t)\, p + \sin(t)\, v.

Since γ(t)=1\|\gamma(t)\|=1, this curve remains on S3S^3 for all tt and traces out a great circle. Rendering, therefore, is simply evaluating surfaces along such geodesics. However, rather than solving for the first intersection of a geodesic with a surface as we would with ray tracing, we instead utilize ray marching. Here, we incrementally step forward along γ(t)\gamma(t) and test for intersections.

We concern ourselves with surfaces specified by homogeneous polynomials F:R4RF:\mathbb{R}^4\to\mathbb{R}, where the level sets F(x0,x1,x2,x3)=0F(x_0,x_1,x_2,x_3) = 0 define projective varieties. Because F(λx)=λdF(x)F(\lambda x)=\lambda^dF(x), the zero set is invariant under scaling, and therefore is well-defined on RP3\mathbb{RP}^3.

Methods of detecting the intersection of a ray and an implicit surface are detailed in the following two sections.

Great circles on S3S^3 satisfy the periodicity constraint γ(t)=γ(2π+t)\gamma(t)=\gamma(2\pi+t). In addition, under the aforementioned antipodal quotient RP3S3/{±1}\mathbb{RP}^3 \cong S^3/\{\pm 1\}, we have that [γ(t)]=[γ(π+t)][\gamma(t)]=[\gamma(\pi+t)]. Thus, it suffices to restrict t[0,π]t\in [0,\pi]. This prevents redundant traversal of the same projective points.

At an intersection point xhit:=γ(thit)x_\text{hit}:=\gamma(t_\text{hit}), we compute the surface normals intrinsically by projecting the Euclidean gradient onto the tangent space of S3S^3: n=F(xhit)F(xhit),xhitxhitn = \nabla F(x_{\text{hit}}) - \left\langle \nabla F(x_{\text{hit}}),\, x_{\text{hit}} \right\rangle x_{\text{hit}}. This produces a vector tangent to S3S^3 and orthogonal to the surface. The resulting intrinsic normal is then used for shading and lighting computations.

We also incorporate a path tracing option to model lighting. Secondary rays are generated at intersection points to simulate reflection and global illumination effects. These rays again follow geodesics in S3S^3, ensuring that lighting computations are consistent with the intrinsic geometry. This enhances depth perception and helps communicate accurate geometric structure.

Implicit SDF Approximation

One way of computing ray intersections with implicit surfaces is ray marching using a signed distance function (SDF). A great discussion of ray marching SDFs has been given many times by many people. One good resource is (Quilez 2008)

A signed distance function for an object is a function on our space that returns the shortest distance between the given point and any point of the geometry of the object, returning a negative value for points inside the object. The SDF at a point pp outside of the object gives us the radius of the largest ball centered at pp that doesn’t overlap with the geometry of the object.

If we march forward from pp by a distance of SDF(p)SDF(p) we are guaranteed not to hit the object.

We can continue marching forward until the SDF(p)SDF(p) is within a given tolerance at which point we decide that we have hit the object.

The following is an implementation of this method written in WGSL (WebGPU Shading Language). The version in our code is modified slightly to work on both sides of the surface.

const EPSILON = 5e-5;
fn marchRay(r: Ray) -> f32 {
  var t = 10.*EPSILON;
  for(var i = 0; i < 250; i++) {
    var sd = sdfScene(flow(r,t));
    if( abs(sd) < EPSILON) {break;}
    t+=sd;
  }
  return t;
}

The main object of our scene is defined as the zero set of a defining implicit function. The raymarching method is in effect converging on the zero set of the signed distance function, but we don’t necessarily know that our implicit function is giving us the signed distance to the object, and in most cases it isn’t.

We use a technique described by (Quilez 2011) where we approximate a true SDF by taking the value of the implicit function ff, and dividing by the length of the gradient δf|\delta f|:

sdf(p):=f(p)δf(p). \text{sdf}(p) := \frac{f(p)}{|\delta f(p)|}.

In effect we are constructing a linear approximation of the SDF at each point. To convince yourself of this, imagine that the surface defined by ff is just a plane, so ff is of the form f(p)=vp+cf(p) = v \cdot p + c for vR4v \in\mathbb R^4 and cRc \in \mathbb R. In this case

sdf(p)=vp+cv \text{sdf}(p) = \frac{ v \cdot p + c }{|v|}

which is the true SDF for that plane! The logic is that if our surface is smooth and we are sufficiently close, it will resemble a plane and this approximation will converge correctly.

In practice this works suprisingly well with artifacts rare even when the surface contains singularities. Unfortunately this method can be slow to converge and requires many steps, especially when the ray is at a very oblique angle to the surface or passes closely by.

On the GPU every pixel essentially must go through the same paths in the code at the same time, so if only a few pixels fail to converge quickly we have to choose between increasing the maximum number of iterations and affecting framerate, or lower the cap and see visual artifacts.

These problems help motivate our second method of ray-object intersection, using Descartes Method in the Bernstein basis.

Bernstein Basis Approximation

To compute ray surface intersections reliably, we approximate F(γ(t))F(\gamma(t)) using the Bernstein basis. This method is implemented to great sucesss in professional CAD software for rendering Bezier curves. A more thorough explanation of the algorithm and it’s connection to Descarte’s law of signs is given in (Mourrain et al. 2005). A proof of concept for algebraic surfaces is implemented by (“Raycasting Implicit Surfaces” 2017).

For a polynomial of degree nn in one variable on the interval [0,1][0,1], the Bernstein basis consists of the functions

Bkn(t)=(nk)tk(1t)nk,k=0,,n.B_{k}^{n}(t) = \binom{n}{k} t^{k}(1-t)^{n-k}, \quad k = 0, \dots, n.

Any polynomial p(t)p(t) of degree at most nn can be written uniquely as

p(t)=k=0nckBkn(t).p(t) = \sum_{k=0}^{n} c_k B_k^n(t).

One important benefit of using the Bernstein basis is that it allows for control over the range of the function. On [0,1][0,1], the polynomial p(t)p(t) is within the convex hull of its coefficients {ck}\{c_k\}. The minimum and maximum values of p(t)p(t) are bounded by the minimum and maximum of the coefficients. This property makes the Bernstein form numerically stable and well-suited for root-finding, since it allows us to find whether a function can change sign on a given interval.

Intersection detection reduces to finding roots of a function

f(t)=F(γ(t)),f(t) = F(\gamma(t)),

where γ(t)\gamma(t) is a geodesic on S3S^3. After restricting to a bounded parameter interval, we approximate f(t)f(t) in Bernstein form. If all Bernstein coefficients have the same sign, then no root occurs in that interval. If the coefficients change sign, we subdivide the interval and repeat the test.

Therefore the Bernstein basis helps us avoid unstable cancellation effects that can arise and allows us to certify the presence or absence of roots with a specific tolerance. It enables accurate rendering without requiring closed-form intersection formulas.

Implementation

WebGPU Architecture

Our implementation uses the the [wgpu]{.smallcaps} crate which is a cross-platform graphics API patterned off of the WebGPU standard, written in pure Rust. This allows our code to compile to DirectX12 for Windows, Metal for iOS and MacOS, Vulkan for Windows Linux and Android, for WebGL and WebGPU for the web by compiling to WebAssembly. The tested platforms are Vulkan on Linux, Metal on MacOS, and WebGL for the web. We use WGSL for our shading language.

The main advantage of using [wgpu]{.smallcaps} is the cross-platform support and the memory-safety guarantees offered by Rust. The WebGPU standard as implemented gives us enough control over the rendering pipeline to be efficient while abstracting way some of the unnecessary and less-portable features of Vulkan. Also, the option of using WebGPU allows for the possibility of using compute shaders or general-purpose storage buffers in future iterations of the software.

Symbolic Lowering Pipeline

Implicit surfaces are defined symbolically on the CPU using a custom polynomial library implemented in Rust. This library supports symbolic differentiation, polynomial multiplication and addition, and monomial expansion in a chosen graded ordering, all on the CPU. Given a symbolic expression for a homogeneous polynomial, these expressions are then expanded into monomial form using a user-specified ordering and baked into WGSL code for use as SDFs on the GPU.

Discussion

We have developed an intrinsic rendering framework for RP3\mathbb{RP}^3 based on its realization as the antipodal quotient S3/±1S^3/{\pm1}. By performing ray marching along spherical geodesics and evaluating homogeneous surface equations directly on S3S^3, we eliminate the artificial distinction between finite and infinite points.

References

Coulon, Rémi, Elisabetta A. Matsumoto, Henry Segerman, and Steve J. Trettel. 2022. “Ray-Marching Thurston Geometries.” Experimental Mathematics 31 (4): 1197–277. https://doi.org/10.1080/10586458.2022.2030262.

“Raycasting Implicit Surfaces.” 2017. February 3. https://cindyjs.org/gallery/cindygl/Raytracer/index.html.

Quilez, Inigo. 2008. “Inigo Quilez  :: Articles  :: Rendering Worlds With Two Triangles - 2008.” https://iquilezles.org/articles/nvscene2008/.

Quilez, Inigo. 2011. “Inigo Quilez   ::   Articles   ::   Distance Estimation - 2011.” https://iquilezles.org/articles/distance/.

Mourrain, Bernard, Rouillier Fabrice, and Marie-Francoise Roy. 2005. “The Bernstein Basis and Real Root Isolation.” In Combinatorial and Computational Geometry, edited by Emo Welzl, Jacob E. Goodman, and Janos Pach. Mathematical Sciences Research Institute Publications. Cambridge University Press. https://doi.org/10.1017/9781009701259.025.