Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is the kind of 3d engines I was making as a teen. The way it works is that you iterate over x screen-space, get a "ray"/"slice", then you iterate over z camera-space (goes inward) using that ray. From there, you have what it takes to sample a heightmap. Draw a vertical line. There is plenty of room for optimizations and it's very good for learning to code.


It seems like this code would be fairly easy to add to a simple 2.5D raycaster (either a cube variant like the old Wolfenstein, or something more advanced like Doom/Doom 2) to give some variation (or more "natural" stuff) for indoor/"outdoor" scenes.

It really isn't much different from floor/ceiling rendering code.

Something else I was thinking was if you flipped it upside down (and kept the current view), you could render "caves"; heck, it probably wouldn't take much effort to mod the current code to achieve this.

Somewhere I have code to a voxel rendering engine someone made in QBasic; they posted a demo of it on youtube, but never posted the code - I got in contact with them, and they sent me a copy of the code. The interesting thing they did, though, was add voxel rendering of "buildings" - you could easily go inside spaces and outside, all voxel rendered, and it was fast (for QB code).

Note - I know about Ken Silverman's voxel and other 3D engines he did in QB (and posted his old code), prior to Duke Nukem 3D - but this wasn't that code; it was completely original...

Anyhow - this is a great little "3D" engine; I'm glad it was posted!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: