Vertex and Pixel Displacement HDRP
In this article I want to cover something really cool you can do in HDRP.
HDRP really excels in realistic environments. I’m going to show you how you can use a height map to make a flat surface appear to be uneven. I’ll be using a stone texture from filebase.
Once I’ve chosen the texture I want to use, I’ll simply create a Plane gameobject by right clicking in the hierarchy and navigating to 3D Objects > Plane.
Now I want to apply the stone material to the plane. If you’re following along, be sure to convert your built in materials to HDRP materials so they arent pink. Not sure how to do that? Check out this article:
After converting I simply drag the stone texture onto the plane and the plane looks like this:
Getting pretty close to it, you can see the texture already looks pretty great, but I’m going to showcase how to make it look better.
Right now its flat. Looking at it from a certain angle, you can tell that its obviously flat.
First I’m gonna bring the color of the base map down a little so it isnt so bright. THen I’ll play around with some of the sliders. Smoothnes Remapping deals with how much light is reflected off the surface. You can see the change when I move the slider here:
Messing around with some of the values here can yield some great results, but I really want to get into mesh displacement.
Check out the Displacement Mode option in the material. You can see there are 2 options. Pixel Displacement and Vertex Displacement. You need a height map for this. I’ll go over how to make a height map real quick. Im not going to act like I’m a height map expert or anything, but I’ll be using GIMP since I dont own Photoshop.
Drag the base map into GIMP.
Now I’m going to navigate to the image menu > mode > then select grayscale.
The image should now look like this:
After that go to Color at the top and select Levels. i set mine to something like this:
Now it looks like this. I export it back into Unity now.
We want to have some dark areas, some light areas, and some inbetwen areas.
Now I want to cover Pixel Displacement first: So Select pixel displacement as the displacement mode. You’ll notice some new options appear in the material.
My height map asnt AWESOME, but now you can see that the texture looks 3D!
You can adjust the new sliders for min and max steps to adjust how far away the camera has to be before the height map fades away and get super detailed with that. With awesome artists on your team, your height maps will always make your coblestone paths look super nice.
With Vertex displacement you’re literally changing the height of specific points (vertices). Each object in Unity will have vertices. To see them you can enable the wireframe of the object in the gizmos tab.
So slecting Vertex Displacement will allow you to adjust the actual physical height of specific points dependant on that height map.
How useful is this compared to Pixel Displacement? It really depends on your game/application. I can see this being super useful for maybe larger areas of terrain where you’ve got hills, while pixel displacement would be more useful for smaller areas where you need a bit more detail.
Another use I could see vertex displacement having is maybe a watery area. Maybe you’re character is on a ship in the ocean and the vertexes are constantly moving around and you could set a minimum and maximum displacement to tame the water. Maybe! Its totally up to you.