Optimizing my Voxel Renderer | Voxels Weekend update #9

Поделиться
HTML-код
  • Опубликовано: 11 окт 2024
  • This last week, I did some optimizations in my rewrite, while I get ready to move soon. Oh and the reason that the framerate in the rewritten code is much lower than in the original code is that the rewrite lacks an acceleration structure.
    The GitHub page for the public code:
    github.com/Gab...
    If you want to chat with other community members and me, you can join my Discord!
    / discord
    My website:
    www.gaberundle...
    GPU: RTX 3070 (8GB VRAM)
    CPU: AMD Ryzen 7 5800x (8 core/16 thread)
    RAM: 16GB 2667 MHz DDR4

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

  • @GabeRundlett
    @GabeRundlett  2 года назад +5

    Hey everyone, I know y'all are waiting for the next video. This last weekend I finally finished moving, so I finally have time to work more on it. I have a loose (and very long but interesting) script as well as I have recorded a few clips, but I need to tie it all together with some good visualizations. This has been tricky because firstly I had to fix a few bugs (as you may have noticed on my GitHub) to get certain things to work properly. But I also need to make new visuals that go along with the script, so that it's an interesting *video* as opposed to me just talking about it, while showing nothing insightful (just looking at code is nice for some, but not intriguing to a wider audience, and you can just check out the code yourself on GitHub!). I'm hoping it'll be out by next weekend but I'm feeling motivated, so maybe sooner 😁

  • @delphicdescant
    @delphicdescant 2 года назад +24

    It seems like doing some equivalent of a depth pre-pass to shorten ray traversal length is an example of convergent evolution among these ray-based voxel rendering engines.
    I saw another RUclips video recently of someone else doing the same thing, and I also do it with mine.
    I guess the fact that it keeps being developed independently probably means it's a good idea at least.

  • @brandondavis230
    @brandondavis230 2 года назад +7

    Good luck on your move! Great work as always!

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

    Speaking of top of the world, there was a cool mod for MC named Cubic Chunks. It's purpose was to make the game world infinite not just in 2 dimentions, but in all 3.

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

      my chunks are cubic! it's just not infinite in ANY direction... I could make it "infinite" pretty easily, but what I wanted first was to integrate saving and loading from disk the chunk data. This is a little tricky for me, since it coincides with compressing the chunk data too. Compressing that much data on the CPU would not be feasible, so I've implemented a compressor that actually runs on the GPU. This has the added benefit of greatly reducing PCI-e traffic!
      In trying to design a compression algorithm that is both space efficient and fast (I managed to make one that is reasonably good at those things) I decided I wanted a better system of testing different formats, which is why I have designed the gvox library. I'm reworking this to be even more efficient at the moment. The gvox library is the main subject of my most recent video!

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

      @@GabeRundlett I am amazed by your work. I hope it will get to the stage when you can just grab it and make a game server, get some gameplay modules, assets, and build your own virtual world.

  • @-Clickertale_2-
    @-Clickertale_2- 2 года назад +2

    Nice work dude! :D also I wish you the best of luck for your move! :D

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

    We really need a complete voxel engine so people can get to making a game with the most efficient implementation for voxels, because right now there are thousands of them

  • @lolyman13
    @lolyman13 2 года назад +5

    Nice work! One thing I've noticed with your experiment with audio is that your saw wave might not actually be a saw wave. Well, at least, it sounds more like a note between F7 or F#7 than anything else.

    • @GabeRundlett
      @GabeRundlett  2 года назад +3

      Do you have perfect pitch or something? Wow! I didn't notice originally, but I was curious why it sounded higher so I thought about my code for a little while, and realized that only the sine wave had the period of 440hz, because I made it oscillate by 440*2pi radians every second. But I used the same input period to the saw and square waves, which meant their pitch was 2pi (roughly 6.28 times too fast) which gives it a pitch of roughly 2764.6hz. According to the internet, that's just under an F7!
      Nice catch! Luckily I also caught it and fixed it already 😂

    • @GabeRundlett
      @GabeRundlett  2 года назад +2

      I myself am not very musical. I can sing a bit, but I know next to nothing about any music theory or even the math of audio, so I am in for a LOT of R&D for it (mostly research). I definitely don't have perfect pitch, and I believed my relative pitch was alright... but the fact that I didn't immediately notice it being completely wrong is a bit concerning to me, haha

    • @lolyman13
      @lolyman13 2 года назад +4

      @@GabeRundlett I've only got relative pitch and compared the note that was playing to the ones on the piano. Glad this could help!

  • @Brynnyay
    @Brynnyay 2 года назад +2

    RUclips gods recommended me to you. In before 100k.

    • @GabeRundlett
      @GabeRundlett  2 года назад +2

      I can only dream of someday having 100k subs 😂 thanks for the kind words!

  • @jonathanz905
    @jonathanz905 2 года назад +2

    Great work!

  • @JoseRomagueraM
    @JoseRomagueraM 2 года назад +2

    Epic

  • @Wobbothe3rd
    @Wobbothe3rd 2 года назад +1

    Amazing work! Bravo!

  • @ich_iel
    @ich_iel 2 года назад +1

    Insane! Keep it going!

    • @GabeRundlett
      @GabeRundlett  2 года назад

      Yes sir, yesterday was my initial move-in day. Still transporting stuff to the new place

  • @dottedboxguy
    @dottedboxguy 2 года назад +1

    that's a really cool project you have there, can't wait to see how it'll go !

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      Thanks! It's a lot of fun for me to work on, that's why I do it 😁

    • @dottedboxguy
      @dottedboxguy 2 года назад +1

      @@GabeRundlett i also hope at some point (way further into development obviously) you'll add some core gameplay mechanics that make this project not just a "minecraft but it's way better", for now it looks awesome and it has really really good performance, but it lacks a bit of personality that some other voxel projects got imo, although don't get me wrong, what you've done is truly amazing and i'm looking forward into future updates

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      @@dottedboxguy I really appreciate your interest! I just might already have plans for gameplay and maybe some world-building lore too 😎 but you're completely right, at the moment it's basically just a tech demo.
      I have only been working on it for a few months, and if things go to plan then it might be an actual game in like 5 years from now.. one thing to understand is that I am practically pushing the limits of hardware at the moment. 30 series Nvidia cards are kind-of the minimum requirements (note: even the low tier 3050 is prob better than the 1080 just because of the memory speed!), so making it a game would only be reasonable to release a few years from now at least - hopefully GPUs are priced normally then and also hopefully people have some more modern hardware.
      Also it only looks like Minecraft because that was the easiest way for me to throw together some art for it, but that's not my plan for it. I don't want it to just be a Minecraft clone.

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      @@dottedboxguy ...and also I'm just a solo developer. I don't have a team, but I have a few close friends who have become interested. One thing that I think will a pretty time consuming project is just learning about audio programming. I've never done audio processing at all, so it's completely new to me and I will want to get it right before just throwing it out there. So that is gonna be a lot of research 😉

    • @dottedboxguy
      @dottedboxguy 2 года назад +1

      @@GabeRundlett that's very cool, and also pretty sad for me since well, my hardware kinda sucks xd... i have a 1050 (not even ti) so i won't be able to try it for myself as of now sadly

  • @luna010
    @luna010 2 года назад +2

    Nice. Are the suzannes being converted from, a mesh to a voxel format at runtime, or is it a precomputed array of voxels?
    I applaud anybody who can actually make progress on personal projects like this, because every time I start something I very quickly get distracted and move on to a newer/shinier/cooler project.

    • @GabeRundlett
      @GabeRundlett  2 года назад

      Thanks! Great question - I load them in magicavoxel files, so yeah I had to precompute that

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      I'm not moving onto something cooler because I think this is the coolest thing I've ever worked on! I love working on it and honestly wish I could do it full time.. of course I have a real job tho to actually make money 😂
      The thing is, the project has a pretty wide breadth of things I can work on, so if (for example) I got bored of the mathematics and algorithms for some time, I could instead use it as a creative outlet - making some art, and of course the opposite is true

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

    So cool. Question: Are only the shadows raytraced + DDA for rendering the voxels or is everything ray traced?

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

      The whole thing is raytraced in vulkan compute. Both use a DDA-like algorithm. If you're curious, be sure to check out the code on GitHub!

  • @oberdiah9064
    @oberdiah9064 2 года назад +1

    Great video as always! What resolution are you running the depth pre-pass at?

    • @GabeRundlett
      @GabeRundlett  2 года назад

      The depth pre-pass is half res on each axis, so 1/4 the total pixels

    • @oberdiah9064
      @oberdiah9064 2 года назад +1

      @@GabeRundlett Have you considered spacing it out even more? I'm working on a similar engine at the moment and I'm using two pre-passes, one course one at 1/20th resolution, and then a fine one at 1/3 resolution, which I found gave me a little speed boost over just one pass

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      @@oberdiah9064 I did consider it but didn't try it

    • @oberdiah9064
      @oberdiah9064 2 года назад +1

      @@GabeRundlett I suppose at 1/2 resolution you don't need to worry too much about rays skipping voxels due to the depth pass being low resolution - in my version I have to take the min depth between four neighbouring depth pass samples to ensure none of the rays accidently miss any voxels. (And I suppose technically you should be doing that here too, to be 100% accurate, but it'll be tiny single pixel mistakes you're very unlikely to notice)

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      @@oberdiah9064 I do still have to worry about that somewhat. I also take the minimum of 4 neighbors, and might take the min of more for a reason I'm willing to chat about in detail but I don't plan on it for my AMA video... Maybe in discord when I make that public

  • @dottedboxguy
    @dottedboxguy 2 года назад +2

    i have a question, that you may answer in the AMA video or here, would having single color voxels (like with a texture of 1 by 1 or just a color atribute) be any faster to render/would allow for special optimizations ? and if so, is it an option you might think on adding for lower end GPUs to be able to render much larger scenes ?

    • @GabeRundlett
      @GabeRundlett  2 года назад +2

      I'll look into it to know for sure, but a solid color vs a textured surface really shouldn't make any difference whatsoever - at least not anywhere near a millisecond per frame - so I don't think it would change things. However, disabling shadows is a huge one. The whole thing is raytraced, even the main image, and for people who REALLY want to play with older cards, I guess that would be fine to disable. Or maybe I figure out a way to do shadows at half resolution.
      Shadows are rough for the GPU because it makes the raytrace super divergent (stalling some of the GPU threads) in comparison to the view rays

    • @GabeRundlett
      @GabeRundlett  2 года назад +2

      It's my own raytracing algorithm, so no RTX is required. You technically don't even need a dedicated GPU. Just something that has a conformant Vulkan driver

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      Erm, well you also have to consider the memory consumption from the textures. Cache doesn't really get hurt at all. So overall memory usage is the only concern. Currently I have 30 (16x16) textures, which is only 7 kilobytes. So I could have 4,000 textures before hitting 1 megabyte.

    • @dottedboxguy
      @dottedboxguy 2 года назад +1

      ​@@GabeRundlett i see, as i'm not really ( yet (: ) into graphics programing, i thought that texture mapping had a somewhat decent impact on speed, but that doesn't seems to be the case, then that's really cool, but yeah options to lower down quality/disable some features is very important (at least for me) to play most games and enjoy them decently, also i'm really glad that game doesn't need an RTX card to be played, that's very cool

    • @dottedboxguy
      @dottedboxguy 2 года назад +1

      oh and while i'm here in graphics card things, how much VRAM is required to be able to run the game ? as my card has only a mere 2GB of it, it is my biggest concern as of now

  • @andy010
    @andy010 2 года назад +1

    What about cubic chunks, for an infinite world height?

    • @GabeRundlett
      @GabeRundlett  2 года назад +2

      Yes, the chunks are already cubic, I just haven't gotten around to the infinite part yet haha. Notice how laterally, the world is also painfully finite 😔 infinite worlds are going to come on the future

  • @ZephaniahNoah
    @ZephaniahNoah 2 года назад +1

    2 views damn. I'm here early
    only 360p oof

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      It's still uploading 😔 for some reason it takes forever to process the HD version

  • @dot32
    @dot32 2 года назад

    what programming language is this

    • @GabeRundlett
      @GabeRundlett  2 года назад +1

      The language you saw me editing was HLSL, Microsoft's shader language. The base application is written in C++, but there's barely any c++ in the project

    • @dot32
      @dot32 2 года назад

      @@GabeRundlett ooh interesting