Groverburger's 3D Engine (g3d) v1.5.2 Release
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Groverburger's 3D Engine (g3d) v1.4 Release
I've looked at the code and I still don't know how you pulled this off. But it's amazing. I played all the way through the Hoarder game and it was so hard to believe I was playing a game in Löve.
Re: Groverburger's 3D Engine (g3d) v1.4 Release
I just wanted to say thank you for making this. After playing Lead Haul i decided to look into this library, And see if i can't make my own old school style fps, Which is something i've always wanted to do. After tinkering with this for a while, And with pretty much zero knowledge or experience with 3d work, I've made this garbage:
There's not much to it, Just a basic level with some horrible pixel art, Basic movement, Which i copied from the camera module, And glitchy collisions. But for a couple days of tinkering it's not bad. And your library made it possible. Thanks again <3
- groverburger
- Prole
- Posts: 49
- Joined: Tue Oct 30, 2018 9:27 pm
Re: Groverburger's 3D Engine (g3d) v1.4 Release
Hey, sorry for the late response. I'd recommend checking out Hydrogen Maniac's game Lead Haul as it does a lot of what you're talking about in g3d.wolf wrote: ↑Sat Jul 31, 2021 6:18 pm Hey Groverburger,
I want to work on a 3D game soon and I thought your 3D engine seems pretty nice to get started on 3D development.
I basically want to create a 3D adventure that takes place in a maze. I might want to add some 3D models for creatures and items and also a few basic animations for creatures.
Looking at the g3d codebase it seems the 3D models don't support animations, right? Do you have any advise on the best way to add animations for g3d, perhaps using another third-party library?
Also, I need some basic lightning. I believe what I want is only light that originates from the player (e.g. a torch carried by the player). I also would like to add fog (as in: things further aways become less visible). Would those 2 features be easy to add? Do you plan to add such features in the foreseeable future perhaps? Seems you did have some light support in a previous incarnation of g3d (ss3d).
As for lighting, I've built g3d around the idea that models can have custom materials (aka vertex and fragment shaders) applied to them easily. So, you would have to write a custom fragment shader for it which isn't as bad as it sounds! There are some useful tutorials online such as this one which tackle implementing some basic lighting effects in a fragment shader. I've also done this myself in my old game Flamerunner, although that codebase is old and ugly and doesn't resemble g3d much anymore.
Doing skeletal animation in 3D is a trickier topic which I haven't tackled yet myself. Implementing this looks like quite a bit of work and added complexity as you would have to add the concept of bones into models as well as write a more sophisticated model importer and vertex shader. This is however totally achievable with some elbow grease.
Good luck, I hope I helped a little.
- groverburger
- Prole
- Posts: 49
- Joined: Tue Oct 30, 2018 9:27 pm
Re: Groverburger's 3D Engine (g3d) v1.4 Release
Thanks for the kind words! I'm glad my tiny project I started in 2019 to figure out how 3D rendering worked could go on to help other people too.veethree wrote: ↑Sun Sep 26, 2021 9:35 pm I just wanted to say thank you for making this. After playing Lead Haul i decided to look into this library, And see if i can't make my own old school style fps, Which is something i've always wanted to do. After tinkering with this for a while, And with pretty much zero knowledge or experience with 3d work, I've made this garbage:
fps_test.gif
There's not much to it, Just a basic level with some horrible pixel art, Basic movement, Which i copied from the camera module, And glitchy collisions. But for a couple days of tinkering it's not bad. And your library made it possible. Thanks again <3
Re: Groverburger's 3D Engine (g3d) v1.4 Release
Awesome engine man.
I was wondering is there a way to have coloured fog rendered in the distance?
I was wondering is there a way to have coloured fog rendered in the distance?
Re: Groverburger's 3D Engine (g3d) v1.4 Release
There is. Conveniently i was just in the process of figuring this out for my game
Before i continue i want to get across that i'm not a huge shader guy, So there might be many things wrong with this. Maybe someone can check my work here.
You need to write a custom shader to achieve this. Here's what i came up with:
Code: Select all
varying vec4 worldPosition;
extern vec3 player;
extern number fog_min;
extern number fog_max;
extern vec4 fog_color;
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 sc) {
vec4 pixel = Texel(tex, tc);
number d = distance(player, vec3(worldPosition[0], worldPosition[1], worldPosition[2]));
number amount = smoothstep(fog_min, fog_max, d);
return mix(pixel, fog_color, amount);
}
Then you use this, along with g3d's standard vertex shader to render your models. I found that for whatever reason, If i just passed my shader to the draw function of models it wasn't working, So i ended up just replacing g3d.shader in init.lua with my own shader.
EDIT: Changed the shader to have a min & max amount for the fog.
Re: Groverburger's 3D Engine (g3d) v1.4 Release
Thanks @Veethree really useful. I'm getting sweet 90s/early 2000s vibes from that gif.veethree wrote: ↑Tue Sep 28, 2021 9:33 amThere is. Conveniently i was just in the process of figuring this out for my game
fog.gif
Before i continue i want to get across that i'm not a huge shader guy, So there might be many things wrong with this. Maybe someone can check my work here.
You need to write a custom shader to achieve this. Here's what i came up with:`player` is the position of the player (or camera), `fog_min` & `fog_max` is the minumum & maximum distance of the fog and `fog_color` is the fogs color.Code: Select all
varying vec4 worldPosition; extern vec3 player; extern number fog_min; extern number fog_max; extern vec4 fog_color; vec4 effect(vec4 color, Image tex, vec2 tc, vec2 sc) { vec4 pixel = Texel(tex, tc); number d = distance(player, vec3(worldPosition[0], worldPosition[1], worldPosition[2])); number amount = smoothstep(fog_min, fog_max, d); return mix(pixel, fog_color, amount); }
Then you use this, along with g3d's standard vertex shader to render your models. I found that for whatever reason, If i just passed my shader to the draw function of models it wasn't working, So i ended up just replacing g3d.shader in init.lua with my own shader.
EDIT: Changed the shader to have a min & max amount for the fog.
Re: Groverburger's 3D Engine (g3d) v1.4 Release
I think it would be fun trying to make a dungeon crawler with swords and shields and skeleton enemies and traps and gates that has hidden keys etc. Will research and see how hard.
Last edited by togFox on Wed Oct 20, 2021 9:25 am, edited 1 time in total.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Idle gridiron. Set team orders then idle and watch: https://togfox.itch.io/idle-gridiron
- Gunroar:Cannon()
- Party member
- Posts: 1143
- Joined: Thu Dec 10, 2020 1:57 am
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Groverburger's 3D Engine (g3d) v1.4 Release
I'm so excited to start playing around with this! I'm currently working on a 3D raycaster but have really been hitting a wall performance wise. I was doing it the old-fashioned way of casting actual rays and drawing walls a line at a time but performance on just the raycasting part was using a lot of update time which pretty much means the game would only run well enough on the highest end of GPUs. But then I found this library and I saw that so many people are also working on 3D games in the same style and now my hopes are much higher. I just have to implement a map generation feature to turn the world into a 3D model to import, like how LeadHaul does, and I'll be able to get it right.
I can't believe how fast this is though. As a test I created a new model space and loaded in 2000 random spheres and cubes with random textures and it only just hits the 60FPS limit. This is an extreme of course. My game itself wouldn't need that many 3D models all at once. But it's cool to see that it works so well.
It even works at my "low resolution" setting. Which makes me happy to see. It took a bit to figure out how to get it to render properly when being drawn to a canvas, since I use my own state manager library that uses a canvas for drawing content. I was having Z-indexing problems and found someone with the same issue on page 7 of this thread. Changed a single part of my state manager to allow depth in the canvas and it fixed my issue! I'm so happy!
I'm gonna have to learn Crocotile or something so I can build my own models. And figure out a way to cull out objects that don't need to be drawn at the moment. Does g3d do any of this stuff by itself? Like say, in my example above, I have a bunch of models loaded up but a bunch are behind me or otherwise out of the view of the camera. Does g3d still "calculate" those unseen models? Does it somehow magically ignore those or is it still performing all the math on those? Should I be trying to not draw models that aren't going to be seen?
I can't believe how fast this is though. As a test I created a new model space and loaded in 2000 random spheres and cubes with random textures and it only just hits the 60FPS limit. This is an extreme of course. My game itself wouldn't need that many 3D models all at once. But it's cool to see that it works so well.
It even works at my "low resolution" setting. Which makes me happy to see. It took a bit to figure out how to get it to render properly when being drawn to a canvas, since I use my own state manager library that uses a canvas for drawing content. I was having Z-indexing problems and found someone with the same issue on page 7 of this thread. Changed a single part of my state manager to allow depth in the canvas and it fixed my issue! I'm so happy!
I'm gonna have to learn Crocotile or something so I can build my own models. And figure out a way to cull out objects that don't need to be drawn at the moment. Does g3d do any of this stuff by itself? Like say, in my example above, I have a bunch of models loaded up but a bunch are behind me or otherwise out of the view of the camera. Does g3d still "calculate" those unseen models? Does it somehow magically ignore those or is it still performing all the math on those? Should I be trying to not draw models that aren't going to be seen?
Who is online
Users browsing this forum: Ahrefs [Bot] and 0 guests