speed

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

UnixRoot wrote: Fri Jun 21, 2024 5:56 am Nice idea. He could later also write a software renderer to learn how a 3D engine works.

Write an Obj parser, the file format is human readable and pretty easy to understand and to parse. Write a vec3 and a mat4 lib to transform your vertices. This way you learn about the math behind all the 3D transformations needed.

Write a framebuffer and a depth buffer with the help of imageData and byteData objects and FFI pointers to the data. Write a backface culling, a occlusion culling and a frustum culling function.

Write a triangle rasterizer that can fill your polygons. Add perspective correct texture mapping. Try to handle all the edge cases.

I did the same thing some weeks ago, and it's completely possible in Love2D. Even with good performance. I'm not a big fan of 3rd party libs. I try to learn from them but always code my own stuff to get better.
Ive made a 3d engine before. Im calculus level. Like I said, I made a 3d engine in scratch. Sorry, I meant scratch mod. But all I added was arrays and a polygon pen.Nnot a good 3d engine, because I stopped. It has no specified textures. there was no need for painters algorithm because there is one color. and one object. Point is it loads 3d in a plane you can run around in and jump. Im no newbie.
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

RNavega wrote: Fri Jun 21, 2024 3:21 am You want to make a 3D engine?
In order to do that, you need to know what makes a good 3D engine. The only way to investigate that is by trying someone else's engine and taking notes of the things you like and dislike about it.

So to expand on what UnixRoot said above with "Try simple things first", I want to give you a challenge:
1) Download Groverburger's G3D engine for LÖVE: https://github.com/groverburger/g3d
2) Run one example, tweak the parameters and things a bit to get a feel for it.
3) After that, using that same engine, start a new project to implement a Pong 3D game. The game looks like this and is very simple:
images.jpg

It's just two boxes for paddles (yours and the CPU's), one sphere as the ball and 4 boxes forming the corridor that's the playing field.
After you finish this challenge then you can confidently begin working on your own 3D engine.
I dont see why not.
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

dusoft wrote: Wed Jun 19, 2024 10:34 am OK, when you decide on using LOVE (with Lua), get back to us.
Cool thanks for the help.
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

UnixRoot wrote: Thu Jun 20, 2024 7:26 am
1Minus2P1Stringer2 wrote: Wed Jun 19, 2024 1:50 am Im really really avoidant of making my own language, but i may have to.
And how do you imagine writing your own programming language? It's much more difficult than reading the Love2D documentation or understanding the concept of a depth buffer.

Just read the Love2D documentation. The logic of programming is actually always the same, regardless of whether you use tools like Scratch or Construct or a real language.

I had no clue of LUA or any other languages when I started using Love2D. I just read the documentation and tried things out, or tried to port existing code to Love2D to understand how everything works.

Try simple things first and don't start with a 3D engine.
Making my own programing laugauge? No that wont be hard, just a bit long. Why would you say that?
User avatar
dusoft
Party member
Posts: 654
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: speed

Post by dusoft »

It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

dusoft wrote: Sat Jun 22, 2024 10:11 pm It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
assembly.
1Minus2P1Stringer2
Prole
Posts: 30
Joined: Mon May 13, 2024 4:05 pm

Re: speed

Post by 1Minus2P1Stringer2 »

dusoft wrote: Sat Jun 22, 2024 10:11 pm It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
Not if the language you were using was confusing you. Which, right now, lua is kinda confusing me. Love2d is fine, but lua's framework confuses me. like how does lua render slower then scratch? Scratch can render an image from an image scanner in 3 seconds. Why is lua rendering at 2 minutes per frame, at real time? I get love2d has a function to load multiple pixels at once, which speeds it up by alot but still?
User avatar
marclurr
Party member
Posts: 158
Joined: Fri Apr 22, 2022 9:25 am

Re: speed

Post by marclurr »

I'm positive if it's taking your program 2 minutes to render a frame that it's your code at fault. I suspect the issue is you're applying scratch idioms to a lua program. If you have any more problems with your code we can definitely help you understand how to fix them if you show us.

As others have said, you're seriously underestimating the complexity of making your own language. I wouldn't discourage someone from learning how to do that, it's definitely worthwhile, but you're not going to make something better than what's already out there with no experience in that field, especially if you're easily confused by trivial parts of the existing ones.
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: speed

Post by pgimeno »

Graphically speaking, Love2D could be defined as a fancy wrapper around OpenGL using Lua. The important takeaway of that definition is that if you use Löve, you have to play by the rules of using the GPU. In particular, if you're rendering pixel by pixel and not using either ImageData:mapPixel or ImageData:getFFIPointer to draw the pixels, and (Image):replacePixels to put these pixels into an intermediate Image object to draw to the screen, then you're doing it wrong, in the sense that you can't expect the speed to be reasonable. See for example this thread for someone using FFI to draw into a framebuffer at over 60 FPS.

Of course, the fact that Löve uses OpenGL under the hood means that it's capable of using GPU acceleration, meaning you don't need to bother writing a full 3D engine, at least not the rendering part. I understand it can be fun to do that, but you won't get the full advantage of GPU acceleration, and even if it's written in assembly, bandwidth issues will prevent it from working fast enough for anything complex (CPUs can't draw nearly as many triangles per frame as GPUs), not to mention you would lose one of the salient point of using Löve: cross-platform compatibility.
User avatar
UnixRoot
Party member
Posts: 100
Joined: Mon Nov 08, 2021 8:10 am

Re: speed

Post by UnixRoot »

1Minus2P1Stringer2 wrote: Sat Jun 22, 2024 11:07 pm
dusoft wrote: Sat Jun 22, 2024 10:11 pm It is much more difficult, @UnixRoot is right. In what (existing) language are you going to write it, anyway?
Not if the language you were using was confusing you. Which, right now, lua is kinda confusing me. Love2d is fine, but lua's framework confuses me. like how does lua render slower then scratch? Scratch can render an image from an image scanner in 3 seconds. Why is lua rendering at 2 minutes per frame, at real time? I get love2d has a function to load multiple pixels at once, which speeds it up by alot but still?
I don't know what you're doing wrong. I can easily render a world, consisting of multiple 4096x4096 height maps with raw 32 bit floating point data and textures of the same resolution on top. Even on my Potato PC, I get hundreds or even thousand of FPS in my CPU based software renderer. Love2D is FAST, if you optimize your code.
love 2024-06-23 12-52-15-55.png
love 2024-06-23 12-52-15-55.png (133.77 KiB) Viewed 1651 times
Edit:

Even with thousands of sprites, checked against a depth buffer, the performace is great. Note, thats an old shot with pretty unoptimized code. It's around two times faster by now. As is said before, thats without using GPU features. It would be even faster with GPU.
love 2024-06-18 17-31-19-39.png
love 2024-06-18 17-31-19-39.png (110.25 KiB) Viewed 1636 times
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 8 guests