Using Height Maps and Pixel Displacements in Unity

How can we turn a texture into a heightmap? Let's see how!


I have a stone material placed in my scene that needs a heightmap. Normals alone do not help much as you can see below.


The image below is the albedo texture of the material.

We need to open it in Photoshop.

Once open, go to: Filter > 3D > Generate Bump (Height) map.

A window panel will pop up.

You can adjust the detail scale if you wish. I put mine to 100 percent. Our Height map will look a bit blurry with soft black and white colors.

Save your heightmap into your Unity’s project folder.

Pixel Displacement

Next, we need to setup up our material in Unity to accept a heightmap. Click on the material, and in the inspector, click on “Displacement Mode” and select “Pixel Displacement.”

It will open the option to attach a heightmap. Drag the heightmap into the box.

Now we can see the effects!

With Displacement:

Without Displacement:

You can tell that there is more depth with the heightmap. If you play around with the amplitude, you can find the perfect adjustment.

Between 1–3 of amplitude, I found best. Yours might be different depending on the texture. Displacement maps are best used on 3D planes. If you were to use them on models such as a simple box, the displacement will break it apart.

Vertex Displacement

We could also switch to Vertex Displacement to see if it adds a better look to our plane mesh.

When we switch “Displacement Mode” to “Vertex Displacement,” we have more options to play around with where “Amplitude” was located underneath Heightmaps.

It will create vertices on the plane so we can raise/lower the mesh with min/max. Down below, you can see the effect.

As you can see, it could be a nice touch for a certain area in a scene that requires more depth. I wouldn’t recommend using Vertex Displacement for all of your displacement needs but use them wisely for performance sake.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store