RAY PORTAL BSDF Node! - Tangent Space, Parallax, & View Vectors

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm not even exaggerating when I'm saying that earlier today just earlier today I was playing around with Parallax mapping which if you don't know takes like a Blain texture and adds texture coordinate offset to simulate depth that isn't really there either way I will make a tutorial about it I'm around with that and then at least I hear about it today a new node Ray portal bsdf I don't want to spoil it so I'm just going to show you what it does okay so here I have a basic scene additionally I've hidden it from I have a plane what do these have in common you may ask and what does the a portal bsdf have to do with it well here comes the big reveal what are you telling me that I just created a duplicate of the same scene in a single face yes look at this this is what the the ray portal bsdf is all about messing around with like space itself and with a bit of math I can change where the camera is even doing a cross-section relative to this plane so it can look like it's significantly below the surface somewhat below the surface or something like that this is literally Parallax mapping but not really so I found a topical I'm in 4.2 Alpha it's a new feature you got to make sure you're in Cycles this is a Cycles only effect at the moment okay so this is my basic scene let's create kind of like this Ray portal plane so this can be any object in the material I'm going to to get rid of this and add a ray portal I view it and then huh no nothing's interesting's happening in fact it's actually exactly the same as a transparent bsdf when you do not change the settings except for you can tint kind of this like window the name of the game is figuring out what direction and position do and figuring out how to exploit them I think the best way to introduce this is with an analogy so I want you to look at these incoming vectors coordinates there's a coordinate system that basically you can almost see like there's a world underneath this plane that gives us these results right so if we can understand the incoming Vector we can maybe hope to understand the other so I want you to imagine that there is a camera and it is viewing the surface here this Vector is kind of what we call incoming really incoming goes from the shading point to the camera but we multiply it by negative 1 incoming is kind of like the coordinate system that is dependent on where the camera is if we look from this angle we look at the vector that goes to that shading point now it's like a different Arrow it turns out there's this coordinate system that changes depending where you look at it from if I take my incoming and scale it by negative one so this time it goes from camera to shading point and I connect it to Direction you're going to notice that nothing changes in fact by default this is using the negative incoming Vector which gives us a hint as to what direction means direction is saying where are we looking from and then position is going to say where are we I don't only want to know which direction the camera is looking at it from but where was this point to begin with and it turns out that these two pieces of information are everything again direction is the negative incoming and position is actually the position however nobody saying we have to use these two right we have nodes so I want you to picture the scenario where we kind of have a portal but I do not want to use these default settings in fact picture this as if the plane itself was somewhere different like we moved it up or down or something like that all we need to do is we take the position where we're saying the shading points are and I can lie a little I can say h maybe they're a little up or down and all of the sudden you can see the Transformations happening and now you're starting to see a little of what's going on here and if I move it out of the way it's no longer there however if I move it down like the Y AIS we can fiddle around with the Y AIS until it shows up and now you can kind of tell the idea of what's going on here so we have access to two pieces of information where is the shading point and then the second one is where do we claim we're looking from so we can already lie about where we are can we also lie about where we are looking from so at the moment what we have is a camera in 3D space and it's actually shooting out Rays from a single point so it kind of creates this kind of like cone or triangle of a field of view instead let's say we look directly down so we somehow have this orthographic infinitely high up in the sky perspective where again this isn't the same as having a camera above looking down cuz then every Point has a bit of perspective and field of view no I want to look directly down for the direction we're not going to use the default incoming by1 instead I'm literally going to hardwire this Direction look down by -1 and you can see all of the sudden let's look back and forth we have just created orthographic using a kind of like One Direction of viewing without any perspective again this is going to be kind of locked to position but notice that when I look around the scene now right this is almost like a texture like pasted on here because regardless of where we're looking from it's not dependent on it right we don't care about the incoming anymore it's literally just always always always going to look down if I change the position you're going to see this is where it matters and also uh the rotation let's take this up another step this time I'm going to make a cube around this so this doesn't have to be just a single face by the way what I'm about to show you is a trick from Ben BB n19 let's have each of our faces kind of look inwards so this top face is going to look downwards into our monkey is going to look this way and basically every single face is going to face towards the origin in other words we're going to take our normal and we are going to invert them so remember incoming scaled by -1 is just going to look as if you know this wasn't even here I'm going to swap in coming with normal and now we have orthographic views from all six sides kind of creating a cube map here and we get that and we can also rotate the plane on which it's sitting to get all kinds of kind of like novel perspectives okay let's take this even a step further if we're looking inwards by the negative normal kind of like a natural thing to try is instead of a cube that has six sides what if we have infinitely many sides right I'm going to make a sphere that goes all the way around this I'm adding an icosphere notice by the way how weird this is looking kind of like a infinite glitched out landscape we're going to take this I'm going to shade smooth and now you can see we're getting kind of like a spherical orthographic view I'm going to get rid of that checkerboard plane so now we just have suzan in here Center this on suzan now gives us this kind of like spherize version we can also go in between perspectives so I'm going to mix these two vectors luckily in both of these cases we're multiplying by NE -1 anyways and now what we've done is we've created a transformation that can spherize any single object if I put a checkerboard texture on this and I'm going to make it relative to UV coordinates it's fully tied into these UVS and now if we look through our kind of like mirror dimension that can stretch as well okay so I'm back to this kind of like orthographic downwards projection however our position kind of updates live so the next order of business is how do I like take this little card with me as if I'm viewing the camera on a little TV screen well you'll notice that as we move our plane we are literally changing the position coordinates so here you can see that in action but in a way I almost do not want to change the position coordinates so that we can bring them with me so it needs to be invariant if we look at some of our options and there are many we have generated coordinates which seem to kind of behave the correct way um so does UV object coordinates is interesting as a first attempt let's try to use object coordinates cuz again it has the nice property where it's centered on the origin you're going to notice that there's no blue component cuz this object since it's an object space basically thinks that it's always on the XY plane this is accurate you can see it's actually reflecting the position coordinates but the moment I move it it it doesn't know that it's moved right it's always always always on the origin we can actually use this to our advantage because this is basically the plane being on the ground and then we just shift it up a little and when we take it with us right at this point when we use object coordinates it's not going to know that we even moved it so we kind of get everything we want I'm going to take object coordinates which are going to look weird what's happening is it's on the XY plane which exactly Cuts this monkey in half I want to move it upwards as if this plane was here cuz again it thinks it's on the XY plane and I'm going to add like five units to it you can see it's kind of doing this downwards projection whereas now I can take this with me so now I have this little viewing card however this does not work with rotation but in terms of location I have this nice little viewing card you can just kind of open up your window of what you can view and then you can scale this down and you can think of this as basically like a animated window an orthographic window uh that you can take with you awesome okay so now let's try to take a swing at fixing this rotation issue so remember I can move my card I can scale it but rotating it actually kind of changes the perspective and why is this rotation an issue well it's not really because of the object coordinates remember they just come along for the ride it doesn't doesn't matter what you do to this coordinate system no the issue is we are trying to look straight downwards using this orthographic normal minus one idea the normal of this is always going to update as we kind of rotate it so what what's a solution well one solution is we can just say explicitly explicitly look downwards doesn't matter what we do um that is one solution but I do want to give you kind of a more General solution in case you do want to use the inverted normals in case you have kind of like more than uh one face going on here so now we have kind of like two perspectives again you have to imagine that this is hovering above and now we're also taking a plane going this way we're good with moving but we are not good with rotating and we can't say look down cuz we have two different normals well let's look at the normal here are our normals you can see they're pointing outwards and as we rotate mesh you can see that the normals are updating accordingly right so they're pointing up and to the right now they're pointing in these new directions the normals are rotating but they're doing it together in fact if I rotate this on the xaxis by let's say 38° if I want to say imagine that those normals never changed aray portal like ah don't be invariant to rotation well all we need to do is then rotate it backwards by 38° so anything we do we kind of invert it to counterbalance this kind of thing is we can do a vector rotate I'm going to set this to Oiler because it's kind of the fastest way to do it and if we rotate by 38° I'm going to put that in right here and I'm going to click invert you can see that this actually uh fix the issue however if I rotate more now it's like let's say roughly 60° I have to type it each time you probably already know where I'm going with this I can rightclick I can copy driver past past driver you can see it's rotation and variant but only on the x-axis copy is new driver paste driver paste driver well now this is not only positionally invariant but it's also rotationally invariant so we get this little thing that we can take with us in fact I'm going to replace this mesh with basically a cube here so now we have our like six-sided projection let me just scale this bad boy down a little so it's occupying more of the space well now we can take kind of like our six-sided die and you know have it but now let's ask kind of the biggest question in my opinion which is how do we take kind of like this perfect window again it's using the default and coming by negative 1 how do we take this perfect kind of view that has perspective and everything and take it with us right we have tricks to do all sorts of things but the projection for this one ultimately depends on incoming so we can't use the normal tricks with rotating or anything like this because this is view dependent we again care about where the camera is so it's shooting out Rays what happens if I take this plane and rotate it well you can see all of the sudden these lines are kind of like intersecting in different places we've changed the entire game we would have needed to rotate the camera with this plane so that like it's kind of like tagging along for the ride and then I rotate it even more and now the camera needs to be over here we don't don't have that luxury cuz I'm viewing where I'm viewing from so what we need to do is we need to take this incoming vector and somehow redefine it in a way where if we rotate it it comes along for the ride and it always knows what shading point we're talking about this is exactly what tangent space is about so this is going to be a bit above the pay grade but I just want to show you that it's possible if this is our incoming Vector it turns out that there's a special transform Matrix take our incoming and make it invariant to how we like rotate or move this is composed of three vectors in the same way that kind of like the world space Matrix is composed of the x axis the Y AIS and the z-axis right it's these arrows but they're special the first of these is tangent and I don't mean um this tangent over here that actually calculates it cylindrically so you'll see if I view this it will look exactly the same no I'm talking about tangents that are dependent on the UV map dependent on how we rotate our UVS you're going to notice by default it's red indicating that we're going up on the xaxis in UV space you can think of as kind of like pointing right as we rotate it I guess this way it becomes fully green indicating that it's going up on the Y AIS which makes sense cuz we just rotated the thing the second Vector you've probably never heard of and it's called by tangent it's basically the combination of the tangent and the normal you take the cross product of the tangent and the normal so this is our first one we have tangent our second one is something called the B tangent and uh the third one is actually the uh normal one of them is the normal that's pointing outwards on the three-dimensional surface and then the other two are basically defined locally on the surface to flow with the UV map right but at the tip of the ear like uh here for example the normal is pointing this way and now the tangent and B tangent are pointing different way so unlike a world or an object coordinate system this one is local we can then take our incoming and then transform it using this kind of Matrix we can't actually have a matrix and shading nodes just a bunch of vectors the best we can do is take the three components of this tangent Matrix and multiply them one by one in matrix multiplication if you've taken linear algebra all you have to do is for each um pairing you take the dot product so first we take the dotproduct of tangent and hour incoming second of all we take the dotproduct of our by tangent and our incoming and then third of all we take the dotproduct of our normal which we got to make sure is actually normal and our incoming so we've done kind of three multiplications which could kind of compel you to turn it into a vector so basically we just did a matrix multiplication by hand so I'm going to connect this over here maybe the best way to think about this is that this is a node group and you can think of this node group as basically a converter and converts it to tangent Space by the way I think I got this cross product crossed up so just invert that and just like before even though this kind of handles our rotation we want to make sure we know where this is in space even if we kind of like move it off to the side this is well behaved when we pretend that it's on the ground plane using object coordinates and then we just move it up a little so we're just kind of combining our tricks here so let's say it's on the ground plane and then we move it four units up this is going to be our position we view this by the way you should probably apply scale so now we have this little thing that we can move around but we can also rotate at this time and if I kind of play with this number you can think of this as the depth in the scene so let me put this down here now we kind of have our copy that we can rotate and view the way you would expect that works in nice little tangent space so again it was very ironic that this thing came out maybe it came out a day or two ago but it came out right after I finished my Parallax mapping thing by the way you should pick it up I'll do a tutorial on it not dependent on a height map which is good in some ways bad in others there you go new node hopefully this helped explain it or made you even more confused
Info
Channel: Default Cube
Views: 49,174
Rating: undefined out of 5
Keywords: ray portal node, ray portal, ray portal bsdf, shading, blender shading, blender parallax, parallax material, blender 4.2
Id: kOCIEoezyJo
Channel Id: undefined
Length: 18min 2sec (1082 seconds)
Published: Thu May 02 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.