Page 4 of 8
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 1:52 am
by TechnoCat
bartbes wrote:I certainly haven't, though I recently saw something about someone who calculated only one wall and used a trick to get all other walls from it.
The guy in that The Colony video?
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 3:50 am
by Jasoco
Well, I recall him mentioning that the rooms in the warehouse were drawn by extending the wall up indefinitely. Don't know about calculating all walls.
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 8:37 am
by bartbes
Yes, he, he was talking about some nice tricks.
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 10:55 am
by pygy
I have tweaked the ray_cast function a bit, and cleaned up the draw routine (I draw the sky and the floor as big rectangles, then the walls as an overlay).
I get 60 fps almost all the time with a sliver width of 3. It's a bit slower (56-58 when the field is wide and deep). I have a Core Duo 2GHz (a 3.5 year old beast).
- raycast.png (17.23 KiB) Viewed 2566 times
The current algorithm is still linear, but a better breed of linear.
It used to be fn( distance * 1/ray_resolution ) ) with ray_resolution = 0.02
it's now fn( ( distance * ( 1/seek_step ) + log2( (1/ray_resolution) * ( 1/distance) )) with
- seek_step = 0.1
- ray_resolution = 1/64
- a security to prevent distance from being < 1 in the calculation.
for pixels far enough, it's thus almost fn( ( distance * ( 1/seek_step ) ) : 5 times faster :-)
While typing this message, I thought of a way to make it faster and more accurate still. I'll post an update when I have the time.
We could implement fog by drawing a gradient on the floor and tweaking the wall colors as a function of distance.
Edit: new version with screen.vsync = false and love.load(dt) modified to move at the speed it had previously when hitting vsync.
Edit2: Love ignores the config file... weird.
Edit3: you can set VSync in main.lua if you want (love.graphics.setMode( config.width, config.height, false, true --[[set this to false]], 0 ))
Edit4: Now with screenshot. Notice the higher resolution and the FPS :-)
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 11:30 am
by kalle2990
I think you forgot using deltatime when moving the camera, because I move very fast...
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 11:40 am
by pygy
I didn't change anything to the load.update() logic. It still uses dt.
Edit: errr... well, actually, it takes a dt parameter, but it doesn't use it. I'll see what I can do :-)
Edit2: now it uses dt... and, yes, it's speedy :-)
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 11:40 am
by bartbes
Woah.. good job, I'm hitting vsync!
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 12:04 pm
by pygy
I tried to disable vsync, but love ignores the config file (both love.conf and conf.lua).
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 12:10 pm
by Robin
pygy wrote:I tried to disable vsync, but love ignores the config file (both love.conf and conf.lua).
You mean game.conf?
And LÖVE does not ignore conf.lua -- do you know the right
syntax?
Re: Raycasting Demo (like Wolfenstein3D, just veery basic)
Posted: Sat Feb 27, 2010 12:31 pm
by pygy
[snip] Edit... I read the wiki too fast...
But the problem was somewhere else:
love.graphics.setMode( 500, 400, false, true, 0 )