I was asked to create a terrain modifier tool that can mimic the Slope Landscape Tool in Unreal. They wanted to take an existing heightmap from World Machine, Houdini, Unreal, Unity, etc, and modify it in either Houdini or Maya. This gave them the ability to design different areas of the map and then export the heightfield back to Unreal.
You can input three different types of terrains. A heightfield, geometry and Houdini terrain. There are options to set the density, height and size of the terrain to match your inputs. The path options give you the ability to set a custom width for your path, create intermediate levels, and curve around the existing the terrain. *This part is needed since there are a lot of walkways along cliffs in our game.
We discovered later on that these landscapes were a bit heavy on the computer. The tool was reworked to only affect the area needed and then subdivide the area after it was finished. This gave us clean and crisp heightmaps.
Another option is the ability to bake vertex colors in the of the new slope to assign the correct material in Unreal.
The last tab in the asset is the ability to export the various heightmaps.
While this tool seems very simple, it really helped with level design and getting assets in the right area. We are a very small team of 6 at the moment and try to keep everything as easy as possible.
A couple of notes: Don't use a Point SOP, it is not multi-threaded. Use an Attribute Wrangle, it is multi-threaded.
Here are my terrain inputs, marked in Blue. I cannot stress enough what a clean network will do for later on in development. It is very difficult getting another digital asset with nothing commented, colored, or organized. It can be messy at times.
Here are my inputs for for the curve. The width of the slope is controlled with the length of the line. Input is marked in Blue, the same as the terrain inputs. I also have some options set to resample the curve if needed. The polyframe is used to set the normals of each point.
This is where we have fun. We set an initial color for the terrain with an Attribute Wrangle. Mental Note: Do not use a Point SOP. The lazy way of setting the terrain to black.
Setting the curve mesh color is a bit different and yet still simple. This will set it to Red. This is important later on, since we are also going to a group based on this color. We can then isolate that area and make more modifications.
I connect the two with an Attribute Transfer. The Cd value is added to the Primitives and everything else is unchecked. The Conditions is linked to the Line width, this will give an accurate representation of the line Cd.
Of course, we want to add more detail to the modified area. We do this with a subdivide node and then use a smooth node. For efficiency, we don't want to subdivide the entire mesh, just the area we modified. In the end it is not the mesh that is getting exported, just a new heightfield. For that we use another Attribute Wrangle, which I called group_by_color.
If the Color Red is greater than 0.1, then create a group called modifiedMesh_grp.
if (@Cd.r > 0.1)
{
i@group_modifiedMesh_grp=1;
}A new group is created called modifiedMesh_grp. We test this by using a Blast node and seeing if the group disappears.
Yay! The group is visible. Mental Note: Don't use Point Sop! Ok, moving forward.
After our Attribute Wrangle group_by_color, I connect an attribute wrangle to essentially handle my Rays. Using VEX in an Attribute Wrangle, and not a Ray SOP. We set the following VEX Expression.
vector hitDir = chv("Ray_Hit");
vector hitPoint;
vector uvw;
int primNum = intersect(1, @P, hitDir, hitPoint, uvw);
if(primNum >= 0)
{
@P = hitPoint;
//@N = prim(1, "N", primNum);
@Cd = {1,0,0}
}Don't forget to create the spare parameter that we created in the first line. chv=("Ray_Hit"). This also depends on your map height as well. I ended up linking my Ray_Hit Height in Y to the heightscale of the terrain map with a percentage.
ch("../heightfield_file1/heightscale")+90/100This gives me a final number of 90.9.
After the Ray VEX Attribute Wrangle Ray_Out I subdivided the mesh using the group we created earlier. In my assets I like to add comments in the Nodes that have a specific group. The subdivided and smooth node both use the modifiedMesh_grp. This can be added in the comment section of the node. Don't forget to select Show Comment in Network.
The final asset.
Terrain imported via heightfield
Slope added
Cd value to show modified area.
Part 2 will cover How to Export maps from your digital asset. Mental Note: Don't use the Point SOP.