Happy Sunday! 😊 Thanks for watching, and if you found the spatial hashing concept helpful, don’t forget to LIKE and subscribe and drop your questions below!
As always, right when i need something like this ❤ There is no other like your content, the topics, the quality, the soothing voice, its just ❤🤌 Thank you for the awesome content 🎉🎉
@@git-amend I tried to mess up with OctTrees, not only from your last video. But I noticed they have problem - extended, long objects are creating very huge, inperformant tree. And also it is hard to control, add and remove objects - you have to debug it in the recursion, trying to catch the error or spontaneous nulls... This algorithmic data structure you brought saved my nerves very much :)
Love the video! I love to actually see these optimization techniques, tools and experiments along with the stress tests behind them. Especially when optimization is not a huge focus on game dev and tutorial channels, since that can be the achilles heel of many noob game devs. I remember starting out, following a tutorial thinking this will be the foundation for my procedural open world game aaaand you realise you can't do anything else with the project. Have a good one, looking forward to the next one!
Cool stuff and all explained so well! I'd love to learn more about how the multithreaded code is actually used by professionals. Thanks for this video!
Hey huge fan of your videos, your code quality is simply the best out there. Quick question, wouldn't Hashsets save us from doing a binary search to get the proper cell?
Good question. In this case, we're not just doing a simple lookup to check if a particle exists in a specific cell, but rather we need to retrieve all particles that belong to the same hashed grid cell. Since HashSets don't allow for storing multiple values per key (like particles in the same grid cell), they'd be ineffective here.
Thank you so much for this tutorial! I just started using ECS with Jobs a month ago, but I had a hard time figuring out how to use Jobs with normal MonoBehaviors and such outside of the Entities Systems, so this really helped me. Would love even more of this style of performance-oriented videos. Just for curiosity, how do you paste all those lines of code so quickly in your tutorials - do you have another IDE open with it on your other monitor or some kind of Clipboard addon? Looks very smooth!
One thing to mention is that you could use TransformAccessArrays to read and write transform data and skip the step of converting it to native structs, as well as having to write to the transform once the job is completed. Also, it would be great if you showed the profiler at the end to show how performant the jobs are, in small cases like this you're probably spending more time rendering the spheres, accessing their material properties and changing their transforms. If you were to bump up the sphere count to 5000-10000 then you'd probably only spend 5% of the frame calculating the job.
Great point! Using TransformAccessArray is a solid optimization suggestion for directly reading and writing transform data without the need for conversion, especially for jobs that manipulate a lot of transforms. I’ll definitely consider incorporating that in a future video-thanks for bringing it up!
TransformAccessArray has a ton of weird quirks IIRC, like not being able to process sibling Transforms in parallel and you have less control overall. It also contains the full matrix data of the transform, which is likely to be less cache efficient than custom data (speaking of which, I would split position from velocity and radius for that same reason since only one of the particle jobs uses the latter two). My hunch (haven't tested) is that it's better to keep the struct data for the updates and sync back using TransformAccessArray in a non-parallel Burst job; but I could be wrong about this. Definitely worth profiling! I'll try to remember to test when near my computer.
Quick update: it doesn't change too much performance-wise with this setup and TIL that there is no easy way to do transform jobs single threaded. The main advantage I saw is that updating a bunch of float3 is a bit faster and you can schedule the transform update in parallel with the hashing and querying. All of the time is still lost on rendering anyway. But I got the full jobs time from 0.6 ms to 0.45 on my machine with 10k particles. Biggest gain was removing the custom sort job and using hashAndIndices.SortJob(). I also made more gains by changing the batch sizes than by futzing with the TransformAccessArray stuff. YMMV, of course. *edit: Forgot to mention that both versions using TransformAccessArray were ~20% faster than when not using it. My point was that separated or not didn't make a huge difference.
hi, Its very good video , easy to understand as always ,Question: Please tell how can i check how much memory i have and is utilizing by using burst compiler as it uses direct memory allocation ? Never used it before and it's still scary for me right now 😊 .
I have this crazy idea of trying to combine the jobs and burst used here with the Octree video of last week. Don't know if it's needed or useful though.
Well, the useful thing about Octrees is that you can disregard huge areas of the 3D space, so it's not quite as useful as with a discrete grid. But it can still be done of course.
Sir i am making 3d mobile game that a lot of enemies following player so i wanna make enemies avoid eachother certain distance. Can i make with this system ? Can you give me some info please if its possible ?
Hey my brother, I felt completely lost 😂👌 Could really be helpful having an Optimization video and Burst/Jobs tutorials in simple stuff first then we'll know how to implement the knowledge in our programming life
Didn't Unity do some really shady stuff recently? Something about changing their rules so for any game made with it, the devs of said game had to pay unity a little bit of money per download? Not only that, they made it retroactive so even before the rule change the devs had to pay for every download of their game, period.
Happy Sunday! 😊 Thanks for watching, and if you found the spatial hashing concept helpful, don’t forget to LIKE and subscribe and drop your questions below!
Your tutorial release schedule is on fire 🔥 bro, and not just fast, but advanced.... Glad we have you as unity tutorial channel, keep it up
I appreciate that!
As always, right when i need something like this ❤ There is no other like your content, the topics, the quality, the soothing voice, its just ❤🤌
Thank you for the awesome content 🎉🎉
Thanks for watching and the kind words!
OMG. This is exactly what I needed for my Voxel systems.
Awesome! Glad to hear that!
@@git-amend I tried to mess up with OctTrees, not only from your last video. But I noticed they have problem - extended, long objects are creating very huge, inperformant tree.
And also it is hard to control, add and remove objects - you have to debug it in the recursion, trying to catch the error or spontaneous nulls...
This algorithmic data structure you brought saved my nerves very much :)
Love the video! I love to actually see these optimization techniques, tools and experiments along with the stress tests behind them. Especially when optimization is not a huge focus on game dev and tutorial channels, since that can be the achilles heel of many noob game devs. I remember starting out, following a tutorial thinking this will be the foundation for my procedural open world game aaaand you realise you can't do anything else with the project. Have a good one, looking forward to the next one!
Thank you! Glad you enjoyed it!
Only part way through the video and already know that I will need to watch a few times. Looks like something I can use, once I understand it.
Yes, spatial hashing has many applications! You got this!
I just love optimizations bro
Who let him cook 🗣️🔥🔥🔥
Thanks!
Huge area of interest for unity devs who want to make a game that doesnt explode potatos! Love it!
Thanks!
I was eagerly waiting for this☺
Awesome, hope it helps you out!
Cool stuff and all explained so well! I'd love to learn more about how the multithreaded code is actually used by professionals. Thanks for this video!
I'm sure we'll talk more about that soon on the channel!
Now you changed the saturation of the font color, I really prefer the the more saturated font color that you had in your previous video!
Interesting, I was wondering if anyone would notice. Thanks for the feedback.
Hey huge fan of your videos, your code quality is simply the best out there. Quick question, wouldn't Hashsets save us from doing a binary search to get the proper cell?
Good question. In this case, we're not just doing a simple lookup to check if a particle exists in a specific cell, but rather we need to retrieve all particles that belong to the same hashed grid cell. Since HashSets don't allow for storing multiple values per key (like particles in the same grid cell), they'd be ineffective here.
Oh right, of course! And this allows us to get multiple and is of log(n) complexity. I missed out on that on the first watch, thanks!
Thank you so much for this tutorial! I just started using ECS with Jobs a month ago, but I had a hard time figuring out how to use Jobs with normal MonoBehaviors and such outside of the Entities Systems, so this really helped me. Would love even more of this style of performance-oriented videos. Just for curiosity, how do you paste all those lines of code so quickly in your tutorials - do you have another IDE open with it on your other monitor or some kind of Clipboard addon? Looks very smooth!
Glad you found it helpful! The pasting is just the magic of editing!
We need more dots tutorials from u . Its soo hard to start with 😫
Yup, one of these days we'll work up to some full blown DOTS.
what a delicious guide, please make ore guides on unity dots, jobs and burst
Yup, one of these days. We'll see how many subscribers are interested in Jobs and Burst first I suppose.
@@git-amend An in depth video just focusing on Jobs & Burst would be great bro
Another day, another good video above youtube unity level.
Much appreciated!
Awesome, would you consider doing a video on creating super efficient voxel / Minecraft type system in unity?
Yeah, a few people have asked already. I'm giving it a bit more thought...
@@git-amend oh that's great, don't worry if it's a bit out of the scope of the channel. Great videos and content 👍. All the best.
Oh look at that I just dropped a comment on the previous video about some possible topics and then a video drops on Jobs and Burst! sweet!
Boom!
One thing to mention is that you could use TransformAccessArrays to read and write transform data and skip the step of converting it to native structs, as well as having to write to the transform once the job is completed. Also, it would be great if you showed the profiler at the end to show how performant the jobs are, in small cases like this you're probably spending more time rendering the spheres, accessing their material properties and changing their transforms. If you were to bump up the sphere count to 5000-10000 then you'd probably only spend 5% of the frame calculating the job.
Great point! Using TransformAccessArray is a solid optimization suggestion for directly reading and writing transform data without the need for conversion, especially for jobs that manipulate a lot of transforms. I’ll definitely consider incorporating that in a future video-thanks for bringing it up!
TransformAccessArray has a ton of weird quirks IIRC, like not being able to process sibling Transforms in parallel and you have less control overall. It also contains the full matrix data of the transform, which is likely to be less cache efficient than custom data (speaking of which, I would split position from velocity and radius for that same reason since only one of the particle jobs uses the latter two). My hunch (haven't tested) is that it's better to keep the struct data for the updates and sync back using TransformAccessArray in a non-parallel Burst job; but I could be wrong about this. Definitely worth profiling! I'll try to remember to test when near my computer.
Quick update: it doesn't change too much performance-wise with this setup and TIL that there is no easy way to do transform jobs single threaded. The main advantage I saw is that updating a bunch of float3 is a bit faster and you can schedule the transform update in parallel with the hashing and querying. All of the time is still lost on rendering anyway. But I got the full jobs time from 0.6 ms to 0.45 on my machine with 10k particles. Biggest gain was removing the custom sort job and using hashAndIndices.SortJob(). I also made more gains by changing the batch sizes than by futzing with the TransformAccessArray stuff. YMMV, of course.
*edit: Forgot to mention that both versions using TransformAccessArray were ~20% faster than when not using it. My point was that separated or not didn't make a huge difference.
As always add a like first then enjoy the content
I appreciate that
hi, Its very good video , easy to understand as always ,Question: Please tell how can i check how much memory i have and is utilizing by using burst compiler as it uses direct memory allocation ? Never used it before and it's still scary for me right now 😊 .
Maybe we'll do another video on memory in the near future...
I have this crazy idea of trying to combine the jobs and burst used here with the Octree video of last week. Don't know if it's needed or useful though.
Well, the useful thing about Octrees is that you can disregard huge areas of the 3D space, so it's not quite as useful as with a discrete grid. But it can still be done of course.
@@git-amend Ok. That makes sense. Thanks.
Nice!
769,721 views, almost 1 Million.
Hard to believe... maybe before the end of the year...
Hi cool video. It would be nice to display the fps alongside, since this is a technique for better performance.
Thanks for watching!
Sir i am making 3d mobile game that a lot of enemies following player so i wanna make enemies avoid eachother certain distance. Can i make with this system ? Can you give me some info please if its possible ?
Is Binary Search faster for this case than a Hashmap?
I think this would be dependent on your use case, and if you wanted to go with a Hashmap you could consider using the NativeMultiHashMap struct.
Hey my brother, I felt completely lost 😂👌
Could really be helpful having an Optimization video and Burst/Jobs tutorials in simple stuff first then we'll know how to implement the knowledge in our programming life
🖥
👍
Didn't Unity do some really shady stuff recently?
Something about changing their rules so for any game made with it, the devs of said game had to pay unity a little bit of money per download?
Not only that, they made it retroactive so even before the rule change the devs had to pay for every download of their game, period.
Unity no longer has a runtime fee, they've thrown that idea out.