I Created a Game Engine Just to Optimise This

  Рет қаралды 895,879

Vercidium

Vercidium

Күн бұрын

Download the source code for all my videos here: / vercidium
I spent the past 6 years creating a game engine and I've been shocked at the things that can make or break performance.
I put together 2 simple optimisations you can use to stop your games from stuttering.
Music is Irradiant and Spirit by Disjoint Square
disjointsquare.bandcamp.com
Timestamps
0:00 Intro
0:16 Burgers
0:36 The Problem
1:16 Alerts
1:52 Two Meshes
2:57 The Kitchen
3:24 Classes
4:04 Over 9000 FPS?
4:34 Interactive Demo
#gamedev #gamedevelopment #gameengine

Пікірлер: 1 100
@Vercidium
@Vercidium 4 ай бұрын
Download the source code for all my videos here: patreon.com/vercidium If you have any rendering or game dev questions, ask them here!
@utilizator500
@utilizator500 4 ай бұрын
Christ, could you have made the code any smaller? I don't know what 4k 60 inch monitor you have but this is bad on small screens.
@FortisConscius
@FortisConscius 4 ай бұрын
Have you looked at Minetest, per chance? Do you have thoughts about it?
@_vicary
@_vicary 4 ай бұрын
Is this technique used by any popular game engines and why?
@Greedy-Allay
@Greedy-Allay 4 ай бұрын
I feel like they should stop inventing new hardware, and instead try to optimise games so they work with the "older" hardware if you know what i mean
@monicde4570
@monicde4570 4 ай бұрын
Recently I learned about Vram for optimization. My game uses Unity and mixes 2D and 3D. So we have a lot of hand-paint texture, filling up my Vram. Starting to learn how Vram works. I found most tech is a comparison for disk size like jpg but when it sends GPU is still big(I know Crunch but it is just for fast decompression not reduced size). Found the only thing I could do was pack the channel and tell the artist to reduce texture count and separate scenes into small chunks to load. I want to know more about Vram's work and if there is any way non-destructive or lost too much texture quality to be optimized in modern GPU. Anything even not for unity is appreciated!
@ThislsYusuf
@ThislsYusuf 4 ай бұрын
The greater skill here isn't code optimization, but rather how you break it down with tasty metaphors to make for easily digestible content. Kudos.
@Tuhar
@Tuhar 4 ай бұрын
I too, am now hungry for burgers.
@DriftJunkie
@DriftJunkie 4 ай бұрын
Just let this man cook
@ThislsYusuf
@ThislsYusuf 4 ай бұрын
Haha, he's cooking fr@@DriftJunkie
@Nerthexx
@Nerthexx 4 ай бұрын
Analogy an average american can understand, yes.
@reed6514
@reed6514 4 ай бұрын
I prefer strawberry flavored metaphors 🍓
@Necrotechian
@Necrotechian 4 ай бұрын
123 optimization videos later: This game runs so smooth you can get 4k graphics with 120 frames a second on a potato clock even without the potatoes.
@uis246
@uis246 4 ай бұрын
Quake 666
@SethbotStar
@SethbotStar 4 ай бұрын
I think the first arm cpu was so energy efficient that it ran on ambient electricity or something like that, maybe that could be an actual goal point of optimization, to have it run on that.
@RowbotMaster
@RowbotMaster 4 ай бұрын
​@@SethbotStarrebuilds crysis to run on a single double A for a year
@elcalabozodelandroide2
@elcalabozodelandroide2 4 ай бұрын
​@@RowbotMasterand yet it remains un-portable for the switch bc nintendo.
@MichaelChin1994
@MichaelChin1994 4 ай бұрын
He's gonna get Doom working on an Ancient Roman sun dial
@ARTEMISXIX
@ARTEMISXIX 4 ай бұрын
Vercidium trying to explain game engine optimisation to an American: "So imagine a burger."
@emporioalnino4670
@emporioalnino4670 4 ай бұрын
They should make a version more at home for Aussies "Ok so imagine a parma.."
@Vercidium
@Vercidium 4 ай бұрын
@@emporioalnino4670 I love a good parma
@violet_broregarde
@violet_broregarde 4 ай бұрын
@@emporioalnino4670 What's a parma, a chicken parmesan? That's standard bar food in Australia? I love that
@CanalDoPhillipeMEME
@CanalDoPhillipeMEME 4 ай бұрын
most healthy american breakfest be like
@Vercidium
@Vercidium 4 ай бұрын
@@violet_broregarde a chicken parmigiana
@KilledByAPixel
@KilledByAPixel 4 ай бұрын
This is why you can use double buffering, which is kind of like what you are doing but instead of for the framebuffer, you are doing it for the mesh. Normally GPU operations queue up in the buffer, they aren't meant to be completed by the end of the refresh. If you use a double buffered system, it allows everything to render without a stall, because when a stall would have occurred, it just shows the back buffer like normal.
@SirNightmareFuel
@SirNightmareFuel 4 ай бұрын
Thank you! so that's where I recognised this technique, it's like a Double Buffering👍❤ Its probably still worth it, but the trade off you have with this technique is with the increased memory usage, as you'd about double the memory needed for the area around the player, and it adds more complexity managing these separate sources of meshes.
@OMGclueless
@OMGclueless 4 ай бұрын
@@SirNightmareFuel That's true but GPUs have massive amounts of very-fast memory these days in order to support the heavy texture bandwidth of AAA games. Doubling or even 10x'ing the memory used by the meshes is not a huge deal because they all refer to the same textures and the textures are the most memory-hungry part of rendering unless you go crazy with poly-count.
@1Maklak
@1Maklak 4 ай бұрын
It's even better with tripple buffering. One framebuffer is displayed on screen, one is being rendered to and the third one is ready to be displayed. When the part of hardware responsible for displaying is done with a display cycle (or VSync kicks in), it looks at the buffers and either displays the same one again or displays the ready buffer if it is newer. When the part that does the rendering is done, it marks it's buffer ready, then renders into whichever of the other buffers is not being displayed. This way the newest ready buffer is always displayed, rendering works continuously and there is no tearing, at least in theory.
@javaguru7141
@javaguru7141 4 ай бұрын
The real downside to this type of technique when used for the framebuffer is latency. I can't play games with triple buffering except on very high refresh-rate monitors because the latency causes me nausea (except with an uncapped internal/buffer refresh rate which doesn't seem to be commonly implemented sadly).
@sarkedev
@sarkedev 4 ай бұрын
Yup, screen buffer was my first thought too.
@stormsoendergaard3023
@stormsoendergaard3023 4 ай бұрын
This is standard behavior in all major game engine used in production for the last 10-15 years.
@diddlenfiddle7311
@diddlenfiddle7311 4 ай бұрын
I was thinking that might be the case because unless I'm missing something, which is likely, he's described async code
@bradbradford8576
@bradbradford8576 4 ай бұрын
I wonder when someone working at Minecraft is going to find out. Split screen with my kids is ridiculous if anyone is crafting. It freezes every time
@gendalfgray7889
@gendalfgray7889 4 ай бұрын
UE already have that?
@greatbriton8425
@greatbriton8425 4 ай бұрын
I'd be surprised if this was true.
@Unethical.Dodgson
@Unethical.Dodgson 4 ай бұрын
@@greatbriton8425 Yeah it was definitely an exaggeration but he's right that it's not new.
@joeroeinski1107
@joeroeinski1107 4 ай бұрын
Semaphores could also be ideal as fences can cause the CPU to stall waiting for GPU work to finish. Semaphores would allow for exclusive synchronization of GPU tasks ensuring the CPU is constantly writing commands and the GPU is constantly processing them. Great video nonetheless.
@oliverer3
@oliverer3 4 ай бұрын
Love semaphores, very useful if a bit scary!
@Stoney3K
@Stoney3K 4 ай бұрын
In real world implementations these are probably implemented as semaphores, because the transferring of data is being done in a background thread anyway. The busy-waiting done by a fence is probably done here for simplicity purposes because it makes the 'waiting' part easier to explain.
@joeroeinski1107
@joeroeinski1107 4 ай бұрын
@@Stoney3K Yes. Transfers don't just run as a background thread, but DMA transfers over PCIe can be done completely async to the rest of the system (and GPUs often have dedicated transfer queues to accommodate this, allowing for ultra-fast async transfer from the CPU). Nowadays you can just generate some data yourself on the GPU though in compute, eliminating the need to transfer entirely and keeping everything local to VRAM.
@Stoney3K
@Stoney3K 4 ай бұрын
@@joeroeinski1107True if you consider transferring of things like textures and shaders from the CPU to the GPU. But most of the waiting is often caused by the game loading in or parsing new assets from disk, which make it noticeably slow because I/O is *much* slower than CPU/GPU/memory access. It's even more pronounced when the game is an online one and the assets have to be fetched from an offsite server.
@joeroeinski1107
@joeroeinski1107 4 ай бұрын
@@Stoney3K Absolutely, though with emerging technology such as DirectStorage this soon may not be an issue.
@stratos2
@stratos2 4 ай бұрын
I just binged all of your optimisation videos. The metaphors are awesome and easy to follow, the code and graphics are clean, the voiceover is easy to understand. This is what I wish school/university was like. Instant subscribe, you have earned a place among my favorite KZfaqrs. Thank you for your work.
@Vercidium
@Vercidium 4 ай бұрын
Far out, thank you! I'm stoked you like them and hope they help!
@ArneChristianRosenfeldt
@ArneChristianRosenfeldt 4 ай бұрын
I can’t read the tiny font
@DaStuntChannel
@DaStuntChannel 4 ай бұрын
school/university should teach you how to come up with these ideas by yourself
@NicosoftNT
@NicosoftNT 4 ай бұрын
@@DaStuntChannel Universities teach you 15 years old techniques in a field that is always 5 years ahead and counting.
@DaStuntChannel
@DaStuntChannel 4 ай бұрын
@@NicosoftNT That as well
@inferno3197
@inferno3197 4 ай бұрын
You lost me at burger
@cuboembaralhado8294
@cuboembaralhado8294 13 күн бұрын
He won me at burger
@SatisfiedOnion
@SatisfiedOnion 4 ай бұрын
I love this man's food analogies as much as this guy loves his optimization. Amazing video, I'm so in love with the animations!
@duncathan_salt
@duncathan_salt 4 ай бұрын
It's worth noting that for some games, the additional input delay might be considered unacceptable. Most games it won't matter but in those rare cases it may be necessary to explore alternatives
@markdmckenna
@markdmckenna 3 ай бұрын
I think this technique won't increase input delay. It effectively just leaves old geometry on screen until new geometry is available. At worst you'll get "pop ins" instead of stalls.
@X606
@X606 3 ай бұрын
@@markdmckennait it does add input delay, think of it this way: now you're shipping a whole frame with this old mesh instead of the new one, that might take 16ms or so, but what if 5ms into those 16ms the transfer completes? now you still have to wait for the full frame to be drawn before we can include the new mesh in the next frame. Whereas if we just stalled for those 5ms we'd only have to wait 5+16 ms instead of 16+16ms
@markdmckenna
@markdmckenna 3 ай бұрын
@@X606 Maybe a different definition of input delay here? IMO as long as we're providing "reasonably" up to date geometry for the user to interact with, there is no added input delay.
@Ghorda9
@Ghorda9 2 ай бұрын
@@markdmckenna instead you get more render latency.
@goreldeeno
@goreldeeno 4 ай бұрын
Easily changed my prespective on how rendering works, Amazing work!
@Mint25pop
@Mint25pop 4 ай бұрын
Videos like this are rare to find But It has to be my favorite type of video by far, making code run faster, better gaming experience, GPU goes vroom I love it!
@Vercidium
@Vercidium 4 ай бұрын
Thank you, more videos to come!
@Candywolf949
@Candywolf949 4 ай бұрын
yooooo i love that not only did you make a cool game i enjoyed, but that you're sharing all the knowledge you learned from making it with everyone. Good luck dude! I hope you continue this, It's really interesting and I love it.
@chrislister3009
@chrislister3009 4 ай бұрын
I really appreciate this format of video from you. Please keep up the good work:)
@starplatinum3305
@starplatinum3305 4 ай бұрын
Bro i need more optimization videos this is amazing af
@Vercidium
@Vercidium 4 ай бұрын
Working on it! Thank you
@chickennuggetman2593
@chickennuggetman2593 4 ай бұрын
​@@VercidiumCan this work for terraria? If so, maybe a mod could be made for my dinky glorified potato with a screen..
@themourningwolf8926
@themourningwolf8926 4 ай бұрын
Uhm, the best person to ask is the dev, I recomment going to the subreddit and asking Redigit and his crew if this is something they have toyed with or even considered. I'm sure he would be stoked to see some new ideas!@@chickennuggetman2593
@Jmcgee1125
@Jmcgee1125 4 ай бұрын
Fantastic overview. Right to the point and thorough enough to show off everything without getting bogged down in the details.
@bejoscha
@bejoscha 4 ай бұрын
I'm not coding games and stumbled here by chance, but this is a really, really well done description which can be appreciated by anyone with at least a bit of coding experience. Thanks.
@Blademaster162
@Blademaster162 4 ай бұрын
Great video, loved all the animations. Even as someone who isn't particularly experienced in coding I feel like I understood everything!
@suza3199
@suza3199 4 ай бұрын
This is genuinely interesting. I love it. Keep it up!
@goatmeal5241
@goatmeal5241 4 ай бұрын
It really was worth buying this 16,000 fps monitor---this is the first video to really use it to its fullest, but boy is it glorious.
@waltonsimons12
@waltonsimons12 4 ай бұрын
Waste of money. Nobody needs 16,000 fps. 12,000 is more than enough.
@AntiAntYT
@AntiAntYT 4 ай бұрын
the eye doesn't see more than 4,000 fps
@nukesrus2663
@nukesrus2663 4 ай бұрын
@@waltonsimons12 Trust me dude, once you've experienced 16,000 fps, 12,000 feels like looking at a slideshow.
@aqua-bery
@aqua-bery 4 ай бұрын
​@@AntiAntYTthe eye sees up to 60fps. Everything above is still useful, because the world runs at ∞ FPS, so the closer your pc can be to that, the better it will ~feel~
@luviam0001
@luviam0001 3 ай бұрын
@@aqua-bery Eyes can see much more than 60fps. The visual difference from 60fps to 120fps is quite noticeable as 120fps is just a lot smoother visually and your eyes can see that difference.
@zivmbs
@zivmbs 4 ай бұрын
I really loved the video and the analogy. I think you should increase the size of the code and animations, because seeing them on mobile is kind of hard. Great video nonetheless!
@Vercidium
@Vercidium 4 ай бұрын
Will do, thank you for the feedback and glad you liked the video!
@cookietheory
@cookietheory 4 ай бұрын
My favorite series on youtube, thank you for doing it!
@Vercidium
@Vercidium 4 ай бұрын
Too kind! Thank you
@KitsumiTheFox
@KitsumiTheFox 4 ай бұрын
This kind of sounds like double buffering, but for the geometry instead of the actual framebuffer. Very cool idea!
@Cara.314
@Cara.314 4 ай бұрын
It's know as Asynchronous Buffer Update/Upload, nothing new. The underlying concept of decoupling data transfer from rendering to avoid stalling the graphics pipeline is fundamental to graphics programming and has been a consideration as long as there have been programmable GPUs and sophisticated graphics APIs. it's been a feature of both directx and ogl for decades at this point.
@MadHau5
@MadHau5 3 ай бұрын
That's exactly what I thought! Same basic principles as double buffering!
@WartimeFriction
@WartimeFriction 4 ай бұрын
I don't code yet but it is something that I find fascinating. I really enjoyed how you made this problem make sense even to me. Thanks for sharing
@Kw1h
@Kw1h 4 ай бұрын
This is a highly optimized dev tutorial. Jokes aside I think you have a true talent for game dev and teaching. Subscribed.
@markonfilms
@markonfilms 3 ай бұрын
This is awesome! Managing stuff like this is still a real challenge and this is a great solution. Thank you for the great easy to understand explanation too!
@datow4327
@datow4327 4 ай бұрын
love the vids
@SylooxD
@SylooxD 4 ай бұрын
Great video and I am sure it will help me in the future 👍At the first moment I thought the sorting by swapping with the first element only works with 2 meshes but after thinking about it I realized it also works well with longer lists too if the transfer time is equal for every mesh. If not, then a circular array/ring buffer might be a better alternative to avoid rendering fast-to-transfer future meshes before slow-to-transfer past ones. That would cause the future mesh to render 2 frames while skipping the past one with your algorithm.
@Vercidium
@Vercidium 4 ай бұрын
Excellent point you’re right, a ring buffer would be more appropriate here. Now you have me thinking: I should be removing the element and inserting it at the start, rather than swapping. You’re right, great pickup! I wrote a similar thing for a particle engine, which does skip over the slow-to-transfer ones to ensure the most up to date buffer is always being rendered (even if it means an entire frames worth of data is skipped), i.e. if the cpu runs faster than the GPU and is writing to 2 buffers each frame, every 2nd buffer will never make it to the screen
@stratos2
@stratos2 4 ай бұрын
​@@VercidiumI would love to see a video where you take all the improvement ideas from the comments and try to apply them and see how they do.
@Zizaco
@Zizaco 4 ай бұрын
"Explain double buffer like I'm five" Great video Vercidium!
@ThatNiceDutchGuy
@ThatNiceDutchGuy Ай бұрын
Wow, I really like that underlaying background simulation at 1:51 I'm trying building something similar myself using Openprocessing but this looks like some great end result! Thanks for the inspiration.
@StewartWild
@StewartWild 3 ай бұрын
This video is epic. Liked, subscribed. I can't wait to watch your other ones, you have a great mind for being able to teach and explain concepts.
@Wishbone_Games
@Wishbone_Games 4 ай бұрын
Excellent video i genuinely learned so much from it. Love the metaphors, keep up the great work!
@Vercidium
@Vercidium 4 ай бұрын
Glad to hear, thank you!
@gavinmorton7682
@gavinmorton7682 4 ай бұрын
Hey small feedback: could you please zoom in when displaying code? Small screens cant see the logic you're trying to showcase (even if the exact text doesn't matter). Awesome video as always❤️
@aljazbrilj1698
@aljazbrilj1698 4 ай бұрын
Very good, thank you for informing the community
@nicolasdesenvolvedor1642
@nicolasdesenvolvedor1642 3 ай бұрын
truly incredible, good job!
@GOLD4DJ
@GOLD4DJ 3 ай бұрын
This.. this is a beautiful explanation. Thank you.
@iminumst7827
@iminumst7827 4 ай бұрын
I had a similar issue in my 2D game made in Game Maker Studio. When it tried to render some high resolution sprites I would get those stutters. However, I found a very useful command "texture_prefetch" which as you can guess loads a texture group into VRAM memory even if it's not being drawn yet. And "texture flush" clears a group from VRAM. By being manually proactive about texture loading, I not only removed all the stutter, but I also cut level loading time down to under half a second. I'm pretty sure all engines have asynchronous buffered data loading / rendering, but I think some developers don't utilize it to it's full extend and just try to render a bunch of unloaded data at once. Your explanation is very good, and I hope it reminds other devs to think more carefully about asset loading.
@lucaspawprint1888
@lucaspawprint1888 4 ай бұрын
The master chef has an infinite number of pans, but doesn't want to overwhelm his apprentices, so he keeps only the amount of pans necessary in the kitchen until a greater or lesser amount is needed.
@Vercidium
@Vercidium 4 ай бұрын
Haha excellent analogy
@angeldude101
@angeldude101 3 ай бұрын
Well, maybe not _infinitely_ many pans. More like, only about 4 billion pans. And usually when the chef needs more, rather than just grabbing the amount needed, usually they'll just grab as many extra pans as they're already using. It wastes a bit more space in the kichen, but it saves on the amount of trips to fetch more pans a way that generally balances out well.
@ichbinschwul187
@ichbinschwul187 3 ай бұрын
incredibly well edited, paced and informative video
@mmmmigs
@mmmmigs 4 ай бұрын
fantastic breakdown. thank you for sharing! subbed and looking forward to your other videos :)
@whitecrow20XX
@whitecrow20XX 4 ай бұрын
Best programming analogy is always about food and cooking.
@Nevict
@Nevict 4 ай бұрын
I like how you're showing alternatives to the "just add more cores/memory" mentality.
@kyraxx
@kyraxx 4 ай бұрын
Won't these extra copy of the mesh consume more memory? I suspect this is a compromise. Here the mesh is extremely simple so it doesn't need much memory. On a more complex mesh this could require you to "just add memory".
@qvindicator
@qvindicator 4 ай бұрын
@@kyraxx The extra threads would require more cores to be more efficient as well. This solution is literally "just add more cores/memory", but it works.
@internet5076
@internet5076 4 ай бұрын
Just one more
@winumoritribe8425
@winumoritribe8425 4 ай бұрын
Holy shit, this is spectacular! It's amazing how much more you can do with that one step further.
@coalkey8019
@coalkey8019 3 ай бұрын
Cool video. I'd love to see everything filling up the screen so I can actually read stuff while watching on my phone.
@mz_eth
@mz_eth 4 ай бұрын
Love the analogies and especially the visuals, you have such a knack for presenting problems in an easy to understand light! Great vid :)
@Vercidium
@Vercidium 4 ай бұрын
Thank you, that means a lot!
@_nwL
@_nwL 4 ай бұрын
Great video, I learned a lot! Small comment for future endeavors: watching this on mobile was difficult because I assume you optimized the text size for fullscreen desktop viewing. Other than that, I loved it!
@Vercidium
@Vercidium 4 ай бұрын
I’ll increase the font size in the next video, thank you!
@SamuelCoupland
@SamuelCoupland 3 ай бұрын
Really eye opening, thank you
@Gegarace
@Gegarace 2 ай бұрын
I really really really like this kind of contents, It's like an art. I wonder what it'd be like if there's a game engine that has all optimization techniques known today and implemented efficiently. I'd really love to try that game engine or it's reels.
@Wyrmver
@Wyrmver 4 ай бұрын
the biggest thing this video taught me is optimization =/= fewer lines
@Kyrelel
@Kyrelel 4 ай бұрын
*fewer
@Wyrmver
@Wyrmver 4 ай бұрын
@@Kyrelel thanks
@nerdycatgamer
@nerdycatgamer 2 ай бұрын
Usually the code with fewer lines is actually severely less optimized. Take a look at all the ""clean"" javascript code with a million abstractions and chained method calls. You have your fancy iterators when a simple for loop is literally 20x faster
@IanZamojc
@IanZamojc 4 ай бұрын
Really excellent explanation for an issue a lot of players, and even developers, incorrectly associate with optimization. Also, I noticed your mic is picking up a lot of room reverb. A cheap mic shroud behind the mic will help a lot. The poor man's shroud is a closet full of clothes with the mic partially inside. If you can't fix it at the mic, try a "de-room" or "de-reverb" plugin. Your visuals are fantastic, your audio can be just as good without much more effort.
@Vercidium
@Vercidium 4 ай бұрын
I can't hear the reverb myself but I did notice an echo when standing next to a wall and recording. I recorded while standing in the center of my room instead, and I'll try a shroud too thank you for the recommendation :)
@IanZamojc
@IanZamojc 4 ай бұрын
@@Vercidium Cool, glad I could help. I noticed you've got a demo video about raytraced audio. Maybe this is an opportunity to do a game engine video about it to test your audio setup.
@dyllanmccreary688
@dyllanmccreary688 3 ай бұрын
something about this video made me super excited to watch, maybe the thumbnail/title.
@takaincur8079
@takaincur8079 4 ай бұрын
Amazing Video thank you!!!
@filiformis
@filiformis 4 ай бұрын
Reminds me of a swap chain, only for geometry instead of fully rendered frames. Very cool!
@noxagonal
@noxagonal 4 ай бұрын
Honestly, that's the future of everything nowadays, almost everything needs to be pipelined, the problem is that the more you pipeline, the more (relative) lag it introduces. Personally I settled for 2 mesh buffers for dynamic meshes, block frame if we catch up and the mesh isn't fully sent yet, though I might change this to non-blocking later. I'm also thinking which mesh data actually needs to be updated anyways. UVs might not need to be re-uploaded to the GPU, it's mostly just the coordinates and vertex normals. So I'm thinking of splitting the vertex into 2 buffers, one for coordinates and normals, and the rest into another struct. This way the transfer size should be smaller and shouldn't cause many issues. This saves space on the VRAM, allows custom attributes. Cache misses are very likely to happen though so it needs to be measured... Lots of options to explore. :)
@budgetarms
@budgetarms 4 ай бұрын
That is not really seen as a real optimization, more like a technique that (as you said) has been done. It is really interesting to see your approach compared to approaches game studio's make. A GDC talk that is on a technical level really interesting is this one "Marvel's Spider-Man: A Technical Postmortem". I also want to ask a question about your previous video, you mention that indeed triangle strip is way faster than triangle list. The problem that I seem to face, is that there are no tools, as far as I know of that convert triangle list to triangle strip. This is not a problem when you make all other models yourself and create a script that does it for you. But how did you do it in your previous video?
@Vercidium
@Vercidium 4 ай бұрын
Absolutely, technically this is a timing issue but since it affects game performance, it falls under the broader ‘optimisation’ category For complex models like characters, converting them into triangle strips isn’t easy. Modern renderers will use an index buffer to help, where the model is broken down into triangle strips of the same length (e.g. 3 triangles) and then a GL_PRIMITIVE_RESTART is set to tell the shader to start a new triangle strip every 3 triangles (for example) There will still be some vertices that hold the same data but any reduction in memory is a performance win
@budgetarms
@budgetarms 4 ай бұрын
​@@Vercidium I wish DirectX had something like that. It's really interesting how other API's do specific things.
@Vercidium
@Vercidium 4 ай бұрын
⁠@@budgetarms looks like DirectX 10 has this feature, check out the ‘Generating Multiple Strips’ section learn.microsoft.com/en-us/windows/win32/direct3d11/d3d10-graphics-programming-guide-primitive-topologies
@budgetarms
@budgetarms 4 ай бұрын
@@Vercidium Thanks, I am looking into it, just wondering do you have a discord server (or is something like that in the works)?
@budgetarms
@budgetarms 4 ай бұрын
@@Vercidium Just wondering, how do you do networking on your game, do you use an external OpenGL library for that or what?
@dennismakesgames
@dennismakesgames 4 ай бұрын
Awesome as always :)
@protossinator
@protossinator 4 ай бұрын
If only you had posted this video a few months sooner! I recently bought a new pc, and repeatedly sent it back to the company since I was experiencing weird stutters when meshes were loaded / updated in my games. I eventually boiled it down to a game engine issue myself, but I'm so glad that this video confirmed that. No money wasted on a broken machine :).
@jan.melcher
@jan.melcher 4 ай бұрын
Wouldn't there be a chance that each new mesh clogs up the transfer pipeline even more, so you would end up with drawing really old meshes at some point?
@Cara.314
@Cara.314 4 ай бұрын
Long freezes in modern games can be attributed to a variety of factors, often relating to resource-intensive operations or inefficiencies in handling game assets and rendering. Here are some of the common causes: Asset Loading: When games load large assets (like textures, models, or sound files) from the disk into memory, it can cause a noticeable freeze, especially if the game is not using asynchronous loading techniques. Garbage Collection: In games developed with languages that have automatic memory management (like Java or C#), garbage collection can sometimes cause freezes or stutters. This happens when the garbage collector runs to free up memory, temporarily halting other processes. CPU/GPU Synchronization Issues: If the CPU is waiting for the GPU to finish rendering (a scenario known as a GPU bottleneck), or vice versa (CPU bottleneck), it can result in freezes. Efficient parallel processing and synchronization are crucial to avoid such stalls. (the one this video covers part of, and far from the only possible cause) Inefficient Resource Management: Poorly managed resources, such as repeatedly loading and unloading the same assets, can lead to performance issues and freezes. Complex Calculations or Scripts: Intensive computations, like complex AI calculations, physics simulations, or extensive world updates, can cause freezes if they are not efficiently managed or offloaded to separate threads. Network Latency or Hiccups: For multiplayer games, network issues can cause freezes or lag if the game's state is tightly coupled with the timely receipt of network packets. Driver or Hardware Issues: Sometimes, the problem may lie outside the game itself, such as outdated or buggy graphics drivers, or hardware that is overheating or malfunctioning.
@cakesteak
@cakesteak 3 ай бұрын
chatgpt has entered the chat
@anotherclearchannel
@anotherclearchannel 4 ай бұрын
Just wow! I am more than impressed with your communication and teaching skills (instant sub because of these traits alone). 🙏🏾 To say that I am so excited to consume your content is an understatement. 😁 I look forward to discovering and learning many new things alongside you. Please be encouraged and Thank You for such amazing content.
@Vercidium
@Vercidium 4 ай бұрын
You are too kind, thank you very much!
@Marc83Aus
@Marc83Aus 2 ай бұрын
I learned that lists and looping are great for optimization, thumbs up!
@SigmaSixSoftware
@SigmaSixSoftware 4 ай бұрын
This guy just added Promises to a game engine
@Vercidium
@Vercidium 4 ай бұрын
Best comment hahaha
@ns2qhd520
@ns2qhd520 4 ай бұрын
Hey love the video man but the code font is a little small for a pc and almost microscopic for my phone. The animations and everything are also amazing but if you could enlarge the code it’d make the content more accessible.
@Vercidium
@Vercidium 4 ай бұрын
Will do for the next video, thank you for the feedback!
@Womcataclysm
@Womcataclysm 4 ай бұрын
Great video, hope this becomes well known
@mrrenreal
@mrrenreal 2 ай бұрын
I’m addicted to your channel! \o/
@sclexz
@sclexz 4 ай бұрын
didn't realize you were sector's edge dev until the end!
@Vercidium
@Vercidium 4 ай бұрын
Haha hey there! What gave it away?
@jiegao3591
@jiegao3591 4 ай бұрын
There's actually an optimization mod for Minecraft that more or less does this where the renderer will keep using an older mesh until the new ones are ready. You did a nice job with the analogies!
@lancestryker
@lancestryker 4 ай бұрын
What's it called?
@nindew21Laughyourassoff
@nindew21Laughyourassoff 4 ай бұрын
What is it called?
@McHorsesCreations
@McHorsesCreations 4 ай бұрын
@@nindew21Laughyourassoffit’s either Sodium or Nvidium, there is also a mod Distant Horizons on the relevant topic
@JATmatic
@JATmatic Ай бұрын
I once implemented in GL4.5 similiar thing, for the uploaded uniform constants (UBO). It used fences to avoid remapping/reallocating the GPU memory each time when possible. It allocated N slots for the blocks in a single UBO. For each slot index, a fence is used tell if CPU is allowed to reuse it yet. If no slot was ready, a new (bigger) UBO would be allocated. After a few initial frames, the UBO's capacity would stabilize.
@duytdl
@duytdl 3 ай бұрын
Very humble explanation style for laymen to understand. Kudos!
@caiman1188
@caiman1188 3 ай бұрын
not even 30 seconds in and it's already being broken down for the americans
@silicalnz
@silicalnz 4 ай бұрын
Just a note. The code you show is a very tiny font size. It was difficult for me to read.
@xaalcarlsonanimations1539
@xaalcarlsonanimations1539 4 ай бұрын
im not really doing anything in game development these days but this tutorial was so well handled and impressive that you earned a new sub. thanks for that vid lol
@Vercidium
@Vercidium 4 ай бұрын
Thank you! It took a while to make
@crzykd1305
@crzykd1305 4 ай бұрын
In my current engine project I've made an upload manager who reuses a set of staging buffers to upload data to the GPU at a capped rate (wouldn't want to choke out the bandwidth), it uses a counter fence to keep track of the latest job completed. When work is submitted to it, the submit function returns a job number and the dependent objects can check with the uploader if the work is finished (via the fence under the hood). Then, the majority of objects used in rendering hold their data in a variety of buffer types (swapped out as needed) with the more common being the swap buffer, which the uploader knows how to handle right away. I've been considering making a swap chain buffer which allows multiple jobs to be queued at once instead of just the 2, I think I'd need to make another system for recycling buffers when their done. I might also want to expand it for texture streaming solutions wherein they could produce work for both uploading and consolidating buffers, but that might be a waste of space if too many jobs are incomplete at once. I love stuff, its a wonderful puzzle, and entirely why I entered graphics programming and game engine development!
@fuzzy-02
@fuzzy-02 4 ай бұрын
Would sorting still be viable if the number of meshes is very big? Also, I loved this video. I never even realized this. Or rather, I knew of it but never was consciously aware of it while coding
@Vercidium
@Vercidium 4 ай бұрын
For heaps of meshes it would get pretty slow, something like a ring buffer would be much better. Thank you!
@kira.herself
@kira.herself 4 ай бұрын
this is what wgpu does behind the scenes, I love wgpu
@kira.herself
@kira.herself 4 ай бұрын
also I love your channel, content like yours is rare, unique and very informative, I learn a lot with every Video, optimizing things to the limit is addicting hehe
@akhileshchandorkar1807
@akhileshchandorkar1807 3 ай бұрын
This is an epic video man, really liked the way you showcased your iterative design methodology to refine the problem into smaller chunks and solved them one at a time.
@Vercidium
@Vercidium 3 ай бұрын
Thank you, I’m not a teacher by any means but I’m learning so much creating these videos. Trying to find the best way to explain these things takes a while and I always resort back to food analogies haha
@akhileshchandorkar1807
@akhileshchandorkar1807 3 ай бұрын
@@VercidiumHonestly, its still really cool that you're able to make parallels with these kinds of arguments. Oftentimes, when I'm trying to explain my code using analogies, they end up just becoming warped, and all of a sudden you have a taxi driver talking about repairing a plane or something :/
@Vercidium
@Vercidium 3 ай бұрын
@@akhileshchandorkar1807 hahaha I know what you mean. I originally was talking about a restaurant with tables, plus a waiter and a chef, but it all got too complex. Simplifying it down to a chef and their pans worked much better. Takes a lot of iteration and feedback before I’m happy posting it here
@digitalasylum369
@digitalasylum369 4 ай бұрын
Great job breaking down such a complex concept to an easily digestible narrative.
@blocc_nova746
@blocc_nova746 4 ай бұрын
This man spent 4 years of his life fixing the little freezes you get every once in a while. Real dedication!
@Cara.314
@Cara.314 4 ай бұрын
he didnt though, most good engines already do this sort of thing. though it is up to devs to properly use the engines systems to take advantage. you could easily circumvent them. Also, this is only 1 possible cause of freezes. It's known as Asynchronous Buffer Updates/Uploads.
@ImNotGam
@ImNotGam 4 ай бұрын
Got it, I just need enough memory for 15 thousand meshes.
@Vercidium
@Vercidium 4 ай бұрын
Hahaha noooo
@zoomstrikegaming
@zoomstrikegaming 4 ай бұрын
Love how in deph u go with it!
@jackta101
@jackta101 3 ай бұрын
This is pooling applied really nicely. And well explained.
@CaptainUltimaFTW
@CaptainUltimaFTW 4 ай бұрын
Stuff like this is why i love graphics engineering, the interwoven understanding of what the hardware does and how you can get it to do what you want it to in the most efficient manner is just fun. Cool stuff!
@Vercidium
@Vercidium 4 ай бұрын
Absolutely, it is a very rewarding kind of programming
@doruvidejesus4508
@doruvidejesus4508 4 ай бұрын
Wow this is incredible, those this also work in Unreal Engine 5?
@Vercidium
@Vercidium 4 ай бұрын
It should, I was talking to a Unity dev about how models are loaded behind the scenes onto the GPU, and it seems like there’s a few tricks you can do with offscreen rendering and preloading (not sure these terms are right) so you can know when a model is actually sent to the GPU, before you try to render it If Unity has these features I’d be surprised if Unreal didn’t! It’s a pretty important feature I reckon
@zeyzer3405
@zeyzer3405 3 ай бұрын
My god it's so hight quality. I subscribe immediately!
@Teflora
@Teflora 4 ай бұрын
oooh this is really clever! I'm thinking about implementing this for our game engine for the dynamic objects that change every frame.
@Vercidium
@Vercidium 4 ай бұрын
Sweet! What kind of objects? Particles or destructible objects?
@Teflora
@Teflora 4 ай бұрын
@@Vercidium particles and we use instanced billboards for characters and enemies!
@samwhaleIV
@samwhaleIV 3 ай бұрын
How dynamic is your game? Would it be more efficient to allocate your meshes ahead of time and instance them?
@Teflora
@Teflora 3 ай бұрын
@@samwhaleIV for the player, enemies and effects we use instancing and recreating them each frame. The base mesh is just a quad bc we use billboards for everthing. So honestly idk what would be much faster, it needs to be tested out
@AlucardNoir
@AlucardNoir 4 ай бұрын
Isnt this just asyncronous compute?
@toxiccan175
@toxiccan175 4 ай бұрын
I’m curious: do you ever look at Minecraft optimization mods to get ideas of how to make your own voxel game engine better? People have tried many methods and there’s a lot of source code out there
@Vercidium
@Vercidium 4 ай бұрын
I haven’t but that’s a good idea, would be interesting to have a look through their source code to see what OpenGL tricks they’re using
@toxiccan175
@toxiccan175 4 ай бұрын
@@Vercidium Check out Sodium and related projects. They rewrote rendering in Minecraft to work with OpenGL and made it really efficient. There are related projects and extension type mods that are easy to find as well.
@Vercidium
@Vercidium 4 ай бұрын
@@toxiccan175 awesome thank you, will do!
@jcm2606
@jcm2606 4 ай бұрын
@@toxiccan175 Minecraft has used OpenGL since the beginning, Sodium and the like just rewrote core parts of the renderer to use newer OpenGL features and be generally more efficient with memory and GPU usage.
@tinoesroho
@tinoesroho 4 ай бұрын
@@jcm2606 i've heard mumbles about the sodium sub-mod, nvidium. what's up with that?
@BlueAndy_
@BlueAndy_ 4 ай бұрын
Damn explained in not even 5 minutes. Good video, keep up the great work!
@dexapnow
@dexapnow 4 ай бұрын
Very nice visuals
@glorytoarstotzka330
@glorytoarstotzka330 3 ай бұрын
at the end the performance was 15k fps, what was the performance of the mesh rendering without any optimizations at the very start, how many fps?
@Vercidium
@Vercidium 3 ай бұрын
About 115, its shown at 0:09
@NoName-1337
@NoName-1337 3 ай бұрын
From now on, my toaster can run crysis.
@JustfknBill
@JustfknBill 28 күн бұрын
Bruv you are the single most valuable resource I have as an indie dev. My games will run buttery smooth because of you and those like you. I've had these stories in mind since i was a child and didn't have the tools or skills to do them right. But with people like you and tools like blender and unreal, I will bring some really fun stuff! For the love of gaming!
@Vercidium
@Vercidium 28 күн бұрын
Thanks so much! I’m glad to help
@JustfknBill
@JustfknBill 28 күн бұрын
@@Vercidium When I grow my company and add to it, you're definitely hired if you want it. I'll respond in the future with a list of works & the studio name.
@reekta3464
@reekta3464 4 ай бұрын
Simplest explanation i've ever seen so far
@nguyenhoangminhtrung2779
@nguyenhoangminhtrung2779 4 ай бұрын
My guy explains double buffer so my 5 year-olds can actually understand it, kudos to you!
@SomeOne-sq7ir
@SomeOne-sq7ir 4 ай бұрын
as I 5 year old I can confirm
@Lopeirada
@Lopeirada 4 ай бұрын
Does this apply to game engine devs, or also to game devs that use game engines like unreal or unity?
@Vercidium
@Vercidium 4 ай бұрын
Game engine devs 100%. Game engines should take care of this but I’ve heard of some devs talking about stuttering because their models weren’t preloaded/off-screen-rendered (not sure if these terms are right) before they tried rendering them onto the screen
@DEKKERcz
@DEKKERcz 4 ай бұрын
Good stuff!
@spicydaddy2526
@spicydaddy2526 4 ай бұрын
buddy idk anything about coding but I love games, and this made (I think) sense to me. well done.
@Vercidium
@Vercidium 4 ай бұрын
That’s great to hear, thank you!
@ChamplooMusashi
@ChamplooMusashi 4 ай бұрын
Should you really be using a list? Wouldn't a pool be much preferable if we're considering optimization?
@SimonBuchanNz
@SimonBuchanNz 4 ай бұрын
A pool is a list though? (Not all lists are linked lists: this looks like C# where List is a dynamic array (like std::vector, ArrayList, Vec, etc)
@Vercidium
@Vercidium 4 ай бұрын
For a tiny amount of items a list is fine, but if we had a global list of all meshes in the scene then 100% should not use a list. A ring buffer that uses an array under the hood would be much better
@shadow50011
@shadow50011 3 ай бұрын
Explaining optimization to an American: "So Imagine a burger..."
@theMooly
@theMooly 4 ай бұрын
I hope more of these topic of videos will be known in the near future, our amateurs and semi-pro (or soon pro) game devs who trained themselves in open source, must benefits from it
I Optimised My Game Engine Up To 12000 FPS
11:58
Vercidium
Рет қаралды 462 М.
Games that Don't Fake the Space
31:02
Jacob Geller
Рет қаралды 2,7 МЛН
Chips evolution !! 😔😔
00:23
Tibo InShape
Рет қаралды 27 МЛН
ISSEI funny story😂😂😂Strange World | Magic Lips💋
00:36
ISSEI / いっせい
Рет қаралды 160 МЛН
Joven bailarín noquea a ladrón de un golpe #nmas #shorts
00:17
Better Mountain Generators That Aren't Perlin Noise or Erosion
18:09
Josh's Channel
Рет қаралды 255 М.
Blazingly Fast Greedy Mesher - Voxel Engine Optimizations
23:35
Is Unity C# better than UE5 Blueprints?
6:19
Overload
Рет қаралды 4,1 М.
4D Games | 4D Graphics | What 4D games look like, 2D 3D 4D 5D
15:04
Cyberstars - Как создать игру
Рет қаралды 1,9 МЛН
This Black Hole Could be Bigger Than The Universe
11:44
Kurzgesagt – In a Nutshell
Рет қаралды 2,3 МЛН
Can a Bunch of Circles Play Für Elise?
10:27
Marc Evanstein / music․py
Рет қаралды 215 М.
Optimizing my Game so it Runs on a Potato
19:02
Blargis
Рет қаралды 300 М.
choosing a game engine is easy, actually
15:08
samyam
Рет қаралды 182 М.
Training an unbeatable AI in Trackmania
20:41
Yosh
Рет қаралды 12 МЛН
Индуктивность и дроссель.
1:00
Hi Dev! – Электроника
Рет қаралды 1,4 МЛН
How Neuralink Works 🧠
0:28
Zack D. Films
Рет қаралды 30 МЛН
Carregando telefone com carregador cortado
1:01
Andcarli
Рет қаралды 1,3 МЛН
Edit My Photo change back coloured with Bast Tech
0:45
BST TECH
Рет қаралды 335 М.