Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Showcase your libraries, tools and other projects that help your fellow love users.
WetDesertRock
Citizen
Posts: 67
Joined: Fri Mar 07, 2014 8:16 pm

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumpin

Post by WetDesertRock » Mon Aug 31, 2015 5:56 am

Do you have any brief introduction to how to use it? The code at first glance isn't super self-documenting. For instance your main.lua, I still don't know what pers is :\

Really interested in this, but not sure where to start with it.

User avatar
Davidobot
Party member
Posts: 1144
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumpin

Post by Davidobot » Mon Aug 31, 2015 7:19 am

WetDesertRock wrote:Do you have any brief introduction to how to use it? The code at first glance isn't super self-documenting. For instance your main.lua, I still don't know what pers is :\

Really interested in this, but not sure where to start with it.
It's not really a library, more of a personal project that I worked on.
In my opinion, it is pretty self-explanatory, as all functions are placed in their respective file (raycasting.lua, spritecasting.lua).

Pers is a library by xXxMoNkEyMaNxXx, which allows for textured polygons, which are used for the ceiling/floor and doors.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

Cruhan
Prole
Posts: 3
Joined: Sat Mar 18, 2017 3:45 pm

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Cruhan » Wed Mar 22, 2017 7:51 pm

interesting that on 0.10 the floors are not correct. What changed from 0.9?

User avatar
zorg
Party member
Posts: 2368
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by zorg » Thu Mar 23, 2017 3:55 am

Cruhan wrote:
Wed Mar 22, 2017 7:51 pm
interesting that on 0.10 the floors are not correct. What changed from 0.9?
0.10.0 0.10.1 0.10.2
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
Jasoco
Inner party member
Posts: 3620
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Jasoco » Tue Mar 28, 2017 6:35 pm

Yeah, I've noticed this too. Something changed with how Shaders work that causes the texture being sent to not line up correctly.

But I'm having an inconsistent problem. I'll make a video showing what I mean...



As I show in this video, I have four separate issues with the library that allows for textured floors and ceilings. I show off four projects. Three of my own and this one by Davidobot. And the problem is presented in three different ways with the fourth being perfectly fine.

First and second my old 3D project from 2015 where I started playing with the library for floors and ceilings by drawing an image for each tile that needed a floor or a ceiling and Davidobot's project from the same time that did the same thing. Both of us had it working fine, but his was working better and more polished at the time. Now it shows textures, but they're flipped on both projects and the alignment is off. It's obvious at this point that something changed once again about how textures are sent to shaders. Maybe I just need to reverse the pixel Y coordinates or something.

Third is my current project. The texture doesn't even show up as a texture now. Just a single giant grey pixel. Which is the color of one of the pixels in the image. But that's all you see. Just one color. So the floor and ceiling just looks like a grey slab. In this project, the width and height of the game itself is much smaller than the actual love.graphics.getWidth() values. But this used to be accounted for via some fun math™ back in the day. I guess that math™ changed.

Lastly is my old 3D RPG engine. I am shocked to see that it's working perfectly and even draws more textures than any of the 3D projects. So it CAN work, but it's going to take some thinking to figure out WHY it works and get it working in the other project. In the end I even show off experimenting with Hatninja's "Playmat" Mode7 library which lines up horizontally with my walls with a bit of tweaking, but I can't figure out how to change the camera perspective to get it to line up vertically. Maybe with some work I can figure it out. Perhaps with some tips from the community.

So it's not necessarily a change in Löve but a change in how shaders deal with images or something.

In my RPG project, the game resolution is always the same resolution as the window. In my other projects, the game resolution is smaller. In Davidobot's project, the resolution is also the same as the window, but things are flipped. So maybe I accounted for the flipping in my RPG project but David never did.

User avatar
Davidobot
Party member
Posts: 1144
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Davidobot » Tue Mar 28, 2017 6:41 pm

Jasoco wrote:
Tue Mar 28, 2017 6:35 pm
...
Cruhan wrote:
Wed Mar 22, 2017 7:51 pm
...
What a coincidence! Just as you posted this long block of text, I uploaded a 0.10.2 version of the raycaster that is working! Let me watch the video and edit this with a comment.

EDIT: So if you look into my .love file, I have an edited pers.lua which works with the latest version of love. I hope it helps.
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
Jasoco
Inner party member
Posts: 3620
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Jasoco » Tue Mar 28, 2017 6:54 pm

Perfect, it works great. Which goes to show that it can work fine with projects that don't try to use a "fat pixels" style. I've had it work before. So I'll have to try and do it again.

Difference between my project and yours is that you just use the whole resolution of the window 1:1 so the shader works fine. But I need to do a smaller resolution for a pixel art look. So it kind of falls apart. I fixed it before by tweaking some variables but now I have to figure it out again. Haha.

User avatar
Davidobot
Party member
Posts: 1144
Joined: Sat Mar 31, 2012 5:18 am
Location: Game-Dev. Land
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Davidobot » Tue Mar 28, 2017 6:59 pm

Jasoco wrote:
Tue Mar 28, 2017 6:54 pm
Perfect, it works great. Which goes to show that it can work fine with projects that don't try to use a "fat pixels" style. I've had it work before. So I'll have to try and do it again.

Difference between my project and yours is that you just use the whole resolution of the window 1:1 so the shader works fine. But I need to do a smaller resolution for a pixel art look. So it kind of falls apart. I fixed it before by tweaking some variables but now I have to figure it out again. Haha.
I'm happy that it's at least back to a working point :awesome: Good luck figuring it out! maybe I should actually make a game using this... some day..
My library:
LovelyMoon

Check out my current project:
Raycaster

Oh hey, I have a website now!

User avatar
Jasoco
Inner party member
Posts: 3620
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Jasoco » Tue Mar 28, 2017 7:12 pm

The problem is back when I first had to modify the library for use with smaller canvases (Since it's designed originally to just work on full resolution windows and not smaller canvases) I added a bit of code to change the scaling of the output to account for it. Then when I added in fog shading I added even more code. So it's a big mess now. The library really needs to be completely redone. I've had problems in the past where it stops working completely if the window is destroyed and remade. (i.e. via changing the window mode through resolution changes and stuff like setting fullscreen) It really needs to be redone.

User avatar
Jasoco
Inner party member
Posts: 3620
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Textured Raycaster [Multiple Levels! Door Covers! Jumping!]

Post by Jasoco » Wed Mar 29, 2017 10:01 pm

Well I got it to work.

Image

It was my own fault. And yes, it is related to the "setMode" problem I mentioned above. I forgot to put the require() part where it loads the library AFTER my win.setMode line in my "setupScreen" state. If I put it before setting the screen mode, it basically destroys the shader. I don't know the specifics. Maybe we can figure it out. But I bet if Davidobot were to try setting his screen mode after the library was loaded in his own project here, it would do the same thing.

In fact, let me try it out...

Yep. Here's a video...



As you can see, if the library is loaded before using setMode, it is erased or something. This doesn't happen for any other library or shader code. So I don't know why it happens. I WILL figure it out. As I said I think the library needs to be rewritten. Or a suitable replacement needs to be found. I wish Löve had this ability built into the lgr.polygon() function. Or a separate lgr.texpoly() feature would be nice if it had the same perspective correction and didn't require clunky meshes to use.

Basically it's working. And this was a completely different problem. The problem with this project was something I had solved a while ago (When I first switched to the preview versions of 0.10.) and Davidobot fixed recently thanks to this thread being bumped. It was a simple fix requiring the pixel y axis to be inverted because for some reason 0.10's libraries reversed them or something. I don't know, I don't care. I am pretty sure it was actually fixing an inverse that was accidentally set a while ago so it is just being returned to normal. I recall having to invert the y axis before. So this is like the second time. The problem I'm talking about here is a completely unrelated one related to setMode. Really I should put this in a new thread. But I'll instead work on trying to rewrite the library and post a thread if I can't fix it. Maybe it's a bug. Since it doesn't seem to affect any other shaders, I don't know why it affects this one specifically.

Maybe David and I can look into it together. He seems really good at bettering me anyway. Haha.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests