News:

Homing Missile Demo – PlayBASIC (30th March 2025)

Main Menu

Another Wolf 3D Demo

Started by stevmjon, March 11, 2025, 01:15:25 AM

Previous topic - Next topic

stevmjon

been experimenting with a different design of the Wolf 3D engine.
this seems to work fast and the textures look good (perspective wise).

Engine :
> raycasting using DDA (Digital Differential Analysis)
> textures using sub-divided polygons

how this works is to cast a ray using DDA technique which steps across a 2D tile map efficiently. as the ray steps on each tile i then draw the floor & roof texture as a sub-divided polygon. the closer the polygon to the camera the more sub-divisions. each time a polygon is drawn i keep a record to make sure it is not re-drawn by the next ray. these rays are separated by a step value to more efficiently step across the camera view frustum (rather than cast for each screen width pixels).

when a wall is collided with this wall is then calculated, sub-divided and stored in an array. the ray now stops here. this prevents any polygons behind the wall from being drawn. i make a record of each wall to make sure it is not re-drawn by the next ray. after all the floor/roof polygons have finished being drawn, then go through the walls array to draw the walls in z order (furthest - closest order).

i set this to run at 50 fps, and with the floor / roof / walls being drawn there is no slow down of frames, yay.

(press M key) the mini map can be re-sized and turned on/off.
(press T key) the textures can be changed to see straightness of textures and sub-divide levels.

i had fun creating this and will update the engine too.

   stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


  Absolutely Beautiful !!!!!


stevmjon

#2
thanks Kev. i am glad it works too.

i have been thinking up ways to make this fast for ages, lol.
i want to thank Kev & Scott_Bro for their many different demo's on this subject. i combined the different techniques together, so it's a collaboration between us all, lol.

i need to update a few few things in the demo like make the mini map follow the player around, not allow player to walk inside walls, and also streamline the code a bit as there is a lot of repeated code about. i was changing techniques as i was building this until i came up with this one.

   stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#3
Steve's 'Another Wolf 3D demo' 




Summary of the video


The speaker starts by introducing Steve's demo and briefly mentions a map toggle feature before shifting focus to a more significant topic—optimizing rendering using ray casting and portal-based spatial partitioning. The idea is to eliminate unnecessary calculations by defining the game world as a series of interconnected volumes rather than traditional tile-based maps. 

Instead of recalculating visibility for every position, the speaker suggests precomputing or dynamically determining which areas (volumes) are visible from a given location. By treating open spaces between these volumes as "portals," the system can efficiently track which areas need rendering. The approach minimizes overdraw and unnecessary processing by ensuring only visible sections are considered. 

The speaker likens this method to Quake's spatial partitioning but in a simpler form. They propose that level designers manually define portal zones for optimal efficiency. The concept aims to maintain a short list of visible elements at any given time, significantly reducing computational overhead. 

The video concludes with encouragement to explore the idea further and experiment with its implementation.



 Read More

  -->  2D portals Conversation





stevmjon

the thing i like about coding and 3D is there is so many different techniques and ways to do things.

portals is what a lot of games use. i have never tried that before.

i like the ray casting idea but this only really works if the player is looking straight ahead.

anyway, more fun to be had yet.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


Quoteportals is what a lot of games use. i have never tried that before.

   For sure..  Occlusion topics are indeed a fascinating area in both 2d & 3d.  Often it's small changes in approach that make the big differences in performance.   I guess the trick as always with these things, is how do I build a system that's cheap (at runtime), easy to implement into a program that actually eliminates a good percentage of overdraw.  Evening out overall performance.   



stevmjon

this test demo is a slow motion version showing how i draw the screen.

this was a fun exercise to show how the raycasting detects walls and draws floors/roof sub-divided polygons.

the ray draws the floors/roof as it steps over tiles (reads floor/roof tile only once), and when it detects a wall it draws red and stores this in an array for drawing at the end (after sorting array z buffer).

the lighter map lines are when the ray first detects a wall, and the darker map lines are when the ray hits an already stored wall (this ray gets ignored for walls, but still checks floor tiles).

> to speed up frames per second in Init.pba change line 8
> to change map size in Init.pba change line 34

   enjoy stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

Steve's "Another Wolf 3D Demo" – Slow Motion Ray Casting in PlayBASIC


stevmjon

glad you like it Kev.

i thought it looked cool the way it builds the screen & map syncronised.
i like being able to visualise how things work.
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin


  Too true, slow motions are fascinating way to understand algorithms.