A Practical Use for Unity's C# Job System

Sign up for the Level 2 Game Dev Newsletter: eepurl.com/gGb8eP
Download the example project: github.com/ThousandAnt/ta-fru...
Ever needed to a render a whole bunch of objects on screen but couldn't do it without taking a hit to performance? Indirect Rendering is a way to repeatedly draw the same mesh with minimal draw calls. In this video, we'll walk you through how to use Unity's C# Job System to perform faster indirect rendering in Unity.
This video was created in collaboration with Porrith Suong / porrithsuong
💬 Join Our Community
Discord: / discord
Patreon: / infalliblecode
Newsletter: eepurl.com/gGb8eP
❤️ My Favorite Unity Assets *
Odin Inspector and Serializer: assetstore.unity.com/packages...
Editor Console Pro: assetstore.unity.com/packages...
Rainbow Folders 2: assetstore.unity.com/packages...
Peek: assetstore.unity.com/packages...
Project Search & Replace: assetstore.unity.com/packages...
⚡ Unity 3D Plus: prf.hn/click/camref:1100l3e8M/...
⚡ Unity 3D Pro: prf.hn/click/camref:1100l3e8M/...
👋 Contact me directly at charles@infalliblecode.com
* Disclosure: These are affiliate links, which means I'll receive a commission if you use them to make a purchase.

Пікірлер: 62

  • @ewwitsantonio
    @ewwitsantonio2 жыл бұрын

    OK, I have no clue what is going on. But it is a good feeling to be *challenged* by unity related videos on KZread, and a good reminder to study the absolute basics of compute buffers, or even just rendering in general. I'll need to find a gentler intro to these topics - if anyone has any recommendations please share!

  • @Marwan-Tech

    @Marwan-Tech

    2 жыл бұрын

    you just toke all my thoughts and struggles and say it out loud :D

  • @michaelbrown4396

    @michaelbrown4396

    2 жыл бұрын

    would be excellent if there was like a step by step because im a snr coder and I understand the code just not where to put it

  • @alfie8778
    @alfie87782 жыл бұрын

    I truly appreciate the push for more advanced topics in your content. However, the script here is far too verbose, assuming far too much and inverting the ‘complex subject/simple explanation’ principle. This feels like having a topic explained by someone who has just discovered the knowledge themselves and is still trying to solidify it in their minds. I don’t mean to sound negative; I understand that your guest is probably new to making this content, and I’m sure they will be amazing in the future. Please keep pushing down the more advanced path. It’s sorely lacking on KZread…

  • @robrab2000
    @robrab2000 Жыл бұрын

    man, I miss this channels so much.. was honestly my favourite channel for so long :(

  • @brockormond4131
    @brockormond41312 жыл бұрын

    As interesting as this was, it seems like a BIG jump in difficulty compared to the last video. I also feel like these videos could use more illistration/diagrams on what is going on conceptionally. A case of 'show, don't tell'. Maybe a few more 'lighter' episodes on ECS as well, as it's different way of thinking about code than Object-oriented programming and they are not necessarly compatible to my understanding.

  • @RiversJ
    @RiversJ2 жыл бұрын

    If you actually need aggressively dynamic rendering (lots of additions/removals, say moving asteroids, arrows etc) then this system seems like the perfect fit for it (will likely adapt it at some point). But the showcase of static foliage is really not good here, you wouldn't want to keep a jobs system doing loads of repetitive functions that can be executed in parallel (what GPUs are entirely designed around and CPUs most definitely are not) described with average gamedev math. Use indirect rendering from a compute buffer and have a compute shader do the culling, you'll never need to send or receive data from the GPU, merely call dispatch on your culling shader which itself can be called indirectly no less.

  • @lucbloom

    @lucbloom

    2 жыл бұрын

    Right. Because the mesh doesn’t change, culling on the CPU is an overhead you don’t need. Not sure why they talked about “sending minimal data”, if it’s not dynamic geometry…

  • @turkeyjerkey
    @turkeyjerkey2 жыл бұрын

    I love the more advanced material, Charles! Please keep it coming!

  • @Haapavuo
    @Haapavuo2 жыл бұрын

    I think this video should go MORE INDEPTH on every aspect in order to understand what is going on. Seems like many are having similar feelings of struggle and even anxiety while watching this and trying to understand. Please try to add more baby steps in between going through the codebase. Thanks.

  • @ravartd.9846
    @ravartd.98462 жыл бұрын

    Very well done and actually one hell of an amazing timing for me! My final thesis revolves around that topic and I was actually thinking about using dots ( but it adds an extra layer of complexity). Your approach with integrating compute shaders is very crafty and gives a clear blueprint :D Thank you very much!

  • @mad616
    @mad616 Жыл бұрын

    Thanks, finally something not newbie. It was easy to understand

  • @diliupg
    @diliupg2 жыл бұрын

    What a great video and collaboration. Thank you for this extremely useful and valuable content.

  • @MatthewAWinston
    @MatthewAWinston2 жыл бұрын

    Congratulations! Great to see you platforming others!

  • @LouisGale
    @LouisGale2 жыл бұрын

    Finally a video that demonstrates real world usage of the Unity job system, rather than the Micky Mouse (tm) examples shown in the documentation, like incrementing the X coordinate of a vertex. This video was truly excellent and the application to instanced rendering aside - it answered a lot of questions for me around how to interface with the job system. I highly encourage you to keep making videos at this level, especially around the job system which tends to be poorly documented.

  • @CreativeSteve69
    @CreativeSteve692 жыл бұрын

    yay charles is back. Hope Barles makes a comeback soon to.

  • @ThienHaFlash
    @ThienHaFlash2 жыл бұрын

    Very nice technique! I really appreciate this kind of advanced topic!

  • @asadickens9353
    @asadickens93532 жыл бұрын

    I appreciate the more advanced topics especially in the realm of optimizations and rendering. Although I understand the underlying concepts of this video it's still not epiphanizing (I made up this word) so I have to watch it over and over again! I also like how I don't have to put the video to 2x speed to get to where I want.

  • @MertKirimgeriGameDev
    @MertKirimgeriGameDev2 жыл бұрын

    Awesome content! I would personally use a compute shader to do the culling but this jobified way of doing things has its own usecases. Good to know!

  • @lucbloom

    @lucbloom

    2 жыл бұрын

    Ah yes, suspicion confirmed. More people are saying this should be used for dynamic stuff like arrows, otherwise, why upload that static data every time…

  • @THEspindoctor84
    @THEspindoctor842 жыл бұрын

    definitely level 2 content. No complaints here, but if anyone is reading this and trying to get a pulse on viewer reaction...it's definitely over my head. But I see there are some folks who clearly grasp it and can respond more constructively. Either way, youtube doesn't need more tutorials on how to get collisions working or how to move objects, so I'm happy about this even if it's over my head.

  • @eizenhorn91
    @eizenhorn912 жыл бұрын

    6:22 (and all other, similar places) - be careful, dangerous usage example of native Begin\EndWrite without mention of possible issues. Because of how it's implemented on the Unity side, the native version of Begin\EndWrite should always be called in the same frame, i.e. if you BeginWrite in frame X then you always should call EndWrite in exactly the same frame. Otherwise, it will randomly corrupt\miss your data on GPU (which will result in strange behaviors, flickering etc.) To be more precise - you should EndWrite before buffer will be used on GPU. In the current case, it will work fine because this buffer (transformBuffer) will be used only after our manual draw indirect call, but it's definitely should be mentioned that it's only allowed for this specific case :) In the regular usage of native Begin\EndWrite rule is strict - EndWrite in the same frame before rendering. Or just use double buffering strategy with memcpy (write to the preallocated native array as many frames as you want and in the end in one frame BeginWrite->memcpy in burst job->EndWrite, which will give you best possible performance)

  • @voxelltech
    @voxelltech2 жыл бұрын

    Hey, I am just curious, since everything here is using a compute buffer, isn't it way faster if we were to just use compute shader to calculate them instead of wasting time copying CPU memory to GPU memory. Is there a reason why we are using job system?

  • @ferozmd9126
    @ferozmd91262 жыл бұрын

    Awesome Content

  • @fkeyzuwu
    @fkeyzuwu2 жыл бұрын

    honestly, this seems way over most of your viewers heads(including me). this isnt level 2 game dev, its more like level 6 game dev lol. the last video however was great! i think that or even a little more advanced level of knowledge should be where you aim should be aiming for.

  • @HumbertoBytes
    @HumbertoBytes2 жыл бұрын

    Oh yes Charles IS BACK!

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    Feels good to be back!

  • @happyfarang
    @happyfarang2 жыл бұрын

    That wasn't complicated at all... *cough cough* hehe. I think i should watch this a few times more 😳

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    It's definitely on the more complex side -- you should download the example project and poke around :D

  • @odo432
    @odo4322 жыл бұрын

    Seems to be a lot of overhead involved. Although there were much fewer draw calls it was about 10% slower than just using static batching.

  • @ingjn7858
    @ingjn7858 Жыл бұрын

    Cool Video!! I have a Unity project for Android, and I have a Networking script to receive > files and save them to temporaryCachePath. Would it be a good idea to use the Job System to run the Networking script. What other options I have to run the Net script in the background?

  • @INeatFreak
    @INeatFreak2 жыл бұрын

    Does this work with additional spot, point lights? Doing a manual Graphics.Draw call doesn't set up required properties for lights as far as I know.

  • @McDerpDerp
    @McDerpDerp2 жыл бұрын

    Charles you are awesome.

  • @QueRedFire
    @QueRedFire2 жыл бұрын

    very very very cool stuff

  • @ananasik-gamedev6381
    @ananasik-gamedev63812 жыл бұрын

    Thanks!:D

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    Thank you for watching!

  • @handleneeds3charactersormore
    @handleneeds3charactersormore Жыл бұрын

    this seems to have an error in the compute side, at 7:30

  • @MarekNijaki
    @MarekNijaki2 жыл бұрын

    My brain feels like messed spaghetti after watching this video 😂

  • @iam_Raavanan
    @iam_Raavanan2 жыл бұрын

    Really great. But, it would be helpful. if more tutorial about C# job system in the graphics side. More of from scratch.

  • @BrontoKroxig
    @BrontoKroxig2 жыл бұрын

    My question is...why I want to reduces my batches, if they hit poorly on my frames per second? 1:06 (btw, I love background music, maybe a link? :3)

  • @tbunreall
    @tbunreall2 жыл бұрын

    I feel like anyone who understands this video, doesn't need this video lol...

  • @PurpleDaemon_
    @PurpleDaemon_2 жыл бұрын

    Barels will definitely need help to grasp this topic.

  • @lambjalfrezi
    @lambjalfrezi2 жыл бұрын

    Yeah....Compute Shaders are *incredibly* powerful, but I wouldn't start from here....

  • @VirtusH

    @VirtusH

    2 жыл бұрын

    There aren't any compute shaders, just compute buffers, which let you send data to the gpu.

  • @faizanqaiser4027
    @faizanqaiser40272 жыл бұрын

    waaaaay too difficult to understand ;( please cover this in an entire playlist

  • @jamesmillerjo
    @jamesmillerjo2 жыл бұрын

    Seems like overly low-level and demanding newly home-made wheels beside a car garage full of wheels...

  • @VirtusH

    @VirtusH

    2 жыл бұрын

    It is reinventing a bit of rendering, but it's very much faster than using any of the other "wheels". :)

  • @defonotme2476
    @defonotme24762 жыл бұрын

    not not not first

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    Not not not not last either

  • @NecroteckLabs
    @NecroteckLabs2 жыл бұрын

    Not not first

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    Maybe next time heh

  • @puretrack06
    @puretrack062 жыл бұрын

    Great information just too much for a single video.

  • @skizooooooooo
    @skizooooooooo2 жыл бұрын

    I have no idea what you're talking about. Is this a tutorial or something? All I hear is a bunch of words lol

  • @kyryllvlasiuk
    @kyryllvlasiuk2 жыл бұрын

    Not first

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    There's always the next one ;P

  • @alokhalder218
    @alokhalder2182 жыл бұрын

    Make multiplayer

  • @InfallibleCode

    @InfallibleCode

    2 жыл бұрын

    Too easy!

  • @eXesic
    @eXesic2 жыл бұрын

    Who is still interested in newsletter in 2021? Better use this content to make a video every two months. Sorry if I sound negative. Your videos are good, even if lately they feel like you're being forced to promote things like this.

  • @handleneeds3charactersormore
    @handleneeds3charactersormore Жыл бұрын

    even though this is an extremely verbose script, poorly narrated by the guest, the real issue is that this makes no sense to implement, at least per your example... Rendering is 10% slower...

  • @_WiseMass
    @_WiseMass2 жыл бұрын

    Well, it turns out engineers at Unity are either dumb or lazy to introduce such API's out of the box

  • @VirtusH

    @VirtusH

    2 жыл бұрын

    Huh?

  • @user-ek7ho8rb9x
    @user-ek7ho8rb9x2 жыл бұрын

    Please pronounce the words more clearly. You are also listened to by non-native speakers.