   3D graphics with spheres
  A friend of mine who does maths, asked me the following question which i was unsure of as to how to answer. I was wondering whether any of you could help.The matter concerns the use of faces and triangles in 3D video games. He asked me why in 3D games, spherical objects are always made up of faces (therefore not actually spherical)? Instead, he asked why not use spheres instead of surfaces.His reasoning is just like a line (which is rendered easily) is a connection between two points, a sphere is the surface created around a fixed radius from a point. Therefore, shouldn't it be similarly easy to render a sphere as a surface in game without the need for splitting it up into faces?I hope i've been clear enough, please ask if you need more info.   
  There aren't a lot of perfect spheres in game levels and more advanced surfaces are quite difficult to draw directly. So it don't make much sense to specialize the hardware to draw spheres (even if it would be probably feasible). Triangle meshes are preferred because they can be rendered easily and approximate a lot of surfaces.   ;  Yes, spheres can be drawn exactly; it's actually quite easy, so long as you're doing it on the CPU rather than GPU.  If you check out some of the old realtime raytracer demos from the late 1990s (here's one of the later ones: Heaven 7), that's exactly what they did.However, if you want to pick one element and only one element that can easily be used to approximate surfaces to whatever accuracy you want, you choose triangles.  They also have the advantage that they can be drawn very quickly.   ;  The answer to the OPs question is that games use a triangle rasterizer, and therefore everything is drawn with triangles.You could easily ray trace a sphere, but it would be too slow for a game.The answer is speed.   ;  Surely you could rasterize a sphere, but the math involved is much heavier as you are acting on non-zero curvature (e.g. there is no perfect mapping of 2d-textures to sphere-surfaces, but texturing alone would anyways only be the easiest task of all, imho).Ray tracing spheres is indeed very introductory and basic stuff; that's not to say it isn't interesting. Kevin Beason wrote a path tracer within 100 lines of C++, solely based on spheres (smallpt: global illumination in 99 lines of c):shameless plug: I have done some brute renders, too (more here; two of those renders I have also submitted to the last irtc so far: irtc 2006-12):But apart from such fun renders, mother nature knows only very few, if any, perfect spheres, so basing the rendering solely on spheres is a worse option than rendering polygons.   ;Quote:Original post by Hello KittyThe answer to the OPs question is that games use a triangle rasterizer, and therefore everything is drawn with triangles.No, that is not an answer to the OPs question. Quote:You could easily ray trace a sphere, but it would be too slow for a game.Recent (unfaked and whitted style) software ray tracers achieve results that make them usable in some realtime games. Have a look at that forum.Quote:The answer is speed.But you have already given an answer.;  Somwhere along the line (early generation 3D hardware) the decision was made to use triangles as the geometrical primitive. All current 3D hardware use triangles, so all 3D accelerated games use triangle to approximate surfaces. This is good because whereas triangles generally work for any shape, spheres only work for spheres (same goes for all complex primitves like cones, cylinders etc) there is not much reason to use such things in a modern engine because most shapes that are drawn are more complex and better described using triangles. And there is little reason to have special case primitives for spheres.   ;Quote:Original post by Matt AufderheideThis is good because whereas triangles generally work for any shape, spheres only work for spheresIn more detail, what Matt says, is that triangles are the polygons that have the least number of vertices, and are hence most suitable of all polygons with zero curvature to tesselate (and thus approximate) any "tesselatible" two-dimensional surface.On the other hand, if you take enough "micro-spheres", you can also easily approximate any polygon. And a modern ray tracer based on such rendering could outperform a rasterizer. That holds especially true when it comes to rendering micro-polygons (with a density of more than one polygon per pixel), where the ratio of setup-time (projecting the triangle, etc.) versus raw pixel-shooting-time is high. (sidenote: think of particle based rendering.) bad wording, see 2 posts below[Edited by - phresnel on April 30, 2009 9:07:50 AM];Quote:Original post by phresnelOn the other hand, if you take enough "micro-spheres", you can also easily approximate any polygon. And a modern ray tracer based on such rendering could outperform a rasterizer. That is absolutely false;Quote:Original post by luca-deltodescoQuote:Original post by phresnelOn the other hand, if you take enough "micro-spheres", you can also easily approximate any polygon. And a modern ray tracer based on such rendering could outperform a rasterizer. That is absolutely falseIs your statement based on the assumption that I am comparing hardware-rasterizing vs. software-ray tracing? Because, I am absolutely not.   