Lead Haul - Old-school space pirate FPS

Show off your games, demos and other (playable) creations.
User avatar
Hydrogen Maniac
Citizen
Posts: 80
Joined: Sat Dec 19, 2015 9:59 pm

Re: Lead Haul - Old-school space pirate FPS

Post by Hydrogen Maniac »

Jasoco wrote: Wed Oct 13, 2021 8:47 pm It sucks because if it weren't for the performance of the actual raycasting it would be perfect. I only have the resolution set to 320 columns but also implemented options to cut it in half (160) or adjust anywhere in-between (where it lets you have the rays on the edges of the screen be doubled but the rays in the center are still normal) with an option for automatic based on your frame rate which helps with performance but it still does have issues with big rooms. It's also a big problem because while I have a 2019 16" MacBook Pro with a discrete GPU, the performance is even worse on machines a few years older. Even my 2013 MBP only gets 45FPS on average. So if I ever release what I have, hardly anyone will be able to play it.
Honestly, 45 fps on a 8 year old Mac book pro doesn't sound that bad. My old gaming laptop from around that time doesn't even boot up anymore and ran most games quite sluggishly in the years leading up to it kicking the bucket.
Jasoco wrote: Wed Oct 13, 2021 8:47 pm Can canvases that are used for the polygons in g3D be changed on the fly? Or do I actually have to destroy the 3D object and recreate it every time a bullet or blood splash hits the wall or floor? And would I even be able to do reflective floors? Like make 3D textures that are partially transparent so you can see stuff under it?
Yes and yes. Changing the texture of a model is really simple, I use it through out Lead Haul to change the door textures when you unlock them or open them for the first time. Semi transparent textures are a little trickier but it will render fine as long as you draw the transparent object after everything around it. I'm sure that if you're good enough with shaders you might even be able to implement something like ssr for you're reflections.
Jasoco wrote: Wed Oct 13, 2021 8:47 pm I am gonna have to throw together a video and a thread to show it off one day before I commit to changing to g3D if I do just to have it for archival sake.
This.

It sounds like you've made something super impressive and interesting, I'm sure a lot of people would be interested in it. What raycasters have that a more conventional 3D engine lacks is the novelty and quirks which makes it stand out, poor performance or not, it's still at the very least an interesting tech demo worth sharing.
I'm way too sober for this...
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lead Haul - Old-school space pirate FPS

Post by Jasoco »

Hydrogen Maniac wrote: Sat Oct 16, 2021 4:03 pm Honestly, 45 fps on a 8 year old Mac book pro doesn't sound that bad. My old gaming laptop from around that time doesn't even boot up anymore and ran most games quite sluggishly in the years leading up to it kicking the bucket.
To be honest I would be so curious to get as much data about how it performs on other machines of varying generations. All different specs and models. You don't wanna know how it performed on a Windows laptop I have from 2014. Definitely doesn't have a dGPU in there. It's horribly unplayable even with all the performance options set correctly. But at least it runs. Like I said, I originally went crazy with the canvas usage but have managed to cut down significantly now.
Hydrogen Maniac wrote: Sat Oct 16, 2021 4:03 pm Yes and yes. Changing the texture of a model is really simple, I use it through out Lead Haul to change the door textures when you unlock them or open them for the first time. Semi transparent textures are a little trickier but it will render fine as long as you draw the transparent object after everything around it. I'm sure that if you're good enough with shaders you might even be able to implement something like ssr for you're reflections.
I hope so. Because I love being able to have animated textures.

I just wonder how good the performance of g3D is. How detailed can polygonal objects be before you start losing frames? I really need to start prototyping and do some stress testing of g3D to see if it'll work for what I want to do. Because if I'm switching to a real 3D engine, I'm gonna want to have as much detail as possible and not just have completely flat walls everywhere. (I'd love to have small details like slightly protruding trim on walls or little protruding pillars on the corners or little alcoves with things in them. Stuff like that.)

How does g3D handle the culling of the non-visible world? Does it? Or does it calculate the whole world at all times and somehow only draws what's right in front? Like when your game is running and a level is loaded, is it calculating every vertex at all times or does it somehow know what isn't in front of you? Like a game like DOOM needed a BSP system to speed things up and make sure only stuff actually in front of you is actually calculated. And an actual raycaster only draws what's in front of you because of the raycasting itself. So what is g3D doing behind the scenes? Or does your own engine handle that stuff? Is it something I'd have to implement myself?
Hydrogen Maniac wrote: Sat Oct 16, 2021 4:03 pm This.

It sounds like you've made something super impressive and interesting, I'm sure a lot of people would be interested in it. What raycasters have that a more conventional 3D engine lacks is the novelty and quirks which makes it stand out, poor performance or not, it's still at the very least an interesting tech demo worth sharing.
If only the raycasting itself wasn't the biggest bottleneck. Löve is great at drawing thousands of images every frame without skipping a beat. But it's all the math you have to perform before you can draw those images that makes it choke. Even with JIT.

But I hope to get a video together at some point soon. Thing is I want to have it looking presentable enough with as many features working as I can before I let it free into the wild.

Also I really hate how ugly my floors are. And believe me, I've tried other methods. I've tried using shaders. I tried using PlayMat which was made to do Mode7 style 3D but I couldn't get the floor to line up right. So I gave up. My floors and ceilings work, but they're really ugly hacks. I'm sure a shader could be written to do them better but I wouldn't know where to start with that.
User avatar
Hydrogen Maniac
Citizen
Posts: 80
Joined: Sat Dec 19, 2015 9:59 pm

Re: Lead Haul - Old-school space pirate FPS

Post by Hydrogen Maniac »

Jasoco wrote: Sun Oct 17, 2021 4:13 am I just wonder how good the performance of g3D is. How detailed can polygonal objects be before you start losing frames?
I haven't done much in depth performance testing but from what I have gathered g3d seems to be able to handle polygon counts in the low millions but struggles a bit when those polygons are spread out across hundreds of models. I think it might have to do with the shader:send calls that model:draw makes. I'm using a pretty decent computer though so your performance might vary, and if want to do some crazy shader stuff, like real time shadows for instance, you might be required to render the game multiple times which would likewise eat into performance.
Jasoco wrote: Sun Oct 17, 2021 4:13 am How does g3D handle the culling of the non-visible world? Does it? Or does it calculate the whole world at all times and somehow only draws what's right in front?
It doesn't. LÖVE 2D has some built in back culling but I don't think that helps performance all that much. But as I mentioned above g3d can handle a surprising amount of polygons so you can get away with some pretty sloppy culling, for Lead Haul I didn't even bother with culling level geometry and most of the performance drop around level 4 and 5 comes from the amount of enemies in the level rather than the higher polygon count. I'm not sure how big you want your environments to be but I think it might be worth considering to not even cull level geomtery at all, even with bigger levels it's probably wise to not divide them into more than a couple dozen cullable parts at most.
Jasoco wrote: Sun Oct 17, 2021 4:13 am But I hope to get a video together at some point soon. Thing is I want to have it looking presentable enough with as many features working as I can before I let it free into the wild.

Also I really hate how ugly my floors are. And believe me, I've tried other methods. I've tried using shaders. I tried using PlayMat which was made to do Mode7 style 3D but I couldn't get the floor to line up right. So I gave up. My floors and ceilings work, but they're really ugly hacks. I'm sure a shader could be written to do them better but I wouldn't know where to start with that.
Cool, I'd love to see it one day. I vaguely remember getting playmat to work with one of my old raycasting projects by rendering the canvas halfway down the screen and messing with the settings until it lined up. I similarly managed to get a working floor / ceiling shader for my last raycaster by messing around wit scaling and rotating the coordinate system until things lined up, I really don't have any proper advice on how to get that sort of thing working the 'right way'. :oops:
I'm way too sober for this...
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lead Haul - Old-school space pirate FPS

Post by Jasoco »

So I decided to download g3d itself as well sa this game and placed the current version of the library in my project and set up a workspace to play around. I copied some of your code for generating the level walls and stuff and copied over the door model and tried to get it working. But for some reason everything was... rotated. Basically the level generated vertically, the doors were all vertically rotated with the texture UVs shifted. And I couldn't figure out why. I played around for hours trying to figure it out. I rotated the level around the Y axis to get it to be flat, but some textures were off on the West and East walls. (On a whim I made different models for the north, south, east and west walls as well as separate ones for the floor and ceiling just to play around and the east and west walls as well as the floor and ceiling had shifted textures by half a tile/polygon height) I was getting frustrated and starting to lose heart. I didn't know why it was working in your project and 3D looked right in the demo that came with the official download but it wasn't working for me.

So I copied the door model and texture into the demo file and loaded it into the demo world and bam. The door looked wrong there too! What in the world? So I decided for the heck of it to copy the g3d library folder from your project into my project and replace the official one. Suddenly everything rendered mostly right. The models were loading right but the walls/flats all still looked wrong. So I removed the extra code in the generation functions to not have the UVs shifted by 0.5 and suddenly everything lined up.

So I decided to use a diff checker to compare the init.lua files from both versions and I discovered that there were two versions of the library. One from May (Yours) and one from September (Current) and the September one had the Y and Z values swapped. Is this something you did? Or something that Groverburger did? It's weird because it just makes models not load correctly now. At least models from your game. I did notice that there's a "clone" function that doesn't exist in the current version. And when I put the current library in your LeadHaul game, it does screw some things up... just a little... (I copied the clone function and the set texture into the current library to get it to run and this is what I get)


(Yes I modified it to give me 1000HP lol)

It's weird because the title screen map is rotated but the game levels are not, but the controls are completely broken. The doors don't show up (You can tell they're there though, the texture is just off) and the textures are... color shifted? And when transparent sprites walk in front of other sprites they make them disappear. So changes were made to the library. But I don't know if they were changes you made or Groverburger made?

BTW, I will be making my video soon to showcase my raycaster. I want to make it before I fully commit to redoing the entire engine in g3d just for posterity. A reminder of what I once made. (I still have videos on my channel of the original raycaster I made 10 years ago. Man I gave up too quickly on that one.)
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Lead Haul - Old-school space pirate FPS

Post by pgimeno »

I guess it's this commit? https://github.com/groverburger/g3d/com ... 13d7526477

Yeah, that changes the models, but it makes a lot of sense to use z for up, for a number of reasons. First, the previous coordinate system was left-handed. This means that angles grow clockwise instead of counter-clockwise; that you need to apply the left hand rule instead of the more intuitive right hand rule for cross products, that quaternion rotations need to take into account the handedness, and so on. Second, you usually specify 2D coordinates in the map as X,Y; having Y be the height places an extraneous number in the middle of those, and you have to specify them as X,Z instead. Third, formulas such as Euler rotations (or more properly, Tait-Bryan angles) work out of the box in the most usual extrinsic X-Y-Z order if X is east, Y is north and Z is up, while the other axis convention gives extraneous results and produces clockwise turning angles. See the mess that Minetest got into for using the Y-for-up convention: https://github.com/minetest/minetest/issues/7927

In short, if you fix your models to work with Z=up, any math you have to do will be easier and the formulas you can find e.g. on Wikipedia will work out of the box.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lead Haul - Old-school space pirate FPS

Post by Jasoco »

pgimeno wrote: Fri Oct 22, 2021 10:52 am I guess it's this commit? https://github.com/groverburger/g3d/com ... 13d7526477

...

In short, if you fix your models to work with Z=up, any math you have to do will be easier and the formulas you can find e.g. on Wikipedia will work out of the box.
Yeah I was wondering that myself. I always thought X and Z were used for forward/backward and left/right movement and Y was for up/down because of the screen coords. I'd been making my own 3D engines based this for years so it made sense that the old version used it as well. So when I downloaded the new version and it was suddenly broken with all the old methods it threw me off.

I guess I'll have to modify my code that I'm using from LeadHaul for creating the world mesh to swap the Y and Z around and probably manually edit the door model to swap them as well so I can use the new g3d version so I don't have to deal with these issues later on down the road if it gets updated or something. Best to do it now when I'm still in the prototyping phases than later on when I've committed so much time to it. I just know this is gonna be a headache. lol

The question is what were the models made in if they work with one version and not with the other? If the library itself was wrong and was changed, but all those model obj creators didn't change. So how did models work before this change was made?

And if I ever learn to use Crocotile and export obj files, are they going to be broken too?
User avatar
Hydrogen Maniac
Citizen
Posts: 80
Joined: Sat Dec 19, 2015 9:59 pm

Re: Lead Haul - Old-school space pirate FPS

Post by Hydrogen Maniac »

Jasoco wrote: Fri Oct 22, 2021 6:12 pm The question is what were the models made in if they work with one version and not with the other? If the library itself was wrong and was changed, but all those model obj creators didn't change. So how did models work before this change was made?

And if I ever learn to use Crocotile and export obj files, are they going to be broken too?
I vaguely remember making some changes to the .obj importer due to some issue regarding Z and Y being flipped and the UVs being messed up, pretty sure the models in the model directory are fine and that there's some issue when you're loading them in. This was an issue with all models I tried to import, not just the ones I made in Crocotile.

I'm unsure why the game is tinted like that or why the controls, title menu, sprites, etc are broken, but I'd love to help in any way I can.
I'm way too sober for this...
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lead Haul - Old-school space pirate FPS

Post by Jasoco »

That was just how it looked when I replaced the older version in your project with the new one released by Groverburger. Now we know the cause and that's not an issue anymore. I was able to use the newer version of the library and modified the wall and floor/ceiling creation code from your version to work with the new method. I was also able to run the door model through a function I made to flip the Y and Z around and the model came out perfectly, except the UV mapping is wrong. I fixed it for now by just flipping the door texture upside down. I don't know enough about how UV works or what numbers in the .obj file even refer to them so this works for now until I am able to make new doors for myself.

I don't know how to use Crocotile though. And I can't actually test its object exporter because it requires me to pay for it first. I tried importing your door into it to see how it would look but it doesn't show up either. I don't know how the program works at all and on macOS it feels broken. Like super broken. It looks like a Java app and is just not Mac-like at all. I wish it was a retro made program that looked and felt like Aseprite. I feel like I'm gonna have to just spend the $25 and take a risk.

I downloaded Blender to see if I could maybe make models there but that program is just a lot more. lol

I'm still completely shocked how fast g3d works. I was able to import the map from my raycasting engine into the new 3d version for testing and it works so well. It uses barely any frame time. I'm going to be able to do so much more with this.

I don't want to derail your thread though, but you seem to be the only one really replying anymore. The actual g3d thread doesn't get much action anymore. I really want to figure out how to use that shader code to do colored fog that was posted in there but I don't know where to put it. I also wonder if g3d can do any sort of lighting, even if it's baked in, without having to create a texture atlas with all the lighting already in it.
User avatar
Hydrogen Maniac
Citizen
Posts: 80
Joined: Sat Dec 19, 2015 9:59 pm

Re: Lead Haul - Old-school space pirate FPS

Post by Hydrogen Maniac »

Jasoco wrote: Fri Oct 22, 2021 11:49 pm That was just how it looked when I replaced the older version in your project with the new one released by Groverburger. Now we know the cause and that's not an issue anymore. I was able to use the newer version of the library and modified the wall and floor/ceiling creation code from your version to work with the new method. I was also able to run the door model through a function I made to flip the Y and Z around and the model came out perfectly, except the UV mapping is wrong. I fixed it for now by just flipping the door texture upside down. I don't know enough about how UV works or what numbers in the .obj file even refer to them so this works for now until I am able to make new doors for myself.

I don't know how to use Crocotile though. And I can't actually test its object exporter because it requires me to pay for it first. I tried importing your door into it to see how it would look but it doesn't show up either. I don't know how the program works at all and on macOS it feels broken. Like super broken. It looks like a Java app and is just not Mac-like at all. I wish it was a retro made program that looked and felt like Aseprite. I feel like I'm gonna have to just spend the $25 and take a risk.

I downloaded Blender to see if I could maybe make models there but that program is just a lot more. lol

I'm still completely shocked how fast g3d works. I was able to import the map from my raycasting engine into the new 3d version for testing and it works so well. It uses barely any frame time. I'm going to be able to do so much more with this.

I don't want to derail your thread though, but you seem to be the only one really replying anymore. The actual g3d thread doesn't get much action anymore. I really want to figure out how to use that shader code to do colored fog that was posted in there but I don't know where to put it. I also wonder if g3d can do any sort of lighting, even if it's baked in, without having to create a texture atlas with all the lighting already in it.
At line 50 in objloader.lua I changed

Code: Select all

uvs[#uvs+1] = {tonumber(words[2]), tonumber(words[3])}
to

Code: Select all

uvs[#uvs+1] = {tonumber(words[2]), 1 - tonumber(words[3])}
That's likely the source of your uv problems.

I can't speak for how it's like to use Crocotile on mac and I also get super overwhelmed by Blender but realistically you could use pretty much any 3d modelling software you fancy since all of them export .obj files in pretty much the same way. Maybe picocad is more your style if want something more retro, although that program might be a little too retro since it's made using by pico-8.

g3d's shader is defined in g3d.vert, that's where you want to stick all your fancy shader code. You could also send your own shader to each model individually if you want to use different shader for different parts of your game using model:draw(<your shader here>). You can do all kinds of lighting effects by modifing the shader code altough I never quite seemed to get the normals working when using generated models rather than the ones I imported. Groverburgers flamerunner has some lighting effects in it if you want to look through a working example and I think most glsl tutorials can be translated into g3d if you want some more advanced lighting.

I think most people have already said what there's to say about Lead Haul itself so I don't mind much that the thread has derailed, but it might be worth creating a thread on the support and development forum if you don't want to bump the thread any time you want help or feedback. ;)
I'm way too sober for this...
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Lead Haul - Old-school space pirate FPS

Post by Jasoco »

I tried PicoCAD but it saves the polygons as quads instead of triangles. So I tried to Google and found a utility that's supposed to let you convert your PCAD files to be triangulated. But it wont launch on my system and macOS complains that it's suspicious. So when it finally opens it's just a blank window. So much for that. I would definitely have used PicoCAD in a pinch.

Thanks for the tip about FlameRunner. I hadn't heard of it but I'll have to see how they did lighting there. Maybe get some ideas. I already implemented fog from that other poster in the official thread.

I also wonder if there's a way to do ambient occlusion without having to bake it in too. I did ambient occlusion in my raycaster by baking it into the floor and ceiling texture and it makes a big difference from just having the flat shaded walls and flats meeting each other. (Compare how Minecraft looked initially before the big lighting update to how it is now with occlusion and smoother lighting)

I'll make a thread of my own eventually. Once I get something really working well enough. I'm making great progress though.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest