Unity Shader Graph — Normal Displacement
Recently, we did some code that messed with vertex placement, but what about normals? Well, we could mess with the actual normals, but let’s start with using the normals to modify the position. We’re going to keep some of the code from the last lesson, but we’re going to remove the bit where it’s just the Y axis, and we’ll modify it so that the sine wave multiples the Normal node vector, adds it to the Position, and then outputs that to the Position.
And what’s the effect? Let’s demonstrate with a cube and with a capsule.
Well, that’s certainly amusing. And… not exactly something terribly useful at the moment. One things you may note is that the cube kind of disassembles while the capsule does the whole expanding and contracting thing. This is basically because the edges of the cube have a sharp cut-off with the vectors. If we build a cube in ProBuilder and Smoothen the normals, we’ll get something more like the capsule.
But let’s suppose that we only want things to breathe in the Y axis, as we had before? Well, this is a slightly more complex than what we did before, simply because we have more things moving in, but we can split out the Y component of our normal displacement, as well as extracting the X and Z of the original vector positions, and then combine them before sending them in.
Not bad… but I’m sure we can do something more sophisticated with this.