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 directly, removing the artificial distinction between finite and infinite points. To accomplish this, we use the identification 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 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 and the quotient . 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 and its realization as the antipodal quotient of . 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 . Formally, it is defined as the space of all one-dimensional linear subspaces of , or, equivalently,
where for every nonzero scalar . A point in therefore represents an entire line through the origin in . Using homogeneous coordinates, we write such a point as
Projective space may additionally be understood as a completion of Euclidean space. In fact, we recover standard Euclidean coordinates via
where we have identified with the affine chart , such that . The remaining points, i.e., those with , are often described as “points at infinity." In this interpretation, parallel lines in 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 to another location, altering which points are labeled infinite. From the intrinsic perspective of , there is no preferred hyperplane and therefore no distinguished set of infinite points. Every point possesses identical local geometric structure.
Consider the identification
Here, is the unit 3-sphere. Note that each line through the origin intersects in exactly two antipodal points. Identifying these antipodal pairs of intersection points produces . Thus, projective space inherits the smooth compact structure of the sphere modulo symmetry.
Rather than embedding into Euclidean space and treating infinity as limiting, we perform geometric computations directly on 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 .
To an observer living in , 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, 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 .
Because is compact and geodesics are periodic, rays don’t escape to infinity.
After identifying antipodal points to obtain , the space remains compact but becomes non-simply connected.
Rendering Framework
Ray Marching on
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 as the ambient space itself, and thus the rays should instead follow geodesics of .
Given a point and a unit tangent vector with , the geodesic through in direction is given by
Since , this curve remains on for all 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 and test for intersections.
We concern ourselves with surfaces specified by homogeneous polynomials , where the level sets define projective varieties. Because , the zero set is invariant under scaling, and therefore is well-defined on .
Methods of detecting the intersection of a ray and an implicit surface are detailed in the following two sections.
Great circles on satisfy the periodicity constraint . In addition, under the aforementioned antipodal quotient , we have that . Thus, it suffices to restrict . This prevents redundant traversal of the same projective points.
At an intersection point , we compute the surface normals intrinsically by projecting the Euclidean gradient onto the tangent space of : . This produces a vector tangent to 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 , 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 outside of the object gives us the radius of the largest ball centered at that doesn’t overlap with the geometry of the object.
If we march forward from by a distance of we are guaranteed not to hit the object.
We can continue marching forward until the 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 , and dividing by the length of the gradient :
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 is just a plane, so is of the form for and . In this case
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 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 in one variable on the interval , the Bernstein basis consists of the functions
Any polynomial of degree at most can be written uniquely as
One important benefit of using the Bernstein basis is that it allows for control over the range of the function. On , the polynomial is within the convex hull of its coefficients . The minimum and maximum values of 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
where is a geodesic on . After restricting to a bounded parameter interval, we approximate 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 based on its realization as the antipodal quotient . By performing ray marching along spherical geodesics and evaluating homogeneous surface equations directly on , 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.