GLSL & Shaders Tutorial - Understanding The Syntax And The Idea Behind The Vertex & Fragment Shaders

By the end of this video, you'll have a solid understanding of the GLSL ES language's syntax. And also the whats and hows behind shaders, the vertex and fragment shaders more precisely.
---
Timestamps
00:00 Introduction
00:13 GLSL definition
00:42 Comments
01:01 Variables and constants
01:25 Basic types
02:09 Vectors and matrices
02:51 Vectors
05:05 Matrices
06:13 Samplers
06:27 Arrays
06:53 Structures
07:29 Control flow statements
07:40 Functions
08:41 Storage qualifiers
26:10 Precision qualifiers
10:48 Shaders definition
11:03 Vertex shader
12:24 Fragment shader
13:41 Example 1
17:45 Example 2
22:52 Example 3
25:40 Final words
---
Article
waelyasmina.net/articles/glsl...
---
The boilerplate that I'm using in my tutorials
github.com/WaelYasmina/ThreeB...
---
Links
WebGL, Shaders, Vertex Shader, Fragment Shader, GLSL ES, and WebGPU In A Nutshell
• WebGL, Shaders, Vertex...
Three.js Tutorial For Absolute Beginners
• Three.js Tutorial For ...
Math For Game Devs by Freya Holmér
• Math For Game Devs (2020)
GLSL built-in functions
www.shaderific.com/glsl-funct...

Пікірлер: 81

  • @WaelYasmina
    @WaelYasmina10 ай бұрын

    Written version of this tutorial: waelyasmina.net/articles/glsl-and-shaders-tutorial-for-beginners-webgl-threejs/ A few mistakes I made in the video: 05:58 there's a missing dot. wrong: float f = matB[0]y; correct: float f = matB[0].y; 08:12 wrong function return. wrong: return vec2(1.0, 2.0); correct: return vec2(x, y); 10:38 we can't set precision to vectors and matrices. wrong: precision highp vec2; correct: precision highp int; correct: precision highp sampler2D;

  • @huynguyen-cy8ig
    @huynguyen-cy8ig Жыл бұрын

    great tutorial, I'm stuck with glsl for weeks. This video is really helpful

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

    Man this tutorial was the best one ever! You have done a tremendous job! 👍

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

    Honestly,this was a very simple and easy to understand tutorial. It really helped me and good video. I wanted to code shaders on glsl but I didn't understand it properly now because of the tutorial I have no confusions

  • @fayboyun4262
    @fayboyun42626 ай бұрын

    you are a great instructor! I am a mechanical engineer with limited js knowledge and your videos helped me build a fun website thank you so much!

  • @shanebenlolo3160
    @shanebenlolo31602 жыл бұрын

    Thank you so much for this video! Have been looking for something like this for weeks, there is surprisingly little content about GLSL on youtube.

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    You're welcome! Yes there's a shortage in terms of GLSL tutorials but I'll try to make more whenever I learn or come up with something worth making a tutorial on.

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

    I've struggling to learn GLSL for some years by now. Your tutorial was the best I've seen in this time. Very concise and didactic. Not only that, it really inspired me to take another chance. Thank you so much for this, dude. Excellent work!

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    I'm so thankful for these kind words, thank you Doug I really appreciate it!

  • @HuynhLuong227

    @HuynhLuong227

    Жыл бұрын

    me too

  • @cardboardspeccies
    @cardboardspecciesАй бұрын

    this is very useful, thank you! i watched the whole thing with only some vague knowledge of c and c# but your teaching style made it pretty easy to digest :)

  • @WaelYasmina

    @WaelYasmina

    Ай бұрын

    Great to hear!

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

    Nice work, very lucid. The depth and breadth is just right.

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

    Omg.. the most outstanding explanation ever.. been trying to understand shader from other video but this top it all.. tq very much sir

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

    Thanks a lot for this tutorial. Cleared a lot of confusions I had with glsl.

  • @Burak-ls5yd
    @Burak-ls5yd8 ай бұрын

    I love this tutorial! It's so clear and informative.

  • @diansong1394
    @diansong13942 жыл бұрын

    Thank you Wael, very concise and organized presentation!

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Glad you think so!

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

    Thank you so much for this video - exactly what I was looking for!

  • @mcemgunes
    @mcemgunes11 ай бұрын

    Thanks for the clear explaination!

  • @ruffaldimarco
    @ruffaldimarco2 жыл бұрын

    Good tutorial, gave me all the info I need 👍

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Glad it helped!

  • @artemaltufiev1045
    @artemaltufiev10452 жыл бұрын

    What an awesome video. Keep going!

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Thank you! Will do!

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

    Thanks , That tutorial very clear and prefect.

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    My pleasure!

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

    Thank you! Helped a ton

  • @gaborkovacs
    @gaborkovacs2 жыл бұрын

    great tutorial, thank you!

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    You're welcome!

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

    Great job!

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

    Great video!

  • @nickaxworthy3236
    @nickaxworthy32362 жыл бұрын

    Really excellent - thank you

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    You're welcome!

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

    thanks , so good video

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

    Thank you so much for this awesome tutorial😍 One problem: when there are different aspect ratio for the mesh and the image.. that image texture got squeezed/stretched. Do you know any solution of that?

  • @ndanzzid566
    @ndanzzid5662 жыл бұрын

    thankyou for the tutorial!

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    You're welcome!

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

    @4:44 What are the components for vect.w, vect.a, and vect.q? You explained the other components for position, Color and Textures, but not for above. TIA

  • @wisdomcube7789
    @wisdomcube77892 жыл бұрын

    Finally a good tutorial

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Glad you think so!

  • @ishaq9607
    @ishaq960728 күн бұрын

    you are a gem.....

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

    All love brother

  • @dartneer
    @dartneer5 ай бұрын

    You da champ!

  • @denisblack9897
    @denisblack98974 ай бұрын

    Dude, I had this wet dream of me drawing tasty animations with shaders and this video got me to a “good enough” level in 20minutes! Thank you!

  • @live-in-clouds
    @live-in-clouds Жыл бұрын

    Thank you

  • @penggreat5992
    @penggreat59922 жыл бұрын

    Very Good Tutorial, you help me understand that vertex shader will execute the same times of the count of the vertices.That is very important.So, how much times will the fragment shader execute? Does it depends on the resolution of the canvas?

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Thank you! Generally speaking 1 fragment = 1 pixel. Thus the fragment shader is executed the number of pixels times. Sometimes 1 pixel > 1 fragment. Thus the fragment shader is executed more times than the number of pixels. To understand the logic behind the 2nd case check these out: stackoverflow.com/questions/68426777/how-many-times-does-the-glsl-fragment-shader-execute-for-one-draw (The answer) kzread.info/dash/bejne/p3xlp7VxfLLYnLA.html

  • @ahmedfarooq7253
    @ahmedfarooq72539 ай бұрын

    PLEASE PLEASE PLEASE DO A FULL COURSEE ON THISS ONEEE

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

    //good vid

  • @theman7050
    @theman70502 жыл бұрын

    Thanks for making shaders a let harrowing concept :) At 24:10, how come the vec4 know that float effect is v3? I mean we are only putting a sin function in float effect, so isnt it a single value?

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    effect is actually a single float value since abs(sin(texture.x + u_time)) returns a single float value. You know sin() returns a value between -1 and 1. vec3(effect) is the same as vec3(effect, effect, effect).

  • @theman7050

    @theman7050

    2 жыл бұрын

    @@WaelYasmina yea I do a lot of p5 animations and sin cos is totally fine with me bro. Thank you very much, again :D

  • @theman7050

    @theman7050

    2 жыл бұрын

    @@WaelYasmina why I was worried is in oneof the shader videos I saw, the uploader got an error in console that was something like, 3 arguments expected 2 supplied. Something like this.

  • Жыл бұрын

    Excellent content Wael! Quick question about usage of GLSL: couldn't we simply use Three to do most of what you've created in this video ? Thanks

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    Thank you Oliver! You mean the examples? I think it's possible to replicate the 1st example without using GLSL. However when it comes to the color gradient and masking I don't think it is possible as far as I know. Anyways even though we have the ability to create cool things without GLSL & shaders they still a must learn if you want to create some high level stuff.

  • @watchingwolf8092
    @watchingwolf80924 ай бұрын

    You have an amazing font in this video, source may be appreciated

  • @WaelYasmina

    @WaelYasmina

    4 ай бұрын

    Itim

  • @watchingwolf8092

    @watchingwolf8092

    4 ай бұрын

    @@WaelYasmina thanks

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

    Wael do you have courses at udemy or any othre platform?? because u should... i want to support you!! Also for anyone trying, on 17:19 substitute like this for a cool example vec3 newPosition = vec3(position.x, position.y, newZ)

  • @ifecojahs8151
    @ifecojahs81512 жыл бұрын

    OH MY GOD!

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    🤩

  • @ColinRichardson
    @ColinRichardson4 ай бұрын

    Okay, I know MUCH MUCH more than I did... But.. I am still lost.. I just seem to have some mental block when it comes to the GL shader stuff.. I might be able to understand it more if there was a "copy/paste GL stuff" and be able to see what the equivalent code would be in JS.. Though, if half of the stuff is doing what I think it's doing, that may not help.

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

    maybe, this lession is WebGL (vertex and shader...)?

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    Indeed

  • @HuynhLuong227

    @HuynhLuong227

    Жыл бұрын

    ​@@WaelYasmina respect you,

  • @niklaskeul7457
    @niklaskeul74572 жыл бұрын

    Sad that i can give only one thumb´s up

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    But your sweet comment is worth dozens of them. Thank you Niklas!

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

    Example 1 shows the power of math in 4 lines of code.

  • @antoniofuller2331
    @antoniofuller23312 жыл бұрын

    I'm probably the best learner here lol

  • @WaelYasmina

    @WaelYasmina

    2 жыл бұрын

    Nice! 💪

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

    You need to be protected at all costs. 😁

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    Thank you lol

  • @antoniofuller2331

    @antoniofuller2331

    11 ай бұрын

    Lmao 🤣

  • @ares106
    @ares1069 ай бұрын

    I feel like I need autism to understand this material.

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

    NOT restricted AT ALL to javascript... glsl is online or offline, has nothing to do with Javascript really.. it's its own language...

  • @WaelYasmina

    @WaelYasmina

    Жыл бұрын

    Did I say something other than that?

  • @antoniofuller2331

    @antoniofuller2331

    11 ай бұрын

    @WaelYasmina No, don't listen to that fool lol

  • @dievas_
    @dievas_2 ай бұрын

    Man, the tutorial is just amazing, but my IQ is jut too low... :D