Getting Started With Compute Shaders in Unity

preview_player
Показать описание
Welcome back, after a long haitus to our Unity 3D Voxel Terrain. We're going to start by looking at how to take advantage of compute shaders to handle advanced destruction techniques. This video will look specifically at introducing compute shaders: highly parallelized computation done on the GPU. Ideally this means we'll be able to distribute calculating voxel destruction in parallel effectively calculating the effects on every single voxel in our terrain simultaneously. Neat stuff!

We aren't going to do any of that here though. Instead we're going to look at introducing Compute Shaders and how to use them in Unity so we can expand on them and do more with them in the next video.

Some handy Compute Shader resources:

Рекомендации по теме
Комментарии
Автор

Hi Zero and thank you fo making this video. This is like breaking into a secret place full of possibilities :D

For future viewers: putting all the code in the update section will hog the memory (you can see the RAM getting gobbled up in the Windows task manager)

Only SetVector and Dispatch need to be in update, the rest can stay in Start, in that case the vars kernel result and compute must be declared as class fields.

HachikoTanuki
Автор

Super awesome of you to go through all the trouble man, great stuff. Constructive criticism I have tho is in the series I watched it's kinda trial and error which can be nice for some people as its a slow pace but a lot of successful tutors prepar their material in advance so it's a smooth streamline of optimised content in say 10 minutes of explaining, anyways thanks again man!

chiefcaptn
Автор

Thank you very much for creating this video/tutorial! It does actually cover some of what I already knew about compute shaders, but you've still provided probably more insight for me into how to use compute shaders for Unity than anyone else so far. That's probably because online videos about compute shaders are very few and far between. Most of what I've found is online documents, and some of the best stuff, like perlin noise generators and such have since been pulled from the web, probably because the creators decided that they wanted to commercialize it and no longer wanted to share their knowledge for free. That being said, I am extremely happy that you're going to make videos about these and I'll be watching videos you post on the subject very closely, and I'm going to try some stuff with them myself.

The hardest thing with computer shaders so far in my opinion is figuring out exactly what to use them for. They're superfast of course, but are virtually useless with branching logic. They seem to be a superior choice for creating dynamic textures that can be changed for each frame, so an idea of mine that I'd like to play around with is making some sort of exceedingly simple falling sand simulator which I think could be a good visual aid in figuring out exactly how to use compute shaders effectively.

Jender
Автор

I think, this is one of the best lecture I've ever seen

scenes_dot
Автор

Just want to say "You ROCK bro !" !!!
Pls keep up the good work !

sarotbusala
Автор

Thank you for this tutorial, really appreciate it! Awesome job!

j-monteiro
Автор

awesome explanation man, you have ahnnialated my compute shanxiety :-)

peterhayman
Автор

Thank you so much for this video it helped me a ton also a quick tip for the camera, if you set it to manual focusing you can get the focus how you like it and then if you move around it’s not gonna try to refocus it might help you

SpencerYonce
Автор

Great work!
A little thing to maybe improve your videos: You have a likable personality with a clear and easy to follow thought process. The only thing is you seem to be just *too* unsure. Showing a certain level of not knowing is not only good and makes you humble, but it can be useful in teaching (like you and us we both wonder what to do/what is going on). But too much of it starts to lose your audience trust in how much you really know your stuff. My 0.0005 cent is to at least do a one-time rehearsal before recording. It would also help to make shorter, denser and more to the point videos.

That said, kudos for putting up so much work and effort into a nice tutorial. Thanks :)

shahinrab
Автор

Thank you for this tutorial, it was really helpful!
Is there a video on how I could implement marching squares using a compute shader?

ellieala-kojola
Автор

Will the mesh collider work with the compute shader.
Or do I have to manually get the vertex XY position out of the mesh and put into the GPU.

jaredchong
Автор

Very honest approach. Thanks ! Really helpful. Tried using the realtime color change thing and it worked for a while playing around with different colors but then the Editor crashed. Did you face anything like this?

vishnuharan
Автор

So are compute shaders what you want if you were making your own lighting system, or if you wanted something that was using a compute shader to know if certain objects were near it and that their appearance should be affected by those other objects.

Andrewzero
Автор

Hey cool channel you have! Im intresting in this topic! So much you can do on GPU with that!

How about rendering this in scene? Like little pixel size particles wich move in random directions? Or actualy some heavy math like rasterization? Or 2d fluid simulation? It might be cool to combine it with tesselation!

krokozorluckychannel
Автор

1:49 I frantically tried to figure out how I had accidentally launched Visual Studio....

richc
Автор

wait.... can i use compute shaders on audio buffers?

elijahlucian
Автор

Great tutorial, thanks! I'm just having a problem with the FindKernel function, it says "FindKernel failed". I saw that it's maybe related to debugging problems with Unity but haven't figured it out yet.

cherrypiemedia
Автор

Hi, good job on the video.

I have a question - you make a 24 bit texture - that is RGB, and in the compute shader you have a float4 RGBA. Should that not be a 32 bit texture?

???

davidbaity
Автор

I need an shader that can do an outline around an object, needs to be in HDRP, please send immediately, thanks.

mathew
Автор

I don't get it... When I did quadtree I implemented the insertion by just applying a intersection from quad to circle. This doesn't run on any 'grid'. At least, the grid that checks with the circle usually is too small to gain anything from sending it to the GPU...

lucasmontec