Coding Adventure: Compute Shaders

  Рет қаралды 778,527

Sebastian Lague

Sebastian Lague

5 жыл бұрын

In this coding adventure I learn about compute shaders by creating a very simple raytracer. I then try use what I've learned to speed up my erosion simulation from the previous episode.
If you're enjoying these videos and would like to support me in creating more, you can become a patron here:
/ sebastianlague
The project is available here:
(updated version) github.com/SebLague/Hydraulic...
(version at time of this video) github.com/SebLague/Hydraulic...
Raytracing article:
blog.three-eyed-games.com/2018...
Compute shader resources I used:
/ physics_simulation_on_...
kylehalladay.com/blog/tutorial...
docs.unity3d.com/Manual/class...
Music:
"Le Grand Chase"
Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0
creativecommons.org/licenses/b...

Пікірлер: 416
@SebastianLague
@SebastianLague 5 жыл бұрын
Hi everyone, hope you enjoy this new episode. If there are any topics that you think would be a good fit for future coding adventure episodes, I'd love to hear them! Also, if you'd like to support me in creating more videos, I have a patreon page here: www.patreon.com/SebastianLague?ty=h Either way, thanks for watching :)
@manjindersahota
@manjindersahota 5 жыл бұрын
Level of detail system for the procedural planets series.That will be great 👍
@davidmcky
@davidmcky 5 жыл бұрын
Oh! I saw this video on procedural mesh generation in 3D, so rather then doing a single plane of terrine you could do a 3D connect shape which can result in procedural trees, with custom dynamic trunks and leaves, custom rocks, and other plants, you could make the plant type change in values depending on biome, you could change texture type and randomly generate that, basically fully randomly generated plants in biomes, that'd be super sick!
@deathhound9400
@deathhound9400 5 жыл бұрын
HAH "bumpy ride" gadem
@allesster
@allesster 5 жыл бұрын
more compute shader
@ultimateskibum6813
@ultimateskibum6813 5 жыл бұрын
Hey man, I would really love to see a couple videos connecting some of your recent projects! If you could add this erosion technique with the procedural planets. Then maybe go more in-depth on erosion or maybe adding procedural rivers/lakes? Just throwing out some ideas. Love all your videos, keep up the great work!
@Flowtail
@Flowtail 4 жыл бұрын
That montage is the most accurate depiction of coding i’ve seen in my life
@fders938
@fders938 4 жыл бұрын
Never works first try.
@zyansheep
@zyansheep 4 жыл бұрын
@@fders938 Unless you are *really* lucky or *really* **really** skilled...
@GregoryTheGr8ster
@GregoryTheGr8ster 4 жыл бұрын
Yes, I totally agree! I was thinking that another good choice for music during this 100% accurate scene would be "Gonna Fly Now" from the Rocky movies. The tune really gets you excitied and fired up about exertion--only programming is mental exertion, not physical exertion.
@toploz_jr5597
@toploz_jr5597 4 жыл бұрын
@@zyansheep Not even skill will save you. My professor, which has 40+ years experience working in C the other day spent 30 minutes trying to fix a segmentation fault in a simple program. It's just our destiny as programmers
@TheGrandexeno
@TheGrandexeno 3 жыл бұрын
@@zyansheep "skill" in coding means you already tackled a problem in any way or shape. Else is "let's go read some docs about how to do this"
@nabeelansari355
@nabeelansari355 3 жыл бұрын
3:20 those flying prices of code even have a shadow, good job Sebastian
@abhishek.rathore
@abhishek.rathore 3 жыл бұрын
OMG, I didn't even noticied.
@WinterNox
@WinterNox Жыл бұрын
That's not a shadow projected in 3d, just a blurred black version of the og image.
@norude
@norude 11 ай бұрын
Price of code is really flying
@jay-tbl
@jay-tbl 4 жыл бұрын
"Oh ok, so with light bouncing, the spheres will take on the color of adjacent spheres a little more, thats neat" SPHERES BECOME BEAUTIFUL PERFECT MIRRORS
@otinaj
@otinaj 3 жыл бұрын
Its only beautiful and perfect because you see yourself in it ;)
@josephdavison4189
@josephdavison4189 3 жыл бұрын
@@otinaj no u dont
@user-dh8oi2mk4f
@user-dh8oi2mk4f 3 жыл бұрын
@@josephdavison4189 it’s a joke
@ujustinree2987
@ujustinree2987 3 жыл бұрын
@@user-dh8oi2mk4f it's a compliment actually
@pinkajou656
@pinkajou656 2 жыл бұрын
I KNOW RIGHT,,, I was expecting just a simple colour gradient sort of thing but NOPE SHINY MIRROR BALLS!!!!
@nielsbishere
@nielsbishere 5 жыл бұрын
Graphics programming student here; numthreads is the amount of threads that share data and are executed in one go. Every group is made out of numthreads and so dispatching less groups is generally faster (less stalls), unless these groups access shared data (or do group syncs). Having numthreads as 1,1,1 will destroy the whole idea of the gpu; paralization (as it just runs minimum number of threads and then masks out everything but one) since gpu cores are way less powerful by themselves then cpu cores. The threads that are dispatched should be a multiple of the GPU's architecture's minimum threads for optimal performance (32 for nvidia, 64 for amd) since less threads will be wasted. These "minimum threads" are also called a warp and all threads in a warp should follow the same branch (otherwise, branch divergence will cause both branches to be executed, but the branch that shouldn't execute the code will be masked out), this is done because the gpu draws its power from SIMD; a technique that allows you to operate the same operation on multiple objects. Their advertised threads are pretty much faked, as the threads they mention have to do the same thing for every warp; so not functioning like cpu threads. Nice to see something about compute shaders :) You can do infinite things with them; generate things procedurally, do lighting & ssao, culling and setting up draw calls, etc. EDIT: Do note that more threads in a group isn't always better in algorithms that have branch divergence, for/while loops, syncs and/or write to memory inconsistently (or use groupshared memory). There's a lot of things that can affect this, mostly the GPU architecture, so be sure to test performance with different group sizes.
@codycero1
@codycero1 5 жыл бұрын
Adding on to this discussion of maximizing performance with compute shaders. A thing that is really worth mentioning, is the nature of ComputeBuffers and the GetData() method. The GetData method, along with other kinds of GPU buffer reads, such as readPixels() for textures, are not asynchronous. They force a hard stall to the CPU thread, and it waits until the data you want from the GPU is ready. And along with that, even if that data is ready, it could be further stalled by anything else that puts the GPU in a busy state. So the time it could take is really not easy to judge. Like... I experimented with it before, and purposefully set up an automatically approximating delay between the dispatch call, and the data fetch, and that did a sort of decent job, but in the end, being just a little bit too early, or too late on the GetData fetch could cause a lag spike. So after looking into it for quite a while, I found this... github.com/digitalsanity/AsyncTextureReader I'll start with a note that I haven't properly tested it in the latest versions of Unity 2018, but it was working in 2017 for sure. Assuming it does work though, It's a very easy to use and modify plugin that allows you to signal that you want data from a GPU buffer immediately after Dispatch, and you can have a constant check for it's status in a loop, without any laggy synchronization issues. (Edit: Oh right, the name of the plugin is a little confusing, it says texture, but it does support ComputeBuffers as well). There is however, another potential solution directly supported in Unity 2018 brought up here forum.unity.com/threads/asynchronously-getting-data-from-the-gpu-directx-11-with-rendertexture-or-computebuffer.281346/page-3#post-3358878 Though I have not tried it out myself. Edit: It's in the documentation docs.unity3d.com/ScriptReference/Rendering.AsyncGPUReadback.html Jeez am I behind on Unity... Kinda stopped focusing on development stuff for like a year now.
@krytharn
@krytharn 5 жыл бұрын
I believe the warp size of NVIDIA is 32 and of AMD it's 64.
@nielsbishere
@nielsbishere 5 жыл бұрын
@@krytharn my bad, changed it
@littlenarwhal3914
@littlenarwhal3914 5 жыл бұрын
Hey, just wondering, you say you're a graphics programming student, do you only study this or other types of programming too. What schools would you recommend?
@nielsbishere
@nielsbishere 5 жыл бұрын
@@littlenarwhal3914 it's a study in Breda (BUas) but mainly focused on game programming (C++). There's a small percentage that ends up doing graphics, but you do get forced to at least do some basic C++ & opengl. Most things you'll end up teaching yourself, as the field is constantly changing and there's a lot of difference even between graphics programmers, so they end up steering you based on your projects and documentation
@HurriO4
@HurriO4 5 жыл бұрын
2:44 RTX: OFF 2:48 RTX: ON 2:55 RTX: ONER 2:59 RTX: EVEN MORE ON 3:03 RTX: THE ONEST
@chrisc7265
@chrisc7265 5 жыл бұрын
RTX RTX 360 RTX ONE RTX ONE X
@fiveoneecho
@fiveoneecho 5 жыл бұрын
RTX RTXS RTXR
@Evangeder
@Evangeder 5 жыл бұрын
RTX RTX 2 RTX 3 RTX 4 PRO
@peepeepoopoothepig6427
@peepeepoopoothepig6427 4 жыл бұрын
2.55 rtx oner 2.59 rtx boner
@ibra.h
@ibra.h 4 жыл бұрын
3:10 RTX R42069 TI
@threeeyedgames2858
@threeeyedgames2858 4 жыл бұрын
Glad you found the ray tracing tutorial useful, thanks for featuring it here :) David / Three Eyed Games
@SebastianLague
@SebastianLague 4 жыл бұрын
Thanks for making it!
@threeeyedgames2858
@threeeyedgames2858 4 жыл бұрын
That GPU erosion definitely looks like something we should put into Mercator by the way... kzbin.info/www/bejne/ZprUfoSgjteVic0
@-vanitas5229
@-vanitas5229 3 жыл бұрын
Your tutorial is really meaningful,when will the part 4 be released?
@threeeyedgames2858
@threeeyedgames2858 3 жыл бұрын
@@-vanitas5229 Currently working on a bunch of other things, so not soon. Sorry.
@-vanitas5229
@-vanitas5229 3 жыл бұрын
@@threeeyedgames2858 Alright,good luck! BTW your tutorial is poetic XD.
@Jejkobbb
@Jejkobbb 5 жыл бұрын
Love this channel, you don't feel pressure to follow along. You can just enjoy watching someone learn and write new code, which is always exciting
@TheShadesOfBlack
@TheShadesOfBlack 5 жыл бұрын
I have literally no idea what's going on but I'ma keep watching.
@thanatos1376
@thanatos1376 4 жыл бұрын
Lol, same
@hedonyable
@hedonyable 5 жыл бұрын
This is the greatest series of KZbin, hands down
@_egi_
@_egi_ 4 жыл бұрын
I subscribed just because of coding adventures
@Turtwiggyyy
@Turtwiggyyy 5 жыл бұрын
3:16 That was unexpected and absolutely hilarious :p
@axelman145
@axelman145 5 жыл бұрын
agreed, made my day
@knowledgedh7700
@knowledgedh7700 5 жыл бұрын
I got an ad
@AHSEN.
@AHSEN. 3 жыл бұрын
I agree
@SolubleParrot9776
@SolubleParrot9776 3 жыл бұрын
It looked like infinite black holes scary ⚫️ OMG THERES ONE COMING RUN!
@nick2718281828
@nick2718281828 3 жыл бұрын
I'm a former programmer who has changed careers to an unrelated field. I just wanted to say how much joy I get from your videos; they truly capture the spirit of why I loved programming.
@BrinkHouse
@BrinkHouse 5 жыл бұрын
Loved this kind of playful video, educational but also fun and entertaining. Please do more of these in the future!
@davidmcky
@davidmcky 5 жыл бұрын
Very impressed with your newer videos coming out Sebastian! Feels much high quality, more engaging and fun, open and honest about your skill level and how you learned it, well explained, entertaining, and still so knowledgeable, well well done, amazing job, keep up the good work man!
@upowlnight
@upowlnight 2 жыл бұрын
I feel lucky to have stumbled across your videos. Every one I've watched so far is showing me a different way of looking at things that I didnt think of. Calculating shadows backwards...wow. I love the style of these videos, and the things they are opening my mind to feels extremely important. Thank you!
@Clumpfy
@Clumpfy 3 жыл бұрын
3:17 I love his extremely realistic coding sequences! They get a realism-approval by me - a fellow coder :D
@LeRouxBel
@LeRouxBel 5 жыл бұрын
Yup, you still got it. I've been coming back to watch your videos on procedural gen, along with that marching square thing more than once. Impressive stuff you did there, lovely to finally have an understanding on how they compute the magic albedo number.
@Wabolas
@Wabolas 5 жыл бұрын
Thanks so much for making these Coding Adventure videos - they're great explanations of interesting problems and very inspirational to try them out yourself. Keep it up!
@eftorq
@eftorq 5 жыл бұрын
I don't code but this is so interesting! I found you through the Ray Marching video and it really blew my mind. I've worked so often with booleans Mandelbrot sets and Metaballs, but getting an insight in the fundamentals of how it would be solved in code is amazing. Keep the good work up!
@benkallsen7593
@benkallsen7593 4 жыл бұрын
I just watched some other videos in this series. I’m in love with it. Good Job!! Can’t wait to see more!!!
@BimzyDev
@BimzyDev 3 жыл бұрын
Thanks for this intro into compute shaders! They are definately something I want to learn more about.
@baseendje5763
@baseendje5763 Жыл бұрын
I just love how those spheres with hard shadows look halfway the video, gently bobbing up and down, esthetically pleasing.
@theignorantphilosopher4855
@theignorantphilosopher4855 5 жыл бұрын
This really is amazing. It's the kind of stuff I really like. My suggestions, just off the top of my head, add some sort of absorption rate, giving raise to river, lakes, etc. Following that, perhaps even consider the still water bodies that'll form, how they interact with the environment and are affect by something or rather.
@usnavyfish
@usnavyfish 5 жыл бұрын
Sebastian, thank you for your fantastic videos. Great balance of depth+breadth. I've been getting back into Unity lately now that they support asynchronous GPU feedback --- this allows you to fetch data from the GPU buffers without causing a pipeline stall. Not needed in your current use case, but if you ever need to fetch results from a compute shader after every frame, you'll want to do so asynchronously. Anyway, great timing on this series, and I really look forward to following your progress with Unity's Compute Shaders!
@jolteous
@jolteous 5 жыл бұрын
This was a really interesting video. Can't wait for the next coding adventure. Keep up the good work, Sebastian ;).
@NoahHornberger
@NoahHornberger 5 жыл бұрын
fantastic content. Thanks for breaking down each step and showing code snippets. I feel inspired to start something myself now
@compi3882
@compi3882 4 жыл бұрын
"Scooch closer" That's one hell of an action button if I've ever seen one
@LordBeef
@LordBeef 3 жыл бұрын
I just went back and looked at that 😂
@kaishang6406
@kaishang6406 2 жыл бұрын
this video is really good. So good that I started learning about compute shaders because of it. Thank you for your amazing work.
@bradhammond923
@bradhammond923 5 жыл бұрын
Just discovered your channel. Great vid, very informative and loads of cool stuff. Appreciate the hard work and sharing your knowledge
@HenriquePhilippi
@HenriquePhilippi 5 жыл бұрын
I can't believe that I've never seen your videos before And you have been doing this for... I don't know, 6 years? You surely deserve more attention, keep doing this great work
@alexanderhuliakov6012
@alexanderhuliakov6012 5 жыл бұрын
Oh, nice. Always glad to see shaders videos.
@kittybeamblob8383
@kittybeamblob8383 3 жыл бұрын
i watch your videos when i am drawing as I find them very relaxing and interesting (even tho idk whats going on half the time). please make more!
@cschott
@cschott 5 жыл бұрын
Great short introduction to compute shaders! I wish I had this when I have tried to learn how they work..
@seguaye
@seguaye 3 жыл бұрын
I love this mans voice so much, it’s very calming. I put on his videos to help me sleep sometimes, works a treat
@TheJonBrant
@TheJonBrant 5 жыл бұрын
Whoa. I'm just getting into unity, I had no idea it was capable of this. Very cool. Instant sub
@HunterHerbst
@HunterHerbst 4 жыл бұрын
I went and followed that paper on compute shaders you linked in the description. Jesus, respect goes out to you man. I am able to follow it and kind of understand what was going on, but I have no idea how I could take that information and use it to make a compute shader for something else like erosion. Time to do more reading and learning I guess!
@ihazpink6135
@ihazpink6135 5 жыл бұрын
These videos are very interesting, would love to see more of these.
@zionen01
@zionen01 3 жыл бұрын
This looks like fun, I think I'll try to follow along for this one. I remember doing ray-tracing in Nvidia CUDA long time ago for college, we've come a long way since then.
@likestomeasurestuff3554
@likestomeasurestuff3554 Жыл бұрын
thank you for the learning ressources; your project looks nice :)
@nilstrieb
@nilstrieb 3 жыл бұрын
I just wanted to say that your terrain looks EXTREMLY realistic!!!!
@codyedgington3897
@codyedgington3897 5 жыл бұрын
Loved the montage of fake typing. Hilarious, would love to see more of that. I enjoy this channel because it fits the code bullet niche but tackles more complicated topics. Can’t wait to see more simulations and other projects. Would it make sense for all the droplets to pool into lakes? Maybe store the final location of all droplets, then calculate lake volume that way?
@J4j4yd3r
@J4j4yd3r 5 жыл бұрын
Due to evaporation & ground absorbance, that might be too simplistic (and/or generate weird terrain, namely an excess of water). It's probably a good start however!
@simondm96
@simondm96 5 жыл бұрын
Maybe if you experiment with a kind of evaporation and/or absorption logic you'd get a nicer waterscape
@AutumnsEquinox826
@AutumnsEquinox826 5 жыл бұрын
wow this is excellent. i just started messing with shaders too so this is a great help. thanks!
@CheeseChuckie
@CheeseChuckie 5 жыл бұрын
You're a god-dam legend, man xD Respect from a fellow South African!
@Stonium
@Stonium 5 жыл бұрын
Oh? Didn't know he's Safrican... Now I feel even more inferior! lol
@LaurentK
@LaurentK 4 жыл бұрын
? his channel description says he's german..
@dxrpz1669
@dxrpz1669 4 жыл бұрын
@@Stonium bc hes not?
@Stonium
@Stonium 4 жыл бұрын
@@dxrpz1669 I don't know what to tell you.
@icantthinkofaname2722
@icantthinkofaname2722 4 жыл бұрын
His (slight) accent sounds German to me. It doesn't matter all that much ofc, but it would've really surprised me if he hadn't at least lived in Germany (or another German speaking country) at some point.
@mehmeteren2276
@mehmeteren2276 3 жыл бұрын
I'm glad I found this channel.
@Frankie.Frankie.
@Frankie.Frankie. 5 жыл бұрын
Keep this series going! It so good
@nzredwolf4048
@nzredwolf4048 2 жыл бұрын
This guy could solve world hunger with compute shaders
@peterstromback
@peterstromback 5 жыл бұрын
Excellent video, looking forward to the next.
@matzibeater
@matzibeater 5 жыл бұрын
When I saw the first video of your terrain gen last month, running it on a GPU was exactly my thought. Since I wanted to try and do something with CUDA, I did pretty much the same thing you're doing with compute shaders in Unity now. Except that I wrote a DLL in C++ for it and used CUDA there, which is just a bit closer to hardware level. Needless to say, going for shaders in C# is probably the better option though as long as you don't try to squeeze out every single bit of performance, as it isn't tied to the OS or an nVidia graphics card. Anyways, here are a couple things I'd like to mention: - For your heightmap generator you're currently starting map.Length many thread groups with just 1 thread each. It should be more like map.Length/1024 threadgroups with 1024 threads each, otherwhise all those threads will be run sequentially and there is no benefit from using a GPU. Keep in mind though that if map length is not divisible by 1024 you need to add an additional threadgroup. Also, you could launch it as a grid so you don't need to calculate x and y all the time (modulo on GPUs is expensive). You'll need to check if your position is still inside the map though, since your GPU will always launch a full threadgroup, even if not all of those threads are needed and would then write to unallocated memory. - Instead of using atomic min/max in every thread you could write yet another kernel for each of those, that implement it as an optimized reduce algorithm that you could launch after the initial computation, before clearing the mapBuffer from your GPU. Maybe there is even a library for that. In my case I just used cuBLAS. Reduce algorithms can be a real pain to optimize though, esp. if you're not familiar with how your GPU handles its threads in depth, and the noise gen isn't really the part that needs all the speed, so feel free to ignore that. - I really like the change you made for the erosion brush, having a list of weights for every map point was really set out to scale badly. I just put essentially the same loop you have for calculating weights into my kernel, instead of creating a list once and using that instead, which isn't really a good idea. I'm just recalculating the same stuff over and over again atm, with sqrts being rather expensive to use. Bad me :( - One thing I haven't tried myself yet and I don't know if its even possible using shaders in Unity: if you write the hight map to the GPUs texture memory it allows you to just read 'in between pixels', doing all the interpolation using hardware acceleration. At least nVidia cards actually have hardwired circuits for interpolation of textures. Pretty sick. Really, thank you for all the inspiration. I really learned a lot of new things from trying to make a CUDA version of this. Your videos are awesome! PS: I also learned that Unity likes to crash a lot if you're not careful with hooked DLLs, better avoid them if possible :p
@horchata4039
@horchata4039 4 жыл бұрын
super cool, super inspiring. Please keep these up!
@mariovelez578
@mariovelez578 3 жыл бұрын
I keep coming back to this video because I find it so interesting
@AlbySilly
@AlbySilly 5 жыл бұрын
I'd really love to see a close up of all the details of the finished result, and maybe even increase the size/detail of the mountain
@jmanindahizouse
@jmanindahizouse 4 жыл бұрын
really enjoyingthis series
@DerAua
@DerAua 5 жыл бұрын
Wow, the speed increase is incredible. I need to use this 😊
@djthomasx
@djthomasx 5 жыл бұрын
These videos are awesome! Please keep it up
@AndyJohansen
@AndyJohansen 4 жыл бұрын
Awesome video! A lot of good stuff here 😁
@bloodypommelstudios7144
@bloodypommelstudios7144 4 жыл бұрын
Really cool and awesome suggestions by other users. It would be so cool to see something like Age of Empires use similar techniques so terrain gradually changes over 1000s of years.
@josephbrandenburg4373
@josephbrandenburg4373 5 жыл бұрын
That erosion effect is so great. If I was a little more handy with code I'd try to port it to C, compile it into a .dll and make it accessible to Python (from there I'd make a Blender addon).
@QuesterDesura
@QuesterDesura 5 жыл бұрын
I really like the series, keep it up :)
@WangleLine
@WangleLine 5 жыл бұрын
Even more of this? I'm in love ❤w❤
@aim__freakz8499
@aim__freakz8499 3 жыл бұрын
You are actually my fav KZbinr! :)
@Thomason1005
@Thomason1005 4 жыл бұрын
nice one! entertaining and helpful. barebone implementation summarized in the video, more detailed links. awesome! this now makes my terrain generator go nnniiiooommmm
@iindii
@iindii 5 жыл бұрын
Thank you for these insights mate.
@nihilistpudding3573
@nihilistpudding3573 2 жыл бұрын
Watching this made me think how cool it would be to save the heightmap of the original landscape before erosion and make each droplet at its creation check if it is on a pixel that has been eroded a certain amount already. The deeper you go, the more dense the ground gets thus it should erode slower. Combining this with a random noise map of "dirt thickness" I think a much more realistic erosion could be simulated with basically no added calculations. Also, the formula (original height - current height) shows how much the ground eroded and -more importantly- based on the "dirt thickness" noise map, it gives you what color the pixel is. Without adding significant calculations to the program, you can color the ground easily, even with multiple ground layers and rock types corresponding to different ground density levels.
@droidBasher
@droidBasher 3 жыл бұрын
I did something similar to learn ruby. Not having easy access to a GPU from code I instead moved dirt in stages, a sort of progressive refinement. I started with a very low resolution map of the world, wore it down, then doubled the resolution and added some random detail. Each stage of the world had the same number of raindrops except the last but since the resolution was smaller the first raindrops were very wide (like glaciers or something). The last stage would get more raindrops. The elaboration I made was to track a global sea level. If a raindrop was below sea level its carrying capacity would be zero. This gave nice river deltas. I could tell that rivers and maybe ponds were happening, but I couldn't get a good way to detect where the rivers were.
@amgames5638
@amgames5638 3 жыл бұрын
I like how you named the button called scooch closer, and literally made it just for moving the camera forward lol
@jkrigelman
@jkrigelman 5 жыл бұрын
Very cool. Nice job dude.
@unknownuser5198
@unknownuser5198 5 жыл бұрын
Amazing! The terrain generated looks so cool! Keep up the great work man! Any chance in the future to see a tutorial about Fog of War? It's really shader heavy I believe and unfortunately I am terrible in writing shader's..
@shyamarama
@shyamarama 4 жыл бұрын
“Scooch closer” 🤣
@cheaterman49
@cheaterman49 5 жыл бұрын
Given a problem that can be solved both ways, I'm fairly sure it's more efficient to use compute shaders and solve it in hardware rather than on CPU time - if only because the inputs to the shader are managed on CPU, but also because you could run other problems that do NOT have a GPU-friendly solution on the CPU in the meantime. Excellent video, thanks :-)
@elliotc4268
@elliotc4268 2 жыл бұрын
sebastian lague is the god of optimizing code
@RetroPortalStudio
@RetroPortalStudio 3 жыл бұрын
Verg first video that i saw! And this is worth Subscribing !
@dusliangames
@dusliangames 5 жыл бұрын
I love your work!
@laoshan3332
@laoshan3332 4 жыл бұрын
Hi Sebastian, great video, as always! What's your Editors (i guess VS Code) color theme?
@iwokssama4772
@iwokssama4772 5 жыл бұрын
I love to watch your videos they are great I learn a lot about unity. thank you so much. 😻
@tarksahin9572
@tarksahin9572 4 жыл бұрын
I have no Idea what you are talking about. But I love it!
@henryso4
@henryso4 4 жыл бұрын
Compute shaders are pretty neat and gave me a good lesson in how GPUs schedule cores towards tasks being run and how to optimise towards that (i.e. scheduling a workgroup with the number of threads available in a "wavefront" for each dispatch). Made a pretty neat raymarcher with some basic shadows and reflections based on some work I'd done in shadertoy, and then because I'm lazy I do a very basic blit of the image I generate, right to the swapchain. It probably runs faster though cause I'm not calling the vertex/pixel shader unnecessarily to get the image up, and the GPU can bypass all the rasterization hardware I believe it's pretty necessary to optimize compute shader code such that your workgroups can all be executed at once (and without wasting any threads!!). For NVIDIA you're looking at executing 32 threads at once for a single workgroup - though I'd imagine doing 64 would not have too much of a drawback - even if two SIMD units have to be activated for that workgroup. For AMD, it's a bit more generous (for some) with 64 threads, so if you're doing quite a large dispatch with many independent threads then an 8x8x1 workgroup for instance runs quite nicely. Intel is a lot more restrictive though - without looking into Xe (which hopefully has some improvements), with your average integrated graphics you can only really dispatch 8 threads at once - but then again developing for intel is a waste of time.
@XoIoRouge
@XoIoRouge 4 жыл бұрын
3:16 was AMAZING
@joshuaisemperor
@joshuaisemperor 5 жыл бұрын
Love the editing
@fastsolution
@fastsolution 5 жыл бұрын
This guy should be awarded with the most educated teacher on KZbin
@happyfarang
@happyfarang 5 жыл бұрын
Very cool! Loving it :)
@manjindersahota
@manjindersahota 5 жыл бұрын
Nice Video Are you going to make an E08 of Procedural Planet ??
@canofair2147
@canofair2147 4 жыл бұрын
Your channel is great
@feildpaint
@feildpaint 5 жыл бұрын
Awesome video thanks again
@AlexTuduran
@AlexTuduran 4 жыл бұрын
Is there anything you are not able to accomplish? xD Great series btw!
@Skyefaux
@Skyefaux 4 жыл бұрын
more of this please
@-aaa-aaa
@-aaa-aaa 5 жыл бұрын
Could you actually do some videos on things like ray-tracing or shaders? I know you said you know hardly a thing about either but your very brief explanation of rays and ray tracing was great.
@sepgorut2492
@sepgorut2492 5 жыл бұрын
Utterly superb!
@zafranullah8328
@zafranullah8328 5 жыл бұрын
Sir I don't believe you are from planet Earth. Exquisite Stuff!
@pixelz3040
@pixelz3040 3 жыл бұрын
This is a really interesting video. I'd love to see your code for the ray tracing spheres. I've been trying to follow the same articles you posted and just can't manage. For example, how did you get that extremely blocky version of the spheres? I never got anything like that.
@akashverma4280
@akashverma4280 5 жыл бұрын
I want to be like you. I love the knowledge you share.
@monmonstartv5159
@monmonstartv5159 5 жыл бұрын
Wow this is very informative! Are you going to ever delve into voxel terrain at some point with the errosion script to make the terrain more realistic?
@SebastianLague
@SebastianLague 5 жыл бұрын
Thanks, yes I do plan to do that at some point!
@ignaciovargas6784
@ignaciovargas6784 5 жыл бұрын
nice video! Are you planning to post more videos about compute shading?
@Pockeywn
@Pockeywn 8 ай бұрын
youre like ahead of me on my quest I feel like your dream game/ project is similar to mine
@thatguynamedmorgoth8951
@thatguynamedmorgoth8951 4 жыл бұрын
A bit about how GPUs work (oversimplification) The GPU has a lot of cores and a main core. When you pass a kernel to the main core, the main core sends the kernel over to free cores. each core is called a group, in this example. The main core also passes the group's ID as (x,y,z) coords. Each core can then run the kernel on a few threads. Since different threads from the same group run on the same core, they can somewhat synchronize and communicate. The same is not true for threads from different groups, as different cores might not even be able to run at the same time.
@kaitsurugi3280
@kaitsurugi3280 4 жыл бұрын
Very interesting!
@khaosth30ry77
@khaosth30ry77 4 жыл бұрын
I really enjoyed this! +1 subscriber :)
@draggedtv6888
@draggedtv6888 4 жыл бұрын
it's guys like this that really make me wish i could afford to support them
@Visigoth_
@Visigoth_ 4 жыл бұрын
lol... I really
@timoteo_cruz
@timoteo_cruz 5 жыл бұрын
u are the best Sebastian
@WalksWithBooks
@WalksWithBooks 2 жыл бұрын
Great work! If you get a chance, try to put a hot air balloon in you scene that travels around with a player camera while the erosion iterates. I'm curious to know what the performance impact and/or considerations will turn out to be. However, I make no promise of following up on my own initiative so if I am too frustrating to ignore, feel free to DM me.
Coding Adventure: Hydraulic Erosion
5:19
Sebastian Lague
Рет қаралды 881 М.
Coding Adventure: Ray Tracing
37:58
Sebastian Lague
Рет қаралды 1,1 МЛН
Miracle Doctor Saves Blind Girl ❤️
00:59
Alan Chikin Chow
Рет қаралды 52 МЛН
MOM TURNED THE NOODLES PINK😱
00:31
JULI_PROETO
Рет қаралды 17 МЛН
Заметили?
00:11
Double Bubble
Рет қаралды 2,8 МЛН
I Need Your Help..
00:33
Stokes Twins
Рет қаралды 146 МЛН
Coding Adventure: Ant and Slime Simulations
17:54
Sebastian Lague
Рет қаралды 1,8 МЛН
Introduction to shaders: Learn the basics!
34:50
Barney Codes
Рет қаралды 275 М.
How do Major Video Games Render Grass?
9:33
SimonDev
Рет қаралды 359 М.
Coding Adventure: Procedural Moons and Planets
22:48
Sebastian Lague
Рет қаралды 1,7 МЛН
Giving Personality to Procedural Animations using Math
15:30
t3ssel8r
Рет қаралды 2,4 МЛН
GPU Compute Shader Work Groups
6:36
Arsiliath
Рет қаралды 5 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 907 М.
2D water magic
10:21
Steve Mould
Рет қаралды 558 М.
How Do Games Render So Much Grass?
15:52
Acerola
Рет қаралды 314 М.
What Are Shaders?
6:24
TheHappieCat
Рет қаралды 195 М.
Miracle Doctor Saves Blind Girl ❤️
00:59
Alan Chikin Chow
Рет қаралды 52 МЛН