Voxel Space

(s-macke.github.io)

99 points | by davikr 3 hours ago ago

17 comments

  • nine_k an hour ago ago

    Technically this is not related to voxels ("volumetric pixels", so to say), which split the 3D space equally along all three axes. This is just a height map, a set of prisms, not entirely unlike a Doom map. Every prism has a regular fixed-size square base.

    For 1992, this was mind-boggling though.

    • cubefox 9 minutes ago ago

      No? Each pixel on a height map corresponds to a column of voxels of the specified height. You could represent the same height data with a fully general octree and it would look exactly the same.

  • a1o 2 hours ago ago

    When this was first posted I made a game with a port of this approach to AGS Engine. Nowadays AGS is much faster since we have improved a lot of things, but this wasn’t the case at the time, so I had to make a few little tricks to make the rendering work well with the engine at the time.

    https://github.com/ericoporto/i_rented_a_boat

  • blaze33 an hour ago ago
  • tdeck 2 hours ago ago

    It's interesting that the color maps seem to have shadows "built in", so that you get a 3D bevel effect from just looking at the color map.

  • mthoms 6 minutes ago ago

    [delayed]

  • Jare an hour ago ago

    [Edit] ah ok they clarify later as a performance enhancement. I think it was pretty integral to the algorithm, but ok.

    Wait why do they say painter's algorithm. Comanche and other such voxel terrain engines went front to back and never had overdraw.

    • s-macke an hour ago ago

      Author here. Yes, it is integral. I chose this approach to first show how to draw it from back to front, because the code is easier to understand this way.

    • swiftcoder an hour ago ago

      Reverse painters algorithm is still painters algorithm. You trade off the cost of a full screen clear before the frame, in return for eliminating overdraw

      • knome an hour ago ago

        You could avoid a full screen clear by using the y-buffer to draw in sky segments after rendering terrain.

        • swiftcoder an hour ago ago

          You still need to have some sort of mask to tell you which pixels have not yet been written this frame

          • knome an hour ago ago

            that's what the y-buffer is that the article mentions in the front-to-back rendering section.

            it tracks how tall each columns write is so you can use it to only write the diff between it and the voxel behind it, skipping writing anything at all if the voxel behind is shorter than the current height.

            So once you're done rendering front-to-back, you've got a y-buffer of highest-writes you can slap your blue sky across from highest-to-screentop on each line, avoiding the need to clear by write the sky to the full screen before starting the render.

            • swiftcoder 10 minutes ago ago

              yes, I guess you can get away with only clearing the y buffer, rather than the whole screen

  • esafak an hour ago ago

    I remember how groundbreaking Comanche was. Now I learned that it was a result of the programmer's experience in the medical industry (CT/MRI scanning): https://en.wikipedia.org/wiki/Voxel_Space

  • taneq 2 hours ago ago

    If you render columns instead of rows you can render near-to-far without a Y-buffer and with zero overdraw. :)

    • nkrisc 32 minutes ago ago

      You just store the last highest Y value as you iterate near to far?

  • TheChaplain 2 hours ago ago

    I really love this kind of articles, so much to learn.