Of course, I see the benefit in using polygons to create 3D worlds. But I sometimes wonder if other methods exist and have been used in published computer games; perhaps even hybrid methods of 3D animation that combine polygons with some other style of rendering, so that the limitations of polygonal rendering might be overcome or just mitigated. For example, a way of rendering human bodies without jagged limbs.
-
\$\begingroup\$ This question discusses another method: Is Unlimited Detail real?. But you might notice that the website for the technology doesn't exist anymore. \$\endgroup\$– PhilippCommented May 24, 2017 at 7:47
-
\$\begingroup\$ Something like that? youtube.com/watch?v=XkSS_veoSg0 It uses two types of rendering, but no animation... \$\endgroup\$– ElDuderinoCommented May 24, 2017 at 8:23
-
\$\begingroup\$ @Philipp It's hard for me to evaluate this "unlimited detail" thing without any visuals, but thanks anyway \$\endgroup\$– DonkeyBoyCommented May 24, 2017 at 9:22
-
\$\begingroup\$ @ElDuderino That looks awesome! \$\endgroup\$– DonkeyBoyCommented May 24, 2017 at 9:22
-
\$\begingroup\$ @DonkeyBoy The videos mentioned in that question are still on YouTube. \$\endgroup\$– PhilippCommented May 24, 2017 at 9:40
4 Answers
A technique which comes around again and again for decades is raytracing. While usual 3d engines are based on taking a bunch of vertices in 3d space and see where they end up if transformed to 2d space through a projection matrix, raytracing engines simulate a ray of light from each screen-pixel into the scene and see where it hits a surface.
Raytracing engines usually like to show off by rendering perfect spheres reflecting their environment. While spheres and reflections are hard to do well in polygon-based engines, they are quite trivial to do with raytracing.
Unfortunately GPUs aren't optimized for raytracing, so very few games make use of this extensively, so no GPU vendors bothers to optimize for it. This chicken-egg problem prevents the method from becoming mainstream. There are a few experimental games which use raytracing-based engines, though.
-
\$\begingroup\$ Interesting. I suppose a company like Sony or Microsoft could get past this chicken-egg problem by developing a new console that has a GPU optimized to support raytracing. \$\endgroup\$ Commented May 24, 2017 at 7:40
-
\$\begingroup\$ Some shaders even use distortion techniques, such as scaling, skewing and rotating to create arbitary shapes from spheres. \$\endgroup\$– BálintCommented May 24, 2017 at 9:08
-
1\$\begingroup\$ I think it's more than a chicken-egg problem. Raytracing is inherently more serial and non-local than polygon rasterization, in the sense that we can't just farm out to a hundred cores their respective swatches of geometry and texture to render independently - to know what colour to paint the pixel at the end of this ray that hit the teapot, we need to know the fate of these bounce rays which might hit potentially any other object in the scene. I would suggest that makes raytracing a fundamentally harder problem to solve efficiently, so it's not just a lack of someone bothering to work on it. \$\endgroup\$– DMGregory ♦Commented May 24, 2017 at 23:41
To throw out one other possibility, we can define a scene in terms of a signed distance field and raymarch against that. Many demoscene creations use this technique to create highly detailed scenes on a minuscule data budget, letting the mathematical formulae do the heavy lifting.
This scene, from a demo called rgba slisesix was created by Íñigo Quilez, one of the most prolific creators using this technique. It's generated from a 4 kilobyte executable, with no models or texturemaps.
You'll see this technique used in many Shadertoy examples too, like these elephants, again by Íñigo Quilez (warning - this link is pretty taxing on the browser)
(Check out Íñigo Quilez's site for more examples and fascinating articles about the math & programming behind these and other effects)
The technique is darn near magical in its ability to represent smoothly curving surfaces and absurdly, even fractally fine detail as you zoom in. Thanks to some clever space-folding math, it's also great for representing repeating content, like regular structures in architechture. Once you render one motif/column/arch/etc, you can mirror and tile it infinitely at little additional cost.
There are many downsides though:
The distance functions for a complex scene can be very expensive to evaluate. (See the elephants above. As a polygonal mesh scene, we could render a similar visual at a much higher framerate using current hardware & software) The usual performance fixes we might apply to polygonal scenes, like level of detail reduction, culling, and impostors, don't have a direct or easy-to-plug-in analogue in signed distance fields.
Authoring a signed distance field scene requires a kind of mathematical sculpting skill that few game content creators have mastered. It's not as simple as creating your scene in a conventional 3D package and clicking "convert to signed distance field." While voxelized distance information from a mesh can be used for some effects like shadowing, any demo with complex signed distance visuals has almost certainly been built from the math up.
Modifying a scene dynamically is even trickier. With a polygonal scene, we can potentially move, delete, or add each polygon independently. We can use skinned meshes to animate characters. With a signed distance field, everything is a product of the formula, and not every intuitive operation we might want to apply has a clear or side-effect-free expression in that domain.
So far, polygonal rasterization has proven to be a more flexible tool, practical for the majority of the games we build today. But I bet there could be some clever ways to design a game around the particular quirks of distance field raymarching and create something pretty cool!
One interesting development in that direction: as I understand it, MediaMolecule's Dreams uses signed distance fields for their creation tools, but they don't render them directly - they convert them to points or quads to render the resulting forms in a more conventional fashion.
Claybook takes this a step further by baking a signed distance field into a 1024 x 1024 x 512 pixel volume texture, to 1/32 voxel precision, and raymarching through that volume in the shader. This limits the detail that can be achieved and the size of the world you can create, but sidesteps the three downsides I listed above.
In this screenshot, the blobby shapes in the foreground are rendered as a raymarched SDF, while the character and room in the background are more conventional polygonal rendering.
-
\$\begingroup\$ On your last bullet point, SDF has some clear advantages too (eg twisting/warping/distorting meshes is notoriously difficult whereas it's trivial with a SDF). It's also possible to parameterise in ways meshes couldn't replicate easily. It all comes down to how au fait you are with the maths and how well you plan ahead. \$\endgroup\$– BasicCommented Apr 26, 2023 at 9:23
It's possible to build a graphics engine using other geometric primitives. In 1994, Accolade released a 3D fighter called Ballz used spheres. It was impressive for the hardware at the time & notably different from other things available on console, but didn't do particularly well as a franchise. The underlying engine was later used for a number of virtual pet games.
Ecstatica & Ecstatica 2 (released by Psygnosis in 1994 & 1997 respectively) primarily used ellipsoids. I didn't play either of these, but again recall that they looked distinctive.
A more recent example is Toribash, which appears to use a combination of spheres, cylinders, cones & polygons.
The most common alternative to describing 3D world in terms of polygons are various voxel based techniques. Voxels are to 3D as pixels are to 2D. You can construct a 2D picture using vector graphics, or pixels. Similarly you can create 3D world using polygons or voxels.
One way of doing voxels is popularized by Minecraft. You divide 3d space into smaller portions using cubes and give each cube a color/transparency - similarly like you did in 2D picture dividing it in small squares. If the cubes are large, you can assign them a texture instead of one color.
A variant of this technique was already mentioned - signed distance fields. It works by dividing space with 3D planes. At cross-section of three planes there is a unique point. This can be visualized as a uniform mesh of points floating in the air. You assign a number to each point. If you want to determine the properties of a point in 3D space, you sum up values in close proximity and for example if it is above certain threshold, you treat the point as solid. Positive numbers "project" solidity around, negative project "opaque". What the world looks like is determined by computing cross-sections of many values.
Cube engines reverse that approach. You take a finite cube of 3D space which will be your world. You divide this cube into 8 smaller cubes, and mark each whether it is opaque, solid (which color/texture/slant/round) or is subdivided. If the cube is subdivided, you mark each one of 8 subdivisions, whether it is opaque, solid or is subdivided. Rinse, repeat. The world is described with a tree structure of such subdivisions. There is no (theoretical) limit to these subdivisions, so you can always make the smallest voxel even smaller and add more detail. You can check tesseract.gg for the latest engine in the line, to see what can be accomplished.
-
2\$\begingroup\$ Note that although Minecraft is logically built from voxel data, in most versions the visible voxel faces are baked out to polygon meshes for rendering. See all the triangles visible here. What you describe as SDF sounds more like metaballs sampled on a discrete grid, possibly related to marching cubes. Numbers in SDFs represent the distance of a sample point from the surface (with ± = inside/outside) , not solidity/opacity/density. SDFs don't always need to use a discrete grid, although they can (as in the Claybook example in my answer). \$\endgroup\$– DMGregory ♦Commented Apr 25, 2023 at 21:14
-
\$\begingroup\$ There are a couple games that use "pure" voxel rendering without converting the voxel data to polygons first. Like the 1992 Comache or the 1999 Outcast. \$\endgroup\$– PhilippCommented Apr 26, 2023 at 14:44