It's very important to note that in modern versions of OpenGL (3.3+) qualifiers "attribute" and "varying" are deprecated and replaced with "in" and "out". And instead of gl_FragColor we are encouraged to use user-defined "out" variables. The logic of writing shaders is still the same, but none of this code will work in modern versions if allowance for the differences is not made.
@BarneyCodes Жыл бұрын
Good call! I think WEBGL is a little behind, but I think that's about to change with WebGPU and WEBGL 2. Thanks for the comment!!
@nepp957411 ай бұрын
I was about to write exactly this. This is indeed pre glsl 1.3 syntax so very old. 1.3 and later uses above syntax and is incorporated into WebGL2 since 2017. This is coupled with OpenGL ES 3.0 which might be worth noting. For anyone interested in these facts, the above video of course still applies ❤
@BarneyCodes11 ай бұрын
I didn't realise how long WebGL2 has been out! I think P5js only started supporting it recently. I've used the newer syntax in other projects, but everything web related I've been using the old syntax. Might be time to change that! Thanks for the comment!
@StarFury211 ай бұрын
I guess what I noted is quite obvious to an experienced user, but me being a noob with OpenGL, it was strange why compiler throws so many cryptic errors in my python+pyglet environment. I saw that built-in classes use default shaders with "in" and "out" qualifiers. Asked ChatGPT and it was like "Dude, you're using an ancient syntax!"😅 Of course, all the love for the author, video is still relevant and definitely a must watch for anyone starting to mess with shaders!❤ @@BarneyCodes
@ecruz231710 ай бұрын
if anyone wants traction for their channels, coding for marmoset will get you some traction, just a heads up, i only need to code 1 shader for myself and that is the "engine", i am using to get the results i want, it combines hlsl and glsl.
@maxenceveilleux7 ай бұрын
Only 3 minutes into the video and you answered so many of my questions. Thanks a ton already!
@BarneyCodes7 ай бұрын
Glad you've already found it useful!
@tirins Жыл бұрын
Does anybody else feel like going for a second helping of this... only a little bit later 😅 The info is dense! Awesome, man!
@BarneyCodes Жыл бұрын
Hahaha yea sorry about that! There's just so much that I wanted to include in the video! I think shaders are just one of those things that take a few goes to sink in. Thanks for the comment!
@rmt3589 Жыл бұрын
Me!
@Seb00lean Жыл бұрын
I go back every week. Such a great starting place. Will there be a part 2 to this? Do you have ideas of what you’d want to include in it?
@BarneyCodes Жыл бұрын
@@Seb00leanGlad to hear you're finding it helpful! I'm thinking I'll do smaller videos that focus on one topic at a time instead of another video like this one. That'll hopefully mean they're more frequent but will also let me go into a little more depth each time. A few weeks ago I put out a video on how to use a noise texture in a shader if you want to check that out! I've got a few ideas such as using normal maps and creating very basic lighting, using vertex shaders to manipulate objects and a few others. Is there anything you would like to see cover?
@OctagonalSquare11 ай бұрын
I haven’t even gotten past the ads and yet know I’ll have to come back haha
@DetectiveConan990v314 күн бұрын
watching this to hopefully understand how this stuff works for my graphics class
@BarneyCodes14 күн бұрын
Hope it's helpful! Let me know if you've got any questions :)
@rrutter813 ай бұрын
perfect no-nonsense introduction to shaders. The pacing was perfect from start to finish. well done.
@BarneyCodes3 ай бұрын
Thanks, glad you liked it!
@nepp957411 ай бұрын
This is better than the official learn OpenGL tutorial (mix of c++ and glsl)❤Nice one! Exactly what I needed on my Vulkan adventures 😃
@BarneyCodes11 ай бұрын
Wow, thank you so much! Hope your adventures go well!
@RhogerAnacleto10 ай бұрын
For the first time in my life, I understood what that Shader code was all about. Thank you for the quick explanation. I'll definitely need more couple of years to be able to write my first shader script to create a simple black circle on screen because is too hard, but this video is definitely one of the best to see about the topic.
@BarneyCodes10 ай бұрын
Thank you so much! You've got this, it took a couple of tries before it started to sink in for me as well, I think that's very normal because it's definitely a different sort of programming from what most of us are exposed to, but I promise it does get easier! If you have any questions or need help, please feel free to reach out!
@bc3f4a8 күн бұрын
Same.
@bynightcore4868 Жыл бұрын
Hi, normally I really don't comment on KZbin videos. But man, this introduction was EXACTLY what I needed to get started with my university project. Thanks a lot man, keep up the good work :)
@BarneyCodes Жыл бұрын
Thanks so much, glad it was helpful and I hope your project goes well!
@emmettdja10 ай бұрын
it helps that p5js just recently made it much easier to use shaders with their library!
@MichaelBurchard-l1z11 ай бұрын
This is better than the official learn OpenGL tutorial (mix of c++ and glsl)Nice one! Exactly what I needed on my Vulkan adventures
@bigfin206 күн бұрын
it's insane just how much stuff inigo has done for shader community. You can't read about them for five minutes without running into a reference to him
@BarneyCodes5 күн бұрын
He's truly a gem, so grateful that he's shared so much of his knowledge with us!
@WarriorAlexOG7 ай бұрын
This was just the video I needed to get started with shaders. I knew very little about them or what they even did or were capable of, but this video really showed me, on a beginner level, just how indepth this really goes. Thank you so much for all the effort you put into this video. You explained so much indepth, while also making it simplistic, while not watering anything down. The care and passion you put into making this really shows.
@BarneyCodes7 ай бұрын
Thank you so much! I'm so glad you found it helpful, shaders can be an amazing tool so getting more people creating and playing around with them is exactly what my goal was! All the best on your shader journey ahead!
@thisguy.-.4 ай бұрын
I'm going through a similar experience drawing primitives in MonoGame, and I'll say it really is handy to have this context because the documentation and tutorials for this stuff are really obscure! Thanks @BarneyCodes for the tutorial, seriously
@jokosalsa6 ай бұрын
this is bar none the BEST video explaining shaders I have watched in YT. Very very very well done!
@BarneyCodes6 ай бұрын
Thank you so much! Glad you found it helpful!
@nouveu111 ай бұрын
I'm not really working in game dev but watched your video out of curiosity and it was a pleasure and nice relax for me. You have a great talent to explain things :)
@BarneyCodes11 ай бұрын
Thanks so much!
@mis4vr877 Жыл бұрын
I absolutely adore this video and your presentation. Shaders seemed like black magic before this but you really helped me understand
@BarneyCodes Жыл бұрын
Thanks so much for the kind words! I'm really glad to hear this video helped!
@facr11 ай бұрын
Love the pace and the insight that gave us on shaders! Great!!!
@BarneyCodes11 ай бұрын
Thanks so much, glad you enjoyed it!
@tristanjohn Жыл бұрын
Thanks loads for this! The comprehensive approach filled in literally all the gaps in my understanding of shaders.
@BarneyCodes Жыл бұрын
No problem, glad you found it so useful!
@DeniseNepraunig Жыл бұрын
Thank you so much for putting this video together! Fantastic explanation of the SDF and I also liked the part about the logic a lot! You touched so many topics with such a great presentation, really amazing man!!
@BarneyCodes Жыл бұрын
Thanks so much, I'm glad you found it useful!
@speckdratz Жыл бұрын
Rating: 12/10 on all levels. This is YT-hall-of-fame material 🏆
@BarneyCodes11 ай бұрын
Hahaha wow, thanks so much!
@boiimcfacto236411 ай бұрын
This is absolute fucking gold. I love you man. Crisp, clear and straight to the point. Your humour was never intrusive like with other tutorials and you even gave links for every checkpoint in the video. God bless you man, this was a fantastic video and I wish I could like it 10 times lol ♥
@BarneyCodes11 ай бұрын
Thank you so much, that's so encouraging to hear and I'm glad you found it useful!
@AD-Dom8 ай бұрын
Um, thank you. Wow. This is exactly the type of rundown I've been seeking.
@BarneyCodes8 ай бұрын
No worries, glad it was helpful!
@MiguelRodriguez-gs3piАй бұрын
this video is pure gold. Thank you so much
@BarneyCodesАй бұрын
No worries at all, glad you found it useful!
@StevesMakerspace10 ай бұрын
Great job, Barney! Congrats on this video and your channel taking off! Well deserved.
@BarneyCodes10 ай бұрын
Thank you so much Steve, I really appreciate all the support you've shown me! I still can't really believe how well this video has done!
@discotecc11 ай бұрын
Getting into graphics programming as a hobby thanks for the video, You're a great explainer. I wish I had gotten into this sooner instead of web development theres a lot of neat stuff to understand
@samdavepollard2 ай бұрын
Only half way through but this is gold. I've dabbled a little with real basic shaders in opengl using c++ but all that VAO, VBO stuff gets pretty old very quickly. I've also dabbled in p5.js a fair bit but never used shaders (didn't even know until recently that shaders in p5.js were possible). Pretty excited to see what I can create with p5.js shaders. Many thanks for getting me started, much appreciated.
@BarneyCodes2 ай бұрын
Haha yea setting all that up can be a bit of a chore, P5 is great for just messing about and getting something on the screen quickly! Have fun!
@Seb00lean Жыл бұрын
Fantastic introduction to shader programming! Thank you for this :)❤ I kept wanting to know more about everything you talked about, it really could have been an even more thorough introduction. Looking forward to a potential series or just more on this wondrous field of programming.
@BarneyCodes Жыл бұрын
Thanks so much! It was pretty hard to decide what to keep in and what to leave out and it still ended up being a long video! I do plan on doing more videos with shaders in the future, is there any topic in particular you'd like to see in more depth?
@geelemo7 ай бұрын
@@BarneyCodes shaders in wgsl!
@xKond3i5 ай бұрын
Really well structured video and easly explained subject. Keep up the good work! 😉
@BarneyCodes5 ай бұрын
Thanks so much!
@Lycanthronaut2 ай бұрын
As a software engineer that uses the standard python and java / C# dabbles, this is like a wizard learning a different school of magic lol, so interesting
@hmmm14826 ай бұрын
the best shader tutorial ive watched so far!!!! THANK YOU!!!!!!!!!
@BarneyCodes6 ай бұрын
No worries, glad you found it helpful!
@smooshymemes8 ай бұрын
Better than my public education 11/10
@TarousDT11 ай бұрын
Small clarification, HLSL is the language used by DirectX, meaning it is windows only. Where as GLSL is multiplatform.
@BarneyCodes11 ай бұрын
Thanks for clarifying!
@johnschmitt91586 ай бұрын
I love this. Lots of information and no wasted time. Very well done.
@BarneyCodes6 ай бұрын
Thanks so much, glad you found it useful!
@ttaylor7604 Жыл бұрын
I really needed a video like this about 2 years ago, when I studied this at university
@BarneyCodes Жыл бұрын
Better late than never I guess?
@Shamysoza9211 ай бұрын
This is amazing! I am going through SimonDevs course but there is alot of clutter with threejs to make stuff happen, but using p5js is way simpler and really makes the javascript code as a secondary element and really focus on the glsl side of things. I hope this series keeps going.
@BarneyCodes11 ай бұрын
I love Simon's videos, they're really great! But yea I think P5js is pretty much as straightforward as it gets for setting up shaders which is why I use it so much! There are some limitations with it though, like the ModelView matrix being combined in the vertex shader so that you can't do world space calculations. What topics would you like to see in the next video?
@Phenylalanin197910 ай бұрын
Brilliant video, really a great way to visually teach complex topics. Very informative and I can appreciate how much work this video must have taken all in all. Also the two Edges was a nice touch :).
@BarneyCodes10 ай бұрын
Thanks so much, I'm glad you enjoyed it! And I think you're just the second person to comment on the Edge joke, good to know there are a few cultured people out there hahaha
@Phenylalanin197910 ай бұрын
@@BarneyCodes Wait a minute ... is cultured code for old?
@chfr8 ай бұрын
Neat video! I went through the (current state of the) book of Shaders. I later saw people being critical on it in forums, saying it has some limitations, and your video helped me see one of it. The book of Shaders tackles pretty much only the contents of the .frag files, but thanks to the "circles array" example you made, I realize the importance of the "CPU" side of things, and passing custom variables.
@BarneyCodes8 ай бұрын
Glad you found it useful! I had similar frustrations with a lot of shader tutorials, so happy to hear that my one has helped in that regard
@jarrettonions3392 Жыл бұрын
Todays the day bro!! :D been so long coming... finally got some bloom and reflective water up and running in unity... wow
@BarneyCodes Жыл бұрын
That's great, nice work!
@MarekFajkus Жыл бұрын
The only bad thing about this video is that it didn’t exist yet back when I was learning this the first time. From now on this will be the introduction I recommend. 👏👏👏
@BarneyCodes Жыл бұрын
Wow! Thanks so much for that, very encouraging to hear!
@theshoulderofgiants Жыл бұрын
thank you ❤amazing work.... i hope you make this is a series..i would love to learn about vertex shaders..looking forward to ur next video 😁
@BarneyCodes Жыл бұрын
Thanks! There will definitely be more shader videos! I'll have to think of something cool to do with the vertex shader!
@wazawoo10 ай бұрын
You are amazing at explaining and visualizing things
@BarneyCodes10 ай бұрын
Thank you, that's very kind!
@atibyte11 ай бұрын
Nice intro to shaders, thank you!
@BarneyCodes11 ай бұрын
Thanks, glad you liked it!
@FurryWrecker91111 ай бұрын
Im a 3d artist who has been wanting to get into technical art seeing that it's tight competition to get a job doing 3D stuff, but everyone and their mother needs like 5-10 tech artists. This is my gateway into securing my future. Did 3D stuff or 7 years under my last employer, but it's still tight as ever to get in anywhere else.
@BarneyCodes11 ай бұрын
Best of luck! Hopefully this can get you started on your shader journey!
@simonnesvadba97578 ай бұрын
This gives my brain a nosebleed, but in a good way like in anime ❤
@moodragonx24 ай бұрын
Very very cool video. I really appreciate the detailed explanations.
@BarneyCodes4 ай бұрын
Glad it was helpful!
@accumulator482511 ай бұрын
You're very good at explaining. Thank you for this video!
@BarneyCodes11 ай бұрын
Thank you and no worries!
@SeasonalMike Жыл бұрын
Wow, I can't wait to learn how to draw a cube!
@marsovac11 ай бұрын
Nice video. Just one nitpick. The grayscale is incorrect, since human eyes don't treat colors equally. It depends on the use case and the color space but the general simple formula is: 0.2126 R + 0.7152 G + 0.0722 B. There are ones with square root and squaring of colors that aproximate it better, but are much more expensive in terms of performance.
@BarneyCodes11 ай бұрын
Huh, that's really interesting! Thanks for the info!
@revenevan113 ай бұрын
This video is the best one I've found so far. The pro tip around <a href="#" class="seekto" data-time="1920">32:00</a> makes a ton of sense but I hadn't thought of it yet, glad you caught me writing my if statements lol. For context I've been working on my very first shader today! Coincidentally also in P5js like your examples. I came here because of confusing syntax errors I've been getting and although I'll have to troubleshoot those some more (or maybe explicitly define the webGL version the syntax I've learned is correct for? 😅) I think this is helpful. The project I'm writing a shader for is rendering the mandelbrot set, moving the load to the GPU as an upgrade to my current p5 sketch for it. The current version I already built has scrolling to zoom in and mouse-drag panning support, as well as using arrowkeys to change the canvas resolution on the fly... but especially at higher resolutions it's taking minutes to render, so it's far from responsive lmao. I failed to make the rendering function render asyncronously to a graphics object *and* have p5 move or zoom in on the last rendered frame while the next one loaded though, I guess because it's not waiting for 1 long operation or fetch and only for a bunch of small calculations, so doesn't ever hand control back while awaiting, so p5 just shows the preview change for a split second after the next image finally renders and then immediately slaps the new one it's been waiting for over it lol. So I'm skipping that idea since I don't feel like learning web workers for it and instead going straight to shaders for the real performance gains! Before watching this video I'd already ported over (from JS to GLSL) my functions for complex number multiplication, mandelbrot iteration, checking if points are inside the set (need to change to using step function now 😆😅), and for coloring points based on the number of iterations each complex number takes to escape... I was trying to pass some uniforms into it for things like the number of iterations and user input for zooming, but I haven't gotten it to load once without getting syntax errors 😒. I mean I also haven't finished some of the basic features like properly mapping between the fragcoords to mandelbrot space *while* taking the zoom input into account, but I made a map function for it that I was about to test when I got weird syntax errors while trying to load my shader for the first time. Previously in the non-shader cpu version I was mapping from pixelcoords to the complex plane (within a range depending on the zooming and panning) so it'll be a bit different and I'll need to make sure I don't stretch the image by the aspect ratio again like I initially did in the cpu bound pixel version, but it's a work in progress and the whole point of this project was for fun and learning!!! 😁
@BarneyCodes3 ай бұрын
Rendering fractals with shaders is a lot of fun and a really great project to get familiar with shaders! If you get stuck, I've got a video on my channel about making a mandelbrot shader ;)
@okie9025 Жыл бұрын
<a href="#" class="seekto" data-time="1610">26:50</a> you can also use the spread operator, which has the added bonus that it works with any number of arrays, i.e.: const colours = [...col1, ...col2, ...col3]
@BarneyCodes Жыл бұрын
Oh that's really good! Thanks for the suggestion!
@wlgemini1991 Жыл бұрын
视频做的真棒, 每一步都介绍的很详细👍
@BarneyCodes Жыл бұрын
Thank you!
@reik200610 ай бұрын
Really good introduction! Thank you
@BarneyCodes10 ай бұрын
Thanks, glad you liked it!
@elisthetic11 ай бұрын
i would like you to know that this video is SO WELL MADE and beautifully explained, that me, a person with 0 prior experience to coding, no idea what the brackets even do, are able to understand the concepts perfectly well. Thank you so much, my journey of learning how to make games is looking a lot less dim now 😭
@BarneyCodes11 ай бұрын
Wow, that's amazing! Glad you found it so useful and good luck on your journey! Feel free to reach out if you have any questions!
@alexeyl2210 ай бұрын
Great stuff. Looking forward for more.
@TechnicJelle Жыл бұрын
What a great video! Thanks for making it :D
@BarneyCodes Жыл бұрын
Thanks so much for the support! Glad you enjoyed it!
@Wkaelx3 ай бұрын
Oh no! I have recivied the power to create an alternate reality in javascript, i shall use this power to conquest the world.
@HipToBeeSquare5 ай бұрын
Demystifies a lot of the syntax that kinda stumped me while giving a cursory glance :)
@akashdalvi53699 ай бұрын
Thanks man.. this really helped a lot. Thank you for putting this much time and effort into this❤
@bespokeprogramming Жыл бұрын
Mate! I love glsl, but your explanation is dope! Thank you!
@BarneyCodes Жыл бұрын
Wow, thanks so much! Glad you liked it!
@mikecu224919 күн бұрын
Great Guide! Amazing video!
@BarneyCodes19 күн бұрын
Thanks so much, glad you found it useful! :)
@jackmalcolm7 ай бұрын
Great video. Wish I understood it. I get the general concepts but a lot of the technical stuff flies over my head. Having a tough time learning basics of coding because I don’t have anything to code, a lot of tutorials/learning resources just feel like I’ve been given a list of a languages syntax.
@BarneyCodes7 ай бұрын
It can definitely be that way when you're first getting started! Thankfully you'll start to notice that there are a lot of similarities between languages so once you get a bit more familiar with one, it'll be easier to pick up more. Keep at it and you'll get there! I highly recommend finding a tutorial for something that genuinely excites you, it makes it a lot easier to stick with it! (For me it was a really really basic game, I think it was a bit like space invaders or something!)
@jackmalcolm7 ай бұрын
@@BarneyCodes I guess a follow up question would be where would/should I do something like that? Would you do that in a game engine like unity? Or just barebones? I feel like using a game engine might be a detriment to some of the learning process because the bells and whistles are already there, but I also don’t want to give myself an additional level of frustration for no reason.
@jackmalcolm7 ай бұрын
@@BarneyCodes though, I guess it’s just personal preference and in finding a tutorial like that I’d get my (or an) answer.
@BarneyCodes7 ай бұрын
@jackmalcolm I think if your aim is to learn to code, I'd probably recommend not using an engine. A really great starting point would be to check out "The Coding Train" here on KZbin. Dan, the bloke that runs the channel, has hundreds of videos for all skill levels and his enthusiasm is infectious! In fact I think he may have pretty recently released a course on getting started programming, which could be perfect! EDIT: It's called "Creative Coding for Beginners - Full Course!" if you want to look it up :)
@mooshy5944 Жыл бұрын
Thanks! this was exactly the sort of tutorial I’ve been looking for 🎉
@BarneyCodes Жыл бұрын
No worries, glad it was helpful!
@adeidara9955 Жыл бұрын
This is great, thank you! Ps. There is a low humming or noise in the background , I don’t mind it but some people could be sensitive to it ^^
@BarneyCodes Жыл бұрын
Glad you found it useful, and thanks for the feedback, I'll look into eliminating it for future videos!
@pengain4 Жыл бұрын
Awesome video. Very entertaining and educational
@BarneyCodes Жыл бұрын
Thank you, glad you enjoyed it!
@auditdb743310 ай бұрын
Lost me at swizzling, but guess it helps to have 3d coding knowledge. Really hard to find a simple tutorial that goes deep on the basics. I really like the style of this vid and you had me for the first ten minutes. I will persevere.
@BarneyCodes10 ай бұрын
Sorry to hear that! Honestly, you can get away with not using swizzling so I'd encourage you to just skip that part and keep going! All you need to know for swizzling is, if you see something like vec.xxy, it's the same as saying vec3(vec.x, vec.x, vec.y) Hope that helps!
@auditdb743310 ай бұрын
@@BarneyCodes thanks 🙏
@JoeFly200911 ай бұрын
Great Video! I saw another comment talking about Minecraft's Vanilla Shaders (Vanilla means that it's the default version, without any API like OptiFine), and I think it would be interesting to make a video about it. Two great examples are bradleyq's shader-toolkit and VanillaPuddingTart. (The default files can be obtained by extracting Minecraft's jar file)
@BarneyCodes11 ай бұрын
Thanks! I'm actually really interested in pursuing this idea so I'll definitely check out both of those!
@doublemax7711 ай бұрын
Excellent video, thank you so much!
@BarneyCodes11 ай бұрын
No worries, glad you liked it!
@thatalbeeguy Жыл бұрын
thank you so much this is an incredible tutorial!
@BarneyCodes Жыл бұрын
No worries, glad you found it useful!
@jermaineallgood Жыл бұрын
Thank you so much!!!! I appreciate this as it will help tremendously!
@BarneyCodes Жыл бұрын
No worries!
@JsbWalker6 ай бұрын
I really wasn't expecting this video to be this difficult to adapt for Java Processing, but it's proving to be incredibly hard to make this example code work there.
@BarneyCodes6 ай бұрын
What issues are you running into? There are definitely some differences in getting the environment set up, but the actual shader code should be usable between both (you might just need to check what uniforms/attributes are available by default in Processing vs P5js) If you're getting any error in particular I can try to give you a hand to get it sorted out!
@JsbWalker6 ай бұрын
@@BarneyCodes That's what I thought as well. When I first copied everything down the shaders just refused to compile, so I figured the names of the attributes must just be different. It took me a while to find any documentation about what attributes were available in the Processing environment (the official site has pretty much nothing that I could find about implementing shader functionality despite this being a feature for years at this point) vs P5, but eventually I found examples in an old backup of a blog that went pretty in depth about how this stuff worked for Processing. After replacing all of the attributes with their correct counterparts the shaders were finally able to compile and run, but specifically the vertex shader just doesn't have the expected behaviour. It refuses to shade anything in 2d that isn't a square that fills the whole screen. I've been tinkering with it off and on for a while trying to figure out what in the implementation is different enough to make this not work, but I don't have enough experience or documentation support to really know what's up here
@BarneyCodes6 ай бұрын
I've only used shaders in Processing for full screen effects, so unfortunately can't be too much help there sorry! A few of the example Processing shaders I've seen have different defines at the top, eg: #define PROCESSING_TEXTURE_SHADER or #define PROCESSING_COLOR_SHADER maybe something like that helps? I know Processing also lets you either supply a vertex shader or just use their default one, not sure which route you've been going down (maybe both already!) but it could be good to try them both out to see if that helps at all. As a last resort, the Processing source code is all available on GitHub so you can also dive into that (if you're feeling brave enough!) to try and figure out what's going on and why it might be behaving strangely! Sorry I don't have a more concrete bit of advice for you, but hopefully there's something in there that's helpful? Good luck!
@Cypekeh Жыл бұрын
Great video, thanks I had some shaders in uni, but I didn't really get it Hopefully I'll start using them more often and learn them, but this video is a great introduction
@BarneyCodes Жыл бұрын
Thanks! Hope the video is helpful, let me know if you have any questions!
@BarneyCodes Жыл бұрын
Finally finished! This video took ages to put together, so if you enjoyed it, it would be great if you could give it a like and share it with anyone you know who needs to learn about shaders! Also, I forgot to mention the amazing www.shadertoy.com which is another great resource and an easy way to get stuck into shader programming in your browser. If you'd like to see what else I'm working on, it would be great if you could wishlist my game Star Mining Co. on Steam! s.team/a/2584800/
@Ibbys_space6 ай бұрын
oh yeah, don't forget graphtoy, it's a graphing calculator specifically with glsl in mind !! there's also a few websites in kishimisu's video on shader art coding but youtube tends to delete comments with links, they're still worth checking out though!!
@Mtaalas11 ай бұрын
Draw a circle... then draw the rest of the fucking pantheon! :D Great video, straight to the point :)
@BarneyCodes11 ай бұрын
Hahahaha thanks, glad you liked it!
@djneils100 Жыл бұрын
this channel rocks - please keep going!
@BarneyCodes Жыл бұрын
Thank you so much! Definitely more to come!
@SirSnowman Жыл бұрын
If you delete "Chapters:" in the videodescription an start right with <a href="#" class="seekto" data-time="0">00:00</a> ... you'll get the chapters also in the videotimebar as well
@BarneyCodes Жыл бұрын
Thanks so much for that! I moved some things around in the description which must have screwed them up!
@SirSnowman Жыл бұрын
@@BarneyCodes no problem, I delete my comment tomorrow, to keep you tutorial clean :)
@syntaxerorr11 ай бұрын
Great video.
@D.E.Nicolas.Goncalves Жыл бұрын
Oh man! Greatfull by your content!
@BarneyCodes Жыл бұрын
Glad you find it helpful!
@WhatDoYouWant0006 ай бұрын
This introduction explains al ot about shaders even tho its just an intro it is really worth watching oh also i wanted to ask is it possible to learn GLSL and opengl at the same time?
@BarneyCodes6 ай бұрын
Glad you found it helpful! I definitely think it's possible to learn both at the same time, in fact it's probably necessary to learn a little bit of GLSL to do anything with OpenGL, but I think it's probably best to just do the basics of one, enough to let you explore the other, and then you can come back and learn the first one properly, just so you're not too overwhelmed!
@BallardRobinett Жыл бұрын
excellent video! really appreciate this
@BarneyCodes Жыл бұрын
Glad it was helpful!
@tommysanger665911 ай бұрын
Great video! A couple questions I have. If shaders are meant for the GPU, what happens when running on a system with only a CPU? For the background image, is there a difference in handling png, jpeg, etc? Or are they passed as just the pixel data? For video games, are shaders drawing everything? Or do they receive the frame (like the background image) and then apply additional changes to that? This is the first shader video I've come across, so I'm sorry if these are commonly answered questions.
@BarneyCodes11 ай бұрын
Really great questions! Most mordern CPUs will have some sort of on-board graphics which is essentially like having a mini GPU built into it. A dedicated graphics card will be a lot faster and usually perform better too. You can get CPUs without graphics in built, but they're the exception not the norm. The CPU is where the work of opening/reading the files happens, and it then will just pass the pixel data to the CPU, so there shouldn't be any difference between different file types. If you're doing it yourself (ie not using an engine/framework), you'll have to set what form that pixel data takes using the graphics API you're using (this will be things like whether its RGBA or ARGB etc) In games, shaders will be drawing everything, but if you're using an engine or framework they will have shaders that do pretty much everything for you, you'll just tell it what models/textures/sprites to use and it will handle the rest. You'll almost always be able to write you own shaders though, if you need to do something a little obscure or want a custom effect. I hope that helps!
@tommysanger665911 ай бұрын
@@BarneyCodes Yes that helps a bunch! I did look some other stuff up and it seems there are more than just vertex and fragment shaders. Are the others just variants of these two that focus on specific aspects which could be combined into the base 2? Also, an additional question. I know NVIDIA applies their DLSS stuff that uses AI to make games look better. Are these just game specific shaders that are created using machine learning? Or does the regular image render from shaders, and then have another round in the GPU where DLSS polishes up the finished frame?
@BarneyCodes11 ай бұрын
That's great to hear! Yea there are a bunch of types of shaders, and they are all their own unique thing and are used at different steps. You hear of vertex and fragment shaders the most though because they are required to draw stuff on the screen, where as the others are optional. The most common non-fragment or vertex shaders are probably geometry and compute shaders. Geometry shaders basically lets you turn a vertex into a group of vertices (eg you could turn a single point into a cube). Compute shaders are essentially just a way for you to use the parallel power of the GPU outside of the rendering process. It uses Shader Storage Buffer Objects (SSBOs) to transfer data between the CPU and GPU, so once the compute shader is finished you can read the SSBOs for the output and then use that information however you want. I don't know too much about DLSS but I had a quick look and it sounds like it's all done AFTER the rendering has finished. I think the idea is that you render to a lower resolution so that it's really fast, then DLSS upscales that smaller frame to a larger resolution. It uses special hardware on modern GPUs that is purpose built for running AI!
@AntonioNoack11 ай бұрын
"For video games, are shaders drawing everything? Or do they receive the frame (like the background image) and then apply additional changes to that?" Yes, shaders are drawing everything, but at the same time, for things like transparency, you can enable blending (glEnable(GL_BLEND)), and then it will combine your calculated color with that of what you have drawn previously. Unfortunately, transparency in 3D is a complicated topic, so I'd recommend avoiding it when starting.
@Jun127 Жыл бұрын
This is a great resource. :)
@BarneyCodes Жыл бұрын
Glad you found it useful!
@zmf1425 Жыл бұрын
Very good. Thank you
@BarneyCodes Жыл бұрын
No worries!
@GodzillaGoesGaga Жыл бұрын
The edge joke cracked me up!! Would be interested if Shaders are used for physics and engineering math calculations ? At the end of the day it’s just doing a load of parallel float (or other) ops.
@BarneyCodes Жыл бұрын
I'm glad somebody got it, it's the first time someone mentioned it hahaha That's a really great question! There's a type of shader called a compute shader that is often used for exactly that! Compute shaders are basically a really flexible type of shader where the programmer gets to define most things about how it is run, and can read/write into "shader storage blocks" so you're not limited to just outputting to textures and you don't need to render geometry to trigger it to run. Before I learned about compute shaders, I did try to use textures to store particle positions but I couldn't get it to work too well. I'm sure that it's possible though!
@onlylikenerd Жыл бұрын
Hey nice video. Good stuff
@BarneyCodes Жыл бұрын
Thanks, glad you liked it!
@theobgshow Жыл бұрын
Superb! Thank you 😊
@BarneyCodes Жыл бұрын
No worries!
@ceruleansky6670 Жыл бұрын
Instructions unclear about beverage choice grabbed vodka now I have to rewatch the video 11/10
@BarneyCodes Жыл бұрын
Hahaha I'll be more specific next time
@omari61085 ай бұрын
This is amazingly helpful. I’ve been having hell of a frustrating time with OpenGL, and this can aid in my woes 😁 In following along, you’re passing pos in the shaders. Where is the value of it coming from? I do understand what’s going on, but having that bit of info known helps. Am I missing it somewhere?
@BarneyCodes5 ай бұрын
Glad you've found it helpful so far! I think I glossed over that in the video a bit. Basically the position value is being set in the vertex shader and is then passed through to the fragment shader (this is why the variable name in the vertex and fragment shaders have to match, because they're being used to pass the value across!) When sending geometry to the GPU to render, you have to specify the position of the vertices, but you can also specify the "UV" coordinates, which are basically the coordinates you'd like that vertex to use when looking up a texture, and this is the value I'm using to set the position variable in the vertex shader. How you set the UV coordinates from your CPU code will depend on what environment you're using, for P5js, they're set automatically! Since the UV/texture coordinate is per vertex, they get set as an attribute, which is only available in the vertex shader, which is why we need to set up the varying variable to pass the value into the fragment shader. I hope that makes sense, it's a bit of a rambling answer! If you've got any follow up questions, please just ask :)
@ruadeil_zabelin11 ай бұрын
More specifically HLSL is used by Direct3D, while GLSL is used by OpenGL and Vulkan. It is also worth noting that crosscompilation through for example spir-v is possible which means you really only need to write 1 language (typically hlsl) to support a wide variety of graphics apis.
@BarneyCodes11 ай бұрын
I'll have to check the cross compilers out, didn't know that was a thing! Thanks!
@ruadeil_zabelin11 ай бұрын
@@BarneyCodes The way I do it in my game engine is write everything in HLSL. Then i use glslang to compile to Spir-V. From there i use spirv-cross to "decompile" to either GLSL that targets opengl or vulkan; at which point you can use the opengl commands to compile it or precompile back to target opengl spirv or vulkan spirv (yep.. they're not compatible with eachother; they have their own spirv flavour). You have to take this decompile step because the HLSL resulting spir-v is not compatible with opengl. Supposedly it works with Vulkan but i couldnt get it to work. But with this it works flawlessly across d3d11, 12, opengl 4.6 and vulkan 1.2. The decompiled GLSL isn't even half bad either.. it looks pretty clean.
@BarneyCodes11 ай бұрын
@@ruadeil_zabelin Thanks for explaining! I'm guessing your engine allows people to choose which renderer they're using then? If so, that's impressive! The only other scenario I can think of where you might need to do something like this is if you're porting a game from one renderer to another. Are there other use cases for such a thing?
@ruadeil_zabelin11 ай бұрын
@@BarneyCodes You can pick a renderer yes, but I made it so it just suggests what I think is the "best" supported one for that platform. So on windows it always defaults to d3d11; on linux its Vulkan, on mac its opengl (though i might try metal someday). I basically studied how unreal engine handles their render api abstraction and found that its basically very similar to the d3d11 api. I wrote a similar interface and just implemented all the function calls for all the graphics api's. If you choose the abstraction well its not all that difficult to do. The only hurdle was the shaders so the possibility of crosscompiling was really nice.
@BarneyCodes11 ай бұрын
@@ruadeil_zabelin Ahhh that makes a lot of sense! Sounds like a really cool project! Thanks for all the info :)
@alexandrewatrin82933 ай бұрын
Really really well made video thanks
@BarneyCodes3 ай бұрын
No worries, glad you enjoyed it!
@Niktmnieniechciej2 ай бұрын
One of the best on youtube.
@BarneyCodes2 ай бұрын
Thanks so much!
@hunam_ Жыл бұрын
thank you very much
@BarneyCodes Жыл бұрын
No worries!
@lukei97724 ай бұрын
THIS WAS SO GOOD PLS DO ANOTHER VIDEO ON 3D STUFF
@BarneyCodes4 ай бұрын
I haven't really explored the 3D side of things too much yet, but it's definitely something I plan on getting into! I'll be sure to make a video showing what I've learnt when I do! Thanks for the comment :)
@brokenumbrellagames Жыл бұрын
Thank you!
@BarneyCodes Жыл бұрын
No worries!
@mireymackey11 ай бұрын
Top-tier video!
@BarneyCodes11 ай бұрын
Thanks so much!
@CodeDisease11 ай бұрын
<a href="#" class="seekto" data-time="40">0:40</a> coffee time
@j_uice Жыл бұрын
yessssssss thanky ou for this!
@BarneyCodes Жыл бұрын
No worries!
@Khazam19925 ай бұрын
Cool, thank you very much.
@BarneyCodes5 ай бұрын
No worries at all!
@fr3ddyfr3sh11 ай бұрын
seems a little shady to me 😅
@bloodaid7 ай бұрын
Never trust shaders
@syphonunfiltered5 ай бұрын
Dumb
@PixelKnight933 ай бұрын
Good one! Lol very clever😂
@Schwein412 ай бұрын
Bro 😅
@Schwein412 ай бұрын
@syphonunfiltered no u
@LBCreateSpace6 ай бұрын
Awesome video Ty!
@felfar19712 күн бұрын
thank you soo much!!!!
@BarneyCodes12 күн бұрын
No worries!
@usernameusernameusername122 ай бұрын
Wich framework are you using? Great video
@BarneyCodes2 ай бұрын
In this video I'm using P5js which is a creative coding library for JavaScript. It uses WebGL, but the concepts in this video should be translatable to whatever framework or shader language you're using!