Light Path Node Demystified and Visualized in Blender

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
have you ever wondered what the light path node does well in today's video we're going to break down every single output and how you can use it and why everything works it's a really underrated note however there are a few caveats which we'll explain the first thing that we need to know is that there's two types of rendering engines the first type is called Ray tracing and the second type is a rasterizing engine now an example of a ray tracing engine is cycles and rasterizing is easy now these render out scenes in completely different ways which you have to understand to make the most out of the light path node so in Ray tracing suppose you do have your camera present over here the camera has different pixels present and it's going to shootout array for every single Pixel now for each pixel the number of race that it shoots out is equivalent to the number of samples that you have so each pixel if you have 32 samples it's going to actually shoot out 32 different rays in random directions this Ray is then going to interact with your scene so all of the different objects that you might have along with all the lights and stuff and it's going to actually bounce it's going to maybe hit this surface and then bounce and hit the light and things like that and after all of the bounces whatever the value is is going to be registered and when you take 32 samples it's going to do that 32 times and average that out to get the actual value or color for that pixel of course this was a much simplified explanation but this is the base concept for Ray tracing on the other hand rasterizing involves going in the exact opposite direction so if you do have your camera present here it is your C that's going to be casting out light that directly goes and hits the camera in the individual pixels that are present so that's why things that are present behind objects are completely hidden out from the camera and they don't even interact with these objects which is why EV does not produce realistic results and even if you do have some sort of Reflections occurring they have to be faked using screen space Reflections and things like that which have to be enabled separately and even those are not too realistic but they just get the job done for stylistic renders however because there isn't any bouncing around and things like that it happens much faster and that's why EV is a real-time engine and it happens so Event Route in less than a second on the other hand Cycles takes a long time to render because it has to shoot out all of these Rays they have to undergo the bounces and then it has to average out the value the light path note makes use of all of these bounces and can manipulate each of these Rays based on what the ray is actually doing so now let's talk about the types of rays that are present in blender or Cycles at least there are four major types of rays the first one is a camera array the second one is a reflection Ray the third one is transmission and the fourth type is Shadow so suppose we have the camera and we have a few objects present on our scene so we just have one sphere present here and we have a light source over here when our camera shoots out array this first Ray that comes out is called the camera array so the label camera array as one two three and four and we'll Point those out over here so this is a camera array similarly every other Ray that directly comes out from the camera and hits any object whatsoever is always going to be a camera array itself but as we said these Rays interact with the objects and then move around so any object is always going to actually reflect off phrase so this way that has been reflected off of this object is going to be a reflection array similarly when we have array that comes off of some surface and has to pass through another object to get to a light source this particular Ray that we have is going to be a shadow array because essentially this light source is going to be casting a shadow and this particular day is going to be within that shadow so this way is the shadow Ray transmission Ray is what we'd get if this object was slightly transparent or translucent so let's say we had a camera array like this to an object like this which is maybe a glass block this Ray is going to actually refract and pass through this block so this refracted Ray is going to be a transmission Ray now each of these Rays can have different properties specifically for the reflection and transmission Rays because when this Ray gets reflected it could be reflected off of two types of materials either a nice glossy material like a mirror or anything that produces specular Reflections or it could come off of a diffuse material like a rock or something like that and the material does not have to be perfectly diffused or perfectly glossy it could be anywhere in between so the reflection Ray is going to have three different properties the properties that it has is diffuse glossy or singular so diffuse implies that the ray that came out is coming off of a material that has some amount of roughness to it and hence the ray that came out is not going to be following the laws of specular reflection and this angle is not going to necessarily be equal to this angle so it'll come out in random directions glossy is how well the light is actually following the law of reflection where this angle is always going to be equal to this angle and these two are essentially a measure of how diffuse it is or how glossy it is on the other hand singular is simply going to be a true or false value which means it's going to return a value of 0 or 1 where it's going to be 0 if it's not completely glossy or completely reflective so in case of reflection it will give out a value of 1 if it is perfectly glossy if there's absolutely zero roughness on the surface and it is 100 glossy the singular law will give out a value of 1. so the same three properties is present for transmission as well diffuse glossy and singular so diffuse and glossy are the same as before except the difference is that in transmission the light Ray is actually going to pass through the material and of course if there's some amount of roughness it's going to have slight variations in these angles which is going to make it diffuse glossy is going to be perfectly following Snell's law which implies that the ior will perfectly determine the angle at which the light Ray comes out of the object and singular implies it is perfectly transparent which means there's no amount of roughness present in this particular object so those are the different types of rays and how they're used but just like before the best way to actually understand this is by looking at examples but before we get to the examples you need to know that because EV is a rasterizing engine and all of these different light paths aren't even present the light path node has major limitations we can't directly use the EV engine for most applications except for the is camera array for everything else there are a few workarounds we'll explain that at the end of the video and with that let's actually start off the examples so here I have a scene where we've already switched the render engine to Cycles I have the sample set at a very low amount to four because my laptop can't really handle cycles that well but four Cycles with denoising yields good enough results for the actual scene I have two planes present behind Suzanne and I have a cube in front as well as a floor plane I also have a light source present behind Suzanne which is lighting up the entire scene and the world background is kept white this play if you actually look at the material is completely metallic with a very low roughness which means it's more or less glossy and reflective this plane has a metallic value of zero and a roughness value of one which means it's completely diffused instead of the principle pstf for both of these you could have simply used a glossy bsdf for this one and the diffuse bsdf for this one but using the principled psdf is fine enough for this block in front we want it to be glass so we've gone ahead and increased transmission all the way to one and has reduced the roughness down to 0.1 as well again we could have just used the glass psdf and that would have worked just as well now the entire effect is going to come out from the material that we add onto Suzanne so let's press 0 to go into our camera view and go back to our rendered View and let's press this plus button to give Suzanne a new material the main way we can use the light path node is by mixing out different shaders so let's remove the principle to psdf and search for a diffuse bsdf and directly plug this into the surface and change the color to whatever we want so let's say that the base color is going to be this bluish color now the reason why I'm using these colors is so that it's very easily noticeable right now you can see that the blue color is being reflected off of this plane and it's passing through this glass and even on this diffused surface there's a little hint of blue happening around the ears and things like that I don't know how well you'll be able to see this with YouTube's compression but it is slightly present now we can press shift a and search for a mix Shader node plug that in here and use a different color as the second Shader so let's make this one the exact opposite of red now when we plug this in we're going to get a mixture of both the colors based on this factor and because they're Polar Opposites we're going to get white because we get the mid value of this which is white right here however we can press shift a and search for a light path node and start playing around with each of these values so let's take this is camera array and plug it into the factor and now you can see if array is coming directly from the camera and hitting the object the value is going to be 1 so we get this diffused output on the other hand all of these colors that are coming through the glass or through the reflection are first going through the glass and converting into a transmission Ray or in this case it's hitting the plane and converting into a reflection way and that's why this no longer sees this value but it sees the diffuse value this is the one thing that works even if you are on EV and that's pretty cool but let's say I want the shadow to have a different color so instead of the is camera array I can take the is Shadow array and plug that into the factor to actually make the shadow a different color instead of the diffuse down here we're going to have to use a transparent bsdf so we can plug this into the Shader and if we change the color to maybe green you can see that if any Shadow is present the shadow is going to have a greenish tint so if you actually see there are shadows being created around the ear region and even in the reflections all of the Shadows are always going to be green so that's how you use the is Shadow Ray if you want to use the diffuse Ray you can plug that in and we have to plug the diffuse back into the Shader so that we have the diffuse nodes going into the different shaders and the is diffuse Ray going into the factor you'll now see that there's a bit of red present through the transmission as well as through the reflection so those red regions or the areas where there's some amount of diffuse Reflections occurring if we hide away the cube you can see the reflections occurring from the floor plane even more for the floor we can just add in a nice diffuse material and you can see any gray that's actually hitting the Suzanne after bouncing off the floor is going to get this reddish color so now let's use the is glossy array here you can see the Rays that are reflected off of the glossy surface as well as The Slight glossy Reflections that are occurring through the transmission are both going to be red similarly if if we take the is singular array and plug that into the factor you see nothing takes on this diffuse value because for each of these materials we see there's a little bit of roughness and if there's a little bit of roughness there's a little bit of diffuse within it on the other hand if you simply take this roughness and make it zero it's going to become a singular array because it's purely reflective and that's why it becomes one we can do the exact same thing with the glass block that we have reduce the roughness down to zero and it instantly becomes red and takes on the other values but as long as there's any amount of roughness it's not going to be a single array anymore it's going to have a mix of some amount of diffuse and some amount of glossiness now we can use the is reflection Ray and that way only if it's a reflection Ray it's going to take on this red value so you can see even though there's transmission over here because we're no longer looking at glossiness and we're looking at only reflection Ray we get only the reflected area to be red similarly if we switch this to its transmission Ray only the area that goes through the glass is going to actually come out to be red now we can actually look at the ray length if you cut the ray length into the factor we get something weird so the way we have to understand this is that the ray length is not going between zero to one but it actually just depends on how far away the length is traveling or the braid is traveling so let's say we had one Ray that's going just like this if this is going through five meters the length is going to be 5 meters long since this mixed Shader is going between a value of 0 for this and a value of one for this essentially if anything is less than one meter or the ray is less than one meter it's going to take on this and if it's greater than one meter it's going to take on this so in our camera view we can see that Suzanne is very far away from the camera and that's why it's going to take on this value because it's getting clamped at one itself so it takes this value on the other hand the length of the ray that's going between the glossy surface to Suzanne is actually less than one meter and that's why we see that it is blue over here similarly for the reflection just this ear region is very close to the ear and less than one meter and that's why this Ray length is actually less than one and that's why it's taking on this diffuse but as we go for further away the reflection Ray is a lot longer and hence it takes this but you can control this easily using either a map range node or simply taking a math node and switching this from add to divide now if we divide it by a larger value you can see how we get even more region to become blue and we got a transition like that so if we were to take this and just grab it on the y-axis and move it further away from Suzanne so that it's greater than 2 meters if we look through it it's still going to be red but as we move it closer to Suzanne because the ray length is starting to decrease between this glass block and Suzanne it's going to slowly transition from red to blue and you can actually get pretty cool Effects by animating things like that you could potentially use this Ray length in many more ways but I'll leave that up to you the next thing is Ray depth Now red depth determines how many times there's actually been some sort of Reflections or Transmissions or how many times it's interacted with different surfaces after it exited the camera so since this is an integer we can actually control this using another math node and we'll switch it to subtract so right now if we subtract a value of Z 0 if the ray depth is 0 it's going to take in this value and that means because these regions are directly coming from the camera and hitting Suzanne it's going to take on this one but all of these Reflections Transmissions the ray already interacted with a different object and that's why it's taking this on the other hand suppose I subtract a value of 1. this region remains red because it's actually interacting with two surfaces on the glass the glass block actually has thickness so there are two surfaces that it refracts off of and that's why it's still red if you switch the value to two you see just these edges have the red tint because those regions actually had three bounces before it actually hit Suzanne so light went in bounced around three times and then hit Suzanne you can control how many times the light can bounce around in your render settings itself under light paths so you can see for me under glossy I can have a maximum of four bounces and for transmission I can have a maximum of 12 ounces so if I reduce this down to one there's going to be very few bounces and that's why this darkens off really really fast on the other had this will actually help me render much faster so you have to strike a balance between what's necessary and what's not to get perfect render speeds but essentially the way depth is going to have a maximum value based on this value over here if this value is kept down at four or five the max Ray depth is also going to be four or five similarly if we take this plane and actually make this one completely metallic with low roughness and let's rotate it a bit more you can see that on this particular surface we have a reflection of the reflection so because we have a reflection of the reflection when we subtract a value of 1 we get a ray depth of two so we can change the subtract value to 1 and because the ray depth is 2 in this case because it is reflecting off of this right hand side mirror and then hitting the left hand side mirror it actually has a rate up of two so if you subtract one we get a factor of one and it takes on this particular diffused value so that's why this becomes perfectly red so if you had even more Reflections occurring such as an infinite mirror you could have them continuously changing colors we'll deal with that in a while however there's also this diffuse depth and glossy depth which are the exact same things which is the number of bounces but only for diffuse materials and for glossy materials so if we go to this diffuse depth remember our Suzanne is diffused we can subtract a value of zero and now whenever there's one diffuse reflection such as over here it's going to take on the reddish value so all of these Reflections have this reddish value in the diffuse section over here glossy depth is for all of the glossy materials so anything that has glossiness is going to take on a value of 2 we can subtract a value of one and that way only the second Reflections are going to take on the red value second and above so second third fourth and so on and so forth if we change the value to 2 only the third Reflections are going to take on that value but in this case everything reflects at most twice so nothing becomes red now we have a transparent depth which is actually very very useful so right now we don't have any transparent materials present remember transparent is different from transmission so even if we do have this glass plane it's not considered as a transparent material so let's just add that in by pressing shift a and adding a plane we'll press RX 90 gz and we'll just bring it in front of Suzanne so now we have this plane present right here we'll press this new button to give it a new material and we'll delete the principle psdf and instead we'll search for a transparent bsdf now when we plug this in it should become completely invisible however if we were to now select Suzanne and directly plug transmission depth into the mix Shader wherever a light Ray is passing through any transparent material the value increments by one so in this case because there's only one transparent material the value becomes red over here if you take this same transparent plane and press shift d y and bring it further in front for our Suzanne material we can actually duplicate this mix Shader plug it in here we'll subtract a value of 1 and plug this into this factor and take this diffuse press shift d and change this to maybe a yellow color and plug it into the Shader so now whenever a light tray is going through two different transparent planes it's going to take on this yellow value otherwise it's going to take on this red value and if it's not going through any transparent plane it's going to take on this blue value so that is pretty cool because the transparent planes cannot be seen but you can use it to create really fun effects by just moving your camera around so if you just shift our camera you can see how the actual colors are changing as well and you could create very trippy animations using this technique and this setup can actually be used for any of these versions as well so maybe instead of this is transparently I can say if it's a shadow Ray I want the Shadows to be red but if it's a glossy array I want it to be yellow remember we need to use a transparent bstf to give the color for the Shadows so let's plug this into the Shader and that way you have red Shadows being cast from a blue object that gives yellow color Reflections so that's super cool but you can make it even better let's say you don't want any Reflections to occur for Suzanne but you want the reflections of other objects in your scene to be present so let's add in maybe another UV sphere let's just scale down and move it here we'll give it a nice red material and now there's a reflection occurring for this UV sphere but I don't want Suzanne's reflection to occur so what I can do is select the Suzanne material and now I say if it's a glossy Ray I just make it completely transparent so duplicate the transparent node make it completely white and plug this into the second Shader for this mix Shader node so now Suzanne does not have any deflections but this ball does have its Reflections and similarly because it's an is glossy Ray Suzanne also does not pass through this particular glass block if I wanted to only not be present in Reflections I can choose is reflection Ray and plug that into the mix Shader so that's how you can actually combine these to create really cool effects and have each thing separate for each effect that you want transmission depth is the same thing as diffuse depth and glossy depth and you can use it based on your transmission so let's select the Suzanne material and just use transmission depth into the factor so that way if it's going through one single transmission it's going to take a value of 1 and suppose we have two of these blocks so let's press shift d y and just bring it in front we can add in a math node switch it to subtract and if we subtract a value of 1 we're still going to get yellow because remember there are multiple surfaces that this is interacting with so it's going to have to go through one two three four different faces before it reaches Suzanne so we actually have to subtract a value of 4 and that way it'll become completely blue even if you subtract a value of 3 we'll have yellow color because the transmission depth is 4 for this case but just like before we can add in mixed shaders let's duplicate this diffuse make it red plug this in and let's take this output and plug it in here and by playing around with these math nodes you can see that if we have a transmission depth of 2 it's going to have in this yellow value if you have a transmission depth of 4 it's going to take on this red value and we can actually change all of these up to create various effects so that was every single output when we're actually using the Cycles Render engine but what happens when we switch to EV instantly everything becomes very Bland so let's just delete the things that we don't require and make sure that you have screen space Reflections and refraction switched on and for for every one of these materials you're gonna have to go to the material properties and switch the blend mode to actually make it refractive and now we have a glass block that we can see Suzanne through you have to make sure screen space Reflections are switched on as well and this is what we have however with Suzanne none of these notes actually work and there's a few things that we have to set up before we do that but the first thing that works directly is the is camera array so let's say Suzanne is supposed to be blue if we take this is camera and plug it into the factory of the mix Shader and mix it in with red we're going to see Suzanne as red but unlike before all of the reflections as well as the refractions are all going to be read as well because again this is a rasterizing engine and so screen space Reflections and refractions and all of that is faked based on what the camera sees so if the camera is seeing red no matter what the actual colors are the reflections and refractions are also going to be red so that way the best way we can use the ace camera array is if we actually use it in the world properties where we can add in two different backgrounds which are going to help light the scene but if it's a camera array the camera will be something else so let's search for a mix Shader plug the two backgrounds in and then a light path node and take the is camera array and plug that into the factor so that way everything is being lit using this one but our camera is going to see the background as black so that's very useful for Ev but let's look at what else can be done with Suzanne if you want to use any of these other values like the is Shadow array diffuse Ray glossary and things like that the first thing that we have to do is use something called an irradiance volume so we go to light probe and choose irradiance volume and now if we switch on overlays we can see what it looks like so this will help us bake the indirect lighting so let's just scale it up so that everything within our scene fits and now we can go to our render properties go down to indirect lighting and just choose big indirect lighting so when we bake indirect lighting we can't actually make changes to objects that are present in the scene without messing up the indirect lighting that has been created so once you've baked in the indirect lighting if you want to actually have the reflections as something else so let's select Suzanne and let's say if it's a glossy array we want it to be red otherwise we want it to be blue it's itself you'll see that it doesn't work with screen space Reflections however if you just hide this Cube take this plane and change it to a reflective surface like glossy plug that into the surface reduce the roughness and then press shift a and search for a light probe reflection plane we can just scale this up and press gz to position it you can see that the Reflection from the reflection plane is going to now be red so that's the only way you can actually use this is glossy Ray and things like that if singular array does not work and all of these reflection Ray is the same as just is glossy Ray and so on and so forth gray depth does not have a value similarly Ray length doesn't work too well Ray depth takes in the day depth while the direct lighting was baked and things like that I haven't been able to successfully use these too well so it's really up to you to experiment and figure out but that was the basis for this node in cycles and the little bit that you could do in Eevee I hope this was useful and you're able to create really cool animations and things like that using this technique and definitely if you use Cycles then the light path node is a must use you can create abstract animations and even ghostly characteristics and things like that with this note and I'd really like to see all the different ideas you all come up with if you like this one I have another video where I explain the vector math node definitely check that out and I post videos every single day so I'm sure you're going to find something or the other on my channel informative and useful so until my next video comes out tomorrow keep creating and don't forget just stay creative
Info
Channel: Deayan Studios
Views: 40,145
Rating: undefined out of 5
Keywords: blender, blender timelapse, blender animation, satisfying, satisfying video, satisfying animation, render, blender tutorial, blender beginner tutorial, blender 3d, abstract, Circles, graphic design, sci fi, simple, eevee, geometry nodes, procedural, light path node, light path, raytracing, cycles
Id: LyJTsmvyZko
Channel Id: undefined
Length: 23min 25sec (1405 seconds)
Published: Thu Sep 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.