I Remade my Voxel Engine from Scratch...

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024

Комментарии • 58

  • @finalforeach
    @finalforeach Год назад +38

    The nice thing about the prototype stage is that you don't need to be scared of tech debt... Rewrites galore!

    • @ragdude7323
      @ragdude7323 8 месяцев назад

      Nice seeing you here.

    • @ragdude7323
      @ragdude7323 8 месяцев назад +1

      I got terrible memory, saw this video again, saw this comment again and was about to comment “Nice seeing you here.” Again

    • @half_invisible
      @half_invisible 6 месяцев назад

      @@ragdude7323 no way, i literally did the exact same thing for a finalforeach comment on another voxel game dev video :p

  • @talis1063
    @talis1063 9 месяцев назад +9

    OpenGL would've been fine if you understand the limitations. In OpenGL you can mapBuffer on main thread, fill it on a different thread and pass an event to main thread that unmaps it again. The highest performance approach is probably allocating a large buffer, and using something like glMultiDrawElementsIndirect to render stuff. Can basically implement a custom allocator that way, and render opaque chunks with a single draw call.
    The thing not clear about OpenGL is that you're writing commands to memory not executing them on the GPU directly. Important to know to avoid freezing.

  • @kpopalitfonzelitaclide2147
    @kpopalitfonzelitaclide2147 9 месяцев назад +6

    You could just use vulkan and c++

  • @Lemonzy
    @Lemonzy Год назад +3

    Very cool! I love Rust and Bevy, it's easy to get started but it can sometimes be difficult.

  • @orangomango
    @orangomango 11 месяцев назад +3

    Really nice videos, I'm making a voxel engine too (just that it's taking me like a few months lol) and I randomly discovered your videos. Great work!

  • @MaxIzrin
    @MaxIzrin 8 месяцев назад

    "Max is stupid"
    Extremely relatable.
    I also remake my whole [insert project here] from scratch on occasion.

  • @oglothenerd
    @oglothenerd Год назад +7

    Do you use Git for version control? It allows you to rollback if you make mistakes.

    • @MaxMakesGames
      @MaxMakesGames  Год назад +1

      I don't use Git right now but I might. And yes I'm using Bevy !

    • @oglothenerd
      @oglothenerd Год назад +7

      @@MaxMakesGames OMG! You are shooting yourself in the foot without Git! You MUST use it! Not using Git is one of the painful mistakes early programmers make! Just learn the basics. You can get away with just knowing the add, commit, restore, and maybe some other Git commands.

    • @oglothenerd
      @oglothenerd Год назад +2

      @@MaxMakesGames Shameless plug: I may make a simple Git guide on my channel later.

  • @AndrewBrownK
    @AndrewBrownK 8 месяцев назад +1

    Thinking about TNT in minecraft, the performance on your engine is looking really promising so far

  • @ThePC007
    @ThePC007 Месяц назад

    What GPU are you running this on? I’m currently trying to render voxels myself and it’d be kinda nice to put the performance you’re getting into perspective. :)

    • @MaxMakesGames
      @MaxMakesGames  Месяц назад

      I have an nvidia geforce RTX 3060 :)

  • @Skeffles
    @Skeffles 11 месяцев назад +2

    Brilliant! How do you like working with bevy and rust?

    • @MaxMakesGames
      @MaxMakesGames  11 месяцев назад +4

      I feel like bevy is easier than just raw graphics api, but also harder than common game engines like unity or unreal. You still have to do a lot of low-level work but it helps with spawning things and basic features like PBR, transparency, etc and also has an ECS so that helps for managing a lot of entities ( it will be a big help later if I want to make pieces fall to the ground and stuff I bet ). Rust is actually pretty similar to c++ but it has a lot more safety so I don't get memory leaks and crashes like I did in c++, but it's a bit harder to use imo.

  • @the0neskater
    @the0neskater 6 месяцев назад +1

    I can assure you opengl and c++ were not your issues haha...

    • @MaxMakesGames
      @MaxMakesGames  6 месяцев назад

      You are right actually it wasn't :P

  • @naterthan5569
    @naterthan5569 Год назад +3

    If you only turned on release mode at 8:00, does that mean that the performance tests in the middle of the video were also in debug mode?

    • @MaxMakesGames
      @MaxMakesGames  Год назад +2

      Yes haha but I think using debug mode only caused lag when I had multiple entities ( aka chunks once I added the loading ). Before I added the loading, the whole thing was 1 entity so it probably didn't affect much.

  • @PotionScape
    @PotionScape 8 месяцев назад

    In the unity game im making, I somehow got it up to 1 billion voxels rendered, but that is like, totally out of the use cases that i would need

    • @MaxMakesGames
      @MaxMakesGames  8 месяцев назад +1

      How do you even store 1B voxels in memory ? Each one has to be at least 4 bytes so that's a minimum of 4Gb and going through that would take a while even with an octree

  • @IsaacCode95
    @IsaacCode95 Год назад +1

    So theres no way to achieve the same with c++ and vulkan instead of opengl ?

    • @MaxMakesGames
      @MaxMakesGames  Год назад +2

      I think it's possible for sure, but rust offers a lot of tools for multithreading like rwlock, arc, etc. that makes it easier to manage multithreading without having errors, crashes, etc due to data race. With c++ you would have to use mutex and stuff like that which would end up locking the thread often ( at least that's what happened to me ) and it's just overall more difficult to manage. Rust will prevent you messing up so it's cool for that, but if you're really careful you could probably do the same thing in c++.

    • @ofrikirshen3071
      @ofrikirshen3071 Год назад +1

      ofc there is but what's even the point of dev if you don't rewrite shit in rust?

    • @FrankGennari
      @FrankGennari Год назад

      @@MaxMakesGames In C++ you can use OpenMP and put a parallel for loop around the iteration over blocks to update. This is how I do it. The large edits that cross multiple blocks are the ones that cause lag and also the ones that distribute well across threads.

  • @agoatchannnel
    @agoatchannnel 11 месяцев назад +1

    Why did you say “my videos suck” on discord, there really good

  • @delphicdescant
    @delphicdescant 7 месяцев назад

    The Rust hype is greatly overplayed tbh.
    You could have done just as well, just as easily, with C++.
    Mostly it's just usually not worth switching languages or API's based on popularity contests, and sticking to something that you're familiar with has a greater advantage imo.
    But I'm not criticizing you - just hoping you don't get stuck in a loop of "stack switching" like sometimes happens to programmers' hobby projects.

  • @tadeohepperle7514
    @tadeohepperle7514 11 месяцев назад

    From your experience, would you say that creating inividual triangulated meshes from voxel data first, is much better than sending the voxels to the GPU as simple primitives (quads) using instancing?

    • @MaxMakesGames
      @MaxMakesGames  11 месяцев назад

      It's a bit more difficult to implement but not that much and it's a lot better in terms of performance!

    • @tadeohepperle7514
      @tadeohepperle7514 11 месяцев назад

      @@MaxMakesGames That is really great to hear! What size are the individual meshes you generate from the voxels? E.g. what kind of voxel volume / triangle count do they cover? One mesh for each loaded chunk?

    • @MaxMakesGames
      @MaxMakesGames  11 месяцев назад

      @@tadeohepperle7514 Right now I create 1 mesh per chunk and my chunks are 50x50 but I might reduce the chunk size because it becomes a bit laggy when doing queries for collisions and stuff. At this size the meshes are around 10k vertices I think but it depends on how flat the surface is. Flat means less side faces so less vertices and triangles. I also started generating structures on them so that increases the count a bit because I put them in the same mesh, but I might seperate them to facilitate physics later.

    • @tadeohepperle7514
      @tadeohepperle7514 11 месяцев назад

      @@MaxMakesGames Thanks! Btw how are you doing collisions and raycasting for picking a block with the cursor?

    • @MaxMakesGames
      @MaxMakesGames  11 месяцев назад +1

      I'm actually not 100% sure how my raycasting works lol I think I found it online and it's been a while so idk where, but here's the code in rust:
      pub fn raycast_hit_cube_pos_dist(cubepos: Vec3, raycastPos: Vec3, raycastDir: Vec3, dist: f32) -> Vec3{
      let halfsize = 0.05;
      let dirInv = 1.0 / raycastDir;
      let tMinVec = (cubepos - halfsize - raycastPos) * dirInv;
      let tMaxVec = (cubepos + halfsize - raycastPos) * dirInv;
      let t1 = Vec3::min(tMinVec, tMaxVec);
      let t2 = Vec3::max(tMinVec, tMaxVec);
      let tNear = f32::max(f32::max(t1.x, t1.y), t1.z);
      let tFar = f32::min(f32::min(t2.x, t2.y), t2.z);
      if (tNear > dist || tNear > tFar || tFar < 0.001) {
      return Vec3::new(-10000.0,-10000.0,-10000.0);
      }
      return raycastPos + tNear * raycastDir;
      }
      halfsize is half the size of my cubes/voxels so mine are 0.1x0.1 so 0.05 halfsize. it checks from the raycastPos in the raycastDir if cubepos is hit within dist distance. If not it returns a -10000 vector and if so it returns the pos hit ( you could also just make it return false/true if you dont care about pos hit ). I just run that on every cube in the chunk and if there's no hits, move to the next chunk in the aim direction and check again. That's why I think I'll reduce my chunk size because looping 50x50 cubes for no hit is very bad lol. It can prob be optimized too but I hope that helps.

  • @AIAdev
    @AIAdev Год назад

    pigboss x max collab? sus.

    • @MaxMakesGames
      @MaxMakesGames  Год назад

      Wait until I add a pig boss to my game before you :)

  • @sti3167
    @sti3167 Год назад

    What AI did you use? 2:53

    • @MaxMakesGames
      @MaxMakesGames  Год назад +1

      The bing AI :)
      I just open Microsoft Edge and it's there, but idk if you can use it in an other browser. It's cool because it can search online. An other cool option is www.phind.com/ it's similar

  • @oglothenerd
    @oglothenerd Год назад +1

    Do you have a Discord server?

    • @MaxMakesGames
      @MaxMakesGames  Год назад +1

      No sorry I don't because it takes a lot of time to manage and everything. I prefer to spend my time on my projects and videos

    • @oglothenerd
      @oglothenerd Год назад +1

      @@MaxMakesGames Could I be the moderator? Or could you at least point people to mine? I want there to be an environment where devs can talk to each other about this channel and stuff, I want to verify that you have the correct Bevy settings in Cargo.toml, etc... Also, Discord has a pretty good (annoyingly good) AutoMod.

  • @HAAAAAAAAHHHHHH
    @HAAAAAAAAHHHHHH Год назад

    Not really related to the video, but are you from Quebec ? xd

    • @MaxMakesGames
      @MaxMakesGames  Год назад

      Yeah 😎

    • @HAAAAAAAAHHHHHH
      @HAAAAAAAAHHHHHH Год назад

      @@MaxMakesGames damn thats cool, i haven't seen any youtuber from there make coding/gamedev videos before

  • @Vilebreken
    @Vilebreken 10 месяцев назад

    Do you speak french?

    • @MaxMakesGames
      @MaxMakesGames  10 месяцев назад

      oui bien sûr :)

    • @Vilebreken
      @Vilebreken 10 месяцев назад +1

      ça fait du bien de pas etre le seule baguette a regarder ce genre de vidéos mdr@@MaxMakesGames

  • @toao_rainys
    @toao_rainys Год назад +2

    not as impressive since you used an engine 😤anyways, the shadows finally look good though.

  • @AllExistence
    @AllExistence Год назад +1

    NOT from scratch.

    • @PeterKilian
      @PeterKilian 4 месяца назад +1

      What the fuck are your expectations?
      Do you want a single person to somehow create a renderer, physics engine, input and windowing api, and everything like.. LITERALLY from scratch? On top of needing to need deadlines for his content creation?
      Seriously? He doesn’t need to be Id software to make something without a typical “game engine” and still have it be impressive and entertaining.
      Where is your game engine from scratch in assembly, that uses no external code?
      I think rust and vulkan is respectable by a single dev.

    • @AllExistence
      @AllExistence 4 месяца назад

      @@PeterKilian Don't fucking lie then.

    • @PeterKilian
      @PeterKilian 4 месяца назад

      @@AllExistence it isn’t a lie? there isn’t 1 way (your way) to interpret the phrase “from scratch”.
      When he says without a game engine, then that can still be interpreted as from scratch to an extent without him needing to create his own fucking OS for a youtube video.

    • @PeterKilian
      @PeterKilian 4 месяца назад

      Maybe get him to build the computer from scratch too with a hammer and nails he built from scratch!