Pushing the rendering limits - Rust Voxel Engine

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024
  • I implemented 6 new rendering related techniques in my voxel engine using the rust programming language and Bevy game engine.
    pbr integration, shadow rendering, fog, level of detail (LOD), far distance heightmap approximation, skybox.
    My discord group:
    / discord
    Want to support me?
    ⁍ Patreon: / tantandev
    ⁍ Monero: 43Ktj1Bd4Nkaj4fdx6nPvBZkJewcPjxPB9nafnepM7SdGtcU6rhpxyLiV9w3k92rE1UqHTr4BNqe2ScsK1eEENvZDC3W1ur
    Resources: (The tech I'm using for my larger voxel game project)
    bevy game engine: bevyengine.org/
    game_stat: github.com/Tan...
    physics (3D and 2D): github.com/dim...
    inspector ui (runtime tweaking): github.com/jak...
    hot reloading using dlls/so files: docs.rs/dlopen...
    benchmarking: github.com/bhe...
    world generation: my own custom implementation is not open source at the moment.
    other rust libraries, that I recommend:
    game engine: github.com/not...
    Graphics rendering api: wgpu.rs/
    multithreading: github.com/zes...
    profiling: crates.io/crat..., using Optick feature
    #gamedev #rustlang

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

  • @fendoroid3788
    @fendoroid3788 ปีที่แล้ว +256

    This man is singlehandedly porting Veloren to Bevy.

    • @cocowwd
      @cocowwd ปีที่แล้ว +21

      Wait veloren doesnt use bevy ??

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

      ​@@cocowwd i was about to type the same, I'm pretty sure it uses bevy-ecs

    • @Tantandev
      @Tantandev  ปีที่แล้ว +31

      @@onelikeandidie I believe veloren uses their own ECS

    • @onelikeandidie
      @onelikeandidie ปีที่แล้ว +6

      I went to fact check myself at this point. It uses the specs crate for ECS, I was pretty sure it used bevy oh well

    • @tsalVlog
      @tsalVlog ปีที่แล้ว +5

      @@onelikeandidie At one point, I think Bevy used specs, switched to hecs, and now has its own ECS implementation.

  • @eboatwright_
    @eboatwright_ ปีที่แล้ว +33

    Genuinely my favorite programming channel. I love coding in Rust, and watching these videos is super interesting to see how you structure all of this

  • @TonsOfHunStudios
    @TonsOfHunStudios ปีที่แล้ว +6

    PBR, Shadows, and LODS oh my! Really interesting to hear the different problems you encountered with each steps and the solutions. Great work!

  • @Danidev
    @Danidev ปีที่แล้ว +8

    very nice pasta Tantan yumyum

    • @bingchilling989
      @bingchilling989 8 หลายเดือนก่อน

      When are you uploading?

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

    Without this video I wouldn't have discovered you could import shader code! It's helped my project, thank you :)

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

      glad that could help, luckily the bevy/shader examples are pretty good if you need to figure out some shader stuff.

  • @giacomo.delazzari
    @giacomo.delazzari ปีที่แล้ว +27

    The progress is very cool! I see that the mesh generation is a bit slow, I noticed that you're using hash map structures, and I was wondering if it would be possible to avoid those, since they cause a lot of memory cache misses (especially if you have very large ones). Or maybe having a lot of smaller ones so they fit inside the L2/L1 caches would be enough!

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

    BABE wake up Tantan uploaded a video!!!!!!

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

    Nice Video, I've never done anything with Graphics Programming. So this is really impressive!

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

    I am making a voxel game in Bevy too, what I do is I have a .draw() method on my Chunk struct, that returns a Bevy Mesh, and then I draw it with PbrBundle.

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

    Nice video! Might I suggest making your voiceover track mono in future uploads? Something about the phase of your mic makes it really hard (personally) to listen to with headphones. Cheers!

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

    Got that sweet, sweet Patreon support locked in! Been loving your content and energy, and it's both educating me and motivating me to revisit a game I didn't finish for ludum dare earlier this year!

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

    Bevy has been so interesting to work in. I've been working on a multiplayer FPS similar to Quake Arena using GGRS for networking. When Bevy works, oh boy it's so nice. Writing a system that just does what it needs to is so awesome. When things don't work tho...it's... interesting

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

    Fascinating to see what problems you've been running into! Great video Tantan.

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

    Love a Tantan video. Thanks for uploading!

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

    Like some other commenters, I notice that you're using hashmaps to keep track of things. I don't know if they are a performance bottleneck for you, but did you know that the default hashing algorithm used by Rust hashmaps is slow? You can replace the hashing function with a crate like FxHasher, and net performance gains from a simple find/replace :)
    (The default hashing algorithm is slow because it was chosen to be DDOS-resistant, but for graphics code that doesn't matter.)

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

    For LOD you could arrange the chunk data like a .png, where the spaced out blocks come first and the next data fills in the gaps

  • @shiva_prasad.m.g
    @shiva_prasad.m.g ปีที่แล้ว +1

    0:43 I can feel you 🥲😐

  • @RoamingAdhocrat
    @RoamingAdhocrat ปีที่แล้ว +4

    Do you need some kind of hysteresis, so if you step back and forward over the edge of one area you're not constantly loading and unloading the same boundary tiles?

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

      like, you are in area B, next to areas A and C, so you have ABC loaded. you move from B to C, so it unloads A and loads D so you have BCD loaded. then you step back from C to B and it unloads D and loads A to give you ABC again. then you make one step forward again - back to BCD... so you need to have a sensibly wide boundary where it doesn't change anything so you don't get this thrash

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

    -> touch some_grass
    `touch`: cannot touch ‘some_grass’: Permission denied

  • @btarg1
    @btarg1 ปีที่แล้ว +14

    Ray Tracing looks great in voxel games, I would love to see you implement ray traced (software-based of course because of your GPU) lighting/shadows/GI etc as an option!

    • @patrykszewczuk8741
      @patrykszewczuk8741 ปีที่แล้ว +6

      wouldn't that be too much for a cpu? I don't know much about ray tracing but I think there is a reason it runs on a gpu

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

      @@patrykszewczuk8741 software rendering in general is a very bad idea even if you have a decent CPU

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

      @@thefurry7165 all rendering is software-based because you need to write software to run on the GPU. I think this term is not good to be used, unfortunately. GPU rendering is a better term overall.

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

      ​@@patrykszewczuk8741 since its a voxel game, some simple raytracing can be done on the cpu, however if you want it super realistic a gpu is needed yes.
      Also don't quote me on this I'm not 100% certain

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

      @@patrykszewczuk8741 op probably meant implementing ray tracing without relying on hardware ray tracing cores that are exclusive to modern NVIDIA and AMD gpus, like how Teardown and Minecraft shaders do it

  • @on-hv9co
    @on-hv9co ปีที่แล้ว +1

    If you're still looking for something to do with the LOD misalignment you can look into adapting the surface shifting technique described in the Transvoxel paper in ch 4

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

      ah thanks for the article, interesting stuff!

  • @willabytes
    @willabytes 2 วันที่ผ่านมา

    Det här var rätt coolt hörredudu... Försöker lära mig Rust först innan jag ger mig på något ens nääääääääära det här haha

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

    6:00 Damn I feel your pain! I spent couple weeks to do it right in my game and it still have some issues.

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

    Если ты завершишь разработку игры, и будешь ее развивать - это будет невероятно круто

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

    Vad roligt!
    I actually have one of those scary books. If only I got the time to reading any of it :D

  • @mabomba.catlati
    @mabomba.catlati ปีที่แล้ว

    Nice work. And theres a also a cool game that is written in rust its called veloren its very amazing

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

    Nice continue the nice work!

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

    new tantan video, the world is saved

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

    you can probably force your world preview to be behind your voxel mesh in shader code by adding some offset before writing to the depth buffer, but i know neither bevy or rust, so that could be hard to do

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

    Hello really liked your video! Could you share what you use to make your drawings like @6:29 :)

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

    It's very humbling to see you work with such an old GPU

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

    If the terrain is far enough away you could try rendering it just as points instead of cubes, like a point cloud they can look pretty good

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

    It's stupid that Minecraft still doesn't have LOD

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

    Very cool work! You are an inspiration to us all. :D

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

    OMG Why didn't I learn this earlier

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

    supporting tantan with seks
    checks out

  • @shehackedyou
    @shehackedyou 8 หลายเดือนก่อน

    Your style choices make me feel a lil' old but I really like the algorithm you came up with for first reducing the overall quality of distant voxels into larger chunks. The method you used is very clever, reducing the count to an evenly distributed sampling is a great concept. Then filling in the rest with guesses based on the limited sample.
    What I really liked was the detail around the player algorithm, where as you move, you are using math from the previous position to make modifications up and down instead of rebuilding. I really like this concept; and I don't even do game dev, but Id watch another video of that in more detail. Its a fascinating subject.

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

    Your VisitStatus type looks oddly similar to what you return in a Future, I wonder if async can be used with a helper crate to simplify the loading and rendering pipeline for chunks

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

    It's insane to me that you first thought of implementing the thing yourself instead of immediately scavenging around for an existing implementation of anything close enough to your needs

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

    So much beauty

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

    Man you are amazing

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

    This project speaks to me! Do you know if criterion take data allocation into consideration for its benchmarks? I think you could save some cycles by considering the data allocations at 1:00 (its seems to me that the positions could be placed on the heap, (*edited*) thus accessed linearly by the computer). Do you have any profiling exempels uploaded?
    Note: Im a bevy rockie, have never used a game engine and do not condone premature optimization ;)

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

    I watched this video just after taking a walk and now you tell me to touch grass 😤

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

    Do you livestream in twitch? Or anywhere

  • @benrex777productions9
    @benrex777productions9 6 หลายเดือนก่อน

    I think youtube is racist. It gave me an IKEA advertisement on your video.
    Greetings from the other Sweeden, also known as Switzerland by insiders.
    I agree that graphics are hard. At least that is my opinion after not having tried it. Voxel games sound cool to make and I'd rather watch other people do it for me.

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

    Level of detail is ideally done with octrees, that way you can have massive render distances. In your current setup, it seems you still keep the same sized chunks?

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

      Do you think octrees could be applicable in a voxel engine that does not use ray tracing? I've been reading online in many places saying that it isn't necessary, but in those cases, level of detail is not implemented I believe...

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

      Octrees are not often a good solution for visual LoD because you can only scale detail by a factor of 2. They're mostly useful only as an implementation detail for large volumes with low entropy. For LoD, a good approach (and one that we use in Veloren) is to artifically stretch the LoD mesh in the vertex shader such that more detail naturally appears close to the camera and this detail reduces gradually with distance from the camera.

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

      @@Tantandev Yep. I've written voxel engines with rasterisation and octrees to store the data. That way you can have exponentially larger chunks as the chunks aren't all the same size in the world. It's a lot of work however to get it all working, so it isn't something one should take lightly.

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

      @@jsbarretto I'm not sure I understand your approach. How do you start with the LoD mesh in the first place that you are to stretch? and what does stretching even entail to add more detail? Is there an article that I could read?

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

    i love bevy

  • @무방-d6q
    @무방-d6q ปีที่แล้ว

    Implement nanite and lumen using rust!

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

    your videos are so inspiring
    I hope I muster the courage to start a channel too😢
    I wanna build a small community and share what I love

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

      The reality is that everyone's first videos will 99% chance be garbage, and that's fine because you won't get good until you have failed many times. We are all scared of judgment, looking like a fool etc... But everyone who has achieved success have all looked like fools at some point. 2 books that personally have helped me overcome fear/procrastination: 1. war of art 2. do the work. Both are written by steven pressfield. Actually check out some of his interviews on YT, pretty dope :)

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

    for LOD why not just use a Quadtree? Very simple logic, make 1 giant chunk, then if the player is inside that chunk, Subdivide that giant chunk into 4 smaller chunks.
    Then repeat until you are satisfied with the number of LOD.
    Also to generate the LOD you shouldn't do just the Mesh, you should also generate lower-resolution chunk data.
    Otherwise, you run out of memory at larger view distances, and giant LOD chunks will need Massive amounts of data.
    Instead, each chunk should always Generate a fixed resolution regardless of its size.
    This way you can easily have massive view distances, like 16km without memory or rendering issues.

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

    nice one

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

    Why are you drawing triangles when they should be squares?

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

    I love me some CHUNKS

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

    What are your thoughts on the rust foundation drama?

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

      The suggestions are absolutely crazy and if implemented would probably hurt the rust community in a very noticable way. So I'm not a big fan... Luckily ThePrimeagen, GamesFromScratch and Theo have all spoken up

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

    So when are you going to make nanite 🙃

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

    The lod where you double the size of the blocks (the one at the end of your vid and outlined in that one 0fps blog post) looks pretty bad IMO. Surely you've seen lots of screen shots of implementations at this point. While it makes sense from a technical perspective. I've never seen an implementation of it that doesnt fuck with your sense of scale and distance. I really wanted to see the height map lod explored further. Maybe that with billboarded trees or something.

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

    Hey, hey !

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

    I hope you're still ending up with a performance improvement, if your changes will also cause chunks to have to load in different detail levels more often!

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

    wow, after those rendering improvments the game looks soooo good. I have a few questions though. Based on the video I saw that you use bevy renderer but write shaders yourself. Is that true? What are the benefits of writing them. And second one, how long does your project compile? I'm getting pretty annoyed at how slow my projects compile but maybe it's normal...

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

      Have you tried enabling the dylib feature of bevy? I found it improved my compile times a lot

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

      @@davawen9938 I've been looking into it but I think I heard that it's not available on windows

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

      ​@@maxplayerone9565 for that reason I recommend setting up wsl2, with pulseaudio and a windows x server.
      It can be quite a bit of work, but it works great ^^

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

      Hmm, gonna look into that. I've used wsl for a while but I didn't see how it would help me so I just stopped :P

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

      @@maxplayerone9565 wsl supports windows out of the box now, since a few weeks i think. Idk hoe good it is doe

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

    wait a second since when did wgsl have import directives? Is this a feature bevy adds? I can't find it in the wgsl spec

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

      Yes its a feature of the bevy preprocessor, not wgsl itself

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

    I'm very sorry, but I am not going to touch grass right now, as it snow-rains 😨 (yes, the mixture of them both)
    But nice progress on the engine 😊

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

    awesome :)

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

    0:21 what's the title of the music?

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

      it's from opengameart! here is a link:
      opengameart.org/content/hyper-ultra-racing

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

      Thanks!

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

    have you seen Veloren?

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

    kul

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

    This stuff looks advanced. Great work. At the moment I make only simple games, so I can only try to imagine how hard this Voxel thing is. Congrats on making it work. Keep up the good work ;)
    - Dan

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

    I'm trying to port my wip game to bevy, since i love rust but it seems there is no easy and nice way to do something like nested assets where you have a filepath to an asset inside another one.

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

      Like a compressed file?
      Or more like a giant blob of data like a .pkg or .dat file? Unsure if thats supported out of the box, however you can certainly write your own handler for it. Shouldn't be that difficult even

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

    So real

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

    How do you manage to develop Rust on 10 year old PC :O
    Mine is ~6 years old and when I compile Rust even the goddamn Spotify starts lagging.

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

    You're so Swedish !! (no?)

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

    I've been watching you for quite some time now, I'm wondering, though, if you have a 10 year old computer. Why not get a new one? I'd say your channel is successful enough to buy it as a business expense? So you can get back taxes as well, it would help your dev work as well.
    So why not upgrade?

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

    please source code github link

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

    Cool video! I've implemented a voxel engine with 100km of render distance and have a video talking about it if you are interested :P

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

    me have gtx 630 no worry

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

    :)

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

    This was nice to watch, but what has been achieved here that is "pushing the rendering limits"? You mean *your* limits?

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

      His engine rendering limits

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

    Qzeq?

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

    ;)

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

    Wtf did i just watch

  • @Prod-23
    @Prod-23 ปีที่แล้ว

    Shhhhhhhh, don't mention the R word ...

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

      I mean... CRAB LANGUAGE!!!

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

    Why don't you use Unreal Engine 5 for graphic design? Your game look trash compare to UR5 game tbh

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

      its not for production purposes, more like a learning experience.

  • @YourMom-rg5jk
    @YourMom-rg5jk ปีที่แล้ว

    what theme are you using for your editor i kinda dig it

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

      with Helix I use: OneDark
      with VSCode I use: OneMonokai

    • @YourMom-rg5jk
      @YourMom-rg5jk ปีที่แล้ว

      @@Tantandev

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

    Cliche editing, primitive problems, unimpressive results

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

      what's wrong with you bud

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

      @@javierflores09 They didn't get enough love as a child, I guess