Building a Wolf 3D-Style Engine in PlayBASIC with Affine-Textured Polygons

March 31, 2025

 

Building a Wolf 3D-Style Engine in PlayBASIC with Affine-Textured Polygons

The idea behind this project was simple: Could I recreate a Wolfenstein 3D-style engine in PlayBASIC while maintaining good perspective but using affine texture-mapped polygons instead of traditional raycasting?

Floors and Ceilings: Subdivision for Perspective

Classic Wolfenstein 3D engines rely on raycasting, but I wanted to explore using polygons. This introduced two key challenges: rendering walls and handling floors/ceilings. I tackled floors first by subdividing floor tiles near the camera, ensuring that closer surfaces were represented with a denser set of polygons. This approach worked well, maintaining an accurate perspective without excessive computational overhead.

Walls: Adaptive Subdivision

I applied the same technique to walls, subdividing them based on their distance from the camera. Surfaces closer to the viewer were represented with more polygons, while those farther away used fewer. This adaptive approach preserved scene perspective while optimizing performance.

Ensuring Proper Polygon Order

A major challenge with polygon-based rendering is ensuring proper drawing order. Since walls, floors, and ceilings are drawn as independent polygons, z-fighting (incorrect layering of polygons) can be an issue. To address this, I implemented a two-pass rendering system:

  1. 1. First, floors and ceilings are drawn.
  2. 2. Then, walls are rendered on top.

This method prevents z-popping artifacts commonly seen in painters’ algorithms and produces a visually appealing scene.


Enhancing the Classic Wolf 3D Look: Adding Light Mapping

To push beyond the classic Wolfenstein 3D aesthetic, I added a light mapping pass. Implementing this in PlayBASIC required rendering the scene twice—essentially brute force—but the cost was only around a 20% performance hit. The visual improvement, however, was well worth it.

The process involved:

  1. 1. Drawing the texture-mapped scene.
  2. 2. Overlaying a Gouraud-shaded version of each triangle, where each pixel’s color was alpha-blended with the background.

This resulted in a real-time light-mapped scene with a Doom-like atmosphere, enhancing immersion and depth.


Pushing Further: 3D Polygonal Characters Instead of Sprites

A long-standing idea I wanted to explore was replacing traditional 2D sprites with 3D polygon-based characters. This concept originated from my work on a rendering engine called "Reality" for Amiga computers back in 1995, which aimed to integrate both sprites and 3D objects within a scene.

Implementing 3D Objects

To bring this concept into PlayBASIC’s Wolf 3D engine, I needed a way to load and render 3D models. I chose the DirectX ASCII format due to its simplicity. The loader extracted three key components:

  • Vertex data (point locations)
  • UV data (texture mapping coordinates)
  • Face data (which vertices form polygons)
  • Fortunately, I had already written a PlayBASIC loader for this format years ago. With minor modifications, I incorporated it into the project and built a simple object library for dynamic 3D models within the scene.

    Sorting and Rendering 3D Objects

    Rendering 3D models in a PlayBASIC-based engine required an efficient way to order polygons. Rather than manually sorting faces, I leveraged PlayBASIC’s built-in 2D camera system. Each face was assigned an average depth value (Z-depth), and the engine used the camera’s sorting system to manage rendering order. This approach avoided the need for a costly manual sort, maintaining decent perspective despite the lack of true z-buffering.

    The final result was impressive: a Wolfenstein 3D-inspired environment with fully textured, light-mapped walls and floors—now featuring real 3D characters and objects.


    Future Optimizations: Reducing Overdraw with a Portal System

    One of the biggest challenges in 3D rendering is overdraw—when objects outside the visible scene are still processed and rendered. While the engine is fast enough to handle this, unnecessary rendering wastes performance.

    To optimize, I am experimenting with a portal-based rendering system. This system:

  • Connects open areas (portals) within the game world.
  • Checks which portals are visible from the camera’s current position.
  • Recursively determines visibility, ensuring only necessary polygons are processed.
  • This technique should significantly improve rendering efficiency without sacrificing visual fidelity. However, that’s a topic for a future update!


    Get the PlayBASIC Source Code

    You can download the full PlayBASIC source code for this project from our forums. Stay tuned for more updates as I refine the engine and explore new rendering techniques!

  • Yet Another Wolfenstein 3D Demo (Texture Mapped Floors & Ceiling)



  • Reality: The Lost Amiga 3D Engine

    March 30, 2025

     

    Reality: The Lost Amiga 3D Engine

    What Is Reality?

    Reality was the name of our Wolfenstein 3D-style game engine, which became an umbrella term for anything related to that pursuit. The project aimed to create a fast and efficient first-person engine on a near-stock Amiga 1200 (020+FastRAM) in the mid-1990s. This archive contains the last known remaining compiled executables from my various attempts to achieve reasonable performance on the platform.

    Originally, the Reality project was most active between 1994 and 1995. Apart from a few screenshots shared with close friends, it was never publicly released. The executables included here represent alpha-stage software—functional but far from stable. While they take over the system in as OS-friendly a manner as I knew at the time, modern systems may not handle them well.



    About the Demos

    Reality.exe - Ray Casting Experiment

    This was the initial test of the engine, developed sometime in late 1993 or early 1994. The first major challenge was the chunky-to-planar (C2P) problem, where my initial attempts using unrolled bit sets failed spectacularly. While this approach might have worked for particle effects, it was a disaster for general-purpose rendering. However, after several iterations, I moved on to a bit-parallel rotation solution, which significantly improved performance.

    This is the only version of Reality that employs a true ray-casting method. The scene is constructed by casting rays outward from the camera’s field of view, step by step, checking for wall collisions. Each map pixel represents a vertical wall strip, likely stored as 8-bit data, allowing for 256 unique wall textures.

    Color depth was either 16 or 64 colors, which struck a balance between visual quality and conversion speed. This version laid the foundation for later advancements.


    Map.exe - 64-Color 2D Polygon Walls

    As development progressed, I re-evaluated the engine’s structure and opted for a different approach. Instead of a traditional grid-based map, I structured levels as a grid of evenly spaced vertices, where walls were formed by linking vertex pairs. This allowed for non-orthogonal walls and greater flexibility in map design.

    Rendering involved rotating and projecting the sector vertices, which determined floor and ceiling heights. The scene was then processed polygon-by-polygon. For each wall, I interpolated across its top and bottom, computing its Z-depth and texture U-values. Instead of rendering strips immediately, the engine stored them in a Z-buffer, ensuring proper visibility sorting.

    A unique optimization was that textures were stored rotated in memory, enabling rapid texel fetching using a simple 8-bit V-offset.


    Project Reality - 256-Color Rendering & 3D Objects

    By early 1994, the gaming world was in the grip of DOOM fever, and we ambitiously aimed to push Reality further. As Commodore's decline loomed, we set our sights on creating something akin to Blake Stone, but with even more complex environments and polygonal objects.

    This demo showcases the most advanced features we implemented:

  • 256-color rendering
  • Textured walls with transparency support
  • Depth-based lighting effects
  • Early support for floors & ceilings
  • Multiple rendering modes
  • Initial 3D polygon rendering
  • For polygonal objects, we experimented with a method where triangles were clipped against the depth buffer. The goal was to calculate the screen-space width of an object, scan across the depth buffer, and determine the visible clipping edges. This technique would have allowed objects to be properly occluded by walls while enabling partial visibility. While not perfect, it was an innovative approach at the time.

    Unfortunately, time and talent ran out. By the time we reached this stage, the Amiga community had already embraced Fears, Gloom, Breathless, and Alien Breed 3D. The dream of completing Reality faded, but looking back, I still wish I had been able to bring my full vision to life on screen.


    System Requirements

  • System: Amiga 1200 / Amiga 4000
  • Processor: 68020 or higher
  • Video: AGA chipset
  • RAM: 2MB + 2MB FastRAM
  • Sound: Not required

  • Final Thoughts

    Reality remains a fascinating relic of my early game development journey. While it never reached a finished state, it reflects the passion and creativity that fueled many indie Amiga developers during the 1990s. This archive preserves those efforts—flawed but ambitious, a glimpse into what could have been.

    Links:

  • Download Reality 3D Tech Demos(Amiga)

  • Twarlex: The Musician Behind the Code

    March 02, 2025

     

    Twarlex: The Musician Behind the Code

    While Twarlex is well known for his contributions to PlayBASIC, particularly the IDE, he is also an accomplished musician. Blending elements of pop, rock, and electronic music, Twarlex has created a unique sound that resonates with fans across genres.

    Early Musical Journey

    Twarlex’s passion for music runs deep, and his journey as a musician began alongside his work in programming. His early influences range from classic rock to modern electronic and experimental sounds, shaping his signature style that combines melodic hooks, deep storytelling, and intricate production.

    Notable Releases

    In 2017, Twarlex released his debut album, Alien Pirate, which introduced his eclectic sound to a wider audience. This was followed by Beware of the Leopard in 2019, further refining his fusion of electronic and organic instrumentation. Some of his notable tracks include:

  • “Dance Around the Fire” – A high-energy track that fuses synthwave elements with rock influences.
  • “Damaged Dream Mended” – A reflective piece exploring themes of resilience and transformation.
  • “F.U.B.A.R.” (feat. Nekro G) – A collaboration that blends rap and electronic production into a powerful anthem.
  • Collaborations and Influence

    Twarlex has worked with several artists, expanding his sound and reach. Collaborations include:

  • Kelly Bell on “The More You Live - Let Go”, a reimagining of a classic hit.
  • Sara Savic on “Time”, an emotive electronic ballad.
  • His music explores a range of emotions and themes, from futuristic storytelling to deeply personal reflections.

    A True Creative Force

    Whether through coding or composing, Twarlex brings innovation, passion, and creativity to everything he does. His ability to balance both programming and music is a testament to his artistic versatility and technical skill.

    For more on his music, check out his official website: twarl.xyz


    Twarlex isn’t just a coder or a musician—he’s an artist who brings worlds to life, whether in sound or software.





    Beware Of The Leopard - https://twarl.xyz/


    Twarlex and the Evolution of the PlayBASIC IDE

    When we set out to create PlayBASIC, one of our biggest priorities was making it accessible to new programmers. A powerful yet simple development environment was crucial, and that’s where Twarlex played a pivotal role.

    A Lean and Mean IDE

    In the early days of PlayBASIC’s development (circa 2003/04), Twarlex took over the development of the PlayBASIC IDE. His goal was clear—build a lean, efficient, and easy-to-use programming environment that would make PlayBASIC approachable for beginners. And that’s exactly what he delivered.

    Unlike bloated development environments of the time, the PlayBASIC IDE focused on providing a streamlined interface with essential tools for writing, testing, and debugging PlayBASIC programs. This approach made it easy for newcomers to dive into coding without getting overwhelmed.

    Expanding with Plugins

    Over the years, the IDE evolved alongside PlayBASIC. We built numerous plugins to extend its capabilities, enhancing features like code editing, debugging, and project management. These tools made PlayBASIC a more flexible and robust platform while keeping its core philosophy intact—simplicity and ease of use.

    An Integral Part of PlayBASIC’s Legacy

    Twarlex’s work on the IDE was more than just a technical contribution; it helped define how new programmers interacted with PlayBASIC. His dedication ensured that learning to code in PlayBASIC was an intuitive and enjoyable experience, solidifying its place as a beginner-friendly language for game development.

    His contributions remain an essential part of PlayBASIC’s history, and we’re incredibly grateful for his work in shaping the IDE that so many programmers have used over the years.


    If you’ve ever written a program in PlayBASIC, chances are you’ve benefited from Twarlex’s efforts. Let’s take a moment to appreciate the impact he had on making PlayBASIC what it is today!



    Twarlex- Way Too Soon (official lyric video)