Log In  

Cart [#13694#] | Code | 2015-09-04 | No License | Embed
23

Simple ray-caster experiment.

It's not perfect, but it's kinda working and I hope it can serve as starting point for some awesome 3D games - especially I am thinking about some cool dungeon/rpg, that would be awesome!

Controls: arrows to move

Update 1.1:

  • added fish-eye effect reduction
  • added dynamic quality settings (when camera moves, quality is lowered)
  • draw distance, step & quality setting can be adjusted in code

Older versions:

Cart [#13194#] | Code | 2015-08-27 | No License | Embed
23

Cart [#13203#] | Code | 2015-08-27 | No License | Embed
23

P#13195 2015-08-27 11:05 ( Edited 2018-02-21 20:40)

:: J

Looks great! Would love to see it turn into a real game. Not enough Pico-8 RPGs :D

Looks like you have a little bit of fisheye going on (which might be intentional, it looks neat). I don't know if you've seen this picture, but it was helpful for me in understanding why that happens.

P#13197 2015-08-27 11:41 ( Edited 2015-08-27 15:41)

Cool. How about making Wolf3d-like fps game? Or Faceball 2000?

P#13198 2015-08-27 11:59 ( Edited 2015-08-27 15:59)
:: AfBu

Thanks J, fish-eye is not intentional - i tried to remove it, but was not yet successful, even that I have seen the image :) I will try to take look at it later, for now I thought it doesn't seem too big deal so I published without correction.

P#13201 2015-08-27 12:15 ( Edited 2015-08-27 16:15)
:: AfBu

Ok, I have made some investigation and found out that reason why fish-eye reduction was not successful - I used 1px step for wall detection and that is way too high, but when I lowered step size, rendering eats too much cpu, so I added dynamic quality settings and few other improvements. Let me know what you think of v1.1 ;o)

P#13205 2015-08-27 13:33 ( Edited 2015-08-27 17:33)
:: Rhys

Why don't you make the step size start small and increase with distance? The stuff at a distance looks fine with the less accurate steps.

Past the red line step size 1 (the fast one) or greater seems OK. Not sure what kind of function you'd want to use for the scaling though.

P#13210 2015-08-27 18:54 ( Edited 2015-08-27 22:54)

This is extremely cute! It'd be really fun to just make a bunch of different spaces you can poke around in with something like this.

P#13211 2015-08-27 19:05 ( Edited 2015-08-27 23:05)
:: AfBu

Currently I am using step size 0.1 up to distance 32, then I switch to 1. This is still pretty heavy for pico's cpu, so I will test continuous step increase with distance. I will post update when this is done. Thank you for your advice, I am still pretty new to pico and raycasting ;o)

Ps: I am using built-in sspr for scaling textures.

P#13212 2015-08-27 19:09 ( Edited 2015-08-27 23:09)
:: AfBu

@lulublululu Go ahead! Download cartridge, modify it and make something fun! If you just want to make some textures and create map with them it's super easy, no changes in code are needed, everything can be done using sprite and map editor.

I am really looking forward if someone will use this as template to their own games and experiments!

Ps: I am currently working on a dungeon/rpg game based on this, with slightly enhanced version of this engine (16x16 textures, 8x16 sprites, etc.)

P#13214 2015-08-27 19:23 ( Edited 2015-08-27 23:23)

I want to see a replica of the old 3D maze screensaver included with windows 98. I could watch that for hours.

P#13567 2015-09-02 13:22 ( Edited 2015-09-02 17:22)
:: AfBu

@UrbanMonk: Impressive idea, will look into that :D I always wondered if there is a way how to actually play it :D

P#13569 2015-09-02 13:46 ( Edited 2015-09-02 17:46)

Hey @AfBu, Trying to work on making a little something out of this. Though the actual rendering code is pretty greek to me so I was wondering why it only renders 16 textures? If you try to use a tile index 16 or higher it renders it as black. Any help?

P#13603 2015-09-03 04:24 ( Edited 2015-09-03 08:24)

I have an idea for a game that would use this engine but since I don't know how to work with raycasters, I'd like following two features to be added (gameplay would be on me though):

  • Add 16x16 textures. Make so first page of spritesheet would contain 8x8 sprites used for setting up level in map editor, but second page would contain 2x2 sprites that would contain actual textures.

  • Make "fisheye" effect even bigger than it already is, what I'm about to make depends on higher fish eye effect.

//edit: I mean something like this (gimp mockup):

P#13630 2015-09-03 16:15 ( Edited 2015-09-03 20:31)

Somehow, the fish-eye effect observed in version 1.1 (only when you're moving) looks different from the fish-eye effect in version 1.0.

P#13651 2015-09-03 20:47 ( Edited 2015-09-04 00:47)

@AfBu: If you make it playable that'd be awesome too! I think having it play itself would be far more impressive though.

P#13685 2015-09-04 11:00 ( Edited 2015-09-04 15:00)
:: AfBu

@Cabledragon, yes, it's because I was lazy :) Just find line 124 (sspr command is there), remove it and add those lines instead:

cy = flr(c / 16)
cx = c - cy * 16
sspr(cx*8+t,cy*8,1,8, 126-i*2,64-d/2,2,d)

this will do the trick and you can use any sprite you want, I updated the cart to reflect that ;)

P#13693 2015-09-04 18:33 ( Edited 2015-09-04 22:44)
:: AfBu

@UrbanMonk playable version is on the way ;)

Cart [#13244#] | Code | 2015-08-28 | No License | Embed
13

P#13695 2015-09-04 18:38 ( Edited 2015-09-04 22:38)

Afbu, could you do the changes I've asked for?

P#13701 2015-09-05 02:30 ( Edited 2015-09-05 06:30)
:: AfBu

@darkhog 16x16 textures are already in the dungeon demo, so look it up in the code, I will not add that to experiment, it's meant to be as simple as possible to encourage you to play with it and extend it your way.

I am trying to remove fish-eye so I am not adding more, see in the source how fish-eye effect is reduced there, you can use opposite approach to make it bigger but remember that this effect affects only vertical lines, it's not like on your picture where both veritcal and horizontal position of pixels are affected.
As @J mentioned this picture should help you understand how it's done.

P#13712 2015-09-05 08:28 ( Edited 2015-09-05 12:28)

Fish-eye can be "removed" by doing the projection through a plane vector.

\
-----^----> camera vector
  \  | direction vector
   \ | 
ray \|
     * origin

In place of casting the rays and trying to offset the ray length since the projection will always be correct with regards to the viewing origin.

A great source that explains the approach: lodev - Raycasting

P#15009 2015-10-05 14:56 ( Edited 2015-10-05 18:57)
:: kozie

Wow! Awesome stuff there! I like the idea of reducing quality while moving.

Keep up the good work ( ^ ^)b

Cheers!

P#15082 2015-10-07 07:08 ( Edited 2015-10-07 11:08)

pls, somebody make a game like doom with this.

P#49465 2018-02-20 18:00 ( Edited 2018-02-20 23:00)

8-bit Skyrim!

P#49490 2018-02-21 15:40 ( Edited 2018-02-21 20:40)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-11-21 10:25 | 0.058s | 4194k | Q:97