Page 12 of 14

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Feb 19, 2012 12:51 pm
by coffee
Jasoco wrote: Got some new friends to keep me company.
I would be afraid of friends like that even having a peaceful look. Are you sure they aren't instead stalkers? :)

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Feb 19, 2012 5:06 pm
by Robin
Nice! Your "friends" look creepy, though. :P

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Feb 19, 2012 8:22 pm
by Jasoco
No more creepy than having a disguised Nazi member following you around. I haven't ported in the AI code yet so they just follow the player. I haven't even drawn other angles yet so it would be useless to do it now anyway. There's a lot to finish here. I'm terrible enough as it is drawing people.

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Mon Feb 20, 2012 2:48 pm
by richapple
You promised to add mouselook after you finish doors :(

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Mon Feb 20, 2012 10:47 pm
by Jasoco
Hold your horse, Captain! There's a lot to do. I can only do so much at once. Plus I have other things like work and recording Let's Plays on the blatant whoring of my YouTune channel spam spam spammity spam watch them spam.

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Sun Feb 26, 2012 5:31 am
by Gravy
Hi all,

I'm also working a game that uses a modified version jfroco's raycasting example. However, I just added in textures and now have severe framerate issues. How are you guys drawing in the textures? I'm basically just pulling pixel by pixel out of the image and drawing a rectangle that color. I have messed around with commenting things out and fixing values, and it seems like the line that actually draws the rectangles is the culprit (love.graphics.rectangle("fill", rayScreenPos,i,stripWidth, 2)).

Code: Select all

function drawStrip(stripIdx,height,vHit, textureX)
	local rayScreenPos = stripIdx * stripWidth;
	local tempw =  math.floor(texture:getWidth() * textureX) 
	for i = 1 + math.floor(viewerHeight - height)/2, -1 + math.floor(viewerHeight + height)/2 do
		local temph =  math.floor(texture:getHeight() * ((i-(viewerHeight - height)/2)) / height)
		local r,g,b,a = texture:getPixel(tempw,temph)
		if vHit then 
			love.graphics.setColor(r*.8,g*.8,b*.8, a)
		else
			love.graphics.setColor(r,g,b,a)
		end
		love.graphics.rectangle("fill", rayScreenPos,i,stripWidth, 2)
	end
end
Yeah, that little 13 is my framerate :(
Image

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Mon Feb 27, 2012 9:00 am
by Jasoco
You take each wall tile texture. Divide it into 1 quad for each pixel width. Draw the appropriate quad at the appropriate Y scale based on the strip's distance from the camera. Your problem is you're drawing every pixel instead of just each strip. My game will draw a minimum of 640 objects per frame. That's with a viewport of 640 pixels width equalling 640 rays.

You're thinking too far into it and in the old DOS ways. This is 2012. Quads are your friend!!! Your method will never get any faster since you're drawing thousands of pixels separately every frame. You have a sheet of wall tiles. You take each tile one at a time and (Say your wall is 64x64) make 64 different quads horizontally across each tile. So you end up with a quad sheet that can be called via something like this: wallQuad[tileNum][textureX]

In my game each texture is 64 pixels by 64 pixels. 64 is stored in a variable (That can be changed) called tileSize. This is used for everything. When a ray hits a wall, one of the variables that's returned (In Jfroco's original code) is "textureX". If you multiply textureX by the tileSize you end up with the quad location of the current tile. Draw that quad at that position with its scale for its height and you got yerself textured walls with better framerate.

Also, stripWidth is stupid and left over from slow computer days and I think it looks ugly so I destroyed it and got rid of every trace of it. My pixels are all 1:1. Not 2:1. The only reason it's in jfroco's code is because it was leftover from the Opera JavaScript code he ported which was leftover from the old DOS QBasic days when computers were slow as moles asses in winter.

Eventually my code will be available. But I don't know when. I'm too self-conscious about it and won't release it until it's perfect. Perfect. Absolutely perfect. Must be perfect. Must be clean.

My version also has floors and doors and soon ceilings and hopefully eventually a dynamic sky and pre-calculated lighting and better enemy and NPC AI and scripting and blood spatters and bullet holes on walls and the floor and the ability to place actual 3D polygonal objects in the game... Eventually. In time.

Right now with Löve 0.8.0 LuaJIT edition I get about the ballpark of 60FPS with everything going on. The final game will have a "low-res" mode that will make the draw resolution 320x200 (More faithful to Wolfenstein and DOOM) to help the speed if normal 640x400 mode is too slow. Right now walls and things will render at the 320x200 mode but the floor and sky render incorrectly. It's on my list of things to fix the hell out of.

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Wed Feb 29, 2012 5:13 am
by Gravy
Thanks! This was not too painful to implement, and I'm getting 60 FPS now.

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Thu Aug 16, 2012 6:50 pm
by LaserGuns
any more progress? or is there a new thread? i demand updates!

Re: Working Raycasting example! WolfenLöve 3D if you will...

Posted: Thu Aug 16, 2012 11:33 pm
by legendman3
I hope it didn't die. I liked this.