I am a high school student taking computer science as a subject, and someone who is very interested in the game development industry. I am currently writing an essay on Raytracing and Z-buffering by comparing them and deducing the right situation for each of them. I was wondering if the developers could help me answer a question of in what specific situations those two are used specifically. I already know how both of them work. Also, do developers prefer another method than these two or is there a way to combine both to make an even more efficient 3D graphics algorithm? Thanks a lot!

  • 3
    \$\begingroup\$ Generally, it is not good idea to ask multiple questions in single post - asking them separately in two separate posts is the preferred solution. You might also consider posting this on graphics focused SE site since raytracing is rarely, if ever, used as main rendering solution in games (unless you are, of-course, interested in its use in games exclusively). \$\endgroup\$
    – wondra
    Commented Jul 27, 2017 at 14:47
  • \$\begingroup\$ @wondra "if ever" -That's an intriguingly antiquated viewpoint. Maybe you should tell that to Miguel Cepero, Gavan Woolery, Bruce Dell, or any of the considerable number of others who are building high performance games and engines favouring raytracing technologies over triangle back-projection based rendering. \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 15:33
  • \$\begingroup\$ This thread on rasterization alternatives might be relevant to your last question about other possibilities. \$\endgroup\$
    – DMGregory
    Commented Jul 27, 2017 at 16:20
  • 1
    \$\begingroup\$ @ArcaneEngineer as long as there is no hardware support, I am afraid "if ever" will hold true - I cannot tell from top of my head single mainstream title that relied on raytracing (sure, there are some experiments however they are not enough to form a trend or even an lively branch). \$\endgroup\$
    – wondra
    Commented Jul 27, 2017 at 17:05
  • \$\begingroup\$ @wondra They have hardware support: GPGPU (OpenCL, CUDA). Generalised though it may be, it can be programmed to do exactly what is required for real-time raytracing, efficiently. \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 17:06

3 Answers 3


"Z-buffers" and "raytracing" are not mutually exclusive. Z-buffers are frequently used to support triangle-based, back-projected rendering (though they are optional in actual usage), and they can also be used to support raytracing. Equating z-buffers to traditional GPU polygon-based, back-projected rendering, just because these are often found together, is outright erroneous.

So, let's talk about Ray-tracing vs. the traditional GPU rendering pipeline, which includes Rasterization (see other wayward answers here) as one of its steps.

Practical pros of traditional triangle-based rendering

  • Can use familiar pipelines and traditional, mature tools like 3DS Max, Maya, Blender to produce 3D content;
  • There are countless resources available for it
  • Processing is very fast on current hardware
  • Doesn't do realistic lighting as well raytracing since the z-buffer it relies on is a boolean concept - you've either drawn at a nearer depth or you haven't, so composing individual pixels according to different factors at that screen point is difficult;
  • It will not require arcane / cutting edges technologies to implement (speaking relatively, of course)

Practical pros of raytracing

  • It can be an extremely accurate way of reproducing real-world lighting conditions
  • It is conceptually quite a lot easier to understand and implement than the traditional approach
  • Since hardware doesn't currently support it specifically (EDIT: This is no longer or only partly true, with the advent of NVidia RTX), you get to write your own implementation which means you understand everything that is going on i.e. how each pixel is composed (also a con, but a lot of fun and direct control over end appearance).


If you want to produce a game quickly, use the former. If you are cutting edge, want a highly individualised art style and have the time to build and endlessly tweak your graphics engine yourself, use the latter. Presently, since time is always of the essence in industry, most prefer the former.

  • \$\begingroup\$ Actually, from what I know I would disagree about the individualised art style for raytracing - the usual use of raytracing is producing hyper-realistic scenes, rather than stylized ones. That brings up quite interesting question though I am not sure I am able answer - Is it even possible to produce heavily stylized scenes/art styles with raytracing? Do you know any resources where it is possible to learn more about that problematic or examples of other people did? \$\endgroup\$
    – wondra
    Commented Jul 27, 2017 at 17:23
  • \$\begingroup\$ @wondra Have a look at Gavan Woolery's game, Voxel Quest. You'll see what I mean. I used to think the same as you, but the way in which he handles light and includes certain tricks greatly affects the visual outcome in what is actually a very pleasant way. There is another recent game prototype I saw, by a different author, but I can't recall the name unfortunately. \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 19:48

Daniel beat me to it but I'm gonna give my own answer anyway since I had fun writing this. His bullet points are solid but I wanted to expand a bit more.

I'm going to use the term Rasterization rather than Z-buffering.

Raytracing is often used for "offline" rendering. Raytracing algorithms give very good pixel quality at the cost of high execution time. Because Raytracing algorithms simulate a light model very similar to the real world, phenomenon such as shadows, reflection and refraction are all very intuitive and simple operations. However since it takes a long time to calculate how a ray of light bounces and interacts with a scene for every pixel (1920x1080 pixels is a lot!) it's not practical to use Raytracing for real-time applications on the CPU. However because the pixel quality is high, "offline" or non-realtime applications use Raytracing extensively. RenderMan by Disney/Pixar which is a good example of an application that uses Raytracing for Film and Animation.

Most GPUs are designed to rasterize triangles to the screen, not to raytrace a scene. PowerVR by Imagination is a series of GPUs that perform hardware Raytracing but that's the exception rather than the rule (and they just lost a lot of market share since Apple is no longer using their GPUs).

I highly suggest you read up on modern GPU pipelines. Along with some reading it's a good idea to try to visualize the pipleine. A fun way to do this for yourself is to take a capture from your favorite game with something like RenderDoc and walk through the different pipeline stages and see what they do.

In recent years there have been two major developments that you may want to read up on. Pathtracing, as an alternative approach to raytracing has been a really popular area of research. Also as Daniel mentioned we've been seeing more and more short-raytracing algorithms being used in compute shaders on the GPU. Volumetric Fog in CryEngine and Lumberyard is generated by Compute shaders on the GPU that execute very short 1-bounce rays. The rays are executed in parallel on the GPU so the operation only takes a couple milliseconds but the results are pretty good.

If you're curious about modern game rendering techniques I suggest reading the articles here. These are a bit dense and very technical but they should give you an idea of the sort of crazy things people have to come up with to get rasterization on modern GPUs to produce realistic visuals.

  • \$\begingroup\$ Glad someone brought this up following the comment I just made on the other answer. I still wouldn't use "Rasterization" - but this is at least a step up from the other answer which doesn't really properly acknowledge this issue. I would use "triangle-based back-projection (and rasterization)". \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 15:35
  • \$\begingroup\$ Rasterization is a good googling term that will bring up a lot of relevant articles which is why I used that. \$\endgroup\$
    – Honeybunch
    Commented Jul 27, 2017 at 15:38
  • \$\begingroup\$ I upvoted you, but it would behoove you to listen instead of being defensive. The problem is that rasterization is one of the final steps in a much larger process used by current GPUs. By talking about rasterization alone, you are calling the larger process by the sub-process's name. As any programmer, engineer or scientist knows, it is crucial to be precise about terms, especially when educating others. I suggest you review the OpenGL or DirectX rendering pipeline in order to clarify your terms and correct your answer. \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 15:41

To put it simply:

  • Z-Buffering
    • Pro: Fast, it's what modern graphics cards tend to be designed around.
    • Pro: It's easy to implement.
    • Con: Getting realistic results isn't necessarily easy.
  • Ray Tracing
    • Pro: Super easy to implement.
    • Pro: Lighting just works. Things like reflection and refraction are pretty much just going to happen.
    • Pro: Can get realistic results very easily.
    • Con: Can be extremely slow, especially with regards to multiple reflections on the rays. And by slow, I mean potentially multiple seconds, minutes or hours for a single frame.
    • Con: Most PC hardware isn't designed to speed this up much. Hardware that does can be very expensive.

Z-buffering is the domain of games and other home computer stuff, mainly because it's so fast to do. Ray-tracing, on the other hand, is more for 3D artists and people in the CG industry as they can afford to wait minutes or hours for a single frame.

For your second question, recent progress in graphics, particularly with deferred rendering, has enabled graphics developers the ability to use some ray tracing techniques in a Z-buffered system for effects like screen-space reflection and shadowing. These are often used with deferred rendering, rather than forward rendering, as shader writers have a lot more detail to perform the ray tracing (Technically ray marching) with. That doesn't mean it can't be done in forward rendering methods, but it tends to be a bit costlier.

  • \$\begingroup\$ Not a bad answer, but what troubles me is that you did not start by pointing out to the OP that z-buffers as such are by no means an either-or proposition as compared with raytracing. Now, raytracing vs triangle-based rendering - yes, by all means those are apples and oranges. Equating z-buffers to polygon-based rendering just because they are often found together, is erroneous logic. You may or may not use a z-buffer of sorts in either rendering approach to support that approach. This is what OP needs in the first place to understand. \$\endgroup\$
    – Engineer
    Commented Jul 27, 2017 at 15:27
  • \$\begingroup\$ Fair points. I'll update this answer when I get home. \$\endgroup\$ Commented Jul 27, 2017 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .