Making voxels MOVE with the separating axis test [Voxel Devlog #11]

Поділитися
Вставка
  • Опубліковано 28 чер 2024
  • Online demo: github.com/DouglasDwyer/octo-...
    Geese event system: github.com/DouglasDwyer/geese
    In this devlog, I go through some of the tough decisions that I made regarding my voxel engine. I talk about the separating axis theorem, and how I leverage linearity to use it efficiently in voxel-versus-voxel collision detection. In addition, I showcase transparent voxels rendered using weighted, order-independent blending!
    Music used in the video:
    Corbyn Kites - The Decision
    Corbyn Kites - Dusk Drive
    Chris Doerksen - Searching for Treasure
    Corbyn Kites - Birds
  • Ігри

КОМЕНТАРІ • 85

  • @GabeRundlett
    @GabeRundlett Рік тому +30

    Awesome! I may take some inspiration from the continuous collision detection 😉

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +9

      I would positively love to see a solely-GPU physics engine! Many things, like the separating axis test, would lend themselves well to parallelization.

  • @Gwilo
    @Gwilo Рік тому +27

    Douglas, the progress you've made with these videos is actually really inspiring and your progress makes me proud
    Please, whatever you're doing to keep yourself motivated, keep it up!

  • @TheRaticide
    @TheRaticide Рік тому +17

    Those transparent voxels look great. I wonder if you could use the pixels of the transparent objects as a mask to distort the solid pixels, allowing you to make a wobbly underwater effect.

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +14

      That's a great idea! Because transparency happens in a separate render pass, I should be able to sample from the solid render target. This could allow for screen-space reflections or underwater refraction :)

    • @Tyradius
      @Tyradius День тому

      Heat waves too I'd think. 🤔

  • @mark_makes
    @mark_makes Рік тому +7

    Very exciting to see more progress! Keep the videos coming! 🙌

  • @GreenDave113
    @GreenDave113 Рік тому +1

    An absolutely wonderful video. I loved the thinking style and the features as well!

  • @ayyship
    @ayyship Рік тому +1

    I spent 2 hours bingeing all your videos so far. Amazing content!

  • @AlienXtream1
    @AlienXtream1 5 місяців тому

    thankyou youtube for this hidden gem!
    on the note of the transparency, i've not heard of it before but it sounds really useful. im wondering if there may be some extra steps you can do to improve the transparency stuff. depending on performance cost you may be able to achieve a sort of middle ground. using the order independent method as a base and passing in some extra info to account for edge cases. maybe some sort of Z-buffer pass that can be used to get some crude ordering. or if there is enough information to imply order from computationally cheep checks you might be able to use a 3D LUT for RGB values. then you could use something like a ray traced transparency to precompute the LUT and bake that in. that'd also mean you (or someone else) could overwrite it too for some potentially cool effects!

  • @jonathandowns282
    @jonathandowns282 Рік тому +1

    Great video as always! I've been watching your videos since you started this series, and I use you to inspire myself to work on my own engine. You're doing amazing work, you have the best engine I've seen since John Lin, and I'm really happy to see this engine progress and each of the features get added. I'm glad you're so passionate about this, and I'm glad I found this channel!

  • @jordanserres-gonzalez9634
    @jordanserres-gonzalez9634 Рік тому

    Awesome dedication been subscribed since 3rd episode and still love the great work keep it up!

  • @bengt-goranpersson5125
    @bengt-goranpersson5125 Рік тому +1

    Your work is so inspiring.

  • @ttj_
    @ttj_ Рік тому +1

    amazing. loved every second of this

  • @shinobudev
    @shinobudev Рік тому +1

    I found success in optimizing my octree raymarcher by reducing the number of octree subdivisions to step into when traversing with a ray by caching the bounding box and index of the octree node you last searched. Given D as the depth of your octree, normally you would:
    origin -> search D octree subdivisions -> move forward -> search D octree subdivisions -> move forward
    But you can just:
    origin -> search D octree subdivisions and save the D/2 box -> move forward -> if still inside the last D/2 box then just start out there and save D/2 depth searches.
    This way you can additionally set the starting D/2 box as the one the camera is in, calculated in CPU and passing it to the GPU as a uniform. You now guarantee that your rays will save less octree subdivision searches.

    • @darkengine5931
      @darkengine5931 Рік тому

      Makes sense to avoid having to start all over again from the root of the tree. Have you tried ray packets by any chance? I'm used to using them for raytracers but never tried for volume ray marchers. It seems a bit tricky to use them combined with your optimization since each ray in the packet might want to resume from a different node in the tree.

    • @shinobudev
      @shinobudev Рік тому +1

      @@darkengine5931 have not but I'll be looking into that now

  • @benrex777productions9
    @benrex777productions9 Рік тому

    Now I'm up to date. Thank you for your videos.

  • @dominicstocker5144
    @dominicstocker5144 Рік тому

    Great work! Thanks for the video!

  • @grevel1376
    @grevel1376 Рік тому

    You are a big inspiration for me.

  • @NotAFoe
    @NotAFoe Рік тому

    Soooo impressive!

  • @jsierra88
    @jsierra88 Рік тому

    Things get harder when you have to rotate them. Otherwise, physics are much easier. Thank you for keeping up updated!

  • @user-tm1iq6il7i
    @user-tm1iq6il7i Рік тому

    exelent work

  • @hemerythrin
    @hemerythrin Рік тому +5

    Interesting that your transparency treats objects as hollow shells (so the intensity of the color only depends on the number of overlapping outer surfaces) rather than as "physically correct" volumes (making the color stronger the more voxels it is deep). Could you tell us why you decided to go that route? Was it better for performance?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +9

      There are two main reasons for this. First and foremost, it was an "artistic choice" to mirror the style of Minecraft transparency. I want to allow people to create thicker glass windows and sculptures, which I fear would appear noisy and majority-opaque if I used volumetric transparency. With the shell approach, users still have the option to create volumetric transparency by layering different materials, which will both appear even on inner surfaces - but by default, it's easy to create thick glass windows. Second, it does help with performance, because there are typically less details to draw :)

    • @hemerythrin
      @hemerythrin Рік тому

      @@DouglasDwyer That makes sense. Thanks for the response!

  • @redstonerti9918
    @redstonerti9918 Рік тому

    Subscription earned.

  • @jarredeagley1748
    @jarredeagley1748 Рік тому +2

    Great work! Transparency rendering can be a real pain to get working well. Did you look into other techniques like depth-peeling too?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +2

      Depth-peeling is an intriguing technique, since it allows for exact results without triangle sorting. However, it places a very heavy load on the GPU (requiring multiple extra render passes and textures). As I want to target lower-end GPUs, this fact made me choose against it.

  • @thertc204
    @thertc204 Рік тому

    Impressive.

  • @TheQxY
    @TheQxY 9 місяців тому

    Would be cool if you could add some fake scattering effect, so less light passes through thicker layers of blocks, this would also allow for realistic looking water, where the shade gets darker with depth.

  • @nullp0inter
    @nullp0inter 10 місяців тому

    u deserve more

  • @ZealanTanner
    @ZealanTanner Рік тому +3

    Incredible job. You know there’s something that has both physics and transparency… are you planning to add water to your game?

  • @user-xd4nb8wm5l
    @user-xd4nb8wm5l Рік тому +1

    do you hear of sign distance field ray marching rendering?

  • @stablemind
    @stablemind Рік тому

    nice

  • @-keimurikxe2252
    @-keimurikxe2252 Рік тому +1

    I have a few questions.
    1. Are you still using Vulkan?
    2. What will happen to performance if you decide to increase the number of voxels, for example, by 8 times, meaning that each voxel will turn into 8 new ones?Will this have critical consequences?
    3. Have you thought about creating a Discord server?"

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +2

      Thanks for watching the video! Let me give you the details:
      1. No, I switched to targeting OpenGL about a year ago, in Episode 4. This was because I wanted to make my project usable in a web browser, and playable on a wider variety of hardware. It was a tradeoff for portability that I made for my specific design goals. I still do miss Vulkan and its modern features, though.
      2. Performance would definitely decrease. For projects like this, achieving good performance means fine-tuning to one's specific use case. As I've designed my engine to work at the scale shown in the video, I fear that it wouldn't run well with larger quantities of voxels onscreen. That's not to say rendering more voxels is impossible - it would just require more engineering and special use of LODs. Dealing with that much data voxel data has consequences beyond rendering, though - I also need to sync voxel objects over the network and store them in-memory, so it's a delicate balancing act :)
      3. I don't have a Discord server - unfortunately, I simply don't have the time and willpower to manage one. However, there's another voxel UA-cam called Gabe Rundlett who's working on some really cool tech. He has a Discord server where myself and a number of other people talk about voxels, so you can reach me there if you'd like!

  • @brunowallner1670
    @brunowallner1670 Рік тому +1

    Can you explain how you implemented the per-voxel lighting?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      Sure! The lighting is a standard shadowmap, as described on learnopengl.com/. To make the lighting appear per-voxel rather than per-pixel, I just round the position at which I sample the shadowmap to the nearest voxel.

    • @brunowallner1670
      @brunowallner1670 Рік тому +1

      Ah i see, I want everything to be per voxel including reflections, but I cannot get any good working method.

    • @chucksneedmoreland
      @chucksneedmoreland Рік тому +1

      @@DouglasDwyer real smart, utilizing what gpus accel at (rasterization) and combining that with existing techniques with a twist

  • @wirththewait144
    @wirththewait144 Рік тому

    you should add a water system like john lins sandbox

  • @Nolanyoyo
    @Nolanyoyo Рік тому +1

    Iv tried to do voxel, witch i had multiplayer working, but at some point something started causing lag and I don't have a back up of it before it started happening without going way to far back. I used unity since it would do shadows and a lot of other effects (I add lighting to the blocks with vertex color and add shadows ontop of that). Do you think unity is bad for voxel? I dont know what alternative I could use, I dont really want to learn a new game engine(or new language).

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      I think that it depends upon your goals! If you're looking to make a game with a voxel art style (or even a game with editable, Minecraft-style terrain) then Unity is an excellent choice. Its batteries-included engine makes it easy to develop gameplay and other fun concepts. This is at the expense of flexibility, though - if you're looking to create a highly-detailed voxel environment (like myself or some other UA-camrs), then it's probably necessary to build your own engine. However, that takes a great deal of time and dedication, and it's a lot harder to make a feature-complete game. So choose whatever best fits your aspirations :)

    • @Nolanyoyo
      @Nolanyoyo Рік тому

      @@DouglasDwyer Thanks, ya unity definitely struggles when you make the voxels smaller then minecraft

    • @bluesillybeard
      @bluesillybeard Рік тому

      Unity allows you to create custom meshes, so you can probably use a greedy-meshing algorithm to speed things up.

    • @Nolanyoyo
      @Nolanyoyo Рік тому

      @@bluesillybeard i just dont think i would have the time to learn greedy meshes and deal with all the bugs from it

  • @UnofficialFoneE
    @UnofficialFoneE Рік тому

    Noice

  • @shohamtzubery8456
    @shohamtzubery8456 Рік тому

    The transparency is great but I feel like something is missing. Usually for transparent objects, the thicker the object is the less transparent it becomes. This effect is most commonly used to makes it harder to see the ocean floor the deeper the water is. Would something like this be possible to implement with your transparency solution?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому

      Thanks for the question! Another commenter asked something similar, about why I chose to make transparency be "hollow." This was my response:
      First and foremost, it was an "artistic choice" to mirror the style of Minecraft transparency. I want to allow people to create thicker glass windows and sculptures, which I fear would appear noisy and majority-opaque if I used volumetric transparency. With the shell approach, users still have the option to create volumetric transparency by layering different materials, which will both appear even on inner surfaces - but by default, it's easy to create thick glass windows. Second, it does help with performance, because there are typically less details to draw :)
      Regarding whether it would be possible, it probably would take some additional work. I wouldn't implement it for normal voxels, for the reasons above. But I would like that kind of effect for water!

  • @augustvctjuh8423
    @augustvctjuh8423 Рік тому

    Very interesting. Btw I think you might be confusing the pronunciation of axis (not plural) and axes (plural)

  • @-keimurikxe2252
    @-keimurikxe2252 Рік тому

    Sorry, just a couple more...
    Are there any alternatives to your engine at the moment?
    Are there any UA-camrs or videos that have helped you? I also want to dive into learning what you're doing, but your project is the first thing I saw on the internet that seems to align with my views on this idea. And of course, very useful links like the ones you leave in the description, such as the link to Nick's Blog.

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      No problem - I love answering these questions, it's why I make videos!
      1. Yes, there are some other people working on voxel engines. One such individual is Gabe Rundlett - definitely check out his channel if you haven't! His voxel engine is open-source, unlike mine. John Lin, Voxelbee, and some other UA-camrs are developing engines as well. I'm not aware of anything that's been completed, though. That's part of my motivation for working on the engine!
      2. While many of the above-mentioned UA-camrs provide inspiration, I don't have as many resources to provide regarding technical help. Do you have any specific areas of voxel engine design that you'd like to learn? There are so many topics - rendering, networking, audio, storage, and the like - which is part of what makes engine development so fun. If you're interested in rendering voxels, the first place to start is probably learnopengl.com. The website provides a stellar introduction to computer graphics :)

    • @-keimurikxe2252
      @-keimurikxe2252 Рік тому

      @@DouglasDwyer I can't believe it, I never expected such a detailed response, thank you so much! You went above and beyond my expectations, and now I'll start exploring the channels and resources you recommended. I already joined the Discord server! I'm absolutely convinced of the success of your project, and I really don't want your idea to die at the stage of creating a game engine, as it happens so often

  • @spr_
    @spr_ Рік тому

    have you considered implementing something similar to "cubic chunks" mod from minecraft?
    i feel like it could improve performance with more detailed worlds but im no dev
    (and possibly allow for faster and more view distance)

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      Yes - in fact, chunks are positioned in a 3D coordinate system already! There's no build height limit.

  • @Alexey_Pe
    @Alexey_Pe Рік тому

    Do you have liquid in your plans? Water?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому

      I would love to have fluids in the game at some point. However, I have some other priorities - such as rigidbody physics, multiplayer, and gameplay - on which I want to focus first.

  • @Nazo224
    @Nazo224 Рік тому

    How small can voxels be?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      Right now, I'm aiming for the scale that Minecraft *would have* if every single voxel were editable. This would mean a scale of 16-20 voxels per meter, since in Minecraft there are 16^3 voxels per block :)

  • @banditbloodwyndevs8782
    @banditbloodwyndevs8782 Рік тому

    I hope it wasn't asked or shown before:
    What graphics API do you use? OpenGL? DirectX? Vulkan?
    I'm asking because maybe I will try to write my own engine just for fun and I'm looking for some examples how others tackle this.

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      I target OpenGL and WebGL 2.0 so that my engine can run in a web browser. However, I am hoping to switch to WebGPU soon - it is a more modern and ergonomic API that will soon be a browser standard.

    • @banditbloodwyndevs8782
      @banditbloodwyndevs8782 Рік тому

      ​@@DouglasDwyer and the CPU code is Rust as far as I can see :)
      So you have some experience in writing a rendering engine. What would you say if someone (not me haha) wanted to write his engine in C#?
      Notice that he tries to make everything manually disposable (via the IDisposable interface), so he can avoid the automatic garbage collection, which can cause stuttering) as good as possible.

    • @DouglasDwyer
      @DouglasDwyer  Рік тому

      @@banditbloodwyndevs8782 I think C# is a fine choice - in fact, my engine started out in C# (see devlogs 1-3). You'll never be able to achieve the performance of a native language, unfortunately - in my testing, I've found that Rust and C++ are about twice as fast. This, coupled with the fact that C# doesn't run well on the web, was why I switched to Rust.
      That being said, C# is a great backend language and very good for writing business logic. So if your primary goal is to create a scalable application with many features, C# should be fine. For any heavy calculations, though, you might need to offload to native code or the GPU.
      Regarding optimizations, I think the biggest thing is avoiding heap allocations entirely. So your primary goal should be to use structs, not classes, wherever possible. If I recall, you can implement interfaces on structs - so using IDisposable with structs might be a powerful idiom. But C# is not at the point of being as fast as a native language.

    • @banditbloodwyndevs8782
      @banditbloodwyndevs8782 Рік тому

      @@DouglasDwyer good points. So one last question:
      In C# we have projects to organize large solutions. Let's say I switch to C++. There we don't have projects. Do you know an easy and elegant way to organize the code in a similar way beside of simple namespaces?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому

      Depending upon your build system, you can still have separate projects with dependencies - I believe that MSVC allows for this, at least. That said, C++ build systems are a nightmare, and I would recommend against them for productivity's sake. Much better to use Rust and its package manager Cargo - which allow you to easily separate your workspace (solution) into multiple crates (projects).

  • @aspidinton
    @aspidinton Рік тому

    not baaad

  • @geko2867
    @geko2867 Рік тому

    Your project look's very cool! But I'd love to know if you're ever going to invest in a better mic, it may help keep people's attention ^^

    • @DouglasDwyer
      @DouglasDwyer  Рік тому +1

      Hey, thanks for watching! I appreciate your honest feedback. If I could ask, what exactly is bothersome to you about the mic? Granted, it definitely sounds bad in my earlier episodes. In the latest few, though, I've managed to eliminate noticeable artifacts like clipping. Truly, it sounds fine to me. What should I improve?

    • @geko2867
      @geko2867 Рік тому

      @@DouglasDwyer Your audio seems a little echoey, and a bit distant.
      I'm going to assume it's a standalone mic and not inside a phone or laptop.
      If you want to make the most of your mic, first you'll want to stay within 2 feet of it. Next, you'll want to prevent your voice from bouncing around the room, the best way is to have something soft like a blanket surround your setup. This is why some people record in a closet with lots of cloth in there. You can also try comparing your audio to a clip of someone testing their studio quality mic and see how close you can match theirs.
      I hope any of this can result in some improvement, but your audio has gotten better recently, but your current audio quality doesn't subtract from the videos or your project! Good luck ^^

  • @dimitrisgkofas7787
    @dimitrisgkofas7787 Рік тому

    If you had a ray shooting from your camera and every time that It hitted an object It could pass through or not. If the ray doesn't pass you give at the camera pixel this color. No if it pass It will give to the pixel the value of it multiplied with the coeficient of transparency. Lets say 1 is zero transparency and 0 is full transparency.For exapmle If you have your first object with color red and transparency 0.9 then the number for this ray is for now 229. Now the next object that the ray hits it will add to that number by a factor of (255-229)/255*newcolor*newtransparency and the output color will continue the gerney until it will hit a wall with transparency 1that will set the end for your ray.

  • @NikZapp
    @NikZapp Рік тому

    The progress is amazing, however I strongly disagree about the way transparency looks. In my opinion it really looks vastly different, but since the transparency you used isn't volumetric in the first place I shouldn't compare it like its physically accurate.

  • @alessioolivieri5460
    @alessioolivieri5460 Рік тому

    Is this project public?

    • @DouglasDwyer
      @DouglasDwyer  Рік тому

      While there is a public demo, the project isn't open-source at present. I'm still working on refining the technology and turning it into a playable game :)

  • @djaccount5458
    @djaccount5458 10 місяців тому

    Hello, is not true voxels? Its look like 3d cubes not voxels.

  • @oliverreader2954
    @oliverreader2954 5 місяців тому

    Light theme? You make me sick!

  • @dandymcgee
    @dandymcgee Рік тому

    Your videos have so much potential, but your audio setup is holding you back. If you want more viewers, stop recording videos with a cheap mic in a hella echoey room. It would make your channel blow up so fast.

    • @st20332
      @st20332 5 місяців тому

      i personally don't mind, im here for the info, and its not distractingly bad

  • @UltimatePerfection
    @UltimatePerfection 5 місяців тому

    Your voxels are too big. Less Minecraft, more John Lin, please.

  • @vinay0arts
    @vinay0arts Рік тому +1

    Amazing work sir, I am a voxealrtist and feel free to contact me if you need any help with models