I Remade Minecraft But It is Optimized!
Vložit
- čas přidán 23. 08. 2024
- In this video, I will talk about the optimizations that I did for my C++ Minecraft Clone!
#cpp #gamedev #minecraft #opengl
Join my Discord:
/ discord
Try my Steam Game Midnight Arrow:
store.steampow...
Join this channel if you want to support me 😻:
/ @lowlevelgamedev9330
Repo:
github.com/mee...
Minecraft Clone Playlist 🟩:
• Minecraft clone
Full Game Guide in C++ 😎🕹️!
• Make a C++ game FULL G...
Z pre-pass:
• How I 2.81x my FPS, wi...
Music: Evan King - Everything is Okay
/ contextsensitive
contextsensiti...
Minecraft soundtrack: C418 - Aria Math
Minecraft soundtrack: C418 - Subwoofer Lullaby
Minecraft soundtrack: C418 - Minecraft
you should greedy mesh air, or you cant?
😂😂😂😂 ye good idea, next April fools video
It’s been a while since last time I heard this
(or you cant do that)
is this an optimized mod for minecraft? If not can you make one that absolutely obliterates sodium? Is it even possible?
@@lowlevelgamedev9330 add the create mod to this clone + Steam N' Rails, Create Enchantment Industry and also Create: Copycats Plus to your MC copy to make it a slightly original game
You could hugely increase performance by using meshlets instead of the standard rendering pipeline, Other things you could do is 1. Greedy meshing 2. In the standard pipeline gpus always check a 2x2 grid during rasterization so If you have lots of small triangles (less then 2x2 pixels it will hit performance quite hard, mentioned in UE nanite talk/website), 3. Don't really understand if you talked about this or something else but you can only ever see 3 faces of a block so you don't even have to bother with checking the rest 4. mipmaping will make the game look better 5 Some kind of occlusion. You may also be limited by something stupid like texture streaming recommend you use renderdoc quite easy to use yet absolutely amnazing it helped me so many times I can't even count. Greate video, really enjoyable to watch
Seriously though, this is sick! I genuinely hope your channel grows because this is a top tier resource.
thanks bro 💪 I really appreciate
This is awesome! I've been thinking about hyper-optimized Minecraft clones lately. I wish I was skilled enough to make one. I have ideas, but ideas alone aren't worth much.
Just finished watching the video. Thanks for making it!
i love watching your vids at 1 am
Best videos to watch 💪, but after that go to sleep 🔫
But after that I will go and my my homework
I love watching your videos at 5 am… before I go to bed 🗿
3:20 am for me
No I will watch more i don't need sleep i need more vids@lowlevelgamedev9330
Very nice video, thank you for making it.
A few things:
Did you consider adding ambient occlusion at all? Seems like a minor performance hit that makes the lighting look very good.
Did you see Vercidiums video on using 6 different meshes for each face for a chunk, so you can do face culling on the CPU side and might mean you can save memory bandwidth on face data.
yo, i had this idea a while ago, i glad someone actually did it because im way to lazy
🤣😂 mood
Would be cool if it talked the minecraft protocol, so you could join vanilla servers
Thats what im saying
If it gets modding api it might become a really cool game.
reminds me of minetest
Wouldn't he get sued tho ?
@@NikhilStill for what?
@@NikhilStill The only thing he might get sued here for is using minecraft's textures i think.
@@kidnamedfinger.productionshe should partner with some texture pack creator to add it to the game, like the Bare Bones texture pack. It’ll look like the games trailers without taking any of the trailers or actual games content
Have you seen Vercidium video on optimizations ? There are some steps that I find quite interesting
I mean you remade it and *tried* to optimize it.
Why the heck did you not START with frustrum culling?
You can't have AO or smooth lighting the way you started.
Any plans to have occlusion culling?
Shadow culling?
Colored lighting?
The chunk visualizer is pretty nice.
well because that was a thing I will do anyway so I wanted to make the other parts as good as possible, for ao I will probably use ssdo or something and I'll see what other things I'll add
Seeing chunk buffer data stored in list + map combo made my eye twitch. Unless i misunderstood something in that code snippet, you gonna choke your memory on linear reads of lists and additions to map - making whole idea of huge buffer obsolete, I know that its very convenient and clean, but good ol' malloc/realloc would perform much better on simple data. Dont wanna nitpick, this might be just a macro optimization in the end, chunk view culling + sorting is deffinetly much more costly part of code anyway. Good luck with optimizations and bug hunting :D
I know that it looks terrible but it is a reason for that. Chunks will be allocated sepparately in the first place, no way around it they are too big so one pointer per chunk, so it is a map to acces it fast. But the list is there because I need to know the order in which I used them, because I want to always throw away the least used chunk. so this is actually a least recently used cache. and again no wat to use one big, buffer that thing has like one gb of memory (measured) ther's no way I can use than when I need load and unload chunks many many times per frame
Use mesh shaders like the minecraft nvidium mod does to make the game only compatible with like 20% of the GPUs out there but run really good lol.
ye that's one reason I don't want to use mesh shaders :((
@@lowlevelgamedev9330 youd be able to support mesh shaders on all gpus from the past 6 years if you written this on dx12 or vulkan, but i dont blame you because these apis are much lower level and more difficult to implement
@@lowlevelgamedev9330 Unless you start over and switch to Vulkan.
To learn something new you could also try ray tracing voxels in compute shader instead, it has way bigger potential and overall way more natural for voxels, once you implement caching of traversal and low-res pass to exploit ray&frame coherence(can do it at CPU too) it's basically instant.. gotta use mip-maps for grid though. Also lower overheads for textures, not necessary to use uv unwrapping.
P.S sure triangle rasterization still fine for voxels but it's boring and has overheads/annoying
Good job, can't wait for more.
it's comming 💪💪
you should look into working on Cosmic Reach, another very promising minecraft-like game, that already has a small community around it.
Unified geometry, still 30 FPS? Its strange, how do you upload that gpuBuffer partially?
well I think it is just the fact that there os too much geometry, after the frustum culling I get to very good fps
The real reason why minecraft is slow is not the graphics. I can't say for sure, but imo the biggest problems are: pathfinding for a large number of mobs, simulation of all processes (except particles, probably) on the CPU side and the fact that the game does not use any of parallelism with many layers case (and i'm not sure is it even possible)
Well graphics are actually a big part of it... Thats why sodium mod works. It updates a lot of the rendering engine with modern OpenGL. Same with nvidium, which uses modern graphics techniques like using meshes. Minecraft's rendering engine is outdated and slow.
Dont get me wrong, theres a lot more too but most people will see a huge improvement with a better rendering engine alone. This is already proved by performance mods. When everything is already loaded into memory (i.e. no cpu intensive chunk loading) the main bottleneck is typically graphics.
@@riley1636 Minecraft on low end CPUs can be a pain in the ass. If you run towards unexplored chunks the game starts stuttering, and if you use an elytra or fly in creative mode it becomes a crazy stuttery mess
@@riley1636 I understand what you're saying. and yes, indeed, the graphical component of Minecraft really suffers, as evidenced by the devlogs of enthusiasts who recreate its graphics (although most still do not do such important things as mobs, particles, blocks with custom models such as anvils, etc. , this is still quite clear evidence). However, i think the graphics are not a bottleneck - that's what I wanted to say. It is much easier to draw 1000 chunks than to simulate same amount correctly. Especially if the game has many objects with non-trivial logic (unlike, for example, noita, where pixels work according to relatively simple laws). By the way, to confirm this, i need to do accurate performance measurements. Without this, it's just a thought experiment (and the result of observing that a couple hundred mobs can cause more lag than a giant factory from create mod)
@@cyanmargh I think youre right in theory, but in practice minecraft doesnt usually have that many mobs all at once for it to be a major issue. You're right though, its more of a thought experiment right now without measuring.
@@riley1636 mesh shaders are not "meshes". nvidium utilizes the new mesh shaders. It replaces vertex and fragment shaders with just one mesh shader which works similar to compute shaders.
Great work!
6:40 The way to solve this performance issue is to do the depth render at a reduced resolution, you can get the rough shape of the geometry at a much lower resolution than what you need for the display, and this can significantly reduce the cost of doing this. This video explains how this is often done in game dev: czcams.com/video/CHYxjpYep_M/video.html
yes that makes sense, thanks 💪💪
About Z-Pre Pass optimisation, I read somewhere that you can get more performance with it, if you for example send less vertices to render it.
For example if you rendering normally, you still need to send vertices multiple times, even if they are adjacent, because if you don't texture coodrinates will be messed up, but if you send same vertex for adjacent blocks, or even better, make a simple greedy mesh geometry (one quad for many block faces) I think it can definitelly increace performance.
But I haven't tested that yet (I'm also playing with making optimized Minecraft-like renderer)
yo that sounds like it might really help, the problem appaeently is that z pre pass doesnt work with discards in the frafment becahse the gpu cant optimize early depth anymore so I have to look at that
What about making cubic chunks like in Cubic Chunks Mod?
It works by generating the terrain of Minecraft in chunks of 16x16x16. Using this method the map's height was able to be increased by 500x while also improving performance.
"With 16x16x16 chunks we don't load all the chunks underground that we can't see, massively reducing the memory load. The memory usage is probably the main improvement, although there could be others like creating standard 16x16x16 chunks for air - use just a few special bytes to describe an empty air chunk, massively reducing memory usage and simplifying any code interaction (rendering, physics, AI) of an empty chunk (extend to all dirt chunks, all water chunks, all rock chunks."
@@ZerSKYi There is a few "known bugs" with that mod and the sky light engine.
Have you seen FinalForEach's minecraft clone?
just wanted to say that!!!
yes, nice project tho I would have to rewatch his first video to see if his optimizations are better than mine, regardless he uses Java so it's different
Ik i wasnt the only on here feom cosmic reach lol
instant mi am dat seama ca esti roman dupa accent
mersii bro 💪
another way to make it run on low end hardware:
low quality lighting
directx version [if you use opengl]
no hd water
this could be like a toaster version to the game
ye I want to add something like that in the settings when the game is ready💪💪
@@lowlevelgamedev9330 lets gooo
Bruh, why even say it was optimized?
???
wait until he finds out that the distant horizons mod uses 3d skyboxes instead of loading the chunks
wait really? 😯😱
Now add 13 years of updates and see how well it'll run
Why you don't try to make a game with Vulkan (or you can't do that)
fuck 😂😂 I don't know vulkan yet but maybe in the future, who knows, if I will do vulkan I will use this comment for the video 💪
@@lowlevelgamedev9330 btw Vulkan has mesh shaders on most modern GPUs.
So... now i know... for my 3d game future projects, i'll learn some c++.
My 2ds will be mae in Java by now.
I haven't watched your series, But is it possible to use codes from other optimization mods on Minecraft to optimize the game?
Edit: Im not smart so don't take my words for blah blah and just correct me, But wouldn't if each chunk instead had huge data and then each block and every block didn't have individual pos data, More block data and blockstate can be loaded (such as biome color?)
Edit 2: Blockface culling
Edit 3: Buffer light updates
Top tier content 🤝🏻
the thumbnail and title make it sound like youre just recreating Bedrock lmao.
Man invented the bicycle. This is called minecraft bedrock edition.
so who will maintain minecraft bedrock edition if no one learns how to make it again?
@@lowlevelgamedev9330 fair enough.
you should make it so it can connect to normal Minecraft servers allowing it to be a custom client
That would be insane
wasnt minecraft built using "entt" an ECS library? it would be really hard to beat them using OOP instead of ECS
I don't know why am loving your video man!!.....also I suggest you do make a beginner OpenGL series if you can XD.....
hmmm I don't know, I don't use neither OOP nor ECS 😂 and it doesn't really matter, what you are talking about relates to gameplay stuff, I haven't gotten there yet
The Bedrock edition was, yeah. Java didn't use ECS though
thx bro 💪 I might do some beginner opengl stuff
@@kplays_6000 Yes - minecraft bedrock edition uses entt. I was thinking of making a minecraft clone with vulkan and the flecs ECS myself.
Instead of rendering whole chunk to render upto -260 can u render only 10 blocks under the player y position because player can't see under the grass blocks unless digging helps increasing fps ??
almost, unfortunatelly it's not that easy but there is an advanced cave culling algorithm that finds lut what you can see and improves the fps even more
Damn imagine what he could do if he was High level game dev
eh probably less things 😂😂😂😂
beautiful water, but no AA?
Do you do greedy meshing?
nope
@@lowlevelgamedev9330 Why not?
So i came from a java background, any tips on learning cpp its hard
yess, the first tip is don't treat c++ like java. Don't allocate things on the heap often. I use containers and stuff that do allocations for me but other than that in that project I trped the word "new" less than 10 times. And you saw the scale of it so don't overuse new. Other than that I have some recent videos on tips for starting learning cpp for gamedev 💪💪
@@lowlevelgamedev9330Alright thanks, CPP has a lot of complex stuff that confuses me, like the #ifendregion type stuff,I understand variables etc
You should release this 😂😂😂 as a pre alpha launch so we all can explore it for fun.
yes I want to do that but I want to finish gameplay stuff first, untill than you can easily compile it and try it yourself 💪💪
Where is the folder space? I don't see it anywhere.
When a Romanian does an even better job than Mojang. :))))))) Respect frate!
suntem destepti noi Romanii 💪
redstone optimisations needed when it's time. hoppers cause stupid lag
Just don't code it to be laggy in the first place
Hoppers now work much better in the latest version of Minecraft and Lithium basically makes them lag free.
Out of curiosity, are you from Romania? Your acceent sounds like it, and if you are, I'm happy to tell you: "Si eu sunt!"
yes si eu sunt 😂😂
optimizationcore
Java minecraft's optimisation almost makes me want to play bedrock
Mojang was talking about rewriting the Java version with C++ (and a small percent in c#). I hope they still think thay way.
well yeah, but for that you can use thing like optifine
hm interesting, tho that would kill all of the current mods :(
@lowlevelgamedev9330 worth it
@@fsForward 🗿
what about lod
Wouldn't at some point you need more space for textures?
I have a 16 bit index for textures so I can have 2^16 textures, that's more than enough
i tried to get into c++ but i have no idea where to start and theres no easy way to get in
first do a hello world, and then study:
variables, for/while loops, if, else, switch statements, functions that take nothing and return void, functions with parameters, functions that return values, a bit on classes/structs, enums, a bit on raw pointers and references, a bit on templates,
then go back and study a lot about inheritance and different rules, rule of 5, 3, none, learn about different types of casting: static, dynamic, reinterpret, c style cast, learn about const, and constexpr, go back to pointers, smart pointers, go back to templates and learn SFINAE and a bit of metaprogramming.Go back on functions and learn lambdas, function pointers, RAII.
Some people might differ with the order of things, but this order to learn c++ is ok
From there you will know what to do next.
Google "freeCodeCamp c# certificate" it's a course that was made last year and it's entirely free and made in collaboration with microsoft
@@ProGaming-kb9io how do you even compile 3d model?
Imagineaza-ti in viitor dupa ce se mai dezvolta inteligenta artificiala poate va schimba modul in care minecraft se genereaza sau se proceseaza combinat cu computere mai puternice si mai eficiente
Wow, I thought single VBO would improve things
Optimised Minecraft, in C++? Well we already had Legacy Console, that then got replaced by a laggy, buggy and un optimised mess called bedrock edition becuse it had micro transactions.
1:51 Each F is only 4 bits tho
you're right and I just realized it 😭 idk how I messed that up, but at least people will get the idea
I wonder.. aren't linked lists pretty much always worse than dynamically allocated vectors?
yes, but there are some times when they are usefull, that is one example because the most common operation is renoving and adding elements, and I also have that map to instantly acces each element
@@lowlevelgamedev9330 it sounds like trading off some storage for speed. Always have to benchmark but I guess you did and found the tradeoff to be good
Your english is good, but its kind of hard to understand what you’re saying. I think it had to do with the accent + slight slur (some words seem blend in with others) good video tho 😊
why do you sound like the Toppat Clan Leader from Henry Stickmin
Try using Vulkan instead of OpenGL. You can get up to 3x performance improvements.
Isnt vulkan notorius for being annoying to use?
@@pootis1699 Not exactly.. vulkan is as low level as it has to be - you shouldn't be using it if you don't know why you need it, and its also better than dx12 in that aspect, vulkan is more consistent and has more resources available online.. though both of them has it's own pros and cons, unique features. You can optimize a lot of things in vulkan, but it's better to start with opengl or dx11, so that you would have some idea of how things are working.. overall it allows a lot of optimizations to be possible, because now that's you who creates "pipeline" and everything, not the driver or API
Would this game run on linux?
yes tho I'm not doing linux dev, you can help me compile it on linux if you want but all of the things that I use are cross platform 💪💪
do you use LODs?
nope
how can i download this game
I don't have a release yet but you can compile it from my github, right click inside the folder and than click open with visual studio, make sure you compile in the release mode
making minecraft in c++ is legit bedrock edition
Mojang: See you in court buddy
*Zach Barth:* _Notch on his blog admitted Minecraft ripped off Infiniminer. “The act of borrowing ideas is integral to the creative process. There are games that came before Infiniminer, and there are games that will come after Minecraft. That’s how it works.”_
unless he sells it, its not a crime
@@roywempor8395 That's incorrect. One CAN sell a Minecraft clone as long as you don't use ANY assets you don't have the legal right to. In the 1980's there where court cases that ruled *gameplay is not copyrightable.*
nice video mate...
thanks mate 💪
Bruh u have the same title as FinalForEach
you should copy minecraft protocol so this works with minecraft servers
wow
Are u gonna add command?
yess, that will be cool to implement
I want to play the game, can you make it available for download?
you can easily compile it: clone the repo, right click inside the folder space, open with visual studio, select from the dropdowm of the play button, ourcraft, add a 64 bit release and ctrl+f5
if you have any problems ping me on my discord server 💪
@@lowlevelgamedev9330 i cant use discord, im too young for it.
@@lowlevelgamedev9330 where is the folder space?
Yo are you Bulgarian?
sounds more hungarian to me
nah he's romanian/moldovan judging by other comments
challenge for you. I have. Very old laptop with only 1gb of ram and a cpu intel atom. You goal is for the game can run t least 15 fps on this. Note that is has. Very old graphics card the i dont remenber the model
Cosmic Reach
well yes but actually no 😂
Minecraft Legacy Console:
minecraft bedrock is already fast and made with C++
How do I build the game?
well it seems to have a build problem rn but I'll try to fix it today and also put building instructions in the readme 💪
@@lowlevelgamedev9330 Thanks bro, keep up the good work! 🙏
Just make the sodium mod for your Minecraft and install it bruh
do you also want to get sued?
yess, check out my Mario Kart clone!
@@lowlevelgamedev9330 damn
You should work in Mojang
C++ Minecraft or yet another minetest
hm it's not made in minetest it that's what you are asking, but I'm trying to get to their level and to be honest they got kinda far
@@lowlevelgamedev9330 (sorry for my english)just joking, sometimes i think this is too much C++ Minecraft in CZcams
mama accentu de roman e prea mare :)))
poate
Mojang where u at?
Mojang taking notes rn
Nah just kidding we all know they are too lazy for that
Omg Minecraft Bedrock
When developer don't have money to buy Minecraft they make their own💪
yes 😂😂
Whose here from cosmic reach
cubic chunks
You sound romanian!
poate
Numai romani talentati avem, keep up the good work!
so from 20 to 30 fps? bruh
ye, fortunatelly after adding frustum culling I got to 60 fps 💪
sooo, bedrock edition?
well no but actually yes 🤣💪
AAAA
now rewrite in rust
bro still using intel...
Issues?
imagine if this was made with python💀
hell nah bro 💀
miros accentu de roman
nu stiu la ce te referi, eu nu miros nimic aici 🤔
Still slower than Minecraft with all its complexity with performance mods, especially w/o shaders
At least in comparison to my r5 5600g w/o videocard. You haven't shown any tests side by side with MC
after the frustum culling it's faster than optifine with similar shaders. However it's not faster than something like nvidium. I would have to implement the more advanced culling algorithm first
@@lowlevelgamedev9330 if so then hope it will be compatible with Minecraft protocol at least partially
why am i watching this
why not
LODs?
yeah lod for a cube,bravo
well good point but apparently nvidium can do it without lod so no, also they are not that easy to do :(( but who knows maybe in the future I will do them
@@yarik_superpro look up distant horizons
@@yarik_superpro you can always make a bigger cube. thats what the distant horizons mod does and it allows you to see thousands of blocks away
@@ettiSurrealAs stated it is not necessary or ever detrimental as new geometry must be computed. I believe you're missing the reason for why lods increase performance. It has not as much to do with decreasing the triangle count as it has with decreasing the number of sub pixel triangles (Which cause a dramatic performance loss). Nvidium already deals with that problem.
A Romanian man stealing Minecraft or something, idk I just started watching the video.
@mojan