Modern OpenGL Tutorial - Compute Shaders

  Рет қаралды 63,195

Victor Gordan

Victor Gordan

Күн бұрын

Пікірлер
@georgiyx9561
@georgiyx9561 2 жыл бұрын
Thank you so much, i've struggled getting my compute shaders to work and with the help of you, they now work :)
@VictorGordan
@VictorGordan 2 жыл бұрын
Good to hear! :)
@jakestein8516
@jakestein8516 2 жыл бұрын
Perfect timing. I was just starting to play around with compute shaders this week.
@VictorGordan
@VictorGordan 2 жыл бұрын
Hopefully you learnt some new stuff ;)
@codeblend5225
@codeblend5225 2 жыл бұрын
You are simply amazing. Even a person like me gets everything (when explained by you).
@codeblend5225
@codeblend5225 2 жыл бұрын
btw, I like using Visual Studio Code more. Is there any way to do OpenGL dev in Visual Studio Code.
@VictorGordan
@VictorGordan 2 жыл бұрын
Yeah, for sure. But I don't know how to link C++ libraries in VS Code, you'll have to look that up. But it is possible!
@mitchellkelly241
@mitchellkelly241 2 жыл бұрын
Every time I come back to the channel the production just keeps getting better and better! I have always wondered how to do animation within OpenGL. Would animation or something along those lines be possible as a tutorial in the future? Thank you for your hard work!
@VictorGordan
@VictorGordan 2 жыл бұрын
Yeah, I'll for sure do an animation series at one point, but right now it's not on my priority list :c
@rose95524
@rose95524 2 жыл бұрын
Thank you soo much for these compute shader videos!! They are absolutely amazing and by far the best resource I've found for making compute shaders :D
@VictorGordan
@VictorGordan 2 жыл бұрын
Awww, thank you! Also, cute profile pic :)
@kylevondra
@kylevondra 2 жыл бұрын
As usual, another banger video. Love to see it, keep up the great work!!
@VictorGordan
@VictorGordan 2 жыл бұрын
Thank you for your continuous support! :)
@krakacats7532
@krakacats7532 Жыл бұрын
i hit the 1k like, haha. Also very great video! I really couldnt find anything useful online for learning compute shader, but this really helped me understand it. Thanks
@jawadch8723
@jawadch8723 2 жыл бұрын
Amazing video! Covered everything I needed!
@VictorGordan
@VictorGordan 2 жыл бұрын
Glad to hear that! If u made smth cool feel free to share it on my Discord server, I like to see what u guys make using my tuts :)
@jawadch8723
@jawadch8723 2 жыл бұрын
@@VictorGordan Sure!
@jeffcummings3842
@jeffcummings3842 2 жыл бұрын
Great explanation, thanks! I decided that maybe I was ready for compute shaders, but now I know that's still a bit of a ways away, but within reach, and this helps with understanding when I may actually need them, however experimentation is warranted! Thanks again.
@VictorGordan
@VictorGordan 2 жыл бұрын
You're welcome! Ray-marching or ray-tracing could be a good start for compute shaders ;) Alternatively, for a non-render use, check out my "planes" video from the procedural generation series. I make use of compute shaders there to vastly improve the generation of planes with high triangle counts!
@jeffcummings3842
@jeffcummings3842 2 жыл бұрын
@@VictorGordan nice, i'll have to check that out!
@Trandunz
@Trandunz 2 жыл бұрын
Love your work Victor, i can still hear your voice when im doing my opengl :)
@clemdemort9613
@clemdemort9613 2 жыл бұрын
Very nice of you to put a like counter in the description of your video! :)
@VictorGordan
@VictorGordan 2 жыл бұрын
Someone has to do it since KZbin gave up on it haha
@SirCobraXI
@SirCobraXI 9 ай бұрын
7:55 Hey, so this caused quite a bit confusion to me. So i did some research and it seems barrier() has implicit shared memory synchronization, so the other call is not needed. However, this seems to not apply for other types of memory, for which you may still need an extra sync call. Also sadly it is not possible to sync a global memory between all thread groups because they are not always executed at the same time.
@chris_burrows
@chris_burrows 2 жыл бұрын
Epic. Thank you Victor.
@VictorGordan
@VictorGordan 2 жыл бұрын
You're welcome :)
@TheRoy714
@TheRoy714 2 жыл бұрын
Awesome tutorial
@VictorGordan
@VictorGordan 2 жыл бұрын
Thank you! :)
@hamimmahmud5777
@hamimmahmud5777 2 жыл бұрын
Keep up the good work
@VictorGordan
@VictorGordan 2 жыл бұрын
Thx :,)
@hamimmahmud5777
@hamimmahmud5777 2 жыл бұрын
Welcome
@darkarchon89
@darkarchon89 2 жыл бұрын
Great video. This clarified a lot of things that mystified me the past couple of days. Question about 5:08 where you normalize the range from [0,1] to [-1,1]. Is this to match OpenGL clip space, or is there another purpose?
@VictorGordan
@VictorGordan 2 жыл бұрын
Good to hear :) And yes, it is because of OpenGL's clip space!
@dmitrykolesnikovich
@dmitrykolesnikovich 2 жыл бұрын
good visuals i am enjoying it
@VictorGordan
@VictorGordan 2 жыл бұрын
Thanks!
@alwinjjoseph888
@alwinjjoseph888 2 жыл бұрын
Thanks for the content.
@VictorGordan
@VictorGordan 2 жыл бұрын
You are welcome! :)
@kalebbruwer
@kalebbruwer 2 жыл бұрын
Thanks. I was missing one line: glUseProgram() and a small eternity later I figured that out thanks to this video
@VictorGordan
@VictorGordan 2 жыл бұрын
U're welcome :)
@bithigh8301
@bithigh8301 2 жыл бұрын
I've just subscribe!! Awesome video! btw, which video editor do you use? thanks for sharing
@VictorGordan
@VictorGordan 2 жыл бұрын
Thx for the sub! :) I'm using Adobe Premiere for editing and Adobe After Effects for animating
@myth0genesis
@myth0genesis Жыл бұрын
Will there be a step-by-step video about how to make one of these from scratch in, say, VS 2022 and C++ (in keeping with your earlier shader programming series)?
@VictorGordan
@VictorGordan Жыл бұрын
It should be pretty much the same thing, no? Or did VS 2022 change that many things?
@myth0genesis
@myth0genesis Жыл бұрын
@@VictorGordan No, VS 2022 didn't really change much as far as I can tell. I meant will you have a tutorial to make a compute shader from the beginning in general? VS 2022 and C++ were just used as examples for illustrative purposes. I don't really know where any of the code goes (I always use IDEs like shadertoy and SHADERed or Unreal Engine to do shader programming, so I've largely been able to get away with not having to hook it into a C++ program from scratch).
@VictorGordan
@VictorGordan Жыл бұрын
Ah, I already have tutorials for that. My OpenGL tutorials go through that process ;) specifically the first 3/4 tutorials!
@myth0genesis
@myth0genesis Жыл бұрын
@@VictorGordan Okay. Thanks for that. Sorry for the seemingly needless question, then. I'm already working alongside the tutorials as I suspected this might have been the case. Everything up to episode 3 is working out (even with VS 2022 and Glad for OpenGL 4.6 instead of 3.3, with the appropriate changes to the major and minor version numbers in the code, of course). Great job making things clear and easy to understand! I'm hoping to be able to remake some popular statistical tests for 128-bit hash functions so they can run on GPUs (to test some of my own out). It seems like all existing batteries of tests I came across are CPU-bound and would take forever to test a good sample size (in the 128-bit cases), so I'm hoping to leverage the parallelism of the GPU compute pipeline to speed things up a bit (or at least it'd be fun to try).
@VictorGordan
@VictorGordan Жыл бұрын
Don't worry about the question haha Good luck with the GPU porting ;)
@dimitrisspiridonidis3284
@dimitrisspiridonidis3284 2 жыл бұрын
very good job 👍
@VictorGordan
@VictorGordan 2 жыл бұрын
Thank you! :d
@codeblend5225
@codeblend5225 2 жыл бұрын
Thanks! I will.
@floriansteinmann7270
@floriansteinmann7270 2 жыл бұрын
Hey can you please show us how to make a galaxy shader Should worl similar to endportal shader in minecraft if possiblr
@0xbinarylol
@0xbinarylol Жыл бұрын
How to provide input as nxn matrix and n size vector and multiply then output
@VictorGordan
@VictorGordan Жыл бұрын
For matrices up to 4x4 you should be able to just use uniforms. For matrices over that size I think you'll have to send the matrix as an array and then make some custom functions that interpret the array as an matrix. But who knows, there might be an easier way out there, not sure :(
@arkadiymel5987
@arkadiymel5987 2 жыл бұрын
5:04 it seems that gl_LocalInvocationID should actually be gl_GlobalInvocationID.
@VictorGordan
@VictorGordan 2 жыл бұрын
Yup, I think you're correct... oops :/
@blaarkies
@blaarkies 2 жыл бұрын
A good example where this is extremely useful is if you have to do n-body gravity simulations, that is, calculate a value between every object and every other object in the game world, and in the end add up all the values for each object (to find the force applied to each object by gravity). Where normal CPUs can handle a few 100 objects before losing framerate, i bet compute shaders can handle thousands of these
@VictorGordan
@VictorGordan 2 жыл бұрын
Yeah, 100%. If written smartly I bet it can go up to tens of thousands or more (just a guess tho)
@gergelybertalan5181
@gergelybertalan5181 2 жыл бұрын
@Victor this is awesome! Where do you learn these things from?
@VictorGordan
@VictorGordan 2 жыл бұрын
Tutorials hidden throughout the internet, stackoverflow, and very imporant, the official documentation ;)
@floriansteinmann7270
@floriansteinmann7270 2 жыл бұрын
Could you please do a tutorial on how to make a grass shader which doesnt only repeat the texture but brings in variation with multiple textures I think the key is noise maps
@VictorGordan
@VictorGordan 2 жыл бұрын
Yeah, I'll make a tutorial on that at some point! It will be part of my procedural generation series which will actually get it's second episode in a week or so ;)
@floriansteinmann7270
@floriansteinmann7270 2 жыл бұрын
@@VictorGordan thats cool ty
@TristanPopken
@TristanPopken 2 жыл бұрын
Hey, thank you for the great tutorial. I finnaly got to make a working compute shader. One question though, it seems like the more invocations and the less work groups, the better the performace is. For example, i get the best performance with x=32 y=32. Why exactly is that?
@VictorGordan
@VictorGordan 2 жыл бұрын
Good to hear that, I'm glad u found it helpful! Tbh I don't fully understand it myself, but as far as I know it will depend from project to project. So even though 32x32 might seem to give the best performance in this case, it might not in other cases. Basically work groups aren't rly done in parallel at the exact same time, but invocations sort of are, so that's a very rough idea as to why more invocations result in better performance. But it will likely differ as I said. Plus that sometimes you simply want certain sizes for the invocations to deal with non-visual stuff, so more invocations does not mean better performance ;)
@alexandru-cristiansandu1016
@alexandru-cristiansandu1016 2 жыл бұрын
Interesting tutorial for some of the more modern capabilities of OpenGL, you definitely become better at making such videos!
@VictorGordan
@VictorGordan 2 жыл бұрын
Mersi! :)
@featherless656
@featherless656 2 жыл бұрын
@VictorGordan , I'm stuck on the 5th tutorial, the only way I could get you to see is to comment on your latest video, whenever I run the program the triangle is white, could you help me with this?(The shader files and code is perfect)
@VictorGordan
@VictorGordan 2 жыл бұрын
I've seen your comment before, but I wasn't sure what to answer. The most common problem when this happens, is a typo. Lots of people have told me they followed perfectly, but 90% of the time they do find a typo. Another problem might be that you said you changed some directories. Since the triangle is displayed in the first place, it's likely a problem with the fragment shader. Or it might have to do with the vertex attributes. Not sure what else it could be :(
@featherless656
@featherless656 2 жыл бұрын
@@VictorGordan It might be my driver for my graphics card, not sure.
@VictorGordan
@VictorGordan 2 жыл бұрын
I also thought of that, but then I think the vertex shader would also not work...
@featherless656
@featherless656 2 жыл бұрын
@@VictorGordan another thing I thought of was the #330 core, I thought that maybe because I had gotten glfw 3.3.6 it wasn’t working
@VictorGordan
@VictorGordan 2 жыл бұрын
It shouldn't matter
@nickgennady
@nickgennady 2 жыл бұрын
So how does OpenGL compare to Vulkin? Also OpenGL does not run on Apple products right? Must be annoying to a certain extent.
@VictorGordan
@VictorGordan 2 жыл бұрын
I think anything up to OpenGL 4.1 runs on Mac, but not the newer versions. But if u're going to make games for example, u wouldn't rly care about Mac since almost nobody games on a Mac. As for how it compares to Vulkan? Vulkan is a lot more syntax heavy. U have to write a lot more boilerplate code and take care of a lot more GPU details to render stuff. OpenGL is simpler in that regards, but because you have less control over the miniscule parts of your GPU it can also be less performant in some situations. If you are a beginner, 100% go for OpenGL. It will teach you all the basics and make it much easier to transition to Vulkan. Keep in mind tho that in terms of graphics, both can look "better" than the other. It really depends on the code you write. OpenGL just dosen't have some of the bleeding edge stuff like RTX support and other things. U're unlikely to use those as a noob.
@KangJangkrik
@KangJangkrik 2 жыл бұрын
Will it support ARM devices like raspberry pi and cheap SoC like Allwinner h6?
@VictorGordan
@VictorGordan 2 жыл бұрын
I don't think so since they don't have a GPU as far as I know, and I doubt the CPU supports OpenGL 4 or higher :(
@KangJangkrik
@KangJangkrik 2 жыл бұрын
@@VictorGordan raspberry pi 4 has two GPUs actually, VC6 and V3D. Currently supports Vulkan but experimental. I don't know about latest supported OpenGL version, too much mixed information.
@spookyghostking608
@spookyghostking608 2 жыл бұрын
God bless!
@VictorGordan
@VictorGordan 2 жыл бұрын
Amen!
@shinystick241
@shinystick241 2 жыл бұрын
When 3d physics?
@VictorGordan
@VictorGordan 2 жыл бұрын
I don't know tbh. It's not a priority right now, but it will come for sure!
@webgpu
@webgpu Жыл бұрын
GUYS. IF YOU WANT TO BE UP TO DATE ON COMPUTE SHADERS: INVEST YOUR TIME LEARNING WGSL (WebGPU's Compute Shader). one of the advantages is that the text (ascii file) with the shader code can be run instantly (with an html helper) in anyone's browser without needing any compiler. -- if you were wondering, the "native" code you're writing now (c++ + opengl) can be already ported "in full" to typescript + webgpu (ie, a web app
@mccrackhead1832
@mccrackhead1832 6 ай бұрын
I don't like you
@Jkauppa
@Jkauppa 2 жыл бұрын
why webgl 1.0 has to be so stupid formatted
@Jkauppa
@Jkauppa 2 жыл бұрын
languages are not made to get things done, they are only for a show
@Jkauppa
@Jkauppa 2 жыл бұрын
pride kills languages and anything good
@arlynwalker9901
@arlynwalker9901 2 жыл бұрын
s/o to you from china bro, working absolutely well
@VictorGordan
@VictorGordan 2 жыл бұрын
Greetings from the Netherlands! :)
WebGPU :: Compute Shaders Crash Course For Beginners
20:00
Visionary 3D
Рет қаралды 10 М.
How To Write Fast Shaders
10:33
Jump Trajectory
Рет қаралды 21 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Solve this to get the #Job. You have 3 seconds
5:48
MindYourDecisions
Рет қаралды 8 М.
An introduction to Raymarching
34:03
kishimisu
Рет қаралды 159 М.
Introduction to shaders: Learn the basics!
34:50
Barney Codes
Рет қаралды 372 М.
Modern OpenGL Tutorial - Tessellation Shaders
7:59
Victor Gordan
Рет қаралды 20 М.
Introduction to Vulkan Compute Shaders
21:39
İlker
Рет қаралды 12 М.
Recreating Noita's Sand Simulation in C and OpenGL | Game Engineering
10:03
Coding Adventure: Rendering Text
1:10:54
Sebastian Lague
Рет қаралды 783 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 1 МЛН
Overview of GLSL, the OpenGL Shading Language
13:56
Shadron
Рет қаралды 106 М.
How Shaders Work (in OpenGL) | How to Code Minecraft Ep. 3
30:48
GamesWithGabe
Рет қаралды 115 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН