#Minecraft Beta re-creation project, in C++ raylib

722 messages · Page 1 of 1 (latest)

opal tundra
#

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)

south hatch
#

looks really good! 👍😄

opal tundra
umbral hinge
#

woah this is really good!!! are you planning to publish the code sometime?

thin badge
umbral hinge
#

it is

south hatch
#

really good! 💯

vast token
#

damn that's impressive!

opal tundra
#

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.

umbral hinge
ocean apex
#

or just make function for this

#
public static int FFloor(float value) => (int)value - (value < (int)value ? 1 : 0);
opal tundra
#

...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 🥲 )

wind hearth
#

cool AO

#

your projects seems nice

opal tundra
#

Thanks!

opal tundra
# wind hearth 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

wind hearth
#

and what was the issue?

opal tundra
#

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)

wind hearth
#

and that was the old function or is it the new one?

opal tundra
#

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

wind hearth
#

I didn't know the modulo operator didn't work with negative numbers

#

I learned something new today

opal tundra
#

but figuring this one issue out in 1000+ lines of code was the main problem

wind hearth
#

relatable

opal tundra
#

also it's C++ soo error messages are useless

wind hearth
#

at this point I just use gdb to print every variable in memory and each function return to see where it fails tbh

wind hearth
opal tundra
#

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!

wind hearth
#

yeah

opal tundra
#

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)

opal tundra
#

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

ocean apex
#

sorry to disrupt you, but evan will be even and agine will be again

opal tundra
ocean apex
brisk lava
# opal tundra

I love how accurate the shadows are. May I ask why you chose C++ and not C?

opal tundra
#

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.

brisk lava
#

Yeah there's a lot of baggage coming with C++. Do you adhere to any specific style of C++?

opal tundra
#

Even tho I learned C++ first (instead of C) I still use the C styling (because it's more readable)

brisk lava
opal tundra
brisk lava
brisk lava
opal tundra
# opal tundra

Yeah I fixed the UV coordinates, you can see it on this picture

opal tundra
ocean apex
#

please don't do rewrite cycle

#

and don't overcomplicate things

#

i learned this hard way

twilit violet
dim yew
#

when will it be open source 😔

opal tundra
#

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

upbeat kite
#

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."

opal fjord
#

probably not javas fault bc most of the time is spent waiting on io, but there are mods to make it faster

opal tundra
dim yew
#

he is back

#

is the fog real now

opal tundra
#

I will make it real tho when I know how to

dim yew
#

can I try it out

#

see how it runs on my craptop

opal tundra
#

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

dim yew
#

gatekeep final boss smh

opal tundra
#

Experimenting with cave gen

dim yew
#

How do you generate the noise?

#

Is it the exact way minecraft does?

ocean apex
#

the fog is coming

ocean apex
#

for caves

#

and this looks like 3d perlin noise

opal tundra
#

the way minecraft generates terrain is awfully complicated

opal tundra
gusty hound
#

anyone know where i can find a good minecraft c++ tutorial on how to make one??

opal tundra
#

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

dim yew
#

how do you do the fog btw

ocean apex
#

fog isn't really hard to do

#

i remember doing it referencing opengl documentation

dim yew
#

glFog can legally drink in the us

ocean apex
#

indeed

#

sometimes i miss fixed pipeline

#

not everyone wants to write whole ass vertex lighting for simple project

dim yew
opal tundra
#

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

dim yew
#

fuck

opal tundra
#

this example uses something called "rlights"

#

that (i think) does not work with C++

#

also like

#

Chinese is easier to read

dim yew
ocean apex
#

i just stripped out rlights

#

fog is mostly just distance

#

and then you mix color by factor

dim yew
#

this is "write once and never see it again" code

ocean apex
#

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

opal tundra
ocean apex
#

herobrian forest

opal tundra
#

yeah 🤣

ocean apex
opal tundra
ocean apex
#

also what does that 2 mean

opal tundra
ocean apex
#

ah

opal tundra
#

the ID of the current block

ocean apex
#

okay

dim yew
# opal tundra

do you compensate for trees spawning between 2 chunks?

opal tundra
#

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

opal tundra
#

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

steep prawn
#

This is so cool, you work fast

#

I can see caves are a bit like random holes made by perlin noise

wispy rune
#

btw minecraft beta had broken perlin noise generator. look thru decompiled minecraft beta src

wispy rune
#

no

#

the terrain generation

#

lemme find it

#

here

modest flower
opal tundra
#

this the sprite sheet I'm using

dim yew
#

Usually you get around this by downloading it automatically when launching for the first time or something

opal tundra
#

trying to make multithreading work

#

ooookay....

#

I fixed my lag issue compleatly without multithreading

opal tundra
#

some cool corruptions

#

I think I'm gonna start working on lighting

ocean apex
#

fire

steep prawn
opal tundra
#

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)

opal tundra
# opal tundra fun

The "old" engine is the actually the third time I tried to make a Minecraft clone work

#

*Just as an interesting fact

opal tundra
#

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.

flat lintel
#

Are you not using git?

opal tundra
flat lintel
#

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
opal tundra
#

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

flat lintel
#

Note that you can use git without github

opal tundra
#

I'm gonna look into it, I never actually used git or github before

flat lintel
#

Ah, yeah then definitely start using it right now. :).

opal tundra
#

Aright, I added Ambient Occlusion to the new engine

opal tundra
#

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)

opal tundra
#

Some other GUI/improvements

#

Tried building something with only these few blocks

ocean apex
#

good fucking job

modest flower
modest flower
#

also you should add LODs, I know it's a beta re-creation but it'd honestly be a huge improvement

opal tundra
#

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

opal tundra
opal tundra
#

Also there is no frustum culling implemented yet (wich would also be massive for praformance)

modest flower
modest flower
# opal tundra I want to do that, but I don't really know how to

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

opal tundra
#

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)?

dim yew
#

But you shouldn't really care about it

#

Mind sharing the source you looked at?

modest flower
dim yew
modest flower
#

Also modern java should optimize out multidimensional arrays into 1d arrays

opal tundra
#

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())

ocean apex
#

it's preferrable to have cubic chunks

#

so 16x16x16 instead of 16x128x16

ocean apex
#

or if you're using c-style array, unload with delete arr;

dim yew
opal tundra
#

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?

opal tundra
#

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

modest flower
#

Sick

opal tundra
#

btw I finally managed to make it so there are no faces drawn in between chunks

ocean apex
#

good job

low forge
#

dope. kinda reminds me of alpha pocket edition

opal tundra
#

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)

ocean apex
#

niceee

dim yew
#

dying to see the code

crystal canyon
#

It's look like a real Minecraft 🧐

#

for a moment I imagined java mod support for your project ...

opal tundra
#

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

modest flower
#

if you are willing to do some gpu tomfoolery, then you should move the meshing to the gpu

#

also good job on the clone

opal tundra
modest flower
opal tundra
#

This, is my chunk meshing function, just plane and simple, how could I do that?

modest flower
opal tundra
#

will it be more praformant than running it on the cpu? (also, what if someone uses integrated gpu?)

modest flower
#

cpu suck at parallel computations

opal tundra
#

And does this work like multithreading? (so the game can run without lag, while chunk loading may lag)

modest flower
opal tundra
#

i'll look into it

opal tundra
#

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)

opal fjord
#

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.

opal tundra
#

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)

opal tundra
#

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)

odd iron
#

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

opal tundra
#

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?

modest flower
opal tundra
#

Now, that the winter holiday is here, I can finally start working on the new engine, I hope it gets somewhere

modest flower
#

Bros stuck in the loop

opal tundra
dim yew
#

like x y z coordinates

#

and stuff

opal tundra
#

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)

dim yew
#

damn

#

why bother optimizing till you got a game?

ocean apex
#

you shouldn't bother with extreme optimizations

#

frustun culling is more than enough

#

also what's wrong with atlases?

modest flower
#

sadly, it's a neccesity

#

you first do optimizations, then the game

opal tundra
#

You can't color faces during runtime?

ocean apex
ocean apex
#

256x256 is already 256 sprites if you use 16x16

#

want animated sprites? you can update texture on runtime

opal tundra
#

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

ocean apex
#

add frustum culling and cull blocked faces

#

it's already enough

opal tundra
#

I tried implementing them for countless hours, and I just can't manage to make them work

ocean apex
#

and also render distance

opal tundra
ocean apex
#

¯_(ツ)_/¯

opal tundra
#

But the chunk saving/loading/generation is way too slow

modest flower
modest flower
brisk lava
opal tundra
brisk lava
#

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?

opal tundra
ocean apex
#

how's it going

opal tundra
#

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.

sinful forum
#

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

safe breach
#

holy moly

#

Insane skill & dedication..

modest flower
sinful forum
#

Oh

opal tundra
#

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.

sinful forum
#

:D

ocean apex
#

you can release even shitty code

#

i won't be mad

#

everyone must do shitty code once

covert fox
#

true

sinful forum
#

oh i didnt read the "once" part

sinful forum
#

Any progress?

sinful forum
#

ig no

covert arch
#

shame, this looked awesome!

modest flower
# sinful forum Any progress?

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

sinful forum
#

welp

#

2% and done

opal tundra
opal tundra
opal tundra
modest flower
#

Literally why hybrid exists

#

You just had extremely slow meshing

modest flower
#

Whereas raster isn't memory heavy like hell so it's faster

opal tundra
#

The meshing was alright

modest flower
modest flower
#

Did you have Lods? Vertex pulling? Greedy meshing? Acceleration structure?

opal tundra
# modest flower Give me the times

...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

opal tundra
modest flower
modest flower
opal tundra
#

Multi threading was the optimization I tried to implement the most, but I couldn't even get that to work. ;_;

modest flower
#

You can squeeze out multiple times better render distance with just greedy meshing

opal tundra
#

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

opal tundra
ocean apex
brisk lava
#

all the fastest voxel renderers use raymarching

#

raymarching performance scales with
pixels_x * pixels_y * depth

whereas vertex performance scales with
visible_faces

modest flower
#

The fastest voxel engines still use raster for prim

#

Where raymarchers actually win is in update speeds

#

In rendering raster is still faster

brisk lava
#

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...

▶ Play video
brisk lava
modest flower
brisk lava
#

interesting

#

but I don't think that defeats the point of raymarching

modest flower
modest flower
brisk lava
#

of course mesh rendering can be faster in some scenarios

#

but I'm speaking primarily about potential scale

modest flower
brisk lava
#

enlighten me

modest flower
#

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

brisk lava
#

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

modest flower
#

A formal evaluation is impossible, because both techniques have different advantages in different cenarios. There are pros and cons to each one

brisk lava
#

please let me know if you find one

modest flower
primal sundial
#

Where can I play this game? I just wanna test the performance

short scaffold
# opal tundra

you totally nailed that ambient occlusion
and also, that fog is really nice
very impressive work!!

short scaffold
opal tundra
#

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.

ocean apex
#

people love old minecraft

opal tundra
opal tundra
#

I only just got actual fog working now, in my latest engine (which isn’t even Minecraft!)

visual frost
opal tundra
visual frost
opal tundra
# visual frost 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

visual frost
#

huh

dim yew
opal tundra
#

The fog IS real.

dim yew
#

your pfp went through changes too

#

wow

#

real character development

modest flower
short scaffold
#

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

opal tundra
#

I might try implementing that

visual frost
sinful forum
#

u may be collecting too many samples

short scaffold
#

@opal tundra which version of betacraft did you send for the showcase? is it public?

opal tundra
#

tho i might just release the visual studio build, i kinda wanna get over this

short scaffold
#

kind of off topic curiosity, but are you really 15?

silent umbra
# short scaffold kind of off topic curiosity, but are you really 15?

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

opal tundra
#

But you can really tell from the code, that's why I'm hesitant to release it. 😅

silent umbra
#

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.

short scaffold
short scaffold
#

your progress is really impressive
at your age, i was just starting off learning python and c a little

silent umbra
#

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

wicked musk
#

Hi. Is the project open-source?

primal sundial
dim yew
#

this is sick, how'd you manage the cave carving?

dim yew
#

perlin worms or whatever those are called lol

opal tundra
opal tundra
dull basalt
#

is the project open source yet ?

#

btw @opal tundra are you writing the physics yourself or you are using some engine ?

opal tundra
dull basalt
#

Did you write the physics yourself?

opal tundra
dull basalt
#

Wait no physics, so currently it's just world generation?

opal tundra
dull basalt
#

It still looks so cool

#

What's the performance?

opal tundra
#

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

modest flower
#

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

frank river
frank river
#

thats what i usually do

#

he kinda knows what ever he knows that works

modest flower
#

It lacks training data

frank river
#

uhh

modest flower
frank river
#

both make the ai way better

modest flower
#

The only good way is going on voxelgamedev discord and looking through resources

#

Or voxel.wiki

#

Especially about optimizations

frank river
#

teardown is also voxel right?

modest flower
#

It's voxel but not true voxel

frank river
#

i do want to learn tho

modest flower
#

Ai is the absolute worst way of learning optimizations

frank river
#

thats kinda rude

modest flower
#

I am being honest to the bone

paper creek
#

truth hurts

modest flower
#

I haven't seen any competent programmer use ai for coding other than small stuff

frank river
#

ok well im gonna try to learn everytime i use ai

modest flower
#

And I wouldn't recommend it myself

frank river
#

and also learn C

#

to code

modest flower
paper creek
#

you mean youll learn off of ai response output?

frank river
frank river
modest flower
#

Don't use ai even if you aren't stuck

modest flower
#

Where did you even get the idea

frank river
#

my brain made it

modest flower
#

What brain?

frank river
#

my brain

frank river
# modest flower What 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

paper creek
#

Constant use of AI will just lead to numb brain when you cant rely on it

modest flower
#

Its like asking 1000 rats for wisdom and expecting anything better than "cheese"

frank river
modest flower
#

Because it forgets or doesn't know without enough data

#

And BECAUSE IT DOESNT THINK, IT DOESNT HAVE A CONCEPT OF A VOXEL

frank river
#

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

paper creek
#

glorified web scraper fr

modest flower
paper creek
#

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

modest flower
#

Also you really want to waste water for that?

#

Because if yes then reconsider yourself as a human being

frank river
#

what do you mean waste water?

paper creek
#

llms use alot of water for cooling

frank river
# paper creek 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

modest flower
#

Still wasting resources

#

At least provide a meaningful service and not some slop that steals data

frank river
# modest flower Still wasting resources

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

paper creek
#

Im pretty sure water used for cooling eventually goes back into the water cycle

modest flower
modest flower
frank river
modest flower
frank river
modest flower
#

From stealing

frank river
#

ok

modest flower
#

Christi is an LLM because this level of lacking technical knowledge is just impressive

#

Especially given the context

frank river
paper creek
#

not sure

modest flower
#

And release CO2 into the atmosphere

paper creek
#

pretty sure beef production uses far more water than LLM farms

#

By a crazy amount

modest flower
#

And are genuinely making our lives worse

#

Also trying to automate out the white collars and blue collars

paper creek
#

sure they wont automate out mitchel sercombe

silent umbra
#

Though i havent heard yet of a meat cow farm running the town it’s settled next to dry

paper creek
alpine swift
#

@frank river just get out of this thread, its about a minecraft project not llms

south hatch
#

Please, stay on the topic of the channel

#

Move to #programming for general discussions

outer mountain
#

@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?

opal tundra
#

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

opal tundra
# opal tundra You could make just a flat array for that, like ```cpp unsigned short BLOCKS[ch...

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)

opal tundra
#

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

opal tundra
#

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

outer mountain
#

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.

opal tundra
#

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

opal tundra
opal tundra
outer mountain
#

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.

opal tundra
outer mountain
#

Yes, that's what i meant i was using.

calm crag
#

im trying to make something similar too

#

it's very bad tho, i'm not as skilled as you, and it has worse performance

calm crag
#

tried adding culling

#

tuff

opal tundra
#

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

opal tundra
# calm crag

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

outer mountain
#

Glad to see this 🙂

modest flower
#

@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

outer mountain
modest flower
#

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

outer mountain
#

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.

modest flower
cedar edge
#

I neeeed this to be open source

opal tundra
# cedar edge 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

short scaffold
#

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)

winged blade
opal tundra
winged blade
#

Do you know if raylib has its own raycast system?

opal tundra
winged blade
#

Thank you :)

opal tundra
#

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

outer mountain
# winged blade Hey, how did you do the block placing/breaking detection? (I mean finding out wh...

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".

tribal wind
#

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

opal tundra
tribal wind
#

Good to know! Thank you

outer mountain
# tribal wind would you recommend using raylib first before going diving into OpenGL; simply t...

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.

tribal wind
spark thunder
#

@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?

opal tundra
# spark thunder <@681882761212330035> if you don't mind me asking, how did you do biome blending...

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 😅 )

spark thunder
#

well, not 3d biomes because my project is 2d

#

but you get the idea

worldly wren
opal tundra
worldly wren
#

Okay thanks

opal tundra
#

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.

opal tundra
#

cry_about_it_c I just now realize that it looks so awful without AO
And it's been like this since forever

ocean apex
sinful forum
rapid idol
#

wow

outer mountain
#

Is that standard AO or are you using the voxel AO trick? Are the shadows under the tree just AO as well?

opal tundra
outer mountain
#

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 .

opal tundra
#

I have a hasAO function to determine whether to count that block or not, so things like plants don’t get AO

outer mountain
#

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 .

worldly wren
#

i want the open source code for this

opal tundra
#

Since then I returned to the old engine, which is still nowhere near presentable/usable

worldly wren
#

.

#

just give the source code

#

dosent matter

short scaffold
#

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.

flint mortar
#

this is the first project showcased in the project showcase video and it's not even public

#

tesó😭

gusty hound
#

wheres the download link to this project ?? i think i had it in the past like last year but i lost it . .

opal tundra
#

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