Unity Shader Graph — Position Displacement

Sean Duggan
3 min readJan 5, 2024

--

Along with tricks like changing colors, we can also change where our object appears to be by messing with the Vertex outputs. Let’s look a base case. We can get the Position of each point on our object by setting up a Position input. Plugging that directly into our Vertex Position does absolutely nothing because we’re just reasserting the values.

But what if we set things up so that there was a sine-wave displacement by adding a Time node that outputs its Sine Time into an Add node that then goes into the Position?

As you can see, this creates a situation where the appearance of the object is displaced off of its collider in a nice convenient way. We can even use a Splitter node combined with a Vector3 node to isolate it to the Y component.

If we wanted to control the speed, we could introduce a float Speed input, which we could multiply Time’s Time output and feed it into a Sine node.

Lastly, we could define an Amplitude to control how much it bobs.

One thing to note is that this changes the appearance of the object, but does not affect its collider, which means that, if the camera can’t “see” the collider based on the angle, it will generally cull the object, even if the displacement means it ought to be visible.

--

--