So not only do your videos show off making stuff look good in video games, but it also shows off making the illustrations in the videos themselves look good. The animations illustrating the concepts you're describing starting at around the 1:18 mark are particularly exquisite. I'm here to tell you that the time, polish, and effort you put into these videos have not gone unnoticed! Well done.
the best part of this is . . . most users of 3D creation software don't have to understand one bit of what you said . . . but we are eternally grateful that people like you do. thank you.
I've just recently discovered your channel. I've put shaders off till the end. But I think every math professor would be so jealous of your ability to explain these abstract concepts. Thank you
Maaaan, thank you for *finally* describing this in a way I can understand. I could never understand why a "flat" normal map was 0,0,1, but makes total sense now when you say we're multiplying the normal map values with the tangent/bitangent/normal.
Thank you for starting this series, I have been looking into shader writing for a while now, but it's so hard to find a collection of useful info anywhere, so thanks a ton!
Your videos are a treat to be honest, and your case study videos are eye opening to all the possibilities that can be done through shaders. How does one acquire a deep knowledge and understanding of shaders as yourself? How did you learn this stuff? There's no other channel or resource that is half as good.. and the blogs tend to be introductory, and no one tackles 2D. I hope you could shed some light.
For me the most important take-away from this is the basic explanation of why normal maps are so important and what they do. The light bulb just clicked on, "that explains a lot of things".
This shit literally blew my mind... this legit made me realise that the games I play use flattish surfaces and they just have fucking wild normal maps so it lights differently... BLEW MY MIND
This was excellent. I'm doing a adv dip including OpenGl, and this is something we've recently covered. Except yours was a much better resource than theirs. ^.^
How would one create normal data if they don't have the original objects but they do have a texture? Note: This is a technical question, not a "use application " question.
Question. Question. Question. At 4:50, shouldn't it be the ObjectToWorld matrix??? And also, shouldn't the matrix be the first parameter? Is the opposite order of the parameters what causes the matrix to be the inverse?? So many questions.....
Very good questions! I don't know why I skipped over this. We are transforming a normal, which is slightly different than just transforming a direction (that's what the math you're suggesting performs). You need to multiply a normal by the Inverse-Transpose of your model matrix to properly account for non-uniform scaling. If you look up why you have to do that you'll come across a stack overflow page with several proofs and different explanations, but the goal is to not squash/stretch your normals if you're scaling non-uniformly. Then a little trick that Unity actually uses in their cg include files, is to perform the multiplication on the right side. This is the equivalent to multiplying by the transpose from the left, except that mathematically you'd be multiplying a 3x1 matrix instead of a 1x3. But shader compilers don't care, they let you use a float3 as a column or a row contextually. So the inverse of ObjectToWorld is WorldToObject, and multiplying from the other side accounts for the transpose, which all in all gives us the effect of multiplying by the inverse-transpose. If you can assume uniform scaling, you can just use ObjectToWorld from the left-hand side as you have suggested and your normals will look just fine :)
Thanks for your response. This actually motivated me to spend 3 hours reading up about the whole matrices things. Thanks for being informative as always. Also I just made a video showing off some of the shaders I wrote. You can check it out on my channel if you want. No pressure tho.
Makin' Stuff Look Good I'm glad you like it. It looks pretty cool. It supports tessellation so you can effectively swap out the model by baking 2 different models on the same base mesh. I'll probably make a video highlighting each of them. Again thank you for your feedback :)
at 4:50 you show the matrix multiplication. shouldn't you do mul((float3x3)unity_ObjectToWorld, v.normal) instead? You use the inverse matrix which also happens to be the transpose on the right side, matrix multiplications are not commutative so while in this particular case it works and it does transforms from object to world space it might not always be the case. If I'm not mistaken unity objects scale does some weird stuff if you get it wrong, besides, its the correct way to read it.
Yeah I probably shouldn't have moved past that so fast. What you've written here will work but only for uniform scaled transforms. Right side by the inverse will work properly with scaling. It's been a while since I've looked at the proof for that, I'll try and find a good source and make an annotation. Thanks!
This was extremely informative, and i'm not even using Unity, so though I filtered and saved for later, a lot of what you said, this helps me finally GET wtf normals are, why they're the colors they are (I was like, is there some standardized gamut everyone is using?) and HOW they work. even though directionality can change by app e.g. in Keyshot vs Blendr, there's plenty of transforms and toggles to fix em. my main confusion was why they were even necessary when you have a bump map, geometry, and in some cases a displacement map. FINALLY i feel a little less dumb today. :) thank you!
Speaking of normals and lighting. I think you should enlighten developers about usage of MatCap shaders and their advantage in mobile development. I've found them extremely useful.
hey nice video but is it possible to explain why more about the blueish purple color being that color? eg. when we divide 255/2 = 127.5 = results in 128 for Red and the Green Channel in the mid value but for the blue when we divide 255/1 = 255 we get a (128,128,255) value. SO my question is is 127.5 = 128 or does the dividing the R and G channels should be 256/2 = 128? thanks
I know these might be really easy but maybe could be a quick video that gets good traffic (because of the game). Maybe you could do a quick case study on the enchanted items icons in and the end portal in Minecraft. And whatever other cool shader stuff is in that game...Can't think of any off the top of my head. Love the depth of knowledge you show on your videos ...i only understand some of it but it reveals there is a lot I didn't know i didn't know. Maybe these (what i presume to be) simple shaders or tricks would be something a broad lower level (relatively speaking to yourself) audience might want to implement and can be knocked out relatively quickly. Also maybe you could consider doing a video showing us the best way to interact with shaders via script such as turn them on/off like in the end of the pokemon dive or modify them with gui controls or through user selection, like you did in your web demo of the Spelunky shader..A unity talk on mobile optimization has me paranoid about mobile optimization..if you watch it you will understand why ahah but he talks specifically about shaders at 34:35. ua-cam.com/video/j4YAY36xjwE/v-deo.html. Maybe you could talk some about shaders and running them on mobile. Just some thoughts. Probably the most technical in depth unity information with professional content on youtube I've found . Great work hope to see more soon.
To be consistent with the rest of the video, that diagram is of a left handed coordinate, with Z point towards us and Y point up. B and C's x values are actually lower than A's. Check this: imgur.com/J73qvjn ab x ac is blue, and ac x ab is red. Sorry for the confusion!
Awesome video. learned a lot about normal mapping because you just showed it how it is. Best way I learn things :D What is that thing with the top hat? Looks like a state of the US?
@5:09 could you explain this bit more? How did you get that texture? I’d really like to be find a good way to take 3D animations and bake the, in 2d with normal maps for games.
I Have an Idea what you could analyse next. Prey's Looking Glass technology... it's basically the same as Portals in Portal but still very interesting and a shader break down would be great
If using forward rendering, why would you want to transform per fragment normals from tangent space into world space?Isn't it better to transform light direction/position from world space to tangent space instead? It would save operations in the fragment shader.
9:06 - yup I mentioned that. It's generally easier to think about and visualize the normals in world space so I explained it this way. As well, there are effects that require world normals anyway so it's good to understand how you would get them out of a normal map.
Am I just crazy or are you using Donkey Kong Country Soundtrack as background music (5:41 sounds like stickerbrush symphony)? Edit: Lol just saw the Video notes and I'm right :-)
Could you make a video on Terrain shaders? One with triplanar for dealing with texture stretching and UV resizing by distance to reduce patterns?( that would be amazing, lol). Anyway, there's hardly any info on terrain shaders for unity in the internet. Most free terrain shaders out there are 4 to 5 years old and don't work anymore. So it doesn't matter if you just want to use them or learn from them, because they just don't work anymore. So I was thinking it would be of great use for many people.
Hey! I know this is a bit off topic to your current video, but do you know of any smart way of masking off the world to only render objects that are inside a sphere? I've tried using the stencil buffer but the problem is that if you angle the camera you will continue to see the object despite of it not being physically inside the sphere... I need to achieve a type of snow globe effect, like a little world inside a sphere☺️ Thanks for the awesome videos! Keep them coming👌🏼
Not entirely sure what you're trying to achieve, but a sphere can be defined by just a point and a radius. So if you're writing/editing the shader of the objects that are within the globe, you could pass through world space positions from vertex shader and use clip/discard with the globe's point and radius.
No plans for parallax mapping in the future, but if you have GDC vault access (or you can get access through a friend/work/whatever), part of the talk "Shaders 102" covered a similar technique in Unreal. The talk as a whole is worth checking out. And stencil buffer ahhh.... I used it in my See through effects video but it's not the best use case for stencil stuff. Compelling reasons to use stencil buffer are pretty few and far between as most ways to use it can be achieved with the depth buffer already. I'll try and think of a cool way to use it for a future video hopefully!
Ah man dude, I really tried to follow along, but you are not making it eazy. Please explain more how you got these two different shaders, at 2:35. The code before that only produces the right one :( Later on with the example at 10:12 my light goes not change the shadow on the sphere. I am really trying to code along but its not working out ;_;
There is no such shader that produces the left side vs the one on the right (at least, not a shader I describe in this video). The concept being explained here is that when normals are shared at each vertex, rather than split, the interpolation that occurs inside the shader governs whether the surface appears smooth or faceted. If you wish to achieve the faceted look, the easiest way is to set your mesh to import with Calculated Normals at 0, or remove all smoothing groups in the modeling suite such. 10:12 is the end of the video, so I'm not sure which other shader you're referring to. Ultimately, this video is meant to be a description of what normals are, where they come from (mesh normals vs tangent space normals), and how they're used for basic lighting. This isn't intended as a watch-and-code sort of tutorial. That being said, all the shaders that produce the various intermittent steps are included in the github, linked in the description. I think it would be much more valuable to check out that code rather than try to infer the final shaders based on the small snippets in the video. I have received other feedback regarding resources vs. video content. In the future I think I'll call out the github link at the beginning, and recommend people follow a long with the code. Sorry for the confusion, please don't hesitate to hit me up with other questions!
How do you calculate the normal at a vertex? If a normal is usually found with a cross product, are vertex normals just averages of the normals of the faces around them?
you explained dot product and I was like "cool I wondered what exaclty dot product was doing" then you said vector to a lightsource from a vertex and it was like the techno wizzardry that is how 3d models are lit became clear.
I came here to finally understand what's a normal map... and not only I didn't understand a word... but now I am even more afraid to dig in. Yes, I had problems at school and my maths level are a that of a child, but there are a lot of people like me... we also have the right to know!! Hahahaha...
I'm a bit late, but your definition of the dot product is only true for unit vectors. The dot product of two like vectors is the square of their shared length. That being said, normals will of course be unit vectors, but I mention this for the sake of accuracy.
Makin' Stuff Look Good. I have a "ray" object with a vertex origin and a direction vertex that points off to "infinity". I know how to render this by hand by calculating a point on the "horizon", but have no idea how to model this in the form of shaders. Can you point me in any helpful direction? Thanks, I appreciate any help.
Hey man, any idea on how Hearthstone make those green energy auras around selected cards? Im not sure if it isnt just animated texture/sprites or if theres an actual fancy effect, or maybe a combination of animation + some gloom.
So, to be clear... the normal map doesn't contain raw normal vectors. It contains what percentage of the normal, tangent, and bitangent go into the final normal, and the normal and tangent will be provided in the geometry data. Is this correct?
Then I'm confused as to how moving the light to tangent space works. There, it appears the normal in the texture is the real normal. I understand that the full math behind tangent space is beyond the scope of this video, but it would have been helpful to see some sample values in the normal map, and show what the values are for the normals in world for tangent space.
I mention that around 9:00 that you can instead transform the lighting direction into tangent space and then you do a few less ALU's in your fragment code. There's an example of that in the github project. As for screen space normals, that would be the approach if you we're writing a deferred shader. If you dig into the Unity cg cinclude files they have some good examples of that!
Yeah, Unity has some support for Forward and Deferred out-of-box. In this video, we're writing a forward base pass with just one directional light. Things can of course start to get much more complicated as we support more lights/lighting features. But to keep the video from being an hour long, I tried to keep it simple :D
The tangent was a little unclear tho. Am i right if i simply say that the 3 values ib rgb are storing the vector normal to the surface. It may be relative to somthing but i cant tell. I need to give a little bit more time
I would love if you went back to the exercises you had in shaders 101, it helps reinforce what you are saying so I am not just listening along. Keep up the awesome videos though!
"I'll get into art as I recover burnout after studying computer science in university. I'm sure everything will be just very calm and no math involved. :)" (jokes aside really good video but lol)
Just my opinion but it would have been better if you used triangle for 3 point plane, as triangle is a figure which can be drawn only two ways given 3 points (the only difference is which way normal is pointing), is why it's used everywhere instead of something like a quad or hexagon, as other figures don't have the same property. Also it's not hard to calculate normals yourself, even though it's useless if you're using an engine, since it will always have a way because calculation is simple and works for any valid mesh.
There are only three points, but 4 are visualized. The fourth is actually point A reflected across BC, that's why there's no control handle for it and it moves on it's own. To visualize a plane, what I really wanted was one that stretched out to infinity like a plane actually should. But that visualization didn't read well so I changed it to a quad.
I have watched all of ur videos but i still dont quite get the distortion uv maps, you some times use the UV color maps, other examples have the normal color map... and finally som e people distorce the uv using a black and white on channel texture.. what is the diference?
Alex Andreasen most patrons have expressed no desire for additional content. Locking resources behind a paywall sort of goes against the series' goals of increasing the gamedev community's knowledge of shaders. I do want to do something special for patrons once in a while though, and am open to ideas for what you think would be cool! Right now there's just the occasional teaser, message, blooper, and sometimes early access to a video that won't be publicly published for another day or so.
I love your style :-).I shared your videos in my game dev class (I study computer science, "Game Development" is an elective class here), more specifically the pokemon battle scene transition, all people I've shown it to so far have loved it.Also very easy to implement using your downloadable asset pack :-).Thanks a bunch for helping us new to the game polishing world people out :-D
Definitely not. Shader Forge is not a plugin I would ever endorse. It's a very naive implementation and would need some serious under the hood changes to be able to make production ready shaders in. I'll be evaluation Amplify Shader Editor soon and if it's a product I think would be valuable to people I'll plan out a pros/cons video without a quick over view on using a node based editor.
So not only do your videos show off making stuff look good in video games, but it also shows off making the illustrations in the videos themselves look good. The animations illustrating the concepts you're describing starting at around the 1:18 mark are particularly exquisite.
I'm here to tell you that the time, polish, and effort you put into these videos have not gone unnoticed! Well done.
Aaron Misner
Well said
Totally agreed. In fact im curious how you produced these. Are these Unity scenes as well?
you're making a great difference for beginner shader programmers community... keep up
the best part of this is . . . most users of 3D creation software don't have to understand one bit of what you said . . . but we are eternally grateful that people like you do.
thank you.
I've just recently discovered your channel. I've put shaders off till the end. But I think every math professor would be so jealous of your ability to explain these abstract concepts. Thank you
Also, if you ever do one on linear algebra/matrix multiplication, etc, I'll be one of your biggest fans.
Maaaan, thank you for *finally* describing this in a way I can understand. I could never understand why a "flat" normal map was 0,0,1, but makes total sense now when you say we're multiplying the normal map values with the tangent/bitangent/normal.
These are high quality teaching videos.
I am doing research for my PhD and this is 10 times better than any scientific paper i have read about Mikktspace normals. Thanks a lot
awesome video dude!
the way you make your videos is perfect, don't change anything!
funny and highly educational.
Love to see new videos! Glad you still have a little free time with your new job!
Just watched your entire Shaders videos, thanks! I'm still super lost, but at least you encourage me to learn more about the subject :)
Thank you for starting this series, I have been looking into shader writing for a while now, but it's so hard to find a collection of useful info anywhere, so thanks a ton!
Your videos are a treat to be honest, and your case study videos are eye opening to all the possibilities that can be done through shaders. How does one acquire a deep knowledge and understanding of shaders as yourself? How did you learn this stuff? There's no other channel or resource that is half as good.. and the blogs tend to be introductory, and no one tackles 2D. I hope you could shed some light.
Name of the channel absolutely delivers.
Amazing video, best tutorial I could find on here that explains normal maps
I feel like such a nerd understanding and feeling gratitude for this help
finally somebody talks about how to orient the normals relative to texture coordinate
As it happens, normal maps are on my to do list for my dissertation! good timing as they're going in in a few weeks :)
Didn't understand 70% of what you just said... feels bad man.
feels bad too
thank god I'm not the only one
they say, "I can explain it to you but I can't understand it for you". The video content is perfectly explained
@@stevejones9044 for some one that alrady knows some data about it, there are many words that people would not know. Still is a good video.
For me the most important take-away from this is the basic explanation of why normal maps are so important and what they do. The light bulb just clicked on, "that explains a lot of things".
Cool, dense material but cool. I'll need to watch more of your videos.
This shit literally blew my mind... this legit made me realise that the games I play use flattish surfaces and they just have fucking wild normal maps so it lights differently... BLEW MY MIND
This was excellent.
I'm doing a adv dip including OpenGl, and this is something we've recently covered. Except yours was a much better resource than theirs. ^.^
Thank you for that. I've been 3D modeling for years and never really got it till now. Keep it up!
Omg, this video helped so much. The tutorial wasn't 90% "do this because MAATHHHHH". Thanks! :D
what a brilliant explanation....well done
Great video! Thank you. Adding the github resources is such a nice touch!
How would one create normal data if they don't have the original objects but they do have a texture? Note: This is a technical question, not a "use application " question.
Question. Question. Question. At 4:50, shouldn't it be the ObjectToWorld matrix??? And also, shouldn't the matrix be the first parameter? Is the opposite order of the parameters what causes the matrix to be the inverse?? So many questions.....
Very good questions! I don't know why I skipped over this. We are transforming a normal, which is slightly different than just transforming a direction (that's what the math you're suggesting performs). You need to multiply a normal by the Inverse-Transpose of your model matrix to properly account for non-uniform scaling. If you look up why you have to do that you'll come across a stack overflow page with several proofs and different explanations, but the goal is to not squash/stretch your normals if you're scaling non-uniformly.
Then a little trick that Unity actually uses in their cg include files, is to perform the multiplication on the right side. This is the equivalent to multiplying by the transpose from the left, except that mathematically you'd be multiplying a 3x1 matrix instead of a 1x3. But shader compilers don't care, they let you use a float3 as a column or a row contextually.
So the inverse of ObjectToWorld is WorldToObject, and multiplying from the other side accounts for the transpose, which all in all gives us the effect of multiplying by the inverse-transpose.
If you can assume uniform scaling, you can just use ObjectToWorld from the left-hand side as you have suggested and your normals will look just fine :)
Thanks for your response. This actually motivated me to spend 3 hours reading up about the whole matrices things. Thanks for being informative as always. Also I just made a video showing off some of the shaders I wrote. You can check it out on my channel if you want. No pressure tho.
Wow there's some really cool stuff in there! The mystique transition is awesome. How does that look on a more complex model?
Makin' Stuff Look Good I'm glad you like it. It looks pretty cool. It supports tessellation so you can effectively swap out the model by baking 2 different models on the same base mesh. I'll probably make a video highlighting each of them. Again thank you for your feedback :)
at 4:50 you show the matrix multiplication. shouldn't you do mul((float3x3)unity_ObjectToWorld, v.normal) instead? You use the inverse matrix which also happens to be the transpose on the right side, matrix multiplications are not commutative so while in this particular case it works and it does transforms from object to world space it might not always be the case. If I'm not mistaken unity objects scale does some weird stuff if you get it wrong, besides, its the correct way to read it.
Yeah I probably shouldn't have moved past that so fast. What you've written here will work but only for uniform scaled transforms. Right side by the inverse will work properly with scaling. It's been a while since I've looked at the proof for that, I'll try and find a good source and make an annotation. Thanks!
really? i thought i was the way around, please do share that information when you find it, I might be doing the wrong way all along without realizing
Awesome video! Would you be able to do one that shows off how Heroes of the Storm does their death & waiting-to-respawn screen effects?
Thanks for the video man, i was always to scared to dive into shaders since i'm clueless about the fundamentals but this video helps out a great deal!
This was extremely informative, and i'm not even using Unity, so though I filtered and saved for later, a lot of what you said, this helps me finally GET wtf normals are, why they're the colors they are (I was like, is there some standardized gamut everyone is using?) and HOW they work. even though directionality can change by app e.g. in Keyshot vs Blendr, there's plenty of transforms and toggles to fix em. my main confusion was why they were even necessary when you have a bump map, geometry, and in some cases a displacement map. FINALLY i feel a little less dumb today. :) thank you!
Thank You, this was very informative to me as 3d artist. Now I see what I have to look for preparing normal maps to be used in Unity.
Speaking of normals and lighting. I think you should enlighten developers about usage of MatCap shaders and their advantage in mobile development. I've found them extremely useful.
Very educational! 👏
You should do a shader case study of Super Mario 3D World. This game is FULL of little details that make the game beautiful and some are... Amazing
You are an awesome human being. Thanks for sharing knowledge! Respect.
Awsome. This is a fantastic video, thanks a lot! Subscribed
please do more! amazing work!
Great stuff. Thanks for making these.
1:41 i think it should be right hand rule, not left hand rule. or is this different in shaders?
hey nice video but is it possible to explain why more about the blueish purple color being that color? eg. when we divide 255/2 = 127.5 = results in 128 for Red and the Green Channel in the mid value but for the blue when we divide 255/1 = 255 we get a (128,128,255) value. SO my question is is 127.5 = 128 or does the dividing the R and G channels should be 256/2 = 128?
thanks
I know these might be really easy but maybe could be a quick video that gets good traffic (because of the game). Maybe you could do a quick case study on the enchanted items icons in and the end portal in Minecraft. And whatever other cool shader stuff is in that game...Can't think of any off the top of my head. Love the depth of knowledge you show on your videos ...i only understand some of it but it reveals there is a lot I didn't know i didn't know. Maybe these (what i presume to be) simple shaders or tricks would be something a broad lower level (relatively speaking to yourself) audience might want to implement and can be knocked out relatively quickly. Also maybe you could consider doing a video showing us the best way to interact with shaders via script such as turn them on/off like in the end of the pokemon dive or modify them with gui controls or through user selection, like you did in your web demo of the Spelunky shader..A unity talk on mobile optimization has me paranoid about mobile optimization..if you watch it you will understand why ahah but he talks specifically about shaders at 34:35. ua-cam.com/video/j4YAY36xjwE/v-deo.html. Maybe you could talk some about shaders and running them on mobile. Just some thoughts. Probably the most technical in depth unity information with professional content on youtube I've found . Great work hope to see more soon.
Finally, feeling good about my year of Linear algebra
The normal vectors at 1:50 are pointing in the wrong direction. ab x ac should be pointing downwards.
To be consistent with the rest of the video, that diagram is of a left handed coordinate, with Z point towards us and Y point up. B and C's x values are actually lower than A's.
Check this: imgur.com/J73qvjn
ab x ac is blue, and ac x ab is red.
Sorry for the confusion!
I see, sorry for the mistake.
Awesome video. learned a lot about normal mapping because you just showed it how it is. Best way I learn things :D What is that thing with the top hat? Looks like a state of the US?
"Tangential explanations" - I see what you did there
@5:09 could you explain this bit more? How did you get that texture? I’d really like to be find a good way to take 3D animations and bake the, in 2d with normal maps for games.
Wonderfully explained them on math. Thank you for this usefull clip.
Thank you, this was very helpful.
Normal map
This is your daily dose of Recommendation
What about a tutorial about making shaders for vfx, like the Diablo Way with multiple multiplied scrolling textures.
Excellent yes I understand everything now thank you
I Have an Idea what you could analyse next. Prey's Looking Glass technology... it's basically the same as Portals in Portal but still very interesting and a shader break down would be great
If using forward rendering, why would you want to transform per fragment normals from tangent space into world space?Isn't it better to transform light direction/position from world space to tangent space instead? It would save operations in the fragment shader.
9:06 - yup I mentioned that. It's generally easier to think about and visualize the normals in world space so I explained it this way. As well, there are effects that require world normals anyway so it's good to understand how you would get them out of a normal map.
Sorry i missed that, yeah world space normals are useful too in some situations.
Amazing vídeo!
How is the code of the shader that shows the normals of the triangles (at 3:05)?
great video !! Please keep uploading new videos
Just realised that bramble blast from donkey Kong country 2 is playing in the background
LOL HE IS ACTUALLY ALIVE
Am I just crazy or are you using Donkey Kong Country Soundtrack as background music (5:41 sounds like stickerbrush symphony)?
Edit: Lol just saw the Video notes and I'm right :-)
Could you make a video on Terrain shaders? One with triplanar for dealing with texture stretching and UV resizing by distance to reduce patterns?( that would be amazing, lol). Anyway, there's hardly any info on terrain shaders for unity in the internet. Most free terrain shaders out there are 4 to 5 years old and don't work anymore. So it doesn't matter if you just want to use them or learn from them, because they just don't work anymore. So I was thinking it would be of great use for many people.
Hey! I know this is a bit off topic to your current video, but do you know of any smart way of masking off the world to only render objects that are inside a sphere? I've tried using the stencil buffer but the problem is that if you angle the camera you will continue to see the object despite of it not being physically inside the sphere... I need to achieve a type of snow globe effect, like a little world inside a sphere☺️ Thanks for the awesome videos! Keep them coming👌🏼
Not entirely sure what you're trying to achieve, but a sphere can be defined by just a point and a radius. So if you're writing/editing the shader of the objects that are within the globe, you could pass through world space positions from vertex shader and use clip/discard with the globe's point and radius.
Amazing video! Do you plan on talking about parallax shaders in the future?
EDIT: Also, how about stencil buffer?
Both of these shaders interest me :)
No plans for parallax mapping in the future, but if you have GDC vault access (or you can get access through a friend/work/whatever), part of the talk "Shaders 102" covered a similar technique in Unreal. The talk as a whole is worth checking out.
And stencil buffer ahhh.... I used it in my See through effects video but it's not the best use case for stencil stuff. Compelling reasons to use stencil buffer are pretty few and far between as most ways to use it can be achieved with the depth buffer already. I'll try and think of a cool way to use it for a future video hopefully!
I appreciate the reply :)
Ah man dude, I really tried to follow along, but you are not making it eazy. Please explain more how you got these two different shaders, at 2:35. The code before that only produces the right one :( Later on with the example at 10:12 my light goes not change the shadow on the sphere. I am really trying to code along but its not working out ;_;
There is no such shader that produces the left side vs the one on the right (at least, not a shader I describe in this video). The concept being explained here is that when normals are shared at each vertex, rather than split, the interpolation that occurs inside the shader governs whether the surface appears smooth or faceted. If you wish to achieve the faceted look, the easiest way is to set your mesh to import with Calculated Normals at 0, or remove all smoothing groups in the modeling suite such.
10:12 is the end of the video, so I'm not sure which other shader you're referring to.
Ultimately, this video is meant to be a description of what normals are, where they come from (mesh normals vs tangent space normals), and how they're used for basic lighting. This isn't intended as a watch-and-code sort of tutorial. That being said, all the shaders that produce the various intermittent steps are included in the github, linked in the description. I think it would be much more valuable to check out that code rather than try to infer the final shaders based on the small snippets in the video.
I have received other feedback regarding resources vs. video content. In the future I think I'll call out the github link at the beginning, and recommend people follow a long with the code.
Sorry for the confusion, please don't hesitate to hit me up with other questions!
is that DK country 2 music playing??
Finally understand the dot product.
Would you consider making a video about writing shaders for text or text mesh in Unity? I've been looking for tutorials and they are non-existent.
How do you calculate the normal at a vertex? If a normal is usually found with a cross product, are vertex normals just averages of the normals of the faces around them?
vertex normals come from the input (from the triangle mesh)
you explained dot product and I was like "cool I wondered what exaclty dot product was doing" then you said vector to a lightsource from a vertex and it was like the techno wizzardry that is how 3d models are lit became clear.
I came here to finally understand what's a normal map... and not only I didn't understand a word... but now I am even more afraid to dig in. Yes, I had problems at school and my maths level are a that of a child, but there are a lot of people like me... we also have the right to know!! Hahahaha...
waiting more awesome videos for shaders and effects....It is really cool...thanks a lot (Y)
I'm a bit late, but your definition of the dot product is only true for unit vectors. The dot product of two like vectors is the square of their shared length. That being said, normals will of course be unit vectors, but I mention this for the sake of accuracy.
Makin' Stuff Look Good. I have a "ray" object with a vertex origin and a direction vertex that points off to "infinity". I know how to render this by hand by calculating a point on the "horizon", but have no idea how to model this in the form of shaders. Can you point me in any helpful direction? Thanks, I appreciate any help.
Hey man, any idea on how Hearthstone make those green energy auras around selected cards? Im not sure if it isnt just animated texture/sprites or if theres an actual fancy effect, or maybe a combination of animation + some gloom.
Can you Please Make tutorials on "Water Effects like in ori and the blind forest , RayMan" it will be very helpful :)
Can you make realistic rain drops on car windshield?
So, to be clear... the normal map doesn't contain raw normal vectors. It contains what percentage of the normal, tangent, and bitangent go into the final normal, and the normal and tangent will be provided in the geometry data. Is this correct?
Yes, that's a very good way of explaining tangent space normals! Thanks for the comment ^-^
Then I'm confused as to how moving the light to tangent space works. There, it appears the normal in the texture is the real normal. I understand that the full math behind tangent space is beyond the scope of this video, but it would have been helpful to see some sample values in the normal map, and show what the values are for the normals in world for tangent space.
You should clarify that with the dot product you're only talking about unit vectors, for example (2,2) . (2,2) = 8 not 1
while i also use unity, it would probably be helpful to also highlight where all these precalculated values like the matrices come from
bitmap texture = matrix
[Previous knowledge of texturing terms necessary to understand anything]
My brain usage reached at 15%, while watching this.
you are a GOD!!!!!!!!!!!!!!!!!!!!! THANK YOU!!!!!!!!!!!!!!!!!!
Great stuff. New subscriber!!
I like the intro
Great video but, wouldn't it be faster and more efficient to use screen space normals instead of world space?
I mention that around 9:00 that you can instead transform the lighting direction into tangent space and then you do a few less ALU's in your fragment code. There's an example of that in the github project.
As for screen space normals, that would be the approach if you we're writing a deferred shader. If you dig into the Unity cg cinclude files they have some good examples of that!
Ah. So your working with a forward render I assume?
Yeah, Unity has some support for Forward and Deferred out-of-box. In this video, we're writing a forward base pass with just one directional light. Things can of course start to get much more complicated as we support more lights/lighting features. But to keep the video from being an hour long, I tried to keep it simple :D
Ah. Are vertex shaders affected by whether or not you use a deferred or forward renderer?
Yes you'd typically write separate vert shaders for forward and deferred because they might need to pass through different data.
Omg someone who explains shit. Not just saying we put this there and that there. This is how u explain things.
The tangent was a little unclear tho. Am i right if i simply say that the 3 values ib rgb are storing the vector normal to the surface. It may be relative to somthing but i cant tell. I need to give a little bit more time
I would love if you went back to the exercises you had in shaders 101, it helps reinforce what you are saying so I am not just listening along. Keep up the awesome videos though!
Really Great!!
"I'll get into art as I recover burnout after studying computer science in university. I'm sure everything will be just very calm and no math involved. :)" (jokes aside really good video but lol)
Just my opinion but it would have been better if you used triangle for 3 point plane, as triangle is a figure which can be drawn only two ways given 3 points (the only difference is which way normal is pointing), is why it's used everywhere instead of something like a quad or hexagon, as other figures don't have the same property.
Also it's not hard to calculate normals yourself, even though it's useless if you're using an engine, since it will always have a way because calculation is simple and works for any valid mesh.
There are only three points, but 4 are visualized. The fourth is actually point A reflected across BC, that's why there's no control handle for it and it moves on it's own.
To visualize a plane, what I really wanted was one that stretched out to infinity like a plane actually should. But that visualization didn't read well so I changed it to a quad.
Which software are you using for those animations? Your Videos always look so polished
Flash for some 2D, and OBS captures from Unity for 3D.
how to make them?
which is the difference between directX and OpenGL normal format?
I have watched all of ur videos but i still dont quite get the distortion uv maps, you some times use the UV color maps, other examples have the normal color map... and finally som e people distorce the uv using a black and white on channel texture.. what is the diference?
love these
How many extra videos do Patreons get?
Alex Andreasen most patrons have expressed no desire for additional content. Locking resources behind a paywall sort of goes against the series' goals of increasing the gamedev community's knowledge of shaders.
I do want to do something special for patrons once in a while though, and am open to ideas for what you think would be cool!
Right now there's just the occasional teaser, message, blooper, and sometimes early access to a video that won't be publicly published for another day or so.
I love your style :-).I shared your videos in my game dev class (I study computer science, "Game Development" is an elective class here), more specifically the pokemon battle scene transition, all people I've shown it to so far have loved it.Also very easy to implement using your downloadable asset pack :-).Thanks a bunch for helping us new to the game polishing world people out :-D
Stickerbrush Symphony?
hello, good videos. i want to translate this one to russian, and upload on my chanel, any suggestion?
Do you have any plan to use Shader Forge for this kind of stuff?
Definitely not. Shader Forge is not a plugin I would ever endorse. It's a very naive implementation and would need some serious under the hood changes to be able to make production ready shaders in.
I'll be evaluation Amplify Shader Editor soon and if it's a product I think would be valuable to people I'll plan out a pros/cons video without a quick over view on using a node based editor.
Thank you.
I love your work dude. I'm putting a bug in .. for fur/hair shader!