(0.9.0) Another raycasting demo 19.12.2013
Re: Another raycasting demo 13.10.2013
is it possible to add basic 3d models in this thing?
Re: Another raycasting demo 13.10.2013
I would seriously recommend using an engine made for 3d if you want to use 3d models.jjmafiae wrote:is it possible to add basic 3d models in this thing?
Re: Another raycasting demo 13.10.2013
I use the canvas method, the same You recommended me, but I've made some changes (I've mentioned this few post above), I've also replaced most of the hardcoded stuff with variables, changed the map format and texture loading code to make some stuff easier.Jasoco wrote:What method did you use for the floors and ceilings?
The most important code relating to floors and ceilings is in main.lua in setupfloor() function, the retexturing stuff is in texture_setup.lua in aplay() function.
This is not a full 3d, so no, but a good artist should be able to make sprites that look 3d (it will never be perfect though)jjmafiae wrote:is it possible to add basic 3d models in this thing?
Re: Another raycasting demo 13.10.2013
is it possible to sell a raycasting game or is it a bit last year?
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Another raycasting demo 13.10.2013
Eh, it's possible. Well, for me it's possible. These raycasting engines, if done the way I expect they are, have each column of the screen as a separate image sorted by distance from the camera, so using the same method I use for my 3D engine, I could totally merge the two engine types into one.Wojak wrote:This is not a full 3d, so no, but a good artist should be able to make sprites that look 3d (it will never be perfect though)jjmafiae wrote:is it possible to add basic 3d models in this thing?
I'm just too lazy to prototype it.
One day.
Not unless you bring something to the table worth purchasing.jjmafiae wrote:is it possible to sell a raycasting game or is it a bit last year?
GunGodz, a really well made FPS twitch shooter made by the guys who did Super Crate Box is free. Take that as you will. Also, Rogue-likes are a dime a dozen these days. But people still buy them. Then again they usually have a lot of polish.
Re: (0.9.0) Another raycasting demo 19.12.2013
This demo (raycast5) in now compatible with LÖVE 0.9.0 + a little bonus
(bonus include resizeable window and the raycasting code moved to scripts/raycasting.lua file)
Download in OP
(bonus include resizeable window and the raycasting code moved to scripts/raycasting.lua file)
Download in OP
- guidedbycthulhu
- Prole
- Posts: 2
- Joined: Wed Jan 15, 2014 3:39 am
- Location: Ottawa, The City that Fun Forgot
Re: (0.9.0) Another raycasting demo 19.12.2013
Not sure if either Wojak or Jasoco could make use of the following but...
With the release of Love 0.9, we've finally gotten the ability to use bitwise operators, as well as C data structures. This got me thinking, and I decided to revisit some old code.
Following "Sin and Cos - The Programmers Pals" http://www.helixsoft.nl/articles/circle/sincos.htm, I've quickly implemented an alternative floor/ceiling renderer. I've only been working with absurd resolutions (1280x720), but it's giving me a bit more oomf than the canvas method at that level.
When running at 720p with the canvas method, I'm averaging 30-33fps on my office computer. Switching to the "FastPixelFloor" method, I'm able to get 39-41fps. Not a huge improvement or anything, but hey.
Somethings to note:
With the release of Love 0.9, we've finally gotten the ability to use bitwise operators, as well as C data structures. This got me thinking, and I decided to revisit some old code.
Following "Sin and Cos - The Programmers Pals" http://www.helixsoft.nl/articles/circle/sincos.htm, I've quickly implemented an alternative floor/ceiling renderer. I've only been working with absurd resolutions (1280x720), but it's giving me a bit more oomf than the canvas method at that level.
Code: Select all
local bit = require("bit")
local ffi = require("ffi")
ffi.cdef[[
typedef struct { uint8_t red, green, blue, alpha; } rgba_pixel;
]]
local sin = math.sin
local cos = math.cos
local abs = math.abs
local floor = math.floor
local renderX, renderY = 1280, 720
local textureWidth = 64
local destinationData = love.image.newImageData(renderX, renderY)
local destinationImage= love.graphics.newImage(destinationData)
local singleTile = love.graphics.newImage("tile.png")
local singleTileData = singleTile:getData()
function Raycaster:FastPixelFloor()
local screenX, screenY
local texX, texY
local distance
local lineDX, lineDY
local spaceX, spaceY
local mapX, mapY
local maskX = textureWidth -1
local maskY = textureWidth -1
local pointerDestination = ffi.typeof("rgba_pixel *")
local pointerTile = ffi.typeof("rgba_pixel *")
local destinationArray = ffi.cast(pointerDestination , destinationData:getPointer())
local tileArray = ffi.cast(pointerTile , singleTileData:getPointer())
for screenY = renderY-1, renderY/2, -1 do
distance = renderY / (2.0 * screenY - renderY)
distance = distance * textureWidth
horizontal_scale = (distance / renderY)
lineDX = (-1 * sin(playerCamera.rot) * horizontal_scale)
lineDY = (cos(playerCamera.rot) * horizontal_scale)
spaceX = -playerCamera.x * textureWidth + (distance * cos(playerCamera.rot)) - renderX / 2 * lineDX
spaceY = playerCamera.y * textureWidth + (distance * sin(playerCamera.rot)) - renderX / 2 * lineDY
for screenX = 0, renderX-1, 1 do
texX = floor(bit.band(spaceX, maskX))
texY = floor(bit.band(spaceY, maskY))
mapX = floor(abs(spaceX / 256))
mapY = floor(abs(spaceY / 256))
destinationArray[screenX + screenY * renderX] = tileArray[texX + texY * textureWidth ]
destinationArray[screenX + (renderY-screenY) * renderX] = tileArray[texX + texY * textureWidth ]
spaceX = spaceX + lineDX;
spaceY = spaceY + lineDY;
end
end
destinationImage:refresh()
love.graphics.setCanvas()
love.graphics.draw(destinationImage, 0, 0)
end
Somethings to note:
- It should be possible to have multiple "heights" for these flats, simulating the tops of platforms or whatever.
- This draws the entire floor/ceiling - very wasteful and could be optimized to only draw visible sections.
- I tried loading a DLL containing a C version of "FastPixelFloor" - no noticeable difference over the LuaJIT version.
Quinoa is a blight on mankind.
Re: (0.9.0) Another raycasting demo 19.12.2013
We need oculus rift support for this!! xD
-
- Prole
- Posts: 1
- Joined: Wed Feb 24, 2016 8:43 pm
Re: (0.9.0) Another raycasting demo 19.12.2013
How do you render floors, I'd like to see tutorial, thank you in advance.
Who is online
Users browsing this forum: No registered users and 5 guests