| On this page |
Masks are an essential part of Houdini’s Copernicus heightfield technology. Masks let you decide, in which areas an operation will affect the terrain. There are four fundamental ways to create masks:
-
Custom images and maps
-
Noise
-
Terrain features like curvature or height
-
Scripting
No matter, which way you're going to use, you’ll always create an image and only the method is different. Please also bear in mind that masks must have a mono signature. RGB images and other signatures are not supported.
Whenever a Copernicus node provides a mask input, you can connect a mono image to control how two elements are blended together. The mask input is not only available with heightfield nodes, but also with many other operators like the Blend COP,
Invert COP, or
Contrast COP.
Images ¶
You can load any image from your hard disk through a File COP and declare it as a mask. The node also supports videos for animated masks. If the loaded file is RGB or RGBA, you must convert it. If you already know the signature, you can use the file node’s Channel Type to pre-adjust it.
To see the image in the viewport, turn on the node’s blue Display flag.
Noise ¶
Noise-based masks are very common because they look very “natural” and share fundamental parameters like Amplitude, Element Size, and Offset. Most noise types also come in two flavors, for example:
-
The
Fractal Noise COP uses the image coordinates to create the noise pattern
-
The
Fractal Noise 3D COP uses world coordinates
Fractal noise is a very convenient way to get naturally looking masks with soft transitions and variable patterns. However, there are other noise types, but you have to decide if they're really suited as terrain masks. For more complex masks, you can also combine different types of noise.
Grunge ¶
Copernicus provides a wide variety of grunge maps. You can find them on the tab menu when you enter grunge. Grunge maps are highly customizable patterns. You can, for example, combine different patterns via Blend COPs and create feature-rich masks.
The result is already of type mono and doesn’t need any further conversion.
Features ¶
There’s a lot of information you can extract from a terrain, for example slope and height. The HeightField Mask by Feature COP turns several properties into masks. To make the node work, you must connect the output of an existing terrain to its
height input. Each property has a ramp to remap the values and control the feathering of the mask. You can freely combine the mask modes by turning them on and off.
-
Slope measures the terrain’s steepness in degrees. To create the mask, define values for Min Slope Angle and Max Slop Angle.
-
Height measures the terrain’s vertical dimension and the mask will be created between Min Height and Max Height. If you don’t know the terrain’s actual height values, click Compute Range.
-
Peaks and valleys are determined through the Max Curvature parameter. You think of curvature as the terrain’s “roundness”.
-
Direction creates a mask based on the “horizontal” direction the terrain surface faces at a given point. Goal Angle defines the mentioned direction. The value is in degrees, plus or minus Angle spread. A value of
0degrees means facing in the -X direction,+90degrees means facing in the -Z direction.Angle Spread is variance parameter around Goal Angle to shrink or expand the mask. -
Occlusion creates a mask based on nearby obstructed terrain areas. The parameters are used to scale the output mask. The settings on the Quality section can improve the overall look of the mask.
Combination ¶
If you're familiar with image processing tools, you've certainly heard about layer blending modes. These modes let you specify how different layers are combined. Typical examples are add, multiply, subtract, or soft light. Most blending modes are also available in Copernicus through the Blend COP and the principle is exactly the same: you connect two layers to a blend node’s
fg and bg inputs. Then, choose an appropriate Mode from the dropdown menu.
You can also connect several blend nodes in series with different modes. It’s possible to use another mask to control the blend effect. A Mask parameter lets you control the strength of the effect.
Processing ¶
Copernicus provides a large number of image processing nodes and they're also available for masks. Typical processing tasks are:
-
Blurring (
Blur COP) creates smooth transitions
-
Hue, saturation, and brightness adjustments (
HSV Adjust COP)
-
Inverting (
Invert COP) flips the mask
-
Contrast (
Contrast COP) controls the ratio between dark and light tones
-
Equalizing (
Equalize COP) lets you fit colors into a given range, for example if the input range is unknown
Conversion ¶
If your mask is of type RGB or RGBA, for example from an imported map, you need to convert it. The node for this task is the RGB to Mono COP. Connect the output of the operator that contains the mask with the conversion node’s
source input. Then link the mono output with the input of the following node.
With the options of Operation dropdown menu you can control how the RGB values are converted. The Signature dropdown also provides other data types like RGBA.
Scripting ¶
Another way to create masks is scripting. The ultimate approach uses OpenCL because Copernicus makes extensive use of the GPU. With VEX, however, there’s a certain overhead because all data must be transferred from the GPU to the CPU and back. Anyway, there’s nothing wrong with VEX and with masks you (most probably) won’t notice any difference in processing speed. The centerpiece of a VEX-based solution is the Wrangle COP.
Tip
You can find several examples for scripted masks on the VEX scripts for heightfields page. This chapter discusses the creation of a circular mask to illustrate the concept.
Circular mask ¶
Let’s start with a script that creates a circular mask with the help of the @mask layer. Add a Layer COP and turn on it’s Type Info option. From the parameter’s dropdown menu, choose
mask. This introduces the required base layer for the script.
Lay down a Wrangle COP, open the Type dropdown menu, and choose Mono. Set Value to 0 to get a completely black layer. For Binding Name, enter mask. You can now see the wrangle’s input and output names have changed. Connect the mask input with the output of the Layer COP.
Use ⌃ Ctrl + C to copy the following VEX script and paste it with ⌃ Ctrl + V to the wrangle’s Snippet field.
vector position = chv("position"); vector offset = set(position.x, 0, position.z); if (length(v@P - offset) < chf("radius")) { @mask = chf("mask_strength"); }
The script provides custom Position, Radius, and Mask Strength parameters. To add the parameters to the UI, click the Create spare parameters for each unique call of ch() button.
-
Position is a vector and determines the circle’s center in pixels. Note that you only need the X and Z values.
-
Radius is the circle’s radius in pixels.
-
Mask Strength lets you control the mask’s opacity. Set it to a value greater than 0.
What you get in the viewport is a black circle with the given radius at the specified position. You can also add a Blur COP to make the mask fade out smoothly. The image shows how the circular mask was used to create a crater-like structure.
Mask to color ¶
Masks also play an important role when you start to colorize a terrain. A good example is the HeightField Mask by Feature COP. You can use masks to separate different types of rock, but also if you want to visualize snow or sediments.
The center piece is the Mono to RGB COP. This node converts a grayscale mask into a true RGB image. Color ramps let you create the impression of terrain features.