Bennu Game Development

English Forums => General => Topic started by: MisterN on August 02, 2011, 03:32:59 AM

Title: Raycasting without .dll's
Post by: MisterN on August 02, 2011, 03:32:59 AM
Exactly what I mean lol. I knew how to raycast back in game maker 4 and some other coding thing (i forget, i think games factory?) I was wondering if it would be possible to do a raycasting of some kind in div/fenix/bennu.
Title: Re: Raycasting without .dll's
Post by: MisterN on August 03, 2011, 04:34:03 PM
bump
Title: Re: Raycasting without .dll's
Post by: josebita on August 03, 2011, 04:53:11 PM
What is raycasting?
Title: Re: Raycasting without .dll's
Post by: gecko on August 03, 2011, 04:58:22 PM
I thought that raycasting was a technique / effect used by 3D render engines to reflect more realistic lights and shadows into objects...

And I have no idea how to do that.
Title: Re: Raycasting without .dll's
Post by: handsource-dyko on August 03, 2011, 05:07:45 PM
Raycasting is the opposite of raytracing. Raytracing is used in professional 3d modelling software, but it is way too slow for use in games wich require "real time" rendering. Raycasting is simpler, faster, but limited in comparision with ray tracing. If you really want realistic images such as required by architectural renderings, you'll have to use raytracing and wait several hours for the result. But in games you need something that can handle 50+ frames/second, so this can be achieved with raycasting.
Title: Re: Raycasting without .dll's
Post by: MisterN on August 03, 2011, 08:12:03 PM
I was wondering if there was some king of ray casting lol
Title: Re: Raycasting without .dll's
Post by: BlackCurtain on August 03, 2011, 10:33:31 PM
"Raycasting" is also a term used for 3d collisions to determine if a collision has been made in the direction of a "ray".
Title: Re: Raycasting without .dll's
Post by: gecko on August 03, 2011, 10:46:00 PM
so... what kind of Raycasting do you want, DoctorN? :P
Title: Re: Raycasting without .dll's
Post by: MisterN on August 03, 2011, 11:02:25 PM
a Wolfenstein 3D tutorial added to the wiki :3
Title: Re: Raycasting without .dll's
Post by: josebita on August 03, 2011, 11:24:32 PM
No idea, really :)
Title: Re: Raycasting without .dll's
Post by: l1nk3rn3l on August 04, 2011, 01:02:39 AM

adapt this code to bennu
http://www.shdon.com/dos/gfx/techniques

http://lodev.org/cgtutor/raycasting.html
http://lodev.org/cgtutor/raycasting2.html
http://lodev.org/cgtutor/raycasting3.html

http://www.permadi.com/tutorial/raycast/index.html

Title: Re: Raycasting without .dll's
Post by: Windgate on August 05, 2011, 04:09:17 AM
Wait... You mean manage raycast in 2D or 3D?

Raycast in 2D is easy if you make a process with a graph that it is a line with 1px of width, it is really easy if its control point is the beggining of the line.

In Bennu 3D there is a premade function for raycast.
Title: Re: Raycasting without .dll's
Post by: MisterN on August 05, 2011, 05:21:42 AM
http://www.youtube.com/watch?v=C00n4rDUMNo (http://www.youtube.com/watch?v=C00n4rDUMNo)
like that, the game is actually fully 2d but its made to look 3d lol
Title: Re: Raycasting without .dll's
Post by: popcade on August 14, 2011, 07:33:03 PM
I think you mean a technique called Mode7?
Title: Re: Raycasting without .dll's
Post by: MisterN on August 15, 2011, 02:09:13 AM
no... mode7 wasnt even invented by time wolfenstein came out in 1992 most likely
Title: Re: Raycasting without .dll's
Post by: BlackCurtain on August 15, 2011, 11:53:24 AM
Quote from: DoctorN on August 15, 2011, 02:09:13 AM
no... mode7 wasnt even invented by time wolfenstein came out in 1992 most likely
Mode7 is a Super Nintendo invention so I believe it was.
Title: Re: Raycasting without .dll's
Post by: MisterN on August 15, 2011, 12:05:24 PM
And as I recall wolfenstein 3d nor doom on the snes used mode 7 at all (doom used the superfx chip, wolfenstein did not). But this keeps going off topic. I am pretty sure raycasting can be done for it was created without plugins, therefore someone must know how to have a raycasting code. If you cannot process what raycasting is. Raycasting is fake 3D believe it or not. The level is entirely 2D. And some code makes it so that each block (wall) represents a cube with textures. I am not entirely sure how its done, I just know it is.
Title: Re: Raycasting without .dll's
Post by: BlackCurtain on August 15, 2011, 12:13:22 PM
I believe it's called "sprite scaling" when you scale the sprites in a certain way to give them a 3d perspective. Galaxy Force 2 used this method, it looked fully 3d but was actually 2d.
Title: Re: Raycasting without .dll's
Post by: Fuseki on November 14, 2011, 09:17:07 AM
You could probably use a combination of mode7 and size scaling and angling of sprites to do raycasting. Someone did a Wolfenstein port for DIV1 using this method, back when it was popular, but unfortunately, the code and game has been lost to the sands of time. The basic process is to draw a map in 2D and have "rays" shoot out from your player object. Anything that falls in front of that object, depending on the distance and angle within the rays, would be drawn in a specific size. If I remember the Game Maker raycasting engine correctly, solid sprites that were already "textured" were used and drawn in this manner.


Come to think of it, I've got the old DIV1 cart racing game source code if that would be helpful, although it doesn't use raycasting, but does use size scaling depending on distance. I have all of the example games that came with that package (40mb download) and just uploaded them to my DC Fenix page at http://atari.vg-network.com (http://atari.vg-network.com). There's also the source code and files for Nazca Dreams, which used a lot of mode7 tricks, on the page as well...
Title: Re: Raycasting without .dll's
Post by: MisterN on January 18, 2012, 11:49:29 PM
site doesnt work anymore
Title: Re: Raycasting without .dll's
Post by: Fuseki on December 09, 2012, 11:30:28 PM
Quote from: DoctorN on January 18, 2012, 11:49:29 PM
site doesnt work anymore


You're right. It's back up now. I moved a redirect index to the wrong directory by mistake, months ago...
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 10, 2012, 12:12:36 AM
m7 isn't for create wolfenstein clones...

I was thinking lot of time about m7 and wall and other objetcts, but it isn't mode7... then I forget all idea of add this features to mode7...

http://en.wikipedia.org/wiki/Mode_7

for 3d, we need other thing.
Title: Re:Raycasting without .dll's
Post by: handsource-dyko on December 10, 2012, 07:48:42 AM
M7 is for super mario kart style games isn't it? A lot of SNES games made creative use of it, like super probotector (a.k.a. contra 3) and turtles in time's neon night riders stage.
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 10, 2012, 02:07:20 PM
yes
Title: Re:Raycasting without .dll's
Post by: theosk on December 24, 2012, 09:15:36 PM
Yeah, it can be done.

I was toying some time ago and made this:
http://www.youtube.com/watch?v=TGRvZsEVHzA (https://www.youtube.com/watch?v=TGRvZsEVHzA)

My implementation is quite lame, but there's a reason for that.

This was made in fenix forever ago. I followed lodev's tutorial and adapted it to what fenix could do with a reasonable frame rate (about 60fps at 640x400). Walls render fast enough, but I couldn't make the floor render as I wanted. Since drawing functions are slow as hell and accessing the image buffer didn't make a difference, what I did was to create one process per vertical line (that's 640 in the example). Then, every texture was split in various 1xn textures (having 64x64px textures, that's 64 1x64px maps per texture). Then every process has a size depending on the distance to the camera based on the line cast.

I got bored before I implemented the sprites, but using regions and fenix/bennu's size variable should make it easy.

Sorry for my horrible explanation, lodev's tutorial explains it all and does it great.
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 24, 2012, 09:32:18 PM
nice!
Title: Re:Raycasting without .dll's
Post by: l1nk3rn3l on December 27, 2012, 03:08:14 PM
 :o AMAZING


please share!!! 


thx
Title: Re:Raycasting without .dll's
Post by: handsource-dyko on December 27, 2012, 04:11:30 PM
pretty nice. reminds me of wolfenstein 3d days.
Title: Re:Raycasting without .dll's
Post by: theosk on December 30, 2012, 11:49:38 PM
Hi, I attached my code to this post.

There's a version without textures too, which boosts the FPS counter to infinity. I'm sorry for this horrible piece of code, It was an almost direct conversion of the tutorials and I was learning about raycasting on the go. I lost interest once I got it working so I don't think I'll keep working on it. If you find this useful at all, please feel free to do whatever you wish with this :)
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 30, 2012, 11:53:46 PM
thanks!
Title: Re:Raycasting without .dll's
Post by: theosk on December 31, 2012, 12:02:15 AM
I don't know if this issue was addressed in bennu:
There are some lines like this in my code:

if(rayDirX==0.0)rayDirX=0.00000000001;end

that's because floating numbers should allow division by zero in c++ (there's an IEEE code for infinite), but fenix segfaulted anyway, so I had to do that in order to avoid divisions by zero. Sorry for the massive offtopic, but I didn't feel like a new thread was worth for this alone :/
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 31, 2012, 12:03:44 AM
float divisions by zero in bennugd give you infinite....
Title: Re:Raycasting without .dll's
Post by: theosk on December 31, 2012, 12:09:09 AM
Woah, that was fast. Thanks, then the code should run without all these lines now :)
Title: Re:Raycasting without .dll's
Post by: SplinterGU on December 31, 2012, 12:58:03 AM
Quote from: theosk on December 31, 2012, 12:09:09 AM
Woah, that was fast. Thanks, then the code should run without all these lines now :)

well, without these lines, in 320x200, without scale2x and replace all fabs by abs... it give me to up 110-180fps... depend what need render on screen... oh, I remove the draws functions too.
Title: Re:Raycasting without .dll's
Post by: theosk on December 31, 2012, 01:27:29 AM
Well, this code was written in fenix some time ago so I had to do REALLY weird things to avoid some old bugs. (abs wasn't even working properly with floats back then... tough times). The drawing functions were meant for higher resolutions, where small sized tile slices became less than 1px wide and wouldn't draw and far away walls became invisible, so fog-like brown lines would fill these gaps. That's why there are various sized tile slices, not the right thing to do, but the way it would work fast enough back then.

Over 100 fps is a huge boost, for sure! I should update myself regarding the current divlike scene, I'm glad to see things are moving forward over here.
Title: Re:Raycasting without .dll's
Post by: l1nk3rn3l on January 07, 2013, 12:52:35 AM
THX...
Title: Re:Raycasting without .dll's
Post by: MisterN on January 08, 2013, 01:10:28 AM
so can you post the updated code?
Title: Re:Raycasting without .dll's
Post by: Imerion on February 21, 2013, 04:10:54 PM
Yep, would be nice to see the updated source! :)
Title: Re: Raycasting without .dll's
Post by: SplinterGU on January 09, 2024, 06:08:12 PM
Quote from: theosk on December 30, 2012, 11:49:38 PMHi, I attached my code to this post.

There's a version without textures too, which boosts the FPS counter to infinity. I'm sorry for this horrible piece of code, It was an almost direct conversion of the tutorials and I was learning about raycasting on the go. I lost interest once I got it working so I don't think I'll keep working on it. If you find this useful at all, please feel free to do whatever you wish with this :)

Marvelous! After 11 years, I just ported it to BennuGD2, and it's working wonderfully!
Title: Re: Raycasting without .dll's
Post by: Goku jr on January 12, 2024, 07:10:40 PM
It even works, on switch!! although with a significant drop in fps compared to a PC

(https://forum.bennugd.org/index.php?action=dlattach;attach=4376)