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

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
yetneverdone
Party member
Posts: 378
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by yetneverdone »

Awesome tool! I could totally use this to try and learn 3d in LOVE. Though i think that most users of this library is going to need a wiki documenting the API.

Also, question, how does one apply collision and basic lighting with this?
User avatar
groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by groverburger »

JJSax wrote: Mon Oct 26, 2020 10:16 pm Thanks for the tool! I used ss3d to create my solar system scale, I'm excited that the project isn't dead! Great work!

If you're interested in what you made possible: https://youtu.be/c_zMSnKyZc8
Cool project! Glad I could help.
User avatar
groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by groverburger »

yetneverdone wrote: Fri Oct 30, 2020 3:47 am Awesome tool! I could totally use this to try and learn 3d in LOVE. Though i think that most users of this library is going to need a wiki documenting the API.

Also, question, how does one apply collision and basic lighting with this?
Thanks for the kind words!

I agree though. I'm procrastinating on documentation because there are still a few things I'd like to change with g3d right now like moving everything out of the global namespace. I do agree it would be helpful - I intend to get to it soon™.

Collision is kinda half-baked at the moment. There is a polygon-ray call you can use, but I think some implementation of the GJK algorithm would be helpful. Lighting can be done by applying a custom shader like so:

Code: Select all

thisModel.shader = myLightingShader
Where thisModel is a variable creating a g3d model and myLightingShader shader code that contains a vertex and fragment shader - use the CameraShader in camera.lua as a reference.
There some tutorials online about lighting shaders in GLSL, like this one, but they can be tricky to translate into love's flavor of shading language.
User avatar
yetneverdone
Party member
Posts: 378
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by yetneverdone »

Oh my bad, i didn't specify what i meant by lighting. What I meant was environmental lighting like shadow and flashlight.
RNavega
Citizen
Posts: 74
Joined: Sun Aug 16, 2020 1:28 pm

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by RNavega »

yetneverdone wrote: Sun Nov 01, 2020 1:54 pm Oh my bad, i didn't specify what i meant by lighting. What I meant was environmental lighting like shadow and flashlight.
Just being realistic here. It might be better for you to try a higher-level engine that already comes with those features, like Unreal or Unity, where you mostly tick the box on the light object to turn on real-time shadows for it, and add a texture projector with additive-blend mode for the flashlight effect.

Otherwise you'd have to implement these things into this engine. Depending on your skillset, this would not help you get closer to your goal of making a simple 3D game but sidetrack it.
User avatar
yetneverdone
Party member
Posts: 378
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by yetneverdone »

Yeah I have no experience with 3D at all (except a couple of basic know-how in 3d modeling), but I want to learn it using LOVEVE and a framework/library like this could really help

I'm aiming for something very simple like this game in terms of perspective and atmosphere, so maybe not really needing much lighting and shadow
RNavega
Citizen
Posts: 74
Joined: Sun Aug 16, 2020 1:28 pm

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by RNavega »

I don't see real-time or baked shadows in there, but I can see fog being used.

This article explains how to implement fog with a shader:
https://webglfundamentals.org/webgl/les ... l-fog.html

The fog factor can be the distance from the vertex to the camera (instead of just the depth of the vertex in relation to the camera plane, which would give you incorrect fog that changes depending on the rotation of the camera towards the object).

Based on the default shader in Groveburger3D, and provided that you send in a uniform with the position of the camera, it'd be something like the following (UNTESTED):

Code: Select all

uniform vec3 worldCameraPosition

varying float distanceToCamera

        #ifdef VERTEX
            vec4 position(mat4 transform_projection, vec4 vertex_position)
            {
                distanceToCamera = length(worldcameraPosition - vertex_position.xyz);
                return projectionMatrix * viewMatrix * modelMatrix * vertex_position;
            }
        #endif
        
       #ifdef PIXEL
            vec4 effect(vec4 color, Image tex, vec2 texcoord, vec2 pixcoord)
            {
                vec4 texcolor = Texel(tex, texcoord);
                if (texcolor.a == 0.0) { discard; }

                // Plug 'distanceToCamera' into some formula that darkens 'texcolor' (the pixel color).
                const float MIN_DISTANCE = 10.0;
                const float MAX_DISTANCE = 30.0;
                const float fogInterval = MAX_DISTANCE - MIN_DISTANCE;
                float fogFactor = clamp(distanceToCamera - MIN_DISTANCE, 0.0, fogInterval) / fogInterval;
                texcolor = mix(texcolor, vec4(0.0), fogFactor);
                
                return vec4(texcolor);
            }
        #endif
User avatar
groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

Re: Groverburger's 3D Engine (G3D) New and Improved!

Post by groverburger »

yetneverdone wrote: Mon Nov 02, 2020 4:18 am Yeah I have no experience with 3D at all (except a couple of basic know-how in 3d modeling), but I want to learn it using LOVEVE and a framework/library like this could really help

I'm aiming for something very simple like this game in terms of perspective and atmosphere, so maybe not really needing much lighting and shadow
This could definitely be achieved in g3d. I wrote some documentation in the wiki on the Github repo.
Hopefully it'll be helpful!

Here's the link to the g3d wiki: https://github.com/groverburger/g3d/wiki
User avatar
yetneverdone
Party member
Posts: 378
Joined: Sat Sep 24, 2016 11:20 am
Contact:

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

Post by yetneverdone »

Yeah im keeping an eye on the lib, but why is the lib global? I think people would want the lib/framework to be localized and decoupled globally.
User avatar
groverburger
Prole
Posts: 35
Joined: Tue Oct 30, 2018 9:27 pm

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

Post by groverburger »

yetneverdone wrote: Sat Jan 16, 2021 7:01 am Yeah im keeping an eye on the lib, but why is the lib global? I think people would want the lib/framework to be localized and decoupled globally.
Yeah I understand that complaint - I'm considering doing kinda what p5js does and having a global/non-global version of the lib.

The main reason the lib is global is because I pulled the files that are now called g3d out of a project I was working on and I didn't change them to be non-global.
I'm worried changing this that would break compatibility, and I've already broken compatibility once.

I also think having the lib in the global namespace may make the source code easier for people to read and understand themselves, which is something I aim for with g3d.

So, I'm open to more feedback here.

(Also if anyone is wondering I mistyped and titled this update v1.2 when I should have typed v1.1 -- oops!)
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests