Jump to content

Photo

Raycasting


81 replies to this topic

#1 Asmusr OFFLINE  

Asmusr

    River Patroller

  • 2,496 posts
  • Location:Denmark

Posted Mon Apr 10, 2017 2:43 PM

I have been looking into how to implement a raycaster for the F18A GPU since Omega suggested this again the other day. It's definitely something the F18A has the power to do, but as far as I can tell the problem is precision.

 

My starting point was this tutorial, but I find it difficult to fit the calculations into 16 bit. I have implemented the algorithm in Java, and it's working fine with floating point numbers, but when try to change the calculations to use fixed point 16-bit numbers (with 32-bit support for mul and div) I'm getting overflows all the time.

 

I also have the source code for the Wolfie3D raycaster that The Mole made in c. This is working with angles instead of vectors which might be better when you don't have so many bits available. But even though the code is commented I'm not sure how the code is working. Is it something you made yourself is it based on some other work that might have a tutorial?

 

I also tried to make my own algorithm, but, of course, I'm running into all the issues that other people have solved before.

 

So, do you have good references to 8/16-bit code for raycasting?

 

Thanks,

Rasmus



#2 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Mon Apr 10, 2017 11:33 PM

This looks interesting: http://retro-system.com/raycast2.htm



#3 TheMole ONLINE  

TheMole

    Dragonstomper

  • 762 posts
  • Location:Belgium

Posted Tue Apr 11, 2017 8:57 AM

Wolfie still has a bunch of rounding errors, most noticeable when the occasional gap between wall segments is visible (on corners), and I never really got around to fixing those. One avenue I went down for both speed an accuracy is precalculating look-up tables for all of the trig math.

 

I'm having a hard time remembering exactly, but I believe I mainly relied on two tutorials while developing wolfie. One of them definitely was Lode's raycasting tutorial (the one you linked to in the original post), the other was the almost equally ubiquitous permadi tutorial: http://permadi.com/1...le-of-contents/

 

Your second example definitely seems to have the same heritage as wolfie: the algorithm is, at it's core, identical in structure.


Edited by TheMole, Tue Apr 11, 2017 8:59 AM.


#4 artrag OFFLINE  

artrag

    Dragonstomper

  • 716 posts

Posted Tue Apr 11, 2017 3:16 PM

My z80 and c sources are here:

https://sites.google...stmsx/msx2-doom

Take the rar from February 2012

but I've started porting to fix point math Lode's Tutorial

This is a video of the result on an msx turbo r


Edited by artrag, Tue Apr 11, 2017 3:17 PM.


#5 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Tue Apr 11, 2017 3:39 PM

My z80 and c sources are here:

https://sites.google...stmsx/msx2-doom

Take the rar from February 2012

but I've started porting to fix point math Lode's Tutorial

 

That's pretty cool.



#6 --- Ω --- OFFLINE  

--- Ω ---

    TI-Runner

  • 10,731 posts

Posted Tue Apr 11, 2017 3:52 PM

Looks like the old DOS game for the PC called Blake Stone: Alien of Gold



#7 artrag OFFLINE  

artrag

    Dragonstomper

  • 716 posts

Posted Wed Apr 12, 2017 2:02 AM

Blake stone does not have lateral and back views for sprites.
My robots have 8 directions of view with multiple frames of animation for walk and standing.
But I ripped and adapted them from another dos game ;)

Edited by artrag, Wed Apr 12, 2017 2:05 AM.


#8 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Sat Apr 15, 2017 5:02 PM

I started by converting Lode's raycaster from c to Java, which I know better. I then wrote a fixed-point library for Java, and made the code run with that. I then went through a lot of pain to make the fixed point calculation work with 16 bits without overflowing too often. I finally converted the Java code to TMS9900/GPU assembly language.

 

It took a lot of debugging, but now I can present this first screen: 

 

Attached File  raycaster.png   3.19KB   1 downloads

 

I only include the code because you cannot move yet, and it's horribly slow - even on the GPU. But I haven't tried to optimize the drawing loop yet. Which is currently done by a call to a procedure using the F18A PIX instruction. I imagine this could be much faster inline.

 

I also want to switch from 256x192 in 4 colors to 128x192 in 16 colors before I try to add textures to the walls. 

 

 

 

Attached Files



#9 LASooner OFFLINE  

LASooner

    Chopper Commander

  • 154 posts

Posted Sat Apr 15, 2017 11:54 PM

ConfusedInformalDorado.gif



#10 artrag OFFLINE  

artrag

    Dragonstomper

  • 716 posts

Posted Sun Apr 16, 2017 12:13 AM

Great work!

#11 gfreige OFFLINE  

gfreige

    Star Raider

  • 75 posts
  • Location:La Plata, Argentina

Posted Mon Apr 17, 2017 7:38 AM

Nice! But... but... if you didn't use raycasting in megademo's Doom part, which witchcraft was invoked? :-o



#12 mizapf ONLINE  

mizapf

    River Patroller

  • 2,623 posts
  • Location:Germany

Posted Mon Apr 17, 2017 8:42 AM

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version. And I remember Blake Stone for getting me really motion sick. Suffered a whole afternoon from it. I don't know why it was so bad with this game, but I get that feeling again when I watch your video. OTOH, I can play Skyrim for hours without any problems.



#13 --- Ω --- OFFLINE  

--- Ω ---

    TI-Runner

  • 10,731 posts

Posted Mon Apr 17, 2017 9:44 AM

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version. 

 

You know, I'm up for a little Blake Stone nostalgia.  I would not mind a bit if you sent a copy of that via a PM my way... in fact I'd be quite appreciative!   :-D   I'm thinking it should run under DOSBOX.



#14 RickyDean OFFLINE  

RickyDean

    Dragonstomper

  • 695 posts

Posted Mon Apr 17, 2017 9:50 AM

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version. And I remember Blake Stone for getting me really motion sick. Suffered a whole afternoon from it. I don't know why it was so bad with this game, but I get that feeling again when I watch your video. OTOH, I can play Skyrim for hours without any problems.

And Duke Nukem, got dizzy a lot. :-D



#15 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Mon Apr 17, 2017 12:18 PM

Nice! But... but... if you didn't use raycasting in megademo's Doom part, which witchcraft was invoked? :-o

 

Raycheating  ;)



#16 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Mon Apr 17, 2017 12:20 PM

 

You know, I'm up for a little Blake Stone nostalgia.  I would not mind a bit if you sent a copy of that via a PM my way... in fact I'd be quite appreciative!   :-D   I'm thinking it should run under DOSBOX.

 

There are lots of abandonware sites where you can download old dos games.



#17 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Thu Apr 20, 2017 2:02 PM

This is beginning to take shape.

 

 

It runs more smoothly on real iron than in the video. It seems to run at 60Hz, but only just.

 

I'm using double buffering for the bitmap, and this takes 12 KiB video RAM for half a screen. The 4 bitmaps in 32x32 16 colors take another 2 KiB, so there's only 4 KiB left for the program, the map, and everything else. I don't know if this would be enough for a game.

 

 

 

 

 

 

Attached Files



#18 --- Ω --- OFFLINE  

--- Ω ---

    TI-Runner

  • 10,731 posts

Posted Thu Apr 20, 2017 2:11 PM

This is beginning to take shape.

 

 

It runs more smoothly on real iron than in the video. It seems to run at 60Hz, but only just.

 

I'm using double buffering for the bitmap, and this takes 12 KiB video RAM for half a screen. The 4 bitmaps in 32x32 16 colors take another 2 KiB, so there's only 4 KiB left for the program, the map, and everything else. I don't know if this would be enough for a game.

 

 

  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o

Even a PARTIAL Castle Wolfenstein would be a major mind-blower on the TI!!!

:-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o

 

Only 4K left for the program eh?  If it's not possible, would you have any objections to SAMS use?



#19 senior_falcon OFFLINE  

senior_falcon

    Dragonstomper

  • 960 posts
  • Location:Lansing, NY, USA

Posted Thu Apr 20, 2017 2:12 PM

As usual, you never cease to amaze me Rasmus!



#20 Asmusr OFFLINE  

Asmusr

    River Patroller

  • Topic Starter
  • 2,496 posts
  • Location:Denmark

Posted Thu Apr 20, 2017 2:14 PM

Only 4K left for the program eh?  If it's not possible, would you have any objections to SAMS & F18A use?

 

SAMS is of no use here, it's video memory I need.



#21 ti99iuc OFFLINE  

ti99iuc

    Stargunner

  • 1,224 posts
  • Location:Italy

Posted Thu Apr 20, 2017 2:16 PM

OH MY GOD RASMUS !   :-o  :-o  :-o  :-o  :-o  :-o  :-o  :-o

 

Incredible to see it on the TI99 for real !



#22 matthew180 OFFLINE  

matthew180

    River Patroller

  • 2,414 posts
  • Location:Castaic, California

Posted Thu Apr 20, 2017 2:29 PM

Well, we can always make the GPU faster... ;-)



#23 Retrospect OFFLINE  

Retrospect

    Dragonstomper

  • 879 posts
  • Location:Wakefield, England

Posted Thu Apr 20, 2017 3:17 PM

This is just nuts.  Things are being done here I didn't think were possible.  Well done Rasmus.   :thumbsup:


Edited by Retrospect, Thu Apr 20, 2017 3:18 PM.


#24 Willsy OFFLINE  

Willsy

    River Patroller

  • 3,038 posts
  • Location:Uzbekistan (no, really!)

Posted Thu Apr 20, 2017 4:25 PM

I didn't think this was possible. Holy sh*t!

#25 Vorticon OFFLINE  

Vorticon

    River Patroller

  • 2,814 posts
  • Location:Eagan, MN, USA

Posted Thu Apr 20, 2017 6:27 PM

 

SAMS is of no use here, it's video memory I need.

 

Could the SAMS be used to store code sections that could be dynamically loaded into VDP RAM kind of like overlays?






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users