Page 1 of 1

So I experimented with Ray Casting

Posted: Wed Jun 24, 2015 1:44 am
by wtg62
And the results of rendering a 7x7 texture make me feel ashamed. (That 'F' on the F block means FPS drop)
The HTML5 canvas sure is efficient, isn't it?

https://dl.dropboxusercontent.com/u/556 ... ycast.html

Re: So I experimented with Ray Casting

Posted: Thu Jun 25, 2015 11:34 am
by testtubegames
Says a lot about game conventions that it took me quite a few minutes to realize that I could walk through the 'walls.'

Is this built-from-scratch-html5? Did you honestly use ray-casting to create a 3d renderer? Respect.

(minor note: check your control-scheme instructions. Front-back is mislabeled)

Re: So I experimented with Ray Casting

Posted: Thu Jul 02, 2015 10:24 pm
by wtg62
testtubegames wrote:Says a lot about game conventions that it took me quite a few minutes to realize that I could walk through the 'walls.'
Yeah, no collision engine yet, but I could easily add it now that I understand the AABB algorithm better.
testtubegames wrote:Is this built-from-scratch-html5? Did you honestly use ray-casting to create a 3d renderer? Respect.
This was written with some guidance, in JavaScript, aside from using keydrown.js to monitor user input.
Thank you for the respect :P
testtubegames wrote:(minor note: check your control-scheme instructions. Front-back is mislabeled)
HAHAHA! Wow! How did I mess that up? Fixed!
Oh man did that make me laugh!

Re: So I experimented with Ray Casting

Posted: Fri Jul 03, 2015 9:09 pm
by testtubegames
wtg62 wrote:This was written with some guidance, in JavaScript, aside from using keydrown.js to monitor user input.
Nice. When I first looked at it, I though... oh a 3d world, and maybe the raycasting is just drawing the 'sight-lines' in the mini-map. Cool.

...

And then I realized it was *ALL* made from scratch. :shock: I'm impressed.

(Clearly not a guy who does much in 3D over here... I stick to the simple world of 2D... or at most 2+1D :) )

Re: So I experimented with Ray Casting

Posted: Fri Jul 03, 2015 9:19 pm
by wtg62
Not 100% from scratch, because I went somewhere to find out how to remove the fish-eye effect from my first attempt.
For some reason, if you use the actual-distance from the camera to the wall, it produces a fish-eye effect.
The best way to prevent this is treat the point on the wall that was hit by the ray as a line parallel to the camera's plane, and find the distance between said lines.
I looked at equations for this, so I can't say 100% scratch :(

Re: So I experimented with Ray Casting

Posted: Sun Jul 05, 2015 11:23 pm
by A Random Player
wtg62 wrote:Not 100% from scratch, because I went somewhere to find out how to remove the fish-eye effect from my first attempt.
For some reason, if you use the actual-distance from the camera to the wall, it produces a fish-eye effect.
The best way to prevent this is treat the point on the wall that was hit by the ray as a line parallel to the camera's plane, and find the distance between said lines.
I looked at equations for this, so I can't say 100% scratch :(
This happened to me before, when I tried a raycaster. An easy way to figure this out is that a square facing you should always look like a square, even though the distances between you and the parts of the square are different. Also, remember that an eye works basically like a pinhole camera, with perpendicular distances being proportionate.

Re: So I experimented with Ray Casting

Posted: Tue Jul 07, 2015 11:44 am
by testtubegames
wtg62 wrote:Not 100% from scratch, because I went somewhere to find out how to remove the fish-eye effect from my first attempt.
Well, if looking up equations while making a game/sim is wrong, I don't want to be right.

So yeah, looking up references is a good thing in my book.

And just to reiterate - well done!

Re: So I experimented with Ray Casting

Posted: Tue Jul 07, 2015 9:19 pm
by wtg62
testtubegames wrote: Well, if looking up equations while making a game/sim is wrong, I don't want to be right.

So yeah, looking up references is a good thing in my book.
I think to clarify, I looked at C code for some help, sorry to have omitted that.
Other than that, yeah, it's mostly scratch!

I consider using references to decrease the amount of scratchiness, but not remove it all. :P