Show HN: OpenGL in super slow motion – visualising Z-buffering
orbides.org
orbides.org
GTA V: http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphic...
Supreme Commander: http://www.adriancourreges.com/blog/2015/06/23/supreme-comma...
Deus Ex: http://www.adriancourreges.com/blog/2015/03/10/deus-ex-human...
HN Discussion about GTA V: https://news.ycombinator.com/item?id=10492876
The description doesn't give a lot of detail about the algorithm or its issues. The main problems to be aware of with Z-buffering are Z-fighting and the lack of support for transparency, neither of which are demonstrated. Here are a couple of links that go into a bit more detail:
I like this post, among other things, it's a nice demonstration of the crazy amount of work your graphics card is doing to display a frame of your game. And it took some work and was put together with love.
But if you're going to call one single thing "the core algorithm of 3d", then yeah I'd have to second this one, perspective projection might be it - perspective is what makes 3d look 3d, you can do it without solid surfaces, and the math for perspective was developed long before computers with z-buffers existed.
I will totally grant that depth testing is the core algorithm of z-buffering, and iterating over triangles is the core algorithm of rendering triangle meshes. ;)
I would say long before computers existed. Perspective projection was the key algorithm of renaissance art!
Funny story though, speaking of renaissance art- I was doing research for my Master's thesis on computer graphics, and got direct access to several books from the 1700s that outlined the geometry of perspective projection as well as the geometry of shadows. (My thesis was about rendering shadows.) They were hand-written tomes, with very ornate covers and bindings and hand-drawn diagrams. The books weren't allowed to leave, but they had a special reading room for them, with archive-safe lead weights to hold the pages down so I wouldn't spread my damaging finger oils everywhere. I was taking some digital photos, and at one point I forgot about the lead weights and turned the page. It tore a little bit, and I was completely mortified!
Sorry, history!
This is old now, and modern techniques have mostly surpassed it, but the basic idea was to combine single-sample ray casting for finding occluders probabilistically with an image-plane flood-fill using analytic methods to render the shadows. It's a way to only pay for accurate shadow calculations where shadows actually exist, and skip the shadow calculations in all the un-occluded areas.
Though I'm having second thoughts about calling perspective projection the most basic part, since most of my work happens from an orthographic camera. Let's call that a perspective projection from a camera at infinity and it all works out.
At any rate, mapping points in world space to points in screen space and then drawing lines between them is a pretty clever system, and the new software and hardware we've added since then is so incredible that it's hard to comprehend sometimes.
Of course, in practice the rasterization happens in terms of larger tiles that contain many 2x2 pixel quads, and many quads are shaded in parallel, with the shader executing in lockstep for all pixels simultaneously. But that's an optimization that can be ignored for exposition, unlike the 2x2 quads.
Z-buffer is a very clever way to draw shapes. The only other way used practically is ray-tracing, where you cast rays through pixels on the screen and see where they intersect with the surface. Z-buffer reverses it - instead of casting rays towards surface we project set points on the surface (vertices) onto the screen. Even though it's asymptotically O(n) vs ray tracing's O(log n), practically it's very fast. The vast majority of CG, from movies to video games relies on this algorithm and I don't know what could be more important. All the stuff listed in other comments: texture mapping, texture mapping, shaders, perspective projection etc are specific algorithms, which don't deal with the shape drawing directly and not used everywhere.
I wanted to visualize the part that is at the very base - the scanline Z-buffer rendering. The foundation of the pyramid of complications that is the mainline 3D rendering.
Ok, we replaced that phrase with "Z-buffering" above.
http://threejs.org/examples/webgl_camera_logarithmicdepthbuf...
Hopefully, you can turn down the DOSBOX CPU budget low enough to see the software rasterizer in action.
This guys did videos of Doom rendering pixel-by-pixel http://fabiensanglard.net/doomIphone/doomClassicRenderer.php But, he didn't do the same for Quake. That's the best I can do for ya.
I wonder, how much computational power (measured in CPU/GPU cycles) is used all over the world for animations/games.
Computers have greatly changed our lives and our perspectives too.
This is not directly exposed in any common API, although Vulkan's renderpasses are intended to help write applications that behave efficiently on tiling renderers (as this kind of GPU is often called).
This isn't exposed to the programmer directly (Vulkan's multi pass API is related) but it has performance characteristics that we engine programmers need to be aware of.
The nice thing, is that this timescope comes with its own visualizer. Other processes have no such luck, it would be interesting to use machine learning to create abstract structured visualizations from the evolution of a process so that one needn't hand code them.
The rectangle algorithm of redraw-updating windows and widgets is quite a curious beast.
However, it didn't feel right and reminded too much of broken graphics card drivers...
It's not exactly millions at once...
Am I being instructed here about the matrix math that creates the perspective illusion on a 2d plane? Not really. All I'm seeing is a bunch of triangles creating a scene. This is not going to instruct a beginner about the principles of the z-buffer in any way that I can see. That requires linear algebra. Unfortunately. No shortcut.
This is a visualization. If you already know how it works, so what? Now you have a visualization of it that isn't confined to your brain.