Three.js Shaders (GLSL) Crash Course For Absolute Beginners

Sdílet
Vložit
  • čas přidán 5. 09. 2024

Komentáře • 144

  • @chaotic_keystroker
    @chaotic_keystroker Před 10 měsíci +7

    Nice tutorial! I had an error when injecting shaders into standard materials because of the replacement. The first line of the pars/main file continues at the end of the last file in the include. This means that it ruins an ifdef block, then the compilation fails. If you let one free line at the beginning of the main file, this won't happen. But if your code starts at the first line, you have to add linebreak into the replace (just add linebreak and don't think about it).
    // Do this for both pars and main injections and you are golden.
    shader.vertexShader = shader.vertexShader.replace(
    parsVertexString,
    parsVertexString + "
    " + vertexPars
    )

  • @ariox5793
    @ariox5793 Před rokem +23

    Finally, I have been learning about shaders for a while. It was a nightmare for me to find any tutorials about shaders on CZcams. This was the best video I saw about shaders. Even though I was already familiar with shaders, I still learned a lot from this video.

    • @visionary_3_d
      @visionary_3_d  Před rokem

      For the record : This is my friend and he has watched my video earlier than anybody else 😅
      I'm glad you learned something bro! Keep up the hard work.

  • @zerpacode
    @zerpacode Před rokem +16

    Hello people!
    I was a bit curious about the variables provided by threejs by default, so here is a list of the most common uniforms provided by threejs (taken from chatGPT) I hope you find it useful:
    modelMatrix: the model transformation matrix that's used to transform model coordinates into world space.
    viewMatrix: the view transformation matrix that's used to transform world coordinates into camera view space.
    projectionMatrix: the projection matrix that's used to transform view coordinates into screen coordinates.
    modelViewMatrix: the combined model and view transformation matrix.
    normalMatrix: the model normal transformation matrix, which is used to transform model normals into view space.
    cameraPosition: the position of the camera in world space.
    time: the time in seconds since the animation started.
    resolution: the screen resolution in pixels.
    map: the texture of the material being rendered.
    opacity: the opacity of the material being rendered.
    color: the color of the material being rendered.
    fogColor: the color of the fog that's being applied to the scene.
    fogNear: the closest distance to the camera at which fog is applied.
    fogFar: the farthest distance from thecamera at which fog is applied.
    sunPosition: the position of the sun in world space.
    pointLightPosition: the position of the point light in world space.
    pointLightColor: the color of the point light.
    ambientLightColor: the color of the ambient light.
    directionalLightDirection: the direction of the directional light.
    directionalLightColor: the color of the directional light.

  • @emerald6434
    @emerald6434 Před rokem +12

    Amazing to see such content free on CZcams, it's a blessing for the community 👊👏
    Keep up the good work 👌

  • @markeeangus
    @markeeangus Před rokem +10

    Hey,
    Just wanted to drop a comment to say a massive THANK YOU for the awesome shader tutorials you've been putting out there! 🙌 Your ability to break down complex concepts and explain them in such a simple and easy-to-understand way is truly amazing. It's really helped me (and I'm sure many others) get a grip on shaders like never before.
    Keep up the fantastic work, and I can't wait to see what you'll share next! You're a rockstar! 🌟
    Cheers

    • @visionary_3_d
      @visionary_3_d  Před rokem +2

      Thank you very much for the kind words ❤
      You just made my day. 😊

    • @alec_sibilia
      @alec_sibilia Před rokem

      second this. you're a legend

  • @adinhobl
    @adinhobl Před 3 měsíci +1

    Excellent course for an absolute beginner in 3d-graphics like me!

  • @tyfooods
    @tyfooods Před rokem +2

    Not even finished yet, and this is a complete GEM 💎 Thank you so much for it, my friend. Sending all the best vibes ✨

  • @markxavior
    @markxavior Před 9 měsíci +1

    This is an excellent tutorial by a very good person. I can say he knows about the subject very well. He has created one of the best guided videos on shaders.

  • @philipanderegg5973
    @philipanderegg5973 Před 6 měsíci

    I think this video answers what I want to do, plan is to make a sphere but color is defined at 4 specific vertices and interpolated elsewhere, which ofc shaders should be perfect for! I'll add an edit to say whether or not it was useful

  • @8561
    @8561 Před 10 měsíci

    I really appreciate the mindset note at 1:08:49. Very important when consuming information for the first time (especially somewhat dense) to step back and give perspective, especially when following a tutorial. Great teacher!

  • @enisbu
    @enisbu Před rokem +2

    Man you are amazing.. for real, first time seeing someone explaining shaders in such a good way! Thank you.

    • @visionary_3_d
      @visionary_3_d  Před rokem

      Thanks! My hope is that these videos are going to help more people get into shaders.
      I'm glad you liked it 🔥

  • @theman7050
    @theman7050 Před rokem

    The most important section in the video is the Mindset one. That's what learners need :D

  • @jessemorningstar
    @jessemorningstar Před rokem

    I'm 33 minutes in and I just had to stop to say that you are a fantastic teacher.
    It's a pleasure to learn from you.
    Count me as a delighted new subscriber. 🤗

    • @visionary_3_d
      @visionary_3_d  Před rokem

      It's my pleasure to be able to teach something to you!
      Thank you for the kind words ❤

  • @IonizedSun
    @IonizedSun Před rokem

    I cant understand why you have 'only' 3k subscribers. Your tutorials are so good, thank you !

  • @benja-min1588
    @benja-min1588 Před rokem

    Super late to the party, but thank you. I have followed courses by Bruno Simon etc, and he is brilliant. But you go to another level with explaining every character. Other channels seem to skip the detail. Thanks for the effort and filling the gaps in my knowledge.

  • @craftymunz7425
    @craftymunz7425 Před rokem +1

    this tutorial was amazing. Thank you so much for sharing your talent and creative power with us. Wish you all the best. loving the way you are explaining things especially the mathematical part where lot of teacher lack at explaining how they got there.

    • @visionary_3_d
      @visionary_3_d  Před rokem +1

      Thanks for giving me the courage and motivation to make more videos ♥

  • @rogeriogouvea7278
    @rogeriogouvea7278 Před 6 měsíci +1

    Thanks this was very helpful.

  • @anis6674
    @anis6674 Před rokem

    genuenly the best glsl tutorial on youtube

  • @Fiiilipes
    @Fiiilipes Před rokem +2

    Nice work man you definetly deserve more people who support you! 💪🏽🔥

  • @jankohlbach
    @jankohlbach Před rokem +1

    huge thanks for your effort put into this thorough video, it's perfect to start into all of this, literally everything needed perfectly explained 👌🏼

  • @visionary_3_d
    @visionary_3_d  Před rokem +6

    Hey guys I hope you enjoy this video.
    Here's the link for my extending three.js materials video if you need it :
    czcams.com/video/vowT_8oVFmM/video.html
    If you want to learn more about shaders checkout this playlist :
    czcams.com/play/PLTEbuqk52pICikiHfD-a52dxEav5UqMLy.html

  • @Joheungju
    @Joheungju Před 3 měsíci

    Yeah!! I finally found the ultimate lecture...

  • @sarahbracken9798
    @sarahbracken9798 Před 9 měsíci

    You are so fantastic at explaining shaders. Thank you so much for this video 🙏

  • @anshsahu1848
    @anshsahu1848 Před 3 měsíci

    I like how he explain, thanks for the tutorial

  • @WawaSensei
    @WawaSensei Před rokem +1

    Your content & video quality are awesome! Keep going 🔥

    • @visionary_3_d
      @visionary_3_d  Před rokem

      Good to see you here sir!
      I was watching your vids a few days ago.
      It's always nice to see other people's process for creating projects 😁

  • @stevenerickson4240
    @stevenerickson4240 Před 7 měsíci +1

    Excellent tutorial!!! I really feel like I learned a lot.

  • @mediprixtutos7064
    @mediprixtutos7064 Před rokem +1

    very helpful and well explained, thanks

  • @zerpacode
    @zerpacode Před rokem

    This is the best ThreeJS channel I have ever seen Black.
    - Another like [1,0,0] -> Red, So the right part of the sphere is red because the x value is equivalent to the R.
    - The front part of the sphere is blue because the vertex positions in this zone are near to [0,0,1]. So, Z is at max and is equivalent to B.
    That`s the why we have this "rainbow Effect". A I correct?
    pd: Again, wonderful content, the best one I ever seen about this 3D on web

    • @visionary_3_d
      @visionary_3_d  Před rokem +1

      Thank You! I'm glad you like the videos.
      Yes you're correct about the rainbow like effect.
      That's exactly what happens. XYZ turns into RGB.

  • @DNEZZA
    @DNEZZA Před rokem

    Gracias por este tutorial, no tienes idea de lo mucho que lo necesitaba, no encontre tutoriales asi en todo youtube, en serio, muchas gracias.

  • @klaasderksen
    @klaasderksen Před rokem +2

    Thank you for uploading this!

  • @prodbyryshy
    @prodbyryshy Před 11 měsíci

    i think it would be helpful if you also covered in general how to deal with large numbers of objects, like if i want to make a grid or particle effect with some shapes. In particular im wondering how to control when objects are created in time

  • @JackLeiLing
    @JackLeiLing Před 6 měsíci

    Very comprehensive and super helpful, great work, thanks

  • @kirillvoloshin2065
    @kirillvoloshin2065 Před 8 měsíci

    great video! splitting the screen would have been perfect

  • @pierre291772
    @pierre291772 Před 9 měsíci

    Amazing course. Really good examples and easy to follow . Thanks a lot

  • @HuynhLuong227
    @HuynhLuong227 Před rokem +1

    great, big thanks and keep going...

  • @illardTrillmore
    @illardTrillmore Před 10 měsíci

    Excellent course man, you're a great teacher. Keep it up!

  • @nomanebenyshahid7435
    @nomanebenyshahid7435 Před 4 měsíci

    Want more shaders course. Please

  • @CodeCraftersStudio
    @CodeCraftersStudio Před rokem +1

    Loved your explaination here ❤❤

  • @alimomeni5234
    @alimomeni5234 Před rokem +4

    bro i exactly did whatever you said about twice until 2:37:18 and get this error that i cant fix can you help me and i exactly followed your video by the way thanks for this cool video ||
    the ERROR is
    ERROR: 0:246: 'ifdef' : unexpected end of file found in conditional block

    • @devlad
      @devlad Před rokem

      Check you have a blank line at the top of each GLSL file ad don't have some autoformatter removing it. That was my issue

    • @LaugeMP
      @LaugeMP Před rokem

      Same error here @visionary3d

    • @cinema4d100
      @cinema4d100 Před rokem

      @@devlad same error, checked for that and didn't work

    • @cinema4d100
      @cinema4d100 Před rokem

      did you solve it?

    • @LaugeMP
      @LaugeMP Před rokem

      @@cinema4d100 I solved the error. My setup is SvelteKit and i tried to load the vertexFrag, vertexMain, fragmentFrag and fragmentMain from a seperate file which for some reason wouldn't work.
      Instead i copied the entire file put it in a variable like const fragMain = `...`
      and used the variable instead of import.
      This solved it for me.

  • @vikasjaiswal3729
    @vikasjaiswal3729 Před 8 měsíci

    Nice and concise thanks for creation

  • @bhaktipasaribu
    @bhaktipasaribu Před rokem

    amazing tutorial, your explanation is better at shader than bruno's
    keep up the good work!

    • @visionary_3_d
      @visionary_3_d  Před rokem

      Thank you for the kind words! 🙏
      FWIW Bruno's videos were a huge help at the beginning of my own journey.
      My hope is that the people watching this will create videos that are 10 times better than this ✌

  • @boltskills5183
    @boltskills5183 Před rokem

    The best shaders course

  • @meditationandmindempowermu183

    You're great, man! Thank you for sharing your knowledge!

  • @rohitpardhi3924
    @rohitpardhi3924 Před 2 měsíci

    Thank you so much, helped a lot.

  • @Sound_.-Safari
    @Sound_.-Safari Před 8 měsíci

    So incredibly useful

  • @kaifrabi5244
    @kaifrabi5244 Před rokem +2

    Man! Thank you sooooooooooooooo much for this.

  • @OneAndOnlyMe
    @OneAndOnlyMe Před rokem

    This was a great intro, thanks.

  • @jribhshandilya6943
    @jribhshandilya6943 Před 2 měsíci

    Thanks for the amazing video!
    A question: In ducky's example, the contrast between black and white in the noise pattern is higher, and black is more concentrated. This is resulting in smoother displacement crests, compared to what we get here (very sharp crests). What do you think I can change to achieve that?

    • @visionary_3_d
      @visionary_3_d  Před 2 měsíci

      Thank you 🙏
      If I wanted to do that I would visualize the displacement color only ( black and white and without the vertex shader doing any displacement ).
      Then I’d try tweaking the values in the code,
      Adding subtracting and maybe dividing, multiplying by a constant in different places and etc…
      For a more detailed answer I’d have to look at the code but that’s what I would do.
      Creating the colors by feel.

  • @yashsharma6112
    @yashsharma6112 Před rokem

    Amazing. Thank you for sharing your knowledge

  • @bloodylupin
    @bloodylupin Před 9 měsíci

    thanks for the content 💎 thats really precious

  • @marianopiriz6366
    @marianopiriz6366 Před rokem

    This is great stuff! Thanks for sharing!

  • @ErwinMotor0
    @ErwinMotor0 Před rokem

    fire video! well done 🔥

  • @maximknyazev118
    @maximknyazev118 Před rokem

    Man, it is so brilliant! Much thanks

  • @theman7050
    @theman7050 Před rokem

    BRILLIANT, brother thanks. :D

  • @user-ts8vz9ow7j
    @user-ts8vz9ow7j Před rokem

    I enjoyed this video. good luck

  • @rfBeaSttt
    @rfBeaSttt Před 10 měsíci

    Really nice content, thanks!!!

  • @BindomCongat2
    @BindomCongat2 Před 9 měsíci

    Good Video!

  • @honeybadger5478
    @honeybadger5478 Před 6 měsíci

    thank you amazing video

  • @chickenchild007
    @chickenchild007 Před rokem

    thanks a lot this was super helpful!!!

  • @iblamehimiblamehim4235
    @iblamehimiblamehim4235 Před 8 měsíci

    Thank you so much for this

  • @tipsytoes333
    @tipsytoes333 Před 8 měsíci

    Hi everyone, can someone help me, I'm trying to find out what that purpleish icon over the shaders folder? What tool is it for ? I see everyone with it but when I open these files I dont have it its; just plain yellow folder. I think it helps connect the glsl file to the js?? I hope you can understand what I am asking,,,

  • @benjaminrochez2370
    @benjaminrochez2370 Před rokem +1

    I've been following every minute of the tutorial but I got stuck at the switch of shader material (onBeforeCompile, ....). I've got an error I can't manage to fix after rewatching multiple times. Any chance we can discuss about it ?

    • @visionary_3_d
      @visionary_3_d  Před rokem

      Hey, sure.
      Let me suggest a few things you can try to debug the problem!
      1. use console.log() and check the shader code ( string ) that you're sending to the compiler. see if you can find any errors within your code there. GLSL compiler errors aren't always obvious
      2. there's a lot of repetition of code happening within that section of the video and in fact I myself made a mistake ( a typo ) and I later fixed it in the video. so make sure you don't have any typos within your code.
      3. further, if you couldn't fix the issue you can push the code to github and paste the link here and I can take a look at your code 🙂

  • @user-oz4rx2hi2p
    @user-oz4rx2hi2p Před rokem

    When I change the vec2 uv = vUv by vec3 coords = vNormal, it shows the sphere but not the pattern we had earlier. It looks like a twinkling light.

    • @user-oz4rx2hi2p
      @user-oz4rx2hi2p Před rokem

      Oh, I had to define the variable on the vertex shader

  • @zend4652
    @zend4652 Před 7 měsíci

    Bro how did you make your vscode vim extension look so smooth

  • @ooogabooga5111
    @ooogabooga5111 Před rokem

    beautiul, thank you sir

  • @Iridium.
    @Iridium. Před 8 měsíci

    Little bit of an off topic question but how is your ide so smooth? I see you jumping thru lines and characters so fast and smooth ? Also there is that smooth effects happening when you type .. What are the configs ? Is it like that because Ubuntu OS?

    • @visionary_3_d
      @visionary_3_d  Před 8 měsíci

      Hey.
      First of all I'm using vim in vscode.
      Also smooth typing is enabled ( this can be enabled in the settings ).
      And I think this should work on all Operating Systems.

  • @ww25_td
    @ww25_td Před 9 měsíci

    do these shaders also work for Lines, or only Meshes? My scene is using Lines and LineSegments but I want to add custom shader code. Any advice is appreciated.

  • @unrealopenworld
    @unrealopenworld Před 10 měsíci

    The question for me is always, how do I get it online? So from localhost to my website. Do you also have a tutorial for this?

  • @deepak8586
    @deepak8586 Před rokem

    tooo good!!

  • @wojtekclouds
    @wojtekclouds Před 5 měsíci

    I wanted to run your code, from main branch and it gives me simple sphere without this complex shape. Shader files are empty, and are imported but unused

    • @visionary_3_d
      @visionary_3_d  Před 5 měsíci

      I don’t remember exactly but try other branches.

  • @sasadhrirao6487
    @sasadhrirao6487 Před rokem

    Brooooo Thank you!!!!

  • @lentyaeev
    @lentyaeev Před rokem

    bro u could have just merged the shaders on initialisation of the material, look it up, u can include standard three shaders in your custom with one line of code :3

    • @visionary_3_d
      @visionary_3_d  Před rokem +1

      That's right.
      At the time of recording the tutorial that method wasn't on my mind but it's definitely possible.

    • @irickhcoding4802
      @irickhcoding4802 Před rokem

      hi, is there some documentation on this other method?

    • @lentyaeev
      @lentyaeev Před rokem

      @@irickhcoding4802 i don't really know but i found that in source code of three js example gpgu water
      that was the code:
      const material = new THREE.ShaderMaterial( {
      uniforms: THREE.UniformsUtils.merge( [
      THREE.ShaderLib[ 'phong' ].uniforms,
      {
      'heightmap': { value: null }
      }
      ] ),
      vertexShader: document.getElementById( 'waterVertexShader' ).textContent,
      fragmentShader: THREE.ShaderChunk[ 'meshphong_frag' ]
      } );

  • @StellarWeb008
    @StellarWeb008 Před rokem

    Could you give us some fragment shader cheatsheets

  • @fwdflashwebdesign
    @fwdflashwebdesign Před rokem

    Do you think this could be done to move baed on a spectrum analyzer to create an audio spectrum analyzer?

    • @visionary_3_d
      @visionary_3_d  Před rokem

      For sure. In fact I'll post videos about this in the near future.

  • @MrDoremis
    @MrDoremis Před rokem +1

    Hey, how do you have a blank line at the top of every glsl file, maybe it's a vscode extension or setting that does this?

    • @visionary_3_d
      @visionary_3_d  Před rokem

      You just press enter ?
      I use vim tho...
      and you can creat one line above with shift + o
      in vim.

    • @MrDoremis
      @MrDoremis Před rokem

      @@visionary_3_d yeah it's just that in vscode the webgl glsl formatter automatically formats the glsl files so that they don't leave a blank line at the top, and this blank line is important since otherwise you get errors when trying to combine THREE.MeshStandardMaterial() with your own shaders

    • @visionary_3_d
      @visionary_3_d  Před rokem

      @@MrDoremis hmmm.
      I'm not sure I've had that error.
      but you can always debug something like that and add blank space manually.
      eitherway thanks for mentioning this since other people might have the same issue.

    • @visionary_3_d
      @visionary_3_d  Před rokem

      @@MrDoremis I'll pin your comment in case other people have this issue.

    • @MrDoremis
      @MrDoremis Před rokem

      @@visionary_3_d great!

  • @Sound_.-Safari
    @Sound_.-Safari Před 8 měsíci +1

    JavaScript doesn’t have true mod either 😂 so I’m already used to the mod function

  • @anis6674
    @anis6674 Před rokem

    perlin noise function not working

  • @Yerevan-yl5oh
    @Yerevan-yl5oh Před 3 měsíci

    👍👍👍👍✨

  • @theman7050
    @theman7050 Před rokem

    At around 2:22:00, why did you transfer the entire noise generation function to vertex shader?

    • @visionary_3_d
      @visionary_3_d  Před rokem

      Cause it runs less and the performance improves a little bit.
      We generally have less vertices than pixels in an object.
      So the gpu can do less calculations that way.

  • @fwdflashwebdesign
    @fwdflashwebdesign Před rokem

    You spent too much time on the easy part and not enough on the hard part :)

    • @visionary_3_d
      @visionary_3_d  Před rokem +1

      I agree with you that I could've spend a little bit more time explaining the stuff towards the end. ( if that's what you mean )
      "easy" and "hard" depend on the level of the individual's current knowledge.
      For example this whole 3 hours of video is super easy for me 😄( I'm mentioning this because I don't know which part you're talking about. I'll appreciate it if you specify )
      Thank you for your feedback! I appreciate it 🙏

    • @visionary_3_d
      @visionary_3_d  Před rokem +1

      Also I want to add that we will have lots of videos about the hard things you can do with shaders and how they work.
      So at least I can promise that 🙂

  • @sleeping_dragon
    @sleeping_dragon Před 7 měsíci

    guy's voice very stuttering, lots of "um"s and "and"s and "uh"s

  • @luciferaswin
    @luciferaswin Před 2 měsíci

    Very bad tutorial, at least teach how to set the entire project, only when i started making my own project i realised directly importing glsl was a no go

    • @visionary_3_d
      @visionary_3_d  Před 2 měsíci

      Starter files are provided however they might be somewhat old, and may need update.
      Part of being a developer is understanding how to create the dev environment with modern tools.
      I look at old tutorials all the time myself.
      Sometimes they're using the wrong syntax and I need to see how to do it the modern way now.
      That's all part of the journey, honestly 🙂

  • @ZJ.Design
    @ZJ.Design Před rokem

    Awesome content!