Page 16 of 22
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Tue Jan 18, 2022 4:38 pm
by Hydrogen Maniac
Jasoco wrote: ↑Tue Jan 18, 2022 12:44 pm
Hydrogen Maniac wrote: ↑Mon Jan 17, 2022 11:36 pm
You can simply call love.graphics.setMeshCullMode between drawing the models.
Code: Select all
love.graphics.setMeshCullMode("back")
model:draw() --drawn with back culling
love.graphics.setMeshCullMode("front")
model2:draw() --drawn with front culling
Why didn't I think of that? Does it have any sort of impact on performance?
I haven't done any serious testing but I'm pretty sure it has no discernible performance impact. It's probably fine to slip it into the model:draw function if you want to implement some sort of model:setCullMode() function.
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Wed Jan 19, 2022 5:32 pm
by Jasoco
Hydrogen Maniac wrote: ↑Tue Jan 18, 2022 4:38 pm
I haven't done any serious testing but I'm pretty sure it has no discernible performance impact. It's probably fine to slip it into the model:draw function if you want to implement some sort of model:setCullMode() function.
Doesn't seem to have any performance hit. I can't see why it would. That's cool. I can just set the proper mode before drawing each model based on whether they should have a back side or not. Better than making the same polygons twice. Though that doesn't seem to have much impact either. This is just easier. lol
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Thu Jan 27, 2022 6:41 pm
by Jasoco
Is it possible to have the triangles be a single color or utilize .mtl files instead of a texture? Would that be possible to implement or should I just stick to using single color textures if I need to have flat shaded polygons?
Also is it possible to easily convert Y-up oriented .obj data to Z-up orientations? I've noticed most of the .obj files I find online use Y-up but g3d changed to Z-up a while ago so they end up importing lying down instead. Is it as easy as just switching the Y and Z around when importing? Surely the UV would have to be manipulated as well if so. I just wouldn't know how to go about it myself.
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Fri Jan 28, 2022 9:42 am
by EngineerSmith
You can easily switch to z up by importing your model into blender, and then when exporting an option for z-up will appear (you can also triangulate faces as an option if they're not yet).
MTL files can be supported - but it will means g3d will have to shift it's idea of what a model is. A model would have multiple meshes as OBJ+MTL can define multiple materials for multiple 'objects' within the file. This means g3d would have to implement a material system to support it - when g3d aim is meant to keep simple so people can easily customize it with little overhead. You could fork it and add such a system in if you want - MTL files are human readable similar to OBJ and you could make the addition in a couple days of works.
Edit: g3d also supports colours within meshes, but not via the obj reader. `VertexColor` can be found as the 4th attribute to the vertex layout (9th index of the vertex (lua arrays)).
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Fri Jan 28, 2022 4:04 pm
by Jasoco
EngineerSmith wrote: ↑Fri Jan 28, 2022 9:42 am
You can easily switch to z up by importing your model into blender, and then when exporting an option for z-up will appear (you can also triangulate faces as an option if they're not yet).
I've done this before I was just wondering if it could just be put into the library as an option. I could probably code my own if I really need it. Probably won't in the end though as I'd just be making my own models eventually and would just export them the g3d way.
EngineerSmith wrote: ↑Fri Jan 28, 2022 9:42 am
MTL files can be supported - but it will means g3d will have to shift it's idea of what a model is. A model would have multiple meshes as OBJ+MTL can define multiple materials for multiple 'objects' within the file. This means g3d would have to implement a material system to support it - when g3d aim is meant to keep simple so people can easily customize it with little overhead. You could fork it and add such a system in if you want - MTL files are human readable similar to OBJ and you could make the addition in a couple days of works.
Edit: g3d also supports colours within meshes, but not via the obj reader. `VertexColor` can be found as the 4th attribute to the vertex layout (9th index of the vertex (lua arrays)).
You'd just load the .mtl file instead of a .png file and it would parse the .mtl file instead. (I only want the face color definitions, not trying to replicate stuff like shiny metal or rough brick textures or whatever) I could probably try and figure it out myself. It's a lot of data to parse but it's pretty much done the same way g3d parses the .obj file itself. It's just having g3d display the triangles as the correct color I wouldn't know where to start with. So let me go look. Maybe I can hack support in myself.
I dunno, maybe it's more complicated. I don't know much about 3D rendering programs. If I did I'd be using Blender by now. lol
I just wanted to implement this because I found some really good royalty free low poly objects, namely a whole bunch of trees and houses, that I wanted to use as placeholders but they all use face colors instead of textures. And I wouldn't know how to change them all to have a texture instead, even if it's a flat color texture. I also like the aesthetic of just flat shaded polygons.
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Fri Jan 28, 2022 8:48 pm
by EngineerSmith
Jasoco wrote: ↑Fri Jan 28, 2022 4:04 pm
You'd just load the .mtl file instead of a .png file and it would parse the .mtl file instead. (I only want the face color definitions, not trying to replicate stuff like shiny metal or rough brick textures or whatever) I could probably try and figure it out myself.
Honestly, if you want a really simple system. First you read the MTL file and grab the colours for the different materials definitions, then as you parse the OBJ you switch which material you use when the command appears (I think I remember it being usemtl <material name> or something) and you then just use that materials colour within each vertex. Then you don't need to have separate meshes for each object - this won't work if you want different textures however - unless they're all on the same texture.
The wiki covers all what the readable files mean
https://en.wikipedia.org/wiki/Wavefront ... te_library you probably want to focus on the key `Kd` in each material for the diffuse colour, and then the others if you want a more interesting lighting.
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Mon Mar 07, 2022 1:58 pm
by Jasoco
I'll just forget about that whole thing. If I want a flat shade I'll just make my models with single color textures. lol
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Sun Apr 03, 2022 9:34 pm
by Jasoco
Question though: Is there a way to tilt the camera around the third axis? You can spin it around the Z (Turning) axis. Tilt it on the X (Looking up and down) axis. But how if possible, do you tilt it on the Y (Forward) axis? Is this possible officially? Or can it be easily implemented? I guess it would also be referred to as rolling the camera.
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Mon Apr 04, 2022 6:57 pm
by groverburger
Jasoco wrote: ↑Sun Apr 03, 2022 9:34 pm
Question though: Is there a way to tilt the camera around the third axis? You can spin it around the Z (Turning) axis. Tilt it on the X (Looking up and down) axis. But how if possible, do you tilt it on the Y (Forward) axis? Is this possible officially? Or can it be easily implemented? I guess it would also be referred to as rolling the camera.
Yep, the easiest way to achieve this is to change the camera's up vector, and make it point up and slightly to whatever direction you want to tilt.
Something like:
Code: Select all
g3d.camera.up = {some vector here}
g3d.camera.updateViewMatrix()
Re: Groverburger's 3D Engine (g3d) v1.5.1 Release
Posted: Tue Apr 05, 2022 10:00 pm
by Jasoco
groverburger wrote: ↑Mon Apr 04, 2022 6:57 pm
Yep, the easiest way to achieve this is to change the camera's up vector, and make it point up and slightly to whatever direction you want to tilt.
Something like:
Code: Select all
g3d.camera.up = {some vector here}
g3d.camera.updateViewMatrix()
Interesting but it seems to rotate the world itself instead of just the camera. In other words, if I'm looking forward and I change say the Y value, it'll look right until I turn my head at which point I realize it's changing the world itself instead of just rolling the camera.
I tried to just use Löve's translation stuff like push, rotate, translate, pop to just rotate the image itself but of course since g3d is all shader based it just ignores all that. lol