I made a Voxel Engine with Rust (NO GAME ENGINE)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

In wanting to improve my graphics programming skills (and potentially remake a voxel game I previously worked on in Unity). I made a voxel engine with rust and wgpu-rs.

It's not the most optimized thing at the moment, but hey it works :)

Source code: https://github.com/TanTanDev/first\_voxel\_engine

👍︎︎ 18 👤︎︎ u/TantanDev 📅︎︎ May 28 2021 🗫︎ replies

Might have given me the push to investigate wpgu-rs! Thanks for the video.

👍︎︎ 9 👤︎︎ u/crutlefish 📅︎︎ May 28 2021 🗫︎ replies

I just started making videos too. What did you use to animate this?? Great stuff :)

👍︎︎ 8 👤︎︎ u/pcvision 📅︎︎ May 28 2021 🗫︎ replies

Thanks for an amazing video! We've been fans of your work, and now seeing you toying with wgpu brought us a lot of joy :)

The flickering issue was a part of growing pains for us as we transitioned from SPIRV-Cross to our own shader infrastructure Naga. It's been fixed since then, so just cargo update -p naga should get you back on Vulkan.

👍︎︎ 7 👤︎︎ u/kvarkus 📅︎︎ May 30 2021 🗫︎ replies

I love that you show your struggles. I feel like a lot of programmers avoid this (Or at least strongly minimize it), but for you it was a complete struggle which reconciled with me. Ty.

👍︎︎ 2 👤︎︎ u/klosor5 📅︎︎ May 30 2021 🗫︎ replies

Bahaha your anecdotes about going through tutorial land are so damn relatable 😅 There are aaaaalways moments where stuff just doesn't work and you need to find some weird workaround and move on pretending nothing happened! Also, I feel like no one ever leaves tutorial island, as there are tutorials all the way up the skill tree it seems and always some new stuff or tools to learn

👍︎︎ 2 👤︎︎ u/BlueSpaceWeeb 📅︎︎ Jun 11 2021 🗫︎ replies

Shonks

👍︎︎ 1 👤︎︎ u/TheTimegazer 📅︎︎ May 29 2021 🗫︎ replies
Captions
hey tantan here welcome back to my youtube channel so i have been considering for a while to recreate my unity voxel rpg game to recreate it without the game engine with rest hear me out okay okay listen listen a little bit okay okay so here's the thing i was working on this voxel game for quite some time but over time it became harder and harder to work with because it was harder to work with my motivation for this project dwindled the code was progressingly turning into spaghetti i like spaghetti don't get me wrong but not this kind look at that class i mean that doesn't make any sense wanting to progress with the game as fast as possible so i have content to show in my videos resulted in me taking any shortcuts i could find i end up writing unoptimized bad code because it is fast and easy to do and in the end it ends up harder to work with enter rust my current favorite programming language it is hard to take shortcuts in rust the language is designed in a way that you have to be thoughtful in how you manage your memory and also ownership of that memory i wanted to see if rust is a viable option for me to recreate my voxel gaming so i decided to see if i am skilled enough to create 3d boxer generation without the game engine is engine less a viable option for me let's find out you may or may not have heard of opengl directx or vulcan this alabama is designed to communicate with the gpu if you want to draw things to the screen the computer has to do a lot of calculations every single mesh every single pixel has to be calculated and graphics cards are specialized in crunching this type of data if you're using a game engine you don't need to know how it works behind the scenes but i'm building this from scratch using rust so i need to level up my graphics programming skills this is kind of a continuation of the video where i started learning opengl again i feel like this is my next natural step in improving my graphics programming knowledge creating a voxel engine i really need to understand the rendering pipeline and really get out of the tutorial zone so i started out by following a tutorial hey it's a good reset okay i wanted to try out wgpu-rs beautiful name by the way it's a graphics api for rust that works with any rendering api back-end i found a tutorial that piqued my interest and looking into the repository i saw that they had a lot of example code this will be my fifth time i'm following a tutorial from start to finish starting with drawing triangles on the screen to loading a 3d model to camera transition to adding lights mesh instancing i did the whole freaking tutorial and it took me about a week but it was at this point graphics programming really started to make sense to me i did run into two issues in this tutorial i had this annoying flickering effect and i couldn't figure out why that happened well switching the rendering api back in from vulcan to directx 12 magically fixed it now i didn't bother to investigate exactly why that happened it's probably an issue with the library but yeah i just continued on like nothing happened the other roadblock in the tutorial i had was with some shader code in this tutorial they used a function called inverse and when i did so the shader just didn't compile when i tried to use it trying to investigate it it was really hard to find information on why this didn't work so i did something different the solution i went with was actually suggested in this tutorial it was not to calculate the matrix in the shader instead passing the matrix from the cpu to the shadow vi uniform as i'm editing this video they just updated 15 hours ago the tutorial they now tell us that this function doesn't actually exist in wgsl so it was not a frictionless experience going through this tutorial but i'm glad i did because after leaving tutorial island entering unknown territory this is what i was able to make we're getting close sweet we got a chunk let's go what's going on how many measures am i drawing at this moment so how did i go from following a rendering tutorial to then making a working procedurally generated voxel engine well the rendering part isn't actually the hard part so if you know how to draw a mesh well you should be able to draw more meshes the hard part is constructing the mesh and that is all about dealing with data how do i generate the data and how do i process it so that in the end we get a mesh i had a lot of vague knowledge on how this works before going into this thanks to consuming probably every voxel engineer video that is out there i have seen a lot of these videos but when it came to implementing it myself i had a very valuable source of knowledge the voxel game i was working on previously now i didn't make the world generation code i bought it from the unity asset store this library is called fast noise and the source code for how the world generation works well it's right there in the library and i don't think i can show that for legal reasons so i'm showing my code here in the background i had this as a reference writing my own voxel engine of course i paid for it but there are probably thousands of free code examples of world generation you can find having a reference is very valuable i started out with trying to generate a shank with blocks there's something wrong with how i'm processing the data but we're getting there we're getting there slowly but surely good morning it is in the morning it's time to figure out what is wrong with me with the chunks look at here this side is completely fine but this side doesn't generate the outer faces a block is just a value is it solid or is it empty technically it's not a boolean but that doesn't really matter i started out by randomizing all of the blocks in a junk and trying to write an algorithm that can generate a mesh from this array of voxels if a block is solid then we should generate the face but if we had a block right before this one creating that phase would be unnecessary so the way the algorithm works is that it samples neighboring blocks doing that we can make sure that we only place faces where the block ends now completely randomizing blocks doesn't create these caves or landscape like shapes to generate the cave structures i'm sampling a 3d purlin noise using the voxel coordinate as input the output purlin value is used to determine if a block is solid or an air block by changing the threshold we can have a tighter cave or a much open cape to create a landscape i only sample the x and set position and the purlin valley is used to decide what the height is if the voxel's y position is below this height then it's solid otherwise it's an air block so now we know how to create a mesh but we need a system to load all of these chunks in this is how it works currently using the camera's position we can find all of the closest chunks and check is this chunk loaded if it's not then we will put it into a queue when we want to create the meshes for the chunks we get all of the shank positions from this queue and run the mesh generation for that chunk figuring out how to write the code for this would have taken me a really long time but thanks of having source code of another voxel generation library the process in building this was pretty smooth of course building all of this requires a lot of trial and error and i want to say boxy generation took me about a week of work probably a little bit more that's how everything works in a nutshell i will leave a lot of resources down below if you're interested in how all of this works articles videos things like that check it out in the description okay so what's next well i had a really fun time working on this project and i definitely want to continue this and improve on it something i haven't looked into at all is optimizing the code nothing is multi-threaded at the moment and there's a lot of rendering optimizations i can try out my plan with all of this is to keep working on this and see how far i can take it the source code for this project is publicly available on github i will not accept any pull requests because i want to keep this code sacred it's my first voxel generation application but i'm making the source code public so you can see how it was made i'm sure pretty much all of this code will change as i continue improving on it but i will continue with this in a private repository so am i really remaking my game in rust well do i have to decide well let's just start with simple voxel innervation and see if i want to take it further when i have delved a little bit deeper into this i really enjoy coding in rust so much in fact that i thought it was worth to see if i'm capable to do this and i'm starting to think i might be in the end whatever state this program ends up being a demo a game at least i have something cool to show and i have learned a lot of things building this and the most important parts i had a lot of fun don't forget to leave a like subscribe and stay tuned for more content let's see how far we can take this this has been tan tan and i'm out bye [Music] you
Info
Channel: Tantan
Views: 17,360
Rating: 4.9694071 out of 5
Keywords: voxel engine, rustlang, creating a voxel engine, wgpu-rs, webgpu, graphics programming, rust game development, no game engine, without a game engine, 2 weeks, procedual generation, coding challange, rust gamedev, opengl, tantan
Id: 96ht7rd3Y5I
Channel Id: undefined
Length: 9min 48sec (588 seconds)
Published: Fri May 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.