3D Raycast Engine

Show us your works in progress and request feedback

Post » Sun Nov 12, 2017 6:10 pm

Image

After tinkering for two days or so I came up with a first draft of a raycaster engine.

It's nowhere near completed but here you have it, what has been made possible with plugins in GameMaker and Multimedia Fusion can as well be accomplished in Construct 2 (or 3 for that matter). So it's more like a proof of concept right now, but it has some capabilities that already exceed Wolfenstein 3D's raycaster (well, after 25 years... :) )

Current features

- Can render any angle on the z axis with correct perspective
- Renders different textures
- Walls can be of any size (x/y) and angle
- Colored / Tinted textures
- Animated textures
- Raycaster renders pixel-perfect overlaps (the cross on the screen is composed of 2 wall blocks)
- Fog depth rendering of any RGB color and range

Current limitations

- Framerate locked to 30 fps
- 320x180 viewport
- FOV of 60°
- Can't z-buffer transparency... yet
- Fixed wall height to 64px

Planned features (phase 1)

- Rendering floors and ceiling
- Rendering sprites (need to tackle z-buffer rendering, back-to-front)

Planned features (phase 2)

- Enemies
- Decoration Sprites
- Weapons
- Pickups
- If there's enough interest, I'll turn it into a template

Planned features (the far future)

- Z-movements
- different wall, floor & ceiling heights


Bombs away!
Last edited by Colonel Justice on Fri Dec 15, 2017 9:03 pm, edited 2 times in total.
Image
B
20
S
7
G
1
Posts: 127
Reputation: 2,215

Post » Sun Nov 12, 2017 6:41 pm

looks interesting
B
41
S
16
G
7
Posts: 1,779
Reputation: 10,029

Post » Thu Nov 16, 2017 12:51 pm

Cool. Are you working on a plugin or are you doing this with events only?
Follow my progress on Twitter
or in this thread Archer Devlog
B
43
S
18
G
19
Posts: 1,066
Reputation: 14,091

Post » Thu Nov 16, 2017 3:47 pm

Currently it's events only, and therefore the performance is quite sluggish. I must admit that my plugin development skills are limited.
I do this mainly as an excercise and to understand the concept of raycasting.

The main routine uses the following plugins:

LoopIterator
EventBalancer
Paster
Trace

So what it basically does is it does a loop times the horizontal width (in this case 320px = 320 iterations). Within the loop the trace object retrieves angle, distance, texture of the wall etc. for each vertical pixel slice respective to the player's angle, then uses a first 1px wide Paster object to paste the object texture on, then move the Paster to the calculated position on another paster (the viewport), and then finally y-scale the 1px paster accordingly and paste that onto the viewport paster object.

Although I think the math is fast enough, clearly the bottleneck is the pasting on the viewport. So in order to maintain 60fps game logic, I use LoopIterator & EventBalancer to slice the mainloop in to digestable chunks and set it to be completed every 2nd frame (that's why it's 30 fps at the moment).

There's probably a better way to do this, but I still have to figure out on how.
If you want I can clean the capx and post it for you to try.

Best would be maybe to have some sort of interface plugin for the pasting (not doing it in events)

Also there's no floor ceiling pasting as of yet.
What would also have an impact on performance is that it doesn't check z-buffers yet. So in order to render sprites, I would first have to test if the cast ray hit a non-transparent object (wall). If so, render. If not, write the information in a z buffer, then continue until a non transparent object is hit. Then render from back to front according to the z-buffer.
Image
B
20
S
7
G
1
Posts: 127
Reputation: 2,215

Post » Thu Nov 23, 2017 2:54 pm

Consider me hyped :)

Would love to have this as a plugin to make some dungeon crawling happen.
B
16
S
7
Posts: 246
Reputation: 2,094

Post » Tue Dec 12, 2017 12:38 pm

Just a quick heads up,
I improved the performance 200-400%, so it runs at 60 fps with 40% single core CPU workload.
Right now, sprites and z-sorting are getting implemented. As the engine is set up, I'll be scrapping translucent walls.

Also I need to find a way to efficiently implement floor and ceiling casting. As this is doneper-pixel (vs. per stripe as for the walls), it's much more expensive.

I'm planning on releasing a first capx when the sprites are done though.
Image
B
20
S
7
G
1
Posts: 127
Reputation: 2,215

Post » Tue Dec 12, 2017 3:09 pm

Colonel Justice wrote:Just a quick heads up,
I improved the performance 200-400%, so it runs at 60 fps with 40% single core CPU workload.
Right now, sprites and z-sorting are getting implemented. As the engine is set up, I'll be scrapping translucent walls.

Also I need to find a way to efficiently implement floor and ceiling casting. As this is doneper-pixel (vs. per stripe as for the walls), it's much more expensive.

I'm planning on releasing a first capx when the sprites are done though.

Sounds amazing, I'm looking forward to seeing more of this. Keep up the great work!
B
43
S
24
G
21
Posts: 156
Reputation: 14,104

Post » Thu Dec 14, 2017 5:54 pm

Next update

-Sprites are working, sprites have also correct Z height display and depth buffering
-Got depth buffering with walls to work
-Initial HUD layer with weapon display (ripped from zdoom's forums, credit goes to the author)

-Furthermore I designed the initial rendering method from scratch. The drawing now doesn't use paster anymore which alone is a performance boost. The engine now only relies on raycasts and Nobody's seamless effect - and of course some math :P
-Engineered a "primitive" routine to generalize map wall objects. For now we only have rectangles, which still has some overhead, e.g. invisible sides of the rectangle still have to be considered in finding the render candidates. Next roadmap goal is to use multipoint polygons instead. In a later editor, we might be able to draw the map in some Doom / Build engine fashion.

Image

The scene in layout editor:

Image

Stay tuned!

Edit: Fixed broken image links
Image
B
20
S
7
G
1
Posts: 127
Reputation: 2,215

Post » Wed Dec 20, 2017 8:59 pm

Great work! I can't wait for test :)
B
18
S
7
Posts: 45
Reputation: 1,330


Return to Works in Progress/Feedback Requests

Who is online

Users browsing this forum: No registered users and 3 guests