Groverburger's 3D Engine (g3d) v1.5.2 Release

Showcase your libraries, tools and other projects that help your fellow love users.
trabitboy
Prole
Posts: 19
Joined: Sun May 12, 2019 2:09 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by trabitboy »

I am having far too much fun with this :)

Image
https://youtu.be/39BqFZIa4a0

I have a couple of comments after using g3d on and off for some weeks:

first my workflow is as follow:
>model and texture in pico8 + picocad
> load obj in blender, test render, save obj with triangulated faces
> vertical flip texture in gimp
> load in g3d, and "voilà" :)

1- there seems to be a bug on texture aliases, as I need to vflip my texture ( probably it is not noticable until you have several textures in one png like me )
EDIT: it can be fixed by doing like in updated obj loader by alesan:

Code: Select all

        if words[1] == "vt" then
            print('uv')
            uvs[#uvs+1] = {tonumber(words[2]), 1-tonumber(words[3])}
        end
2- I went and looked at the source of hoarder's horrible house of stuff ( super great game btw ),
it's loader looks updated, it supports quad faces directly, and vertex color; is there a conceptual reason not to merge it? do the render shaders need to be updated? EDIT: on more careful reading, it doesn't seem to support loading of quads

3- since I do super low pixel for the textures, I wonder how to switch off bilinear filtering for the textures?
to have something like "GL_NEAREST" . Is it something that needs to be done in the fragment shader ? It would be cool to have an API such as for 2D : Texture:setFilter("nearest", "nearest")
EDIT: this can be achieved by :setFilter on passing a Texture instead of a texture file name on model load.

I want to thank GroverBurger, I have been wanting to do 3d for gamejams for some time, but his lib ticks all the right boxes for me :)
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by groverburger »

trabitboy wrote: Tue May 25, 2021 4:58 pm I am having far too much fun with this :)

Image
https://youtu.be/39BqFZIa4a0

I have a couple of comments after using g3d on and off for some weeks:

first my workflow is as follow:
>model and texture in pico8 + picocad
> load obj in blender, test render, save obj with triangulated faces
> vertical flip texture in gimp
> load in g3d, and "voilà" :)

1- there seems to be a bug on texture aliases, as I need to vflip my texture ( probably it is not noticable until you have several textures in one png like me )
EDIT: it can be fixed by doing like in updated obj loader by alesan:

Code: Select all

        if words[1] == "vt" then
            print('uv')
            uvs[#uvs+1] = {tonumber(words[2]), 1-tonumber(words[3])}
        end
2- I went and looked at the source of hoarder's horrible house of stuff ( super great game btw ),
it's loader looks updated, it supports quad faces directly, and vertex color; is there a conceptual reason not to merge it? do the render shaders need to be updated? EDIT: on more careful reading, it doesn't seem to support loading of quads

3- since I do super low pixel for the textures, I wonder how to switch off bilinear filtering for the textures?
to have something like "GL_NEAREST" . Is it something that needs to be done in the fragment shader ? It would be cool to have an API such as for 2D : Texture:setFilter("nearest", "nearest")
EDIT: this can be achieved by :setFilter on passing a Texture instead of a texture file name on model load.

I want to thank GroverBurger, I have been wanting to do 3d for gamejams for some time, but his lib ticks all the right boxes for me :)
Thanks for the kind words! Very interesting picocad workflow as well!

Yeah, there are some inconsistencies in g3d right now as to whether positive or negative y are up. This can be noticed when rendering models to a canvas, as they render upside down. In order to fix this, I'm thinking about changing the up vector to be (0, 1, 0) so that positive y is up instead of negative y being up like it is now, although this would of course be a breaking change. It seems weird, but the reason I originally had up being negative is to be consistent with love's 2d rendering functionality. For now yeah alesan's obj importer is probably more like what you want.

With regard to your second point, g3d should support vertex coloring right now, unless I broke something lol. I'm not sure about whether it does in the 1.3 release however... I'll make sure this works as expected for the 1.4 release.

You've figured this out already but yeah you can use love's built-in texture filtering functionality. For my pixel art games, I set love.graphics.setDefaultFilter("nearest") at the top of main.lua. This makes all images loaded use the nearest-neighbor pixel art filter, and works well with g3d as well because g3d textures are just normal love images.
trabitboy
Prole
Posts: 19
Joined: Sun May 12, 2019 2:09 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by trabitboy »

Hi,
I did further progress,
now feeling very confortable loading models and rotating objects around:
Image

regarding this I have several comments,
for newbies, it would be really useful to have a diagram / gif like this on the wiki,
to demonstrate axis and the direction of the rotation angles on each axis:
Image


actually it demonstrates something that is counter intuitive,
as if you do some kind of top down game, with x z axis as your ground,
you would tend to have the rotation axis in the other direction:
Image

hence, in my code, when moving my "rainbow bullets" on x z , via speed and angle,
when rotating the g3d model of the bullet on the y axis, I need to
setRotation( 0,-angle,0 ) which doesn't look super great and is hard to explain to beginners I think?

apart from that, having a ton of fun, planning to do a process video to encourage jammers to use this :)
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by pgimeno »

Yeah, this choice of axes is weird. Positive X and Y should be east and north, and Z should be up, and then everything falls into place nicely.
trabitboy
Prole
Posts: 19
Joined: Sun May 12, 2019 2:09 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by trabitboy »

I was having a look at the collision functions and they expect the model to be correctly positionned in space
( setTranslation and setRotation already called )

This means that for my blocky city I need to create a Model by cube or tile I want to render ( if I want to test collision ) ?
Is it the way to properly use g3d ?

At the moment I create the "skyscraper" model once,
and everytime I need to render it I do

Code: Select all

    for j=1,16
    do
      for i=1,16
      do
        tnum=floor[8*j+i]
      if tnum==1 then
        modelRep[tarmacId]:setTranslation(16+i*8,ty,j*8)
        modelRep[tarmacId]:draw()
      else
        modelRep[buildingId]:setTranslation(16+i*8,ty-4,j*8)
        ..
        modelRep[buildingId]:draw()        
      end
      
        
      end
    end
Which means I do call setTranslate hundred of times when rendering.
Is setTranslate by any chance, costly ? :)
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (g3d) v1.3 Release

Post by groverburger »

trabitboy wrote: Wed Jun 09, 2021 6:01 pm actually it demonstrates something that is counter intuitive,
as if you do some kind of top down game, with x z axis as your ground,
you would tend to have the rotation axis in the other direction:

hence, in my code, when moving my "rainbow bullets" on x z , via speed and angle,
when rotating the g3d model of the bullet on the y axis, I need to
setRotation( 0,-angle,0 ) which doesn't look super great and is hard to explain to beginners I think?

apart from that, having a ton of fun, planning to do a process video to encourage jammers to use this :)
Glad you're having fun with it! Yep, that's just how Euler angles work, and the negative sign is required because negative Y is up. A nice gif or a wiki post explaining this would be helpful I think.
pgimeno wrote: Wed Jun 09, 2021 7:26 pm Yeah, this choice of axes is weird. Positive X and Y should be east and north, and Z should be up, and then everything falls into place nicely.
I chose the axes to be consistent with love's 2D rendering, where negative Y is up. You can change the camera's up vector if you want though.
trabitboy wrote: Sun Jun 13, 2021 9:12 pm This means that for my blocky city I need to create a Model by cube or tile I want to render ( if I want to test collision ) ?
Is it the way to properly use g3d ?
There are a bunch of ways to go about implementing collision. In my opinion, it's easiest if your entire level is one model so you only need to run one collision test against it per frame, but that isn't your only option. 3D collision is a tricky thing to program, so I recommend reading some articles on it and the g3d wiki article on collision. Here's a good article that goes into 3D collision in more detail.

Here's my old test repo from back in February where I implemented first-person player movement in g3d, it might help to reference how I got it working.
trabitboy wrote: Sun Jun 13, 2021 9:12 pm Which means I do call setTranslate hundred of times when rendering.
Is setTranslate by any chance, costly ? :)
The setTranslate function isn't that bad in g3d 1.3, but you may see some slowdown if you call it thousands of times. The function has been optimized a lot since then and it will be faster in g3d 1.4. The most optimal thing would be to have your entire level be one model, but if you don't notice any performance issues, you should be fine.
wgrool
Prole
Posts: 1
Joined: Sun May 23, 2021 8:17 pm

Re: Groverburger's 3D Engine (g3d) v1.4 Release

Post by wgrool »

Hello! I would like to report a large memory leak, if you run it for like 2-3 minutes, the project runs out of ram and crashes, thanks!

Info about project: about 1-2k tris, pretty sure that's all you need, i have checked my code, it doesn't cause it
User avatar
groverburger
Prole
Posts: 49
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (g3d) v1.4 Release

Post by groverburger »

wgrool wrote: Sat Jun 19, 2021 5:32 pm Hello! I would like to report a large memory leak, if you run it for like 2-3 minutes, the project runs out of ram and crashes, thanks!

Info about project: about 1-2k tris, pretty sure that's all you need, i have checked my code, it doesn't cause it
I'm not sure that it's a g3d issue.

I just ran the g3d demo on a sphere with over two thousand triangles and it took up only two more megabytes on ram without using the compress method. Furthermore, g3d has been specifically designed to not allocate any memory unless you call newModel, newMatrix or compress yourself. Are you calling one of these methods often by any chance?

If this problem persists, please open an issue on the Github repository with more specific information so that your problem can be reproduced.
wolf
Prole
Posts: 13
Joined: Tue Jan 12, 2021 10:24 am

Re: Groverburger's 3D Engine (g3d) v1.4 Release

Post by wolf »

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).
mogmoug
Prole
Posts: 1
Joined: Tue Aug 03, 2021 2:23 am

Re: Groverburger's 3D Engine (g3d) v1.4 Release

Post by mogmoug »

Wow, that's great
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests