I Remade my Voxel Engine from Scratch...

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 66

  • @finalforeach
    @finalforeach ปีที่แล้ว +42

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

    • @ragdude7323
      @ragdude7323 ปีที่แล้ว

      Nice seeing you here.

    • @ragdude7323
      @ragdude7323 ปีที่แล้ว +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 10 หลายเดือนก่อน

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

  • @talis1063
    @talis1063 ปีที่แล้ว +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 ปีที่แล้ว +7

    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 ปีที่แล้ว +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 11 หลายเดือนก่อน

    "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 ปีที่แล้ว +8

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

  • @RicardoRocky0
    @RicardoRocky0 3 หลายเดือนก่อน

    Step 1. Making a voxel engine from scratch
    Step 2. Remaking my voxel engine from scratch
    Step 3. Recreating a computer from scratch

  • @AdamCodes2
    @AdamCodes2 2 หลายเดือนก่อน

    To optimize the engine you can use ocular exclusion

  • @AndrewBrownK
    @AndrewBrownK ปีที่แล้ว +1

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

  • @PotionScape
    @PotionScape ปีที่แล้ว

    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  ปีที่แล้ว +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

  • @Skeffles
    @Skeffles ปีที่แล้ว +2

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

    • @MaxMakesGames
      @MaxMakesGames  ปีที่แล้ว +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.

  • @ThePC007
    @ThePC007 5 หลายเดือนก่อน

    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  5 หลายเดือนก่อน

      I have an nvidia geforce RTX 3060 :)

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

  • @tadeohepperle7514
    @tadeohepperle7514 ปีที่แล้ว

    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  ปีที่แล้ว

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

    • @tadeohepperle7514
      @tadeohepperle7514 ปีที่แล้ว

      @@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  ปีที่แล้ว

      @@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 ปีที่แล้ว

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

    • @MaxMakesGames
      @MaxMakesGames  ปีที่แล้ว +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.

  • @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++.

    • @Joerje
      @Joerje ปีที่แล้ว +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.

  • @the0neskater
    @the0neskater 10 หลายเดือนก่อน +1

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

    • @MaxMakesGames
      @MaxMakesGames  10 หลายเดือนก่อน

      You are right actually it wasn't :P

  • @agoatchannnel
    @agoatchannnel ปีที่แล้ว +1

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

  • @delphicdescant
    @delphicdescant 11 หลายเดือนก่อน

    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.

  • @stiliok
    @stiliok ปีที่แล้ว

    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

  • @ImGelling
    @ImGelling 3 หลายเดือนก่อน +1

    If mineceaft Java exists, YOU DONT NEED OTHER Languages. If they cab do it, so can you.

    • @MaxMakesGames
      @MaxMakesGames  3 หลายเดือนก่อน +2

      @@ImGelling Minecraft java is terribly inefficient tho... Why do you think they made a new one?

    • @Gabriel-rg7cy
      @Gabriel-rg7cy 3 หลายเดือนก่อน

      ​@@MaxMakesGames this is the point. If they made such a banger with so little, just go with the flow

  • @AIAdev
    @AIAdev ปีที่แล้ว

    pigboss x max collab? sus.

    • @MaxMakesGames
      @MaxMakesGames  ปีที่แล้ว

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

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

  • @AdamCodes2
    @AdamCodes2 2 หลายเดือนก่อน

    Make this open source or make a tutorial with source code

    • @MaxMakesGames
      @MaxMakesGames  2 หลายเดือนก่อน

      @@AdamCodes2 It's too big for a tutorial and maintaining code quality for open source would require a lot of work :(

    • @AdamCodes2
      @AdamCodes2 2 หลายเดือนก่อน

      @@MaxMakesGames ok it's alright but amazing game

  • @Vilebreken
    @Vilebreken ปีที่แล้ว

    Do you speak french?

    • @MaxMakesGames
      @MaxMakesGames  ปีที่แล้ว

      oui bien sûr :)

    • @Vilebreken
      @Vilebreken ปีที่แล้ว +1

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

  • @toao_rainys
    @toao_rainys ปีที่แล้ว +3

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

  • @AllExistence
    @AllExistence ปีที่แล้ว +1

    NOT from scratch.

    • @PeterKilian
      @PeterKilian 7 หลายเดือนก่อน +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 7 หลายเดือนก่อน

      @@PeterKilian Don't fucking lie then.

    • @PeterKilian
      @PeterKilian 7 หลายเดือนก่อน

      @@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 7 หลายเดือนก่อน

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