I'm in the process of coding a simple raycaster, and so far the performance is horrenderous. I believe this might be due to the fact that I am drawing the pixels to the screen one at a time. I tried using the canvas, but it really didn't help (maybe I was using it wrong?). Should I be using a canvas for something like this, or is there another way for me to draw a bunch of pixels more efficiently?
I attached a .love file. Can also check out the source on my GitHub profile (see footer).
Thanks in advance!
Efficiently drawing pixels
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 17
- Joined: Sun Jul 22, 2012 11:15 am
- Location: Copenhagen, Denmark
- Contact:
Efficiently drawing pixels
- Attachments
-
- love2d-raycaster.love
- (32.25 KiB) Downloaded 169 times
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Efficiently drawing pixels
Drawing pixels one by one? That's more a [wiki]Shader[/wiki] thing.
Help us help you: attach a .love.
-
- Prole
- Posts: 17
- Joined: Sun Jul 22, 2012 11:15 am
- Location: Copenhagen, Denmark
- Contact:
Re: Efficiently drawing pixels
Hmm, I am not quite sure how I would go about doing this with a shader. I have always thought of shaders as something I use to add effects to my game. I looked up shaders in the wiki, but I am not any closer to a solution. Can you point me to a good resource for shaders, or alternatively show how I would go about doing this?
EDIT: Actually, I googled and found some old posts on raycasters in LÖVE and I think I found a solution. I can simply draw the columns of each texture as quads, which should significantly reduce the number of draw calls.
EDIT: Actually, I googled and found some old posts on raycasters in LÖVE and I think I found a solution. I can simply draw the columns of each texture as quads, which should significantly reduce the number of draw calls.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Efficiently drawing pixels
I was wondering if a shader could be written to do the floors and ceilings in a Raycasting game actually.Robin wrote:Drawing pixels one by one? That's more a [wiki]Shader[/wiki] thing.
When I was playing around with Raycasting a while ago I did floors by casting rays against a rotated canvas inside another canvas and drawing each line of the floor from its horizon to the bottom of the screen and just scaled each row quad based on its distance from the camera. It worked great and was super fast, but caused obvious graphical inconsistencies due to the rotating of the image. Maybe a shader could handle this instead?
One day I plan on getting back to designing a 3D Wolfenstein style engine. Especially after playing through GunGodz which is an amazing game and very inspiring to simple FPS designers.
-
- Prole
- Posts: 17
- Joined: Sun Jul 22, 2012 11:15 am
- Location: Copenhagen, Denmark
- Contact:
Re: Efficiently drawing pixels
So I managed to drastically improve fps by using the quad method. I can't exactly see how I would use that for the floors and ceilings, however. That must be a challenge for another day. Jasoco, do you by any chance have the source for that lying around? The thing with canvases sounds pretty interesting, and maybe I can use that to improve my code.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Efficiently drawing pixels
It's lying around this forum in many places. Mainly every single other Raycasting thread.
Edit: I'll post it once again.
Don't expect to use it with anything other than 0.8.0. And it's shitty code. You won't like it at all. Enjoy!
I'd rather have a shader-based method for figuring out what the floor should look like.
Edit: I'll post it once again.
Don't expect to use it with anything other than 0.8.0. And it's shitty code. You won't like it at all. Enjoy!
I'd rather have a shader-based method for figuring out what the floor should look like.
Re: Efficiently drawing pixels
Do you use love.graphics.quad?christiankolding wrote:So I managed to drastically improve fps by using the quad method. I can't exactly see how I would use that for the floors and ceilings, however. That must be a challenge for another day. Jasoco, do you by any chance have the source for that lying around? The thing with canvases sounds pretty interesting, and maybe I can use that to improve my code.
Because that doesn't exist anymore since 0.9, if so just updating to 0.9 could make your code run more efficiently due to LuaJIT.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests