I'm trying to re-create Minecraft Beta 1.7.3 in C++ raylib, and so far I have: Block breaking/placing, any kind of custom block, a chunking system, infinite worlds, saving/loading chunks and worlds and Ambient occlusion. I have been working on this for days now, and I don't plan on stopping (well at least until I don't hit an impossible road block)
#Minecraft Beta re-creation project, in C++ raylib
722 messages · Page 1 of 1 (latest)
looks really good! 👍😄
woah this is really good!!! are you planning to publish the code sometime?
that lighting is shockingly accurate
it is
really good! 💯
damn that's impressive!
I'm working on a full engine re-write. And if my code is good enough, I might release it!
The new engine will (hopefully) have evan better preformance. And chunks in every direction (this engine was only infinite in the X and Z axis, with limited height, also there was no support for chunks that have negative coordinates)
The new enigne already has a better way of storing the blocks and chunks
And it can have infinite chunks in every direction! (But right now I'am trying to make negative chunks work)
The new chunks:
The yellow outlines are the edge of chunks, and the chunks that have a red outline are in the negative coordinates
The rendering works in the negative chunks, but block placing and breaking doesn't work at all. I have to fix this!
Also there is no Ambient occlusion jet, it is not that important at this stage of development.
i would like to see it either way! it's not like your code has to be good :p
remember: remove 1 from value if you are casting negative number to int
or just make function for this
public static int FFloor(float value) => (int)value - (value < (int)value ? 1 : 0);
...finally
After way, way too much suffering with the block breaking, it seems to work...
(I was trying to fix this for days now at this point 🥲 )
Thanks!
how did you do it?
It just uses a simple raycaster, that was not the issue, the issue was the fact that EVERY - SINGLE function breaks in negative chunks (like the getBlock/setBlock functions)
And I had no clue what was wrong. So I was just debugging non-stop, trying every single raycaster'n stuff
But now, It seems to be working
and what was the issue?
there were a lot, but the main issue was the function that turns world coordinates into chunk coordinates
If this got fed any negative coordinates it broke (without me knowing, it just didn't work)
and that was the old function or is it the new one?
this is the function that didn't work (in the negative coordinates)
I had to do this instead:
The issue itself is not that hard to fix
I didn't know the modulo operator didn't work with negative numbers
I learned something new today
but figuring this one issue out in 1000+ lines of code was the main problem
relatable
also it's C++ soo error messages are useless
at this point I just use gdb to print every variable in memory and each function return to see where it fails tbh
SAME!
yes, I hate it!
To find the issue I had to write out at lest 15 variables each frame to see what's up
Also, the most annoying thing about it was it either just crashing, or NOTHING happening at all!
yeah
In the end the block breaking function is just this big:
(This is the one that finally worked)
This doesn't even use any fancy voxel raycasting algorithm like Bresenham’s line algorithm.
Just some D.I.Y thing, that actually works
(But still, I will probably have to eventually implement an actual raycasting algorithm)
i'm really starting to have enough
block placing doesnt work as well
and even after making a "working" block placing system
it just doesn't work sometimes
it has some block that it just wont break
AND I didn't even toch the mesh building code, jet it still somehow broke the mesh generation
I don't even know what to do at this point
The easiest "fix" would probably be to just start over... again
i feel like i'm going crazy
sorry to disrupt you, but evan will be even and agine will be again
oh, thanks, my English grammar is awful
👍
I love how accurate the shadows are. May I ask why you chose C++ and not C?
Only for the preformance, I don't use classes
You could probably re-create this project in C without much trouble
Mostly because I don't really use any of the advantages of C++ over C.
What a delight! ✨
Yeah there's a lot of baggage coming with C++. Do you adhere to any specific style of C++?
No, I prefer the C styling. I don't like the complexity of the C++ style
Even tho I learned C++ first (instead of C) I still use the C styling (because it's more readable)
May I ask why you don’t just go for C?
I actually have no clue
Is your project open source?
Also, I think your UVs are flipped.
Yeah I fixed the UV coordinates, you can see it on this picture
No, not jet, but If I finish it (and it's readable) I will make it open source
please don't do rewrite cycle
and don't overcomplicate things
i learned this hard way
looking great!
when will it be open source 😔
I don't know
The original engine is not great
I tried re-writing it a thousand times
I worked a LOT on the "new" engine that was supposed to have infinite chunks in each direction
but I never got to block placing and breaking working
Each engine was somehow unstable
each one crashed sometimes, and I don't know why
I still really want to make a working and stable clone, and I consider working on it each day, but I don't know If i'll ever start working on it
is chunk loading way faster than most versions of minecraft? i always felt chunk loading was unnecessarily slow, especially when the project started in Java or whatever it was. when it came out i told my friend, "uh, this should definitely have been written in C."
probably not javas fault bc most of the time is spent waiting on io, but there are mods to make it faster
I still have to add a ton of optimizations, all the faces are drawn in between chunks, and there is no multithreading
Your game might even crash after generating a new chunk
gatekeep final boss smh
Experimenting with cave gen
the fog is coming
minecraft does "worms"
for caves
and this looks like 3d perlin noise
yes, it is
the way minecraft generates terrain is awfully complicated
anyone know where i can find a good minecraft c++ tutorial on how to make one??
I don't know any spacific tutorials, but as for me, I watched every Minecraft clone devlog, or any guide, and did the same thing they did, but sometimes a bit differently
also if you follow a tutorial, but you don't know what the code actually does, after the tutorial series ends, you cannot really add anything new (because you have no clue what is happening/where in the script)
probably the best one so far
glFog can legally drink in the us
indeed
sometimes i miss fixed pipeline
not everyone wants to write whole ass vertex lighting for simple project
I did think about using opengl 2.1, where both glsl and the fixed pipeline are allowed
I do not understand shaders. And have never done fog before in any of my games, so I just used a trick that I have already explained before
this example uses something called "rlights"
that (i think) does not work with C++
also like
Bruh
Chinese is easier to read
its only to light the objects
i just stripped out rlights
fog is mostly just distance
and then you mix color by factor
this is "write once and never see it again" code
i have this in one of my projects (screenshoted ao you won't copy this shit)
basically it's hust stripped fog example
i think there needs to be simpler fog example
this reminded me of orespawn mod with weird trees
also what does that 2 mean
The current block selected
ah
the ID of the current block
okay
do you compensate for trees spawning between 2 chunks?
No
Guys... i think something is wrong
okay, so trees are basically done
Also I made it so trees cannot spawn at the edge of the chunk (so they wont get cut off)
also caves affect trees
Also while I'm at it, might as well add birch
I also improved a bit on the grass color
I might also experiment with biomes
now there is a plains and a forest biome
Man... world gen is so fun
Also changed a bit on the fog
Here is a screenshot with higher resolution
This is so cool, you work fast
I can see caves are a bit like random holes made by perlin noise
btw minecraft beta had broken perlin noise generator. look thru decompiled minecraft beta src
you mean that sand genertion?
no
the terrain generation
lemme find it
https://www.reddit.com/r/VoxelGameDev/comments/1fbryci/the_secret_to_minecraft_betas_famous_terrain/
here
Where did you get the textures
You can open the .jar file of any minecraft version, and every asset can be found there (I know it is copyrighted, this is just a proof of concept)
this the sprite sheet I'm using
As long you don't redistribute it you're free to use it
Usually you get around this by downloading it automatically when launching for the first time or something
whoa
trying to make multithreading work
ooookay....
I fixed my lag issue compleatly without multithreading
fire
so crazy
Now, instead of just "making lighting work", I actually just made another engine, mostly for fun, and for experimenting
And this engine is actually more efficient, easier to handle, AND has better optimization
I HAD to do a re-write, because I changed how blocks are stored completely
In this engine instead of each chunk having an array of blocks, now there is an universal unordered 3D map that stores every block in the game
This is a lot more efficient, and A LOT easier to work with, I can add lighting, block physics, world pre-generation... that I had no idea how to do in the other engine
Also, it already has better optimization, because there are no in-between faces drawn between chunks
(I tried to implement it in the other one, but it was simply not possible, in this new engine it was the easiest thing ever)
At first I thought that the only issue with this engine is that it cannot have infinite worlds, but now that I think about it it is probably possible (and it might even be easier than in the other one)
(I even named it Minecraft Pre-Classic because I thought that I could only re-create the original Minecraft island, when the game was not infinite)
(also in the window name, the number after the name of the game is the "tries counter", in this one, it says "2" because I tried implementing this before but I was not able to)
The "old" engine is the actually the third time I tried to make a Minecraft clone work
*Just as an interesting fact
I also made backups when I added something big to the engine
I'm actually so hyped for this new engine! I even think I could make the "infinite chunks in each direction" work.
Are you not using git?
nah, should I?
Yeah kind of.
Does exactly what your doing but:
- faster
- more space efficient
- and with more features
Also your then using the tool you will need if your employed in any software job
also, it is saved on the net
I might start using github, it would also be easier to share the project if I ever decide to
Note that you can use git without github
I'm gonna look into it, I never actually used git or github before
Ah, yeah then definitely start using it right now. :).
Aright, I added Ambient Occlusion to the new engine
I also ported every block from the old engine to the new one
I also "fixed" the grass color (finally), and it's size
I also (finally) made it so you can see the current block selected (for placement)
And you can just switch between them by scrolling with your mouse
(and it actually uses the side data of blocks, so it just works even if I add a new block)
good fucking job
Dude... not really, yeah it's easier to work with, but it's not more efficient, yeah on small scale maybe... but on a bigger one? Hell no
oh that's noisy
also you should add LODs, I know it's a beta re-creation but it'd honestly be a huge improvement
Yeah, fun fact, I had to make worldgen and saving and loading to realise that, It is sadly way, WAY slower...
I don't even know If this will ever work (at least in infinite worlds)
Since the last update here, I got back to the original engine, and implemented some thing I fixed in the new one
(for example: circular chunk generation, fixed Ambient Occlusion bugs. made it look better)
and I will add the GUI as well
The game's resolution here is 900x600 (But it supports any resolution), also there is no Antialiasing yet
I want to do that, but I don't really know how to
Also there is no frustum culling implemented yet (wich would also be massive for praformance)
it won't, I know from experience ;P
let's say the lod num is equal to it's size and we will set it as N
basically you take the the most common block(or the most common color or the average of those colors, depends on your engine) of an N * N * N structure, then just set the blocks accordingly
I looked at some de-obfuscated Minecraft Beta code, and Notch just used one single blocks[] array, a simple 1D bytes array. Is it the most efficient way? Vectors are easy to handle and to unload, but are they worse for praformance (or for memory)?
Yes it is more efficient than vectors
But you shouldn't really care about it
Mind sharing the source you looked at?
It is but a 3d array is simpler and performant, my chunks store their blocks this way
I think multidimensional arrays has issues due to some Java related things so thats why its better to store blocks in a 1D array
He is writing it in C
Also modern java should optimize out multidimensional arrays into 1d arrays
So the worst way of storing blocks is with an unordered_map, and the best way is to use a set sized array (like: "unsigned short Blocks[16x128x16]")?
Also in C++ a 1D arrays have the same praformance as 3D arrays?
(And how do I unload a set sized array from memory? because with a vector I can just type: Blocks.clear())
std::vector has destructor
or if you're using c-style array, unload with delete arr;
you can just heap allocate a simple array and delete it till you're in that world
Now, but how do I store chunks? I was storing them in unordered_maps too, what is a faster/more efficient way of storing these? I need some basic functions like getChunkAt, setChunkAt, updateChunkAt... but how do I store these chunks in a way they can be accesed like this, without using something like an unordered_map?
use std::vector
I got back to the old engine, and added some things, for example, biomes:
So far, there is a forest, a desert, and a plains (all of these can be seen on the screenshot)
Also added dead bushes, and cacti (with correct rendering)
Chunk loading is now circular
Also, some basic sky lighting
Sick
cactu
btw I finally managed to make it so there are no faces drawn in between chunks
good job
dope. kinda reminds me of alpha pocket edition
Now here are a few updates
I still have no frustum culling, LOD, or greedy meshing, but I was curious how the game would look on larger render distances
I added a few more blocks, and started working on some dungeons (btw the new blocks are: cobblestone, mossy cobblestone, sandstone, gravel)
These dungeons have random sizes, and I also added some random floor variants (these are a lot rarer)
There is also a 50% chance, that the dungeon is "broken", this just makes it so if it is in a cave (or on the surface), it will have a lot of broken blocks where the air should be
AND there is a really slight chance that the dungeon is a "surface dungeon", wich just makes it so It can generate a lot higher (with the max height being "water level")
(also I added back the GUI from the other engine)
niceee
dying to see the code
It's look like a real Minecraft 🧐
for a moment I imagined java mod support for your project ...
Right now I'm researching cave generation, mostly because I'm not happy with the current caves, 1# they are way too cummon, 2# they are usually not connected (so I have to make a worm like cave generation)
I will somehow have to implement perlin worms
if you are willing to do some gpu tomfoolery, then you should move the meshing to the gpu
also good job on the clone
What do you mean? Using multithreading?
No, run the meshing using compute shaders
This, is my chunk meshing function, just plane and simple, how could I do that?
well, you'd need to write a compute shader, dispatch it, collect it's output and then render it, ideally all without involving the cpu
will it be more praformant than running it on the cpu? (also, what if someone uses integrated gpu?)
it will always be more performant because it's a task perfectly suited for the gpu
cpu suck at parallel computations
And does this work like multithreading? (so the game can run without lag, while chunk loading may lag)
Something like that, but much better
i'll look into it
Yeah, so they are
Well, just like multithreading, computing shaders are awfully complicated, but I really need to implement one of these
(I bet Notch didn't implement these either because he didn't know about them, or he knew what a pain they are to implement)
Compute shaders only made their way into OpenGL in 2012 (and even then only as an extension), at which point Minecraft not only had been released, but also received three major updates.
ah, well I didn't know about computing shaders up to this point, so I'm clueless
It would be a lot easier to implement these if my game was in an earlier stage, but now, I would have to change half of my code for these to work (multithreading/computing shaders)
I think I will make another enigne (AS A SIDE PROJECT) and see how much optimizations I can add to it, and if it is better then the current one, I will move to that instead
I really want this to work, so I will do anything, even if it requires re-writing the enigne 100x times! (wich I have already done like 10x)
You could also store the vertex data in a singular int/long which would save sending a lot of data to the GPU
The standard raylib mesh sends way more data than necessary for voxel meshes
Another thing I'm worried about is, how do I cache generation information of chunks? For example: I generate tree on the edge of a chunk, but the chunk next to it is not loaded yet, how/in what format do I save this information?
Also I'm currently using an unordered_map to store the currently loaded chunks, is that a good way of doing it?
True, I am at what an 8th iteration currently?
Now, that the winter holiday is here, I can finally start working on the new engine, I hope it gets somewhere
Bros stuck in the loop
yeah, i would love to do that, but i have no clue how
you just pack chunk data
like x y z coordinates
and stuff
I'm really starting to burn out... I cannot implement a single optimization (like: multithreading, computing shaders, mesh data compression). And I even tried implementing new things, like JSON block data storage, instead of hard writing every single block, and seperating each block texture to different files, but once I've done that, I could not make mesh generation to work (because it uses atlases)
^^^
you shouldn't bother with extreme optimizations
frustun culling is more than enough
also what's wrong with atlases?
it's a voxel engine
sadly, it's a neccesity
you first do optimizations, then the game
you don't need to follow youtube way
Limited size?
You can't color faces during runtime?
yes you can
you won't notice this for long time
256x256 is already 256 sprites if you use 16x16
want animated sprites? you can update texture on runtime
I would continue development, but the praformance is bad, even for my pc. The only omptimizations that would (probably) help are really complicated, and stuff I had never done before
I tried implementing them for countless hours, and I just can't manage to make them work
and also render distance
I've done that already
¯_(ツ)_/¯
But the chunk saving/loading/generation is way too slow
specifically with voxel engines, it's a neccesity, you need to optimize as much as you can
binary face culling, binary greedy meshing? multithreading?
Hey, I would really recommend the voxel dev content by a vlogger named Douglas. He's been building a voxel content engine for the last two years, and the techniques he discusses are really interesting. You might find his ideas useful.
Thanks for the suggestions, but I actually watched his series before, but he uses a different rendering technique.
I'm aware you are using a very different technique, this is just for me personally the most interesting approach I've seen to voxel rendering. I'd probably try to emulate his engine's behaviour if I were implementing one myself.
An interesting quirk however is the per-voxel lighting in his engine.
It makes sense since it eliminates the need for faces, but makes me wonder how well some of the techniques would translate to a texture-based renderer, like what is present in Minecraft.
Do you have a GitHub account where I can follow you?
I do not have one. But I'm planning on making one.
how's it going
I really don't know how to optimize it further
I kinda lost inspiration
I might just release what I made so far, and just move on
There are no chunks in the negative directions
Performance is bad when loading/generating chunks
The code is a mess
I've probably done the most inefficient things I could have done
But even still. This was probably the most ambitious/complex game I've ever developed, so I'm happy about that.
Yooooo, this is so cool!
I wonder if you have documented how you gotten around to making it, kind of like a video from GWG recreating Minecraft in OpenGL
Hopson has an excellent series about this, though if you want to make your own then the starting point would be the meshing example. An Algo you will need to look into is binary face checking if you want to implement such project
Oh
I still feel an urge to make this work, even releasing it as open source. But the code is an absolute mess, and I probably made a 1000+ mistakes. But if I get to it, and clean the code a bit, maybe switching to CMake (instead of using visual studio), I might release it for yall.
:D
true
Thats ok, dont be afraid
Any progress?
ig no
shame, this looked awesome!
Tomi gave up on the project, he made too many core mistakes, so to fix it he needs to remake it from scratch, and he doesn't want to do that
I never forgot about it, though. I made a GitHub account in case I’m ever satisfied with it. I’ve tried countless times since my last message, but I never got as far as I did with the last engine.
Skill issue
just raytrace
It's really that though
I might try that, it's probably the biggest improvement for performance
No? Raymarching for primary rays is many times slower lmao
Literally why hybrid exists
You just had extremely slow meshing
Really? lol
Yes, memory isn't fast enough for ray tracing to be bottlenecked by compute operations
Whereas raster isn't memory heavy like hell so it's faster
It's actually not because of that
The meshing was alright
Give me the times
What techniques did you use
Did you have Lods? Vertex pulling? Greedy meshing? Acceleration structure?
...I don't exactly know how to do that, I just know that it was fine, because re-generating a mesh each frame didn't really affect performance
I had none of those implemented lmao
Did you use multi threading? What are your specs
Then you didn't even scratch the iceberg of possible rendering and meshing speeds
My specs are probably the reason the game runs this well, with soo little optimizations (I have an Intel Core i7-6700 CPU (3.40GHz, 8 cores), and an RTX 3060)
Multi threading was the optimization I tried to implement the most, but I couldn't even get that to work. ;_;
You can squeeze out multiple times better render distance with just greedy meshing
The worst thing on performance was the generation/saving/loading of the chunks
The frames drop from ~500 down to ~200
Multi threading could easily fix this, but I was just not able to implement that
I tried it, and it actually drops down to >150 most of the time, sometimes causing freeze frames
greedy meshing is good only on flat terrain. If you have worldgen like in mc or just buildings, then you're just wasting time calculating possible connections
that's actual yap
you're wrong
all the fastest voxel renderers use raymarching
raymarching performance scales with
pixels_x * pixels_y * depth
whereas vertex performance scales with
visible_faces
Raymarching is far slower for primary rays than raster. You're absolutely yapping. I can say that as a person who is writing my own raymarcher.
The fastest voxel engines still use raster for prim
Where raymarchers actually win is in update speeds
In rendering raster is still faster
for more information, I'd recommend this video on rasterization by Douglas:
https://youtube.com/watch?v=aY4Zet_C9Zs
Online demo: https://github.com/DouglasDwyer/octo-release
Additional voxel models: https://drive.google.com/drive/folders/1lXTpIvv9BGtOaAVj0oaVUmOKiZ_cfWwE?usp=sharing
It's time for another devlog, and the engine has undergone a ground-up rewrite! In this video, I showcase the new ray marched graphics. I discuss the drawbacks of rasterization a...
raymarching is also rasterisation terminology wise
Bro, I was literally discussing techniques with Douglas for his engine
It literally isn't
Raymarching wins in dynamic scenes as I already said
of course mesh rendering can be faster in some scenarios
but I'm speaking primarily about potential scale
It will literally always be faster than raymarching, raymarching wins in only dynamic scenes
enlighten me
Raymarching cannot defeat raster simply because of memory speeds
While raster won't suffer as much from the io limitations
The current fastest voxel engine is in raster and massively outperforms every other engine.
Which is Ethan's gore engine
Not only raymarching voxel engines only really perform well with hwrt, and suffer major loses when swrt. Raster however with proper loding can run on really any gpu
it would be interesting to see some more formal evaluation of potential performance
but without sources, I find it difficult to believe that it would be impossible to scale raymarchers
A formal evaluation is impossible, because both techniques have different advantages in different cenarios. There are pros and cons to each one
it is certainly possible to see a more formal evaluation
please let me know if you find one
There is none
Where can I play this game? I just wanna test the performance
you totally nailed that ambient occlusion
and also, that fog is really nice
very impressive work!!
huh? but the lighting looks good already?
dedication 💯
Thanks!
I really enjoy looking back at this project, it had such great development, even though it was never finished.
I was honestly kind of overwhelmed by how much love it received.
people love old minecraft
I was talking about a different engine I tried making (spoiler: it failed)
fun fact: I had no idea how shaders worked, so I made my own crappy DIY fog
I only just got actual fog working now, in my latest engine (which isn’t even Minecraft!)
I have no idea either can you explain them to me from 0
They are not so simple that I can just explain them here. Look up tutorials on shaders (You need to learn glsl/hlsl if you want shaders in your games 🙃 )
like what's the main idea of them
Basically, they're just scripts that run on the GPU. They're mostly used to create cool visuals, but there are also compute shaders, which can be used to multithread certain tasks, and they're incredibly fast
huh
you figured out actual shaders now?
it's been soo long, and I can finally say-
The fog IS real.
One billion dumb af cpu cores doing math
I wonder how futile it would be to try to add real infinite terrain gen
since billions of blocks is infinite enough for a human's playtime
maybe make the map wrap around like Pac-Man? when you reach the world border, you just seamlessly walk through the same direction from the opposite world border
I actually had the same idea!
I might try implementing that
update: I learned how to make really basic shaders, such as a blur shader that makes your gpu wanna commit suicide (dont ask why)
u may be collecting too many samples
@opal tundra which version of betacraft did you send for the showcase? is it public?
It was the latest version. But it's not public
tho i might just release the visual studio build, i kinda wanna get over this
kind of off topic curiosity, but are you really 15?
yeah
It’s not that surprising, teenagers got loads of free time. In this day and age, they can just learn stuff themselves through researching demo's, tutorials and examples.
But recreating minecraft is still very impressive, no matter the age at which you do it, especially if you do it all on your own without outside help. Big props to you vtomi
But you can really tell from the code, that's why I'm hesitant to release it. 😅
Whether you release it or not is up to you. I'd personally be more concerned copyright-wise, since there’s plenty of games with a major fanbase that have terrible code. If it works, it works.
Optimisation is nice but not a necessity for a project like this. Any possible mistakes you've made in this project won’t show up in your next project.
copyright-wise, it's fine as long as he doesn't distribute minecraft textures and assets but even if he does i doubt mojang or microsoft will take action
there's already thousands of minecraft clones on github alone
don't worry, we won't judge you for your code (I've probably written worse code anyway)
your progress is really impressive
at your age, i was just starting off learning python and c a little
At that age i didnt even know how to code or that i liked it, i just made small games in Scratch
Only in university when I got a few introductory python lessons I learned that I was really good at it, and i switched bachelors to pursue computer science engineering
Hi. Is the project open-source?
Not today
this is sick, how'd you manage the cave carving?
i guess the same way minecraft did
perlin worms or whatever those are called lol
its beautiful bro
I would have done perlin worms, but I don't really know how to implement that. So it's just simple 3D perlin noise.
This is still how the game looks currently
is the project open source yet ?
btw @opal tundra are you writing the physics yourself or you are using some engine ?
No, it's still not. I want to release it, but I'm not happy with the engine
Did you write the physics yourself?
There aren't any physics currently, but If I do add physics, I'll do it by myself
Wait no physics, so currently it's just world generation?
Yes, and basic player interactions
It's alright. The engine still lacks quite a few optimizations (and most I can't even manage to implement)
I have a good PC. When the game is not loading or generating any chunks the fps is between 600-800
(Placing and breaking block doesn't really affect performance)
But the generation (and the saving, loading of chunks) is not really optimized, so the FPS can drop massively (based on the amount of chunks being generated)
And I feel like I can't release it, if it doesn't have (at least!) a 100x better performance then the OG Minecraft
tho if it's just "a proof of concept" then it's fine
That isn't all dat hard to achieve
Like I told you, binary greedy meshing + lods + chunked palette compression + fast noise 2 for terrain generation
And some multithreading
that looks hella close to real minecraft bro
you can always ask chatgpt for optimisation help
thats what i usually do
he kinda knows what ever he knows that works
Don't, especially with voxels
It lacks training data
There is like 30 triangle papers per one voxel paper
both make the ai way better
The only good way is going on voxelgamedev discord and looking through resources
Or voxel.wiki
Especially about optimizations
teardown is also voxel right?
It's voxel but not true voxel
i do want to learn tho
Ai is the absolute worst way of learning optimizations
thats kinda rude
I am being honest to the bone
truth hurts
I haven't seen any competent programmer use ai for coding other than small stuff
ok well im gonna try to learn everytime i use ai
And I wouldn't recommend it myself
You ain't learning this way , or you'll learn bad paradigms
you mean youll learn off of ai response output?
no i mean tutorials on youtube and a bit of ai if i am stuck
but arent ai and youtube tutorials good
Don't use ai even if you aren't stuck
Ai isn't good
Where did you even get the idea
my brain made it
What brain?
my brain
wait but some ai's are trained from the internet and reddit and people give good feedback there right so then how would they be that bad like you are saying
Constant use of AI will just lead to numb brain when you cant rely on it
Because it physically doesn't think
Its like asking 1000 rats for wisdom and expecting anything better than "cheese"
right but they do know the answer that people gave and so why would it not give the correct answer im confused
Because it forgets or doesn't know without enough data
And BECAUSE IT DOESNT THINK, IT DOESNT HAVE A CONCEPT OF A VOXEL
ok but web search features does exist and some ai's will just search online at the start. from what i seen in my experience
glorified web scraper fr
There are so few voxel related sites it will have a hard time finding it unless you manually go through specific old forums, yt vids and discord servers
Real advice just try your hardest not to fall back to AI when you are stuck and when you are beginning learning, try to do your own research you will learn and find out more that way
Also you really want to waste water for that?
Because if yes then reconsider yourself as a human being
ok i will note that
what are you saying
what do you mean waste water?
llms use alot of water for cooling
ohhh. i didnt know that but its kinda true since thats what they use for cooling tho i saw google some time ago put their servers under the ocean and left them there. their cooling was way better than at surface
Still wasting resources
At least provide a meaningful service and not some slop that steals data
i wonder if AGI will be way way way better than a 1T parameter ai since its a AGI right and so it would technically be the same inteligence as a human or beyond a human
and so would they just be way better at coding than us? i mean probably
deepseek mentioned
Im pretty sure water used for cooling eventually goes back into the water cycle
AGI is physically impossible for us to achieve with current models
Every fucking model mentioned
openai is tryna make a AGI tho but im sure it wont be more inteligent than us
If you knew actually a thing about ai then you'd realize we are wasting resources on the ai agents
not really since open source ai's can run locally and so its not every ai mentioned
Where do you think data came from?
From stealing
Christi is an LLM because this level of lacking technical knowledge is just impressive
Especially given the context
wait isnt that what they do like the water is cold. used for cooling = gets hot and then gets thrown in the ocean or remade cold and reused?
not sure
Cooling still takes powrr
And release CO2 into the atmosphere
But llms still consume crazy amounts of power
And are genuinely making our lives worse
Also trying to automate out the white collars and blue collars
sure they wont automate out mitchel sercombe
Just because one thing is bad doesnt mean another thing isn’t
Though i havent heard yet of a meat cow farm running the town it’s settled next to dry
Yeah ofc not ,just found it interesting
@frank river just get out of this thread, its about a minecraft project not llms
Please, stay on the topic of the channel
Move to #programming for general discussions
@opal tundra i'm doing a similar project mainly for learning purposes. As i'm really new to the field i feel bit overwhelmed sometimes with how much techniques and approaches there is 😄 (i learn very well by examples and there are not many that i could find) Could you share what techniques are you using for drawing/calculating chunks? Are you meshing them individually or just treating blocks by themselves?
That's exactly what I've been doing!
As for the logic, it's not that complicated, but adding stuff like complex optimizations will be difficult (if you plan on adding any), that's mainly why my project is on hold
Each block should be in a chunk, I even recommend making a struct (or class) for chunks, and each chunk having an array of block ID's (just numbers)
You could make just a flat array for that, like
unsigned short BLOCKS[chunkSize]```
I used vectors instead, for stuff like deleting the array, and it being stored on the heap instead
But the flat array still (probably) works
idk how much you know about programming, but in C/C++ (and in a lot of other languages), you need to set a type for each variable (like "int" for integgers, "string" for strings, you get it), and the "unsigned short" just means a short number (from -32,768 to 32,767), and unsigned just mean it cannot be negative, which also doubles the size in positive, so an unsigned short is a whole number from 0 to 65,535
This is recommended because each variable also uses up some memory
the variable type that uses the smallest amount of memory is an unsigned char, which can be any whole number from 0 to 255, and it only uses 1 byte of memory
a short is 2 bytes, an int is 4 bytes etc...
Chunking is probably the most complicated part of the project. Even I ran into issues that I did not manage to fix.
What I did for chunking, is I made a struct for chunks, each chunk having an array of block ID's, and the chunk's position.
The first problem, is that we need a way to store the loaded chunks, so we access them by their X and Y positions in the world. I used an std::unordered_map for that, but that might not be the best option. (an unordered map is basically just an array that stores data based on keys, like x and y positions, i recommend you look into them)
You should also experiment/learn dynamic mesh generation
Even I learned that for this project (I have never done anything 3D before this project)
I could dump some more crazy info on ya, but what I actually recommend you do (the same thing i did when I started working on this project), is for you to just make a working example, like a terribly optimised mess, that just works, and even from that you'll learn a lot, and probably have more courage to try making an actually good game
I actually documented most of my progress on this game in this server
My shitty-but-working first try at this was here: #madewithraylib message
Below that was my second attempt
And there was an entire forum on my progress besides this one https://discord.com/channels/426912293134270465/1299768326834098221
Looking back at this project always makes me so nostalgic, even tho it was not even a year ago since I started working on it
i was doing some mesh generation and it actually seemed slower but i guess this is because currently theres just a couple of chunks being generated so just spiting triangles is probably faster. And yes the chunk generation+mesh creation is actually what i'm interested in as that's where the real optimization challenge is. From doing some custom shaders to be able to send compacted data to greedy meshing. More than the game itself that's the challenge that's mostly driving me. hence my curiosity.
Also, im using Zig, just because, so there's an added layer of suffering.
Well, I sadly don't know anything about Zig, so I can't really help you out with that.
What I did for the mesh generation is that each chunk has a raylib mesh, and when a chunk gets modified, I re-generate the entire mesh. And then in the game's main loop I go thru each loaded chunk each frame and draw them using raylib's "drawMesh" function
This might not be the best method, but it works, and it's pretty performant
I'm not sure if greedy meshing would help a lot on the performance, this was already discussed in this channel some time before, but greedy meshing would probably just complicate things
It would be less triangles in most cases, but would complicate the engine a lot
There are some issues with raylib's mesh system, like deleting a mesh from memory sometimes just doesn't work, compressing mesh data, like vertex positions is just not possible...? (i'm pretty sure at least)
I don't know much about shaders, but in raylib it seems you can't use multiple shaders for drawing a mesh/model
This i'm doing manually. Meaning that i'm not using raylib api but accessing directly opengl api to go around raylibs limitations. I'm using and example and basically i'm compacting vertex info into a 32bit value and then it decompresses in the shader itself (of course you need custom shader just for this part).
Tbf, i love zig promises and build system, but i'm bumping to much into type conflicts between zig and the way it imports C code (in this case raylib), probably because i don't know any better so i may just end up giving up and porting this to c++ where for sure i'll have more support and compatiblity.
There's actually an official extension to raylib called rlgl, which basically just adds a lot more stuff from opengl
Yes, that's what i meant i was using.
im trying to make something similar too
it's very bad tho, i'm not as skilled as you, and it has worse performance
One of the reasons I stopped working on it was the performance, specifically the chunk generation
My version had like ~300-600 FPS when not loading anything, but once you started moving, the frames dropped like crazy
Now, I actually know what the issue was with generation, but I'm not sure if I can fix it easily
It's funny that you colored the entire grass block texture green, so the top of it is not white.
I'm pretty sure I did the same thing in the first version of my engine
At this render distance, rendering each chunk, my engine has about 450 FPS
But the engine does not contain a lot of major, needed optimizations, like LODs or multithreading
With a higher render distance:
Since the last update to the engine I learned a lot, so I might come back to this project
Glad to see this 🙂
@opal tundra simplest optimization you can do is by having noise be calculated on the gpu, since it's a major slow down in terrain gen
Even with raylib, just run a frag shader that calculates it on a texture
Do you have any backing data for this? I was under the impression that noise functions would be really inexpensive for CPUs. Would expect it to be a significant bottleneck for terrain generation.
It is the single handedly most expensive function you can do for a voxel game
Especially 3d noise
I am unable to respond rn with data, I am out on the city
But well optimized meshing will take at least a few times less than even best optimized noise based terrain generation
Also how the hell did you come up with such a conclusion it takes many expensive floating point calculations
I didn't come to any conlusion, hence why i wrote "under the impression", but to elaborate, i was expecting that CPU would be "better" at math (non-parallelized) than gpus. The only experience i had with terrain generation the bottle neck was the meshing part because it did a big amount of data check to implement optimizations like culling. That's why i was asking you if you had any data so i could go from "under the impression" to a substantially more solid. I'm not doubting or questioning the validity of what you're saying, i'm genuinely curious and would like to understand the real impact by looking at specific examples/data.
NOISE GENERATION IS EMBARASSJNGLY PARALLEL
I neeeed this to be open source
In the current state of the engine, the codebase is terrible. It's embarrassingly bad.
If you want to make your own voxel engine, it really not that difficult in raylib (just, making an actual good one)
If I make another voxel engine in raylib, I'll make it with open-source in mind
There're a lot of voxel engines out there for inspiration
in c, c++, c#, java, javascript, python, rust, zig, etc.
and using various graphics libraries too.
one of them that I'm following is Cubyz
(by following I mean spectating)
Hey, how did you do the block placing/breaking detection? (I mean finding out what block you clicked) I tried making that in godot with raycasts but somehow it did not work at all and I always got the wrong block coordinates so I want to make that game in raylib now :)
Admittedly, I used a rather techy/DIY/duct-tape solution that ‘just works’ (with the intention of implementing real raycasting later). But since it’s been working well enough, I’ve kept it.
Ah, thanks for the answer though!
Do you know if raylib has its own raycast system?
Raylib does have Ray and RayCollision structs with some basic functions and variables, but I haven’t used them much.
Thank you :)
The thing I did (instead of looking up how a proper 3D raycaster works in a voxel environment (I couldn’t be bothered)), was use a neat trick.
You can take the .target variable of the Camera3D struct and subtract camera.position from camera.target to get the camera’s direction vector (basically).
Then you set the block cursor’s position to the camera’s position and move the cursor tile-by-tile by adding the camera’s direction vector to its position (you can devide or multiply it by your liking).
Each step, you check whether the tile the cursor is in is not air, if it isn’t, you break the tile. And if you want to place something instead, you just subtract the direction vector once when the cursor hits a block, and place a block there.
As I said, not a recommended method, but it works if you just want to test things out
You need to be more specific. There's infinite ways to screw this up 😂 But raycasting should be fairly simple. I will search for the implementation i did with Jeffs voxelMap c++ example (i think i might just have delete it -.-'). Usually to figure it out i just make thing show on screen. Draw the ray itself, draw a sphere on the hit point position, and so on. The equivalant debug strategy to print("im here") on any language.
when i was trying to do one of the first hit box selections i draw each line a diferent color, blue and red square and the local first and last vertice of the block and the yellow is the raycast collision position. This would allow me for instance to figure out rounding issues when i got near the edge of the block because the "yellow cube" would go to the block "behind".
would you recommend using raylib first before going diving into OpenGL; simply to get a handle of 3d game dev.
I plan on building a minecraft clone as well but OpenGL is just hard so perhaps I'm jumping the gun a bit too early
Yeah sure! It's a lot simpler than just plane old OpenGL, and you can actually use most of OpenGL WITH raylib by using rlgl
(not to mention that raylib actually uses OpenGL for rendering)
Good to know! Thank you
My personal opinion is that raylib balances very well not taking you by the hand in everything but allows you to skip most of the hard parts of opengl. You'll probably feel the need to slowly understand some stuff and that's where raylib shines, when you need you can go to the rlgl abstraction (1 layer down the rabbit hole), and if you really need you can go and look at the code itself. If your point is learning 3D graphics highly recommend. If you just want to make a game, you'd probably do better with an engine.
Yeah! My goal is to learn computer graphics without getting overwhelmed too much at first and slowly transition to OpenGL once I a better understanding of how things work
@opal tundra if you don't mind me asking, how did you do biome blending and determination? is it the classic 2d noise map to determine biomes or do you have 3d biomes?
I don’t mind at all!
In the current state of the engine, I just use a simple 2D noise map to determine biome layouts. But if I were to add new biomes, I’d implement a more complex biome system (kind of like Minecraft’s) using two noise maps, one for temperature and one for humidity. Based on those values, it would decide which biome to use.
For biome blending, it’s deterministically random: if the noise value is just a little lower than a biome’s threshold, it adds a small amount of that biome in the area. (it’s flawed 😅 )
thank you!
i've been struggling with biome generation because i wanna do 3d biomes, and i thought of using voronoi for that (since it generates the collision polygons for free) but i dont like how straight the cell edges are
well, not 3d biomes because my project is 2d
but you get the idea
Dude, this look's incredible, how did you even manage to make thing like this? do you have a Github repo or more photos you could show me?
It's really not that difficult to make a game that looks exactly like Minecraft, and raylib is really easy to get into.
I currently do not have a public GitHub account, and the project is in a state, which I do not feel like releasing.
For extra photos and more information on the project/it's development you can just scroll back and see it all. (most of it is documented)
Okay thanks
Funny little update, turns out trees actually have Ambient Occlusion (such a huge realization I know 🙄)
I was wondering why trees looked like plastic in the engine, but it turns out it was just the lack of AO. I'm pretty sure that in Minecraft leaves only have ambient occlusion in between themselves, yet sometime ago I disabled AO completely for leaves for some reason.
I just now realize that it looks so awful without AO
And it's been like this since forever
oops
ig u can make leaves itself have AO but not solid block that surrounds it
wow
still avoiding shaders?
Is that standard AO or are you using the voxel AO trick? Are the shadows under the tree just AO as well?
The AO is calculated when the chunk mesh is generated and simply changes the vertex colors. The shadows under the trees are plain sky lighting, also calculated during chunk mesh generation, and they likewise just modify vertex colors.
But you’re using the AO algorithm for voxels ? By checking the neighbours?
I’ve been working on something similar but not in Raylib. I’m curious because everyone does Minecraft clones but very few actually do the lighting properly, so is very cool to see someone doing it .
Yeah, it’s really that simple.
When I’m going through each block in the chunk to generate the chunk mesh, I check each surrounding block and see how many solid blocks there are around each vertex, then shade it accordingly.
I have a hasAO function to determine whether to count that block or not, so things like plants don’t get AO
Yup, makes sense. It’s funny because that Voxel AO techqnicue is simple and not that heavy but then you get to light and light updates and it’s easily gets expensive real quick .
is it good enough now
i want the open source code for this
That engine rewrite had major flaws, so I scrapped it not even a week after starting development
Since then I returned to the old engine, which is still nowhere near presentable/usable
I think vTomi just does not want to give the source code. That may be because of personal reasons, or he has a really bad case of code shyness, or whatever other reason. He's been putting it off since 2024, and I don't expect him to do something he doesn't want to.
this is the first project showcased in the project showcase video and it's not even public
tesó😭
wheres the download link to this project ?? i think i had it in the past like last year but i lost it . .
I will probably never share the source code of the project, but if anyone is still looking for a Minecraft like engine in raylib then I suggest looking into rlVoxel by OldMenYells, who just shared his engine in another forum.
His engine is not just open source, but also better than my engine in almost every conceivable way.
https://discord.com/channels/426912293134270465/1484863316844347512