Displace terrain mesh with a heightmap in 3ds Max.
- [Instructor] Modeling convincing terrains can be challenging in 3ds Max, because with the polygon object, there's no way to adaptively tesselate the model based upon screen size. In other words in some programs you have the ability to divide up an object into triangles so that near object polygons are smaller in absolute world size than polygons that are distant. And in 3ds Max there's no method for that.
However, we do have an alternate method which is to use a ground plane, which is a plane primitive that can render at higher density at render time, and additionally we can use a space warp, or world space modifier, to displace that plane in world space based upon a height map, and that's what we see here in this image, which is actually stolen from another course, which is 3ds Max: Rendering with Arnold.
In this demo, we'll look at how I created the ground terrain here. All right so let's go into 3ds Max and take a look. Here's the scene in which we simply have that architectural dome, and a camera, and now we need a ground plane. Let's go into the Create panel. Under Geometry, Standard Primitives, Plane. Click and drag in the top viewport, release the mouse and right-click to complete the tool.
Go over to the Modify panel with that object still selected, and rename it. I'll call it terrain. Also, change its color to a neutral gray. Let's setup its parameters. The beauty of this technique is that we can change the length, width, the density, and position and rotation of the object at any point in the future, but because we're going to use a world space modifier, the height map will be locked to the world, and that will give us the ability to position the ground plane anywhere we want, so that we maximize the polygon density within the camera field of view.
I'll set the length here to 2,500 meters. The width also to 2,500 meters. To give us enough level of detail to visualize what this model will look like in the viewports, we need to increase the length and width segments. Let's set those each to 500. And we have a total number of faces here of 500,000, but that won't be enough for a production rendering.
But because this is a plane primitive, we can increase the density, or level of detail, at render time. Let's set the density to a value of five. And now we have a total number of faces here of 12.5 million. We're generating default mapping coordinates for the plane, but we're not using the real-world map size option. So we've got our plane created, and as I said a moment ago, we can position and rotate that anywhere we want. I'll dolly back here in the top viewport with the mouse wheel, and use the middle mouse button to pan around.
I can position this so that it basically fills the camera field of view, and I can rotate it a bit too. All right so I've got the ground plane for the terrain. Can dolly back here in the perspective view as well. Let's now create the world space modifier to displace the ground plane. Go back into the Create panel, and under Space Warps, in the Forces section, we have Displace.
Click that and then click and drag in the viewport to create the object. Right-click to exit the tool. With the space warp object still selected, go to the Modify panel, and scroll down a little bit. Very importantly we want to make sure that we're using a Planar projection, and we want to set the length and width. These values will determine the size of the image that we're going to use for the height map. We'll set the length to 2,500 meters once again.
And the width to 2,500 meters. We want to position it right at the origin. I've still got the Move tool active, and I'll set the X position value to zero, and likewise the Y position to zero. Now as we look at it in the top view, notice that the displace space warp icon is much larger than the terrain object. Even though in both cases we entered in a length and width of 2,500 meters.
It's just a quirk of the displace space warp that it's actually going to be twice as long and twice as wide as the values we plug in here. So in fact this is 5,000 meters, or five kilometers on a side. And that's quadruple the surface area of the plane. Okay so that's there, and now we need to assign the bitmap. That is here. Under Parameters, Image, Bitmap. Click on None, and in the current project's sceneassets images, I've already got a height map, and it's labeled heightmap_desert_mesas_4096x4096.exr.
That's a grayscale image, and it's actually a 32 bit floating point EXR, so it will have a great deal of accuracy to the displacement effect. Click Open, and we get the OpenEXR Configuration dialog. We don't need to change anything here so we can just click OK. And we see the bitmap is now applied in the displace object parameters. You see up at the top of the parameters, we have a Strength, and we can increase that to apply more displacement, or deviation to the polygons.
However, we won't get any effect unless we bind the object to the space warp. Up here on the main toolbar, we've got a button labeled Bind to Space Warp. Click that button, and then click on the terrain plane object and hold the mouse down, and drag over onto the space warp and release the mouse. Now that binding has been made, and if the plane is selected, we will see that in the modifier list. We have Displace Binding WSM, or world space modifier.
Now we can reselect that displace space warp and go back to the Move tool, and now finally we can increase the strength. It'll need to be quite a high value here. As I click and drag on the spinner and drag that up, really I don't see much happening here, so I'll need to increase this up quite a lot. Maybe a value of 1,000. Now we can see we're getting some displacement. In fact I know what I want here because I've already experimented with this scene. I'll set the strength to 1,390.
And let's take a look at this in the perspective view. Middle mouse to pan, and mouse wheel to dolly back. Alt + Middle Mouse to tumble. We can see that the terrain is floating above the ground. We can fix that through adjusting the Luminance Center value here, and that's just going to bias the displace effect up or down. Enable Luminance Center, and as we click and drag on the Center spinner, we can move that object up and down.
I'll set it to a value of 0.43 in this case. And we're still not quite there yet. We want to move the plane itself, so select that plane, and with the Move tool selected, set the Z position to negative 177 meters, and now it's positioned roughly where we need it to be in elevation. Okay, and now the magic happens. As we move the terrain object around, notice that the displacement is constant in world space.
So we can position this anywhere we need it to be in order to fill the camera field of view. Very cool. So we can go back to the displace space warp, reselect that, and there are a couple other little things in here. A height map is a pixel-based image, and it may be a little bit jagged. You might see some strange artifacting, especially for a very large object. You can mitigate that a little bit with this parameter down here, which is labeled Blur. If we click and drag on that spinner, we can increase the amount of blur.
If I give it a low value of, let's say 0.1 or so, we can see that it sort of softens this up a little bit. I'm going to give it a very small blur amount of .001. That's just enough to soften up the mesh, so that when we render this, it will look nice and clean. Okay, so that's basically the technique. We can now position this ground plane anywhere we need it to be, and the displacement will be stuck to the world.
By positioning the object so that it just fills the camera field of view, we can optimize the level of detail, so that we're not loading down our scene with way too many polygons. Now there is no material currently on the object, so let's assign that. I've got it in the Material Editor. Go into the Material Editor, and use the middle mouse button to pan around in the view. You're looking for the material labeled terrain. Then click and drag from the output of that terrain material node onto the object in the viewport, and because I previously enabled Show Shaded Material in Viewport for that material node, we actually get a bitmap image applied to the diffuse, and also to the bump.
I'll close the Material Editor, and now when we move the terrain around, notice that the displacement is happening in world space, but unfortunately the texture is stuck to the object, in object space. If we want the ability to move the plane around and maintain the mapping in world space, we'll need to use a different technique. We'll look at that in the next installment of the course, and that will be all about using the camera map world space modifier.
But that's the basics of using a displace space warp to apply a height map in world space.