Three.js Tutorial on Shaders (beginners)

  Рет қаралды 74,828

SimonDev

SimonDev

Күн бұрын

Follow me on:
Twitter: / iced_coffee_dev
Github: github.com/sim...
In this video I'll be taking a look at customizing shaders in Three.js and JavaScript. This tutorial is very beginner friendly, we'll be starting with what shaders are, before moving on to how to integrate and customize your own shaders in three.js and working through some easy examples. There's a few api points to cover in Three.js, including classes like ShaderMaterial and RawShaderMaterial, as well as going over vertex/fragment shader and uniform support.
This is yet another video in a series aimed at beginners and new users of Three.js, aimed at helping you get started. There's no requirement or background needed, beyond having watched other videos in the series. With each project, you should walk away with a solid understanding of both the concepts involved, such as what shaders are fundamentally, as well as working through concrete examples.
The three.js library is available in JavaScript for cross-browser 3d graphics, wrapping webgl and making high level functionality available in the web browser. It’s an extremely mature and well maintained library that I use for many of these videos.
In the video, we cover:
WebGL Shaders, what they are, what vertex/fragment shaders are.
Shader bindings, the difference between attributes, varying, and uniform values, and how to think about them.
Three.js API's such as ShaderMaterial and RawShaderMaterial
How to instantiate and use your own shaders in Three.js/JavaScript

Пікірлер: 83
@simondev758
@simondev758 2 жыл бұрын
If you enjyoed this, check out my GLSL course: simondev.teachable.com/p/glsl-shaders-from-scratch Or support me on patreon!: www.patreon.com/simondevyt
@FelixG
@FelixG 3 жыл бұрын
Your tutorials make learning JS and three.js even more fun than it already is :) All of your videos are so succinct and serve as optimal starting points for everything that you cover. They make it really easy, can't wait to see what you'll cover next.
@simondev758
@simondev758 3 жыл бұрын
Happy to hear that! It's hard to walk that line of under-explaining and over-explaining, glad to hear the current ratio is working out.
@dhruvalraval8078
@dhruvalraval8078 3 жыл бұрын
Most needed. Please continue more on this series. Like integrating three.js functions and classes with shaders manipulations and more
@simondev758
@simondev758 3 жыл бұрын
Awesome, yeah I have more planned like integrating physics.
@hakimrouatbi
@hakimrouatbi 3 жыл бұрын
Didn't take much for me to subscribe, this channel is GOLD. I don't know why it took me so long to stumble upon it. Thanks for sharing you knowledge !
@KibukuluFabrice
@KibukuluFabrice Жыл бұрын
Wow!!! I can't believe that I have a clear understanding of the basics of shaders after watching this video
@covenantersoldier9165
@covenantersoldier9165 Жыл бұрын
Simon, you're a legend. I truly enjoy learning from you. "tip of the hat to you good sir"
@scottonanski4173
@scottonanski4173 Жыл бұрын
Way beyond my level of understanding. Fun to watch, but I'll have to come back to this later.
@Gigatless
@Gigatless 2 жыл бұрын
You have the best tutorial man, so rare to find something that good on shaders
@arielklevecz
@arielklevecz 3 жыл бұрын
very nice and concise explanation of shaders in three! I also somehow didn't know that three vectors had a lerp method built into them, so thank you for continuing to elucidate both low and high level tricks. I think your projects are quite elegant, so I'm not sure you want to go down this route, but if you use something like Webpack you could have glsl files bundled as assets and then import them as opposed to using strings. It is nice to have syntax highlighting and some added file organizing power, but it does include the overhead and idiosyncrasies that come with a more involved dev environment.
@simondev758
@simondev758 3 жыл бұрын
Thanks! Nope haven't considered packaging this all up nicer, right now I kinda like just going the dead-easy route of just write/refresh over and over. The syntax highlighting and all that does sound nice though...
@sharketespark6495
@sharketespark6495 Жыл бұрын
bruv, I LOVE YOU, loved everything in this and other playlists. keep it coming so that i can be atleast 1% of you :)
@BrettKromkamp
@BrettKromkamp 3 жыл бұрын
Man, this is good stuff. Excellently explained like always.
@simondev758
@simondev758 3 жыл бұрын
Much appreciated!
@EricMalek
@EricMalek Жыл бұрын
Did I see Trogdor on the stickman diffuse texture shield? LOL Great stuff man!
@fr3ddyfr3sh
@fr3ddyfr3sh 3 жыл бұрын
Thanks a lot. Perfect shader tutorial for me (very familiar with non 3D programming and lacking the 3D part). Till now I was lost between super basic tutorials and superbrain stuff like shadertoy. Shadertoy is really crazy, it’s like the demo scene, making realistic looking textures without texture images. They create textures in shaders (with black magic and perlin noise). Same accounts for geometry, no 3D models just functions and magic ;-)
@simondev758
@simondev758 3 жыл бұрын
It's not black magic, mostly stuff like sdf's, which I'll be covering on this channel. Hopefully I can get you to that same level :)
@melkileo
@melkileo 3 жыл бұрын
Your channel is fire, thank you for all your tutorials!
@simondev758
@simondev758 3 жыл бұрын
No worries, happy you're enjoying them!
@ewwitsantonio
@ewwitsantonio 2 жыл бұрын
Excellent demonstration!! Thank you so much for creating this tutorial. It's really helpful.
@ZeeshanAli-kc3zc
@ZeeshanAli-kc3zc 3 жыл бұрын
Really need a next tutorial on shaders!
@dungeonHackMedia
@dungeonHackMedia 3 жыл бұрын
Great tutorial. The tip about outputting various things as color for debugging was extremely helpful. Any chance we could get a tutorial on how to implement lighting for shaders?
@simondev758
@simondev758 3 жыл бұрын
I'll add it to my ideas list.
@clearmindstudios
@clearmindstudios 3 жыл бұрын
Thanks dude your channel is fire look forward to learning more
@simondev758
@simondev758 3 жыл бұрын
Appreciate it!
@simoncalem
@simoncalem 3 жыл бұрын
You have the best tutorials
@simondev758
@simondev758 3 жыл бұрын
Thx, lemme know if you got suggestions too!
@fteiyp
@fteiyp 2 жыл бұрын
youre a hero
@GamesandBacon
@GamesandBacon 3 жыл бұрын
I don't even use JS or anything. Your work just fascinates me xD ( I'm really dyslexic so I work with unreals blueprints)
@simondev758
@simondev758 3 жыл бұрын
I'm a big fan of visual coding too, really makes it accessible.
@kadekeqw23
@kadekeqw23 3 жыл бұрын
FANTASTIC, thank you
@simondev758
@simondev758 3 жыл бұрын
np!
@patrickc.6183
@patrickc.6183 3 жыл бұрын
Hey Simon, great video! Would you consider making a series of videos on vanilla WebGL fundamentals? I have only been able to follow a few MDN examples to create a triangle, and a textured cube. There are hardly any materials that I have seen online that are clear enough to explain every part of graphics programming to someone who is unfamiliar with it. I am a web dev, with no background in graphics, however I am very interested in learning.
@simondev758
@simondev758 3 жыл бұрын
I might put something together for that, lemme throw it on my ideas list.
@NaiyoGames
@NaiyoGames 3 жыл бұрын
Awesome content ! Could you do a video explaining how to add custom shader to an existing material? That would be awesome! Thanks !
@simondev758
@simondev758 3 жыл бұрын
I have a video queued up for tomorrow morning that does that exact thing as part of the project. The video isn't about that specific functionality, but I do cover it.
@NaiyoGames
@NaiyoGames 3 жыл бұрын
@@simondev758 That is great !! Top quality content :) thanks a lot :)
@GarronArgentina
@GarronArgentina 3 жыл бұрын
This is amazing content! Contgrats an thanks!
@simondev758
@simondev758 3 жыл бұрын
My pleasure!
@froquede
@froquede 3 жыл бұрын
nice content crabman, subscribed
@simondev758
@simondev758 3 жыл бұрын
Glad to have you around!
@BipinOli90
@BipinOli90 3 жыл бұрын
Cool stuff 🙂
@simondev758
@simondev758 3 жыл бұрын
ty!
@nomadshiba
@nomadshiba 3 жыл бұрын
im wondering, why not use a separate file with shader extension for shaders and just import it in? if it doesn't work in three.js why not make a small script that's importing the shader code there while building.
@simondev758
@simondev758 3 жыл бұрын
You totally can, I just didn't, no good reason.
@BlazPecnikCreations
@BlazPecnikCreations 3 жыл бұрын
Thank you so much
@simondev758
@simondev758 3 жыл бұрын
np!
@urajcic1
@urajcic1 3 жыл бұрын
Hey Simon, Thank you very much for sharing. Your tutorials are awesome :) Could you make one about multiple UVs in single mesh? For example how to merge(multiply/add) diffuse map with baked lightning? Or how to separate normalMap channel from other channels? Best regards
@simondev758
@simondev758 3 жыл бұрын
I can add it to my ideas list. What do you mean by separate normalMap channel?
@urajcic1
@urajcic1 3 жыл бұрын
@@simondev758 Well if you repeat texture map, all the maps will be repeated with that value. I was looking for solution to have one repetition value of texture for diffuse, and other repetition value for normalMap.... Something like that..
@anficyon
@anficyon 3 жыл бұрын
Thanks, awesome
@simondev758
@simondev758 3 жыл бұрын
np!
@overloader7900
@overloader7900 3 жыл бұрын
What about compute shaders? If web has them, it makes most of the performance concerns obsolete (anything that does not require computing literaly millions of things should be able to run perfectly fine on CPU, especially considering the JIT compiled nature of js...)
@simondev758
@simondev758 3 жыл бұрын
Yeah there's webgpu now, think it's available on canary?
@mineHDtutorials
@mineHDtutorials 3 жыл бұрын
YES!
@simondev758
@simondev758 3 жыл бұрын
Heh
@sealuke2724
@sealuke2724 2 жыл бұрын
Amazing !!!
@maik6478
@maik6478 3 жыл бұрын
Amazing, can you make a video about soft particles? They are pretty important for making fog, fire, explosions etc.
@simondev758
@simondev758 3 жыл бұрын
Sure, easy enough! I'll add it to my TODO list.
@maik6478
@maik6478 3 жыл бұрын
@@simondev758 Thank you, looking forward to. Soft particles work with the z buffer right?
@cyb3r_81
@cyb3r_81 6 ай бұрын
Hey Im trying to do a project in one of my college classes and its due at the end of the semester, Im trying to make a static backrooms-esque environment using Three.js and making 2 or 3 shaders with Shadertoy, is there any tips on where I should start? thanks!
@fr3ddyfr3sh
@fr3ddyfr3sh 3 жыл бұрын
@simondev if you’re creating a lake/ocean with waves, do you create the wave geometry on the cpu and push that geometry to the gpu where it get‘s „just rendered as is“. Or would you just push a pure plain terrain to the GPU and create the waves by the geometry or vertex shader. I guess, when you need something realistically floating (a boat or the player) on the water, you would need that geometry on the cpu, wouldn’t you? I guess there are much more options like NVIDIA Physix and doing the wave physics in a compute shader.
@simondev758
@simondev758 3 жыл бұрын
Yes, any of those, it depends entirely what you're targeting.
@crowbr
@crowbr 2 жыл бұрын
I have some problemens to make hair in thress js, I exported from blender and my character get bald lol, with tranparency i make hair with plane, you have soluction in your course?
@felipebrod
@felipebrod 3 жыл бұрын
I'm trying to add shaders to a Physicjs material and it does not work =(
@danielb7023
@danielb7023 Жыл бұрын
What was your favourite console game to develop back in the days?
@magnusbrzenk447
@magnusbrzenk447 3 жыл бұрын
Question. I'm looking at the code at 10:03 and the resultant multi-colored sphere based on normal vectors. Is each segment on that sphere mesh the same color, or is there color interpolation going on within each segment?
@ahmadsaerozi6688
@ahmadsaerozi6688 Жыл бұрын
How to make shader material can receive shadow?
@marcosvolpato8135
@marcosvolpato8135 3 жыл бұрын
is there any way to me export the mesh's modification made on the shader to a real mesh? maybe using one exporter library?
@mrqreeny
@mrqreeny 2 жыл бұрын
@8:46 This methods seems a bit hacky?? It broke the casted shadow. Anyone knows why? Could it be that he shadow in Three.js is calculated based on the geometry and now we are changing the geometry in the material section?
@joshuadelorimier1619
@joshuadelorimier1619 3 жыл бұрын
Any chance you could do a follow up video explaining how to get it to "stick" to the 3d model it looks like it's being projected and how to pass in lighting? Thanks so much though for this I got one of my shadertoy designs to be displayed over the model so progress.
@simondev758
@simondev758 3 жыл бұрын
Not super sure what you mean by projected? Like a decal?
@joshuadelorimier1619
@joshuadelorimier1619 3 жыл бұрын
@@simondev758 I meant UV mapping man I most of been off that day I figured out that part still working on passing lights but I'll figure it out thanks for your tutorial!
@richardcook2651
@richardcook2651 2 жыл бұрын
Could you say which of your repositories are for this video? None of them have "shader" in their name.
@simondev758
@simondev758 2 жыл бұрын
Looks like I forgot to upload it. Lemme root around and see if I even still have the source for this, I released this video a while ago.
@johnliou4628
@johnliou4628 2 жыл бұрын
How to write the custom shader recive shadow?
@SonGohan182
@SonGohan182 3 жыл бұрын
Do you have patronite account ?
@simondev758
@simondev758 3 жыл бұрын
Nope
@swoorp
@swoorp 3 жыл бұрын
please make a discord server
@mfpears
@mfpears 2 жыл бұрын
Are you British? Why "colour"?
@NoobsDeSroobs
@NoobsDeSroobs 8 ай бұрын
Because it is correct.
I Tried Making a 3D RPG Game in JavaScript
14:19
SimonDev
Рет қаралды 1,2 МЛН
Welcome to Shaderland - An introduction to shaders in Godot
1:12:51
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 28 МЛН
Introduction to shaders: Learn the basics!
34:50
Barney Codes
Рет қаралды 340 М.
How Big Budget AAA Games Render Clouds
10:45
SimonDev
Рет қаралды 275 М.
What Is A Graphics Programmer?
30:21
Acerola
Рет қаралды 429 М.
React Three Fiber (R3F) - The Basics
1:10:56
rithmic
Рет қаралды 74 М.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Рет қаралды 1 МЛН
Intermediate Three.js Tutorial: Make a Globe with Custom Shaders
1:34:01
An introduction to Raymarching
34:03
kishimisu
Рет қаралды 143 М.
Emergency Phone Wireless Charger
0:36
IAM
Рет қаралды 1,9 МЛН
iOS 18 в реальной жизни
14:42
HUDAKOV
Рет қаралды 190 М.
Что лучше ноутбук или ПК в бюджете 100к?
0:34
Voice Changes Keypad Mobile
0:51
Nj Studio 24
Рет қаралды 1,1 МЛН