Jump to content

Photo

1 FPS - Low Res - Slow as mud Raycaster 'Engine'


18 replies to this topic

#1 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Tue Sep 1, 2015 9:51 AM

Hi all,

 

I've ported this engine to Android before and it went well. ahhhhh modern tech where you don't have to care.....

 

I thought for a laugh I would port it to rb+.   Cause I hate myself like that   lmao

 

Managed to get it from 0.25 FPS up to a full 1 FPS before giving up.  The main gain was switching from real time COS/SIN functions to lookup tables to store the values the engine needs.  Still not enough though.

 

If anyone fancies the challenge, see if you can make this faster  lololololol

 
Perhaps removing all the floats might be a good start?  who knows...

 

I already reduced the 320x240 res down to 80x240 (using 4px wide sprites) so it looks nice and blocky.

 

It's based off the widely available java source out on the interwebz - but i've included it in the project for completeness.

 

DPad to Move like some kind of swamp thing.....

 

I've not even bothered testing on a real Jag for obvious reasons.

 

Maybe I should put my bank holidays to better use in the future (didn't take long though i'm happy to say)   :thumbsup:

 

EDIT: Although I have also ported this one before (non-textured version) to another platform too and the code looks like it might be more efficient. Damn, that's my next holiday gone.....

Attached Files


Edited by Sporadic, Tue Sep 1, 2015 10:16 AM.


#2 ggn OFFLINE  

ggn

    Stargunner

  • 1,210 posts
  • Location:Athens, Greece

Posted Tue Sep 1, 2015 11:29 AM

If you could only see the smirk in my face right now :D.

 

Now, make a 0.5fps doom 3 port and you'll win the internets ;).

 

(will add to the ever growing rb+ examples if it's ok with you)

 

[EDIT] Changing the sine/cosine tables to 16.16 fixed point doesn't seem too impossible either - just needs a bit of time and motivation!


Edited by ggn, Tue Sep 1, 2015 11:31 AM.


#3 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Tue Sep 1, 2015 11:33 AM

If you could only see the smirk in my face right now :D.

 

Now, make a 0.5fps doom 3 port and you'll win the internets ;).

 

(will add to the ever growing rb+ examples if it's ok with you)

Hahaha do what you will with it. Not sure its of much use to anyone except an example of what not to do ;)

 

Would be great to get something like that moving well. The other one I linked to was actually better code so I may try porting that one day.....


  • ggn likes this

#4 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Tue Sep 1, 2015 12:56 PM

Still not sure how much it will help the speed because to draw the screen it loops 80 times (for each ray) and for each of those it steps forward until a wall is found.

 

That stepping loop may be quicker on the other code I linked to as it only steps on the joins of the array grid.

 

That looping and stepping is a killer :)


Edited by Sporadic, Tue Sep 1, 2015 12:58 PM.


#5 sh3-rg OFFLINE  

sh3-rg

    River Patroller

  • 3,267 posts
  • doge + tie = dothemath
  • Location:BOLTON, England

Posted Tue Sep 1, 2015 1:07 PM

I'm away for a few days with only my lappy and VJ for company. Will deffo check this out, thanks again for sharing!



#6 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Tue Sep 1, 2015 1:13 PM


I'm away for a few days with only my lappy and VJ for company. Will deffo check this out, thanks again for sharing!

Excellent  :thumbsup:


  • ggn likes this

#7 GroovyBee OFFLINE  

GroovyBee

    Games Developer

  • 9,736 posts
  • Busy bee!
  • Location:North, England

Posted Tue Sep 1, 2015 1:41 PM

Get rid of the floating point and it'll fly! :lol:

#8 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Tue Sep 1, 2015 1:50 PM

If I port the other method, I'll definately post that too.

 

Perhaps I need to get fluent in fixed point math. Not had an excuse to bother in the past :)



#9 ggn OFFLINE  

ggn

    Stargunner

  • 1,210 posts
  • Location:Athens, Greece

Posted Tue Sep 1, 2015 2:30 PM

If I port the other method, I'll definately post that too.

 

Perhaps I need to get fluent in fixed point math. Not had an excuse to bother in the past :)

 

Fixed point arithmetic is the spawn of Satan!

 

 

...but you learn to live with it :P.



#10 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Wed Sep 2, 2015 7:41 AM

Here is the second RayCaster example I said i'd do.  This is based off Lode's tutorial found here.

 

To me this looks faster overall (more stable with whatever is on screen) - doesn't slow down when long corridors appear.

 

It's still slow but it might sometimes reach a whole 2fps  lol.

 

I haven't bothered removing the floats yet and changing things to fixed point.  To start with I just wanted to get it working and remove any functions for quick wins.  Hence the precomputed COS and SIN value variables.  Unfortunately the function that's left is a SQRT function, which are slow as shit, plus its a float version.  I tried a couple of other implementations but they didn't look right so left as is for now.

 

Anyway, this one looks a bit better, it has different coloured walls depending on the face/side of the wall.

 

DPAD to move like swamp things slightly younger brother...

 

Still not bothered testing on real hardware.  I don't have a fire extinguisher handy.

Attached Files



#11 ggn OFFLINE  

ggn

    Stargunner

  • 1,210 posts
  • Location:Athens, Greece

Posted Wed Sep 2, 2015 11:43 AM

MOAR



#12 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Wed Sep 2, 2015 12:40 PM

As long as the framerate keeps doubling, we're golden



#13 Shamus OFFLINE  

Shamus

    Dragonstomper

  • 604 posts
  • Moo, er, Roar!
  • Location:Ur-th

Posted Wed Sep 2, 2015 12:57 PM

Good luck with that. :D



#14 Zerosquare OFFLINE  

Zerosquare

    River Patroller

  • 2,346 posts
  • Location:France

Posted Wed Sep 2, 2015 4:16 PM

I'm sure he'll just use VJ and buy faster hardware until it runs at 60 fps :P



#15 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Thu Sep 3, 2015 10:22 AM

As a learning exercise, the fixed point conversion has started (using the second project).

 

I don't expect it to make much difference but it's a good example to learn with.


  • ggn likes this

#16 ggn OFFLINE  

ggn

    Stargunner

  • 1,210 posts
  • Location:Athens, Greece

Posted Thu Sep 3, 2015 11:35 PM

Well it'll be interesting if the framerate can be bumped up to 2fps :)



#17 TXG/MNX OFFLINE  

TXG/MNX

    River Patroller

  • 3,619 posts

Posted Sat Sep 5, 2015 6:17 AM

When the float math would be replaced by fixed point and maybe pre-calculated tables it could reach 2fps or more...

Sent from UMI hammer with Tapatalk

#18 Sporadic OFFLINE  

Sporadic

    Moonsweeper

  • Topic Starter
  • 415 posts
  • Probably RB+ing
  • Location:UK

Posted Thu Nov 3, 2016 8:50 AM

Been wanting to try this for a while and had time today - made for a good side project distraction.

 

Changes;

 

- Have changed all math to fixed point and added more precalcs.

- (Offline) randomly generated maze.

- Shaded Walls

- A or C to Strafe

- 0 to disable floor

 

The upshot of the fixed point math?  I think the FPS is now in double figures!  Not bad for BASIC  ;-)

 

There's other things i'd like to try with this, but i'd best get back to finishing other stuff first.

 

Binary attached for your consumption....

 

 

Attached File  Raycaster.png   3.94KB   3 downloads

Attached Files



#19 CyranoJ OFFLINE  

CyranoJ

    River Patroller

  • 4,712 posts
  • RAPTOR in LOCAL
  • Location:Adelaide, SA

Posted Thu Nov 3, 2016 10:03 AM

Nice work!

 

And a binary as well :)





Reply to this topic



  


0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users