Paint holes in the terrain
Paint holes in the terrain to allow characters and objects to enter caves or other underground structures.
읽는 시간 2분최근 업데이트: 17일 전
To simulate cave openings and overhanging formations, such as cliffs, use the Paint Holes tool to hide a part of the terrain. Then use other Editor tools, such as ProBuilder, to create the cave or overhang geometry.
Access the tool
To paint a hole, in the Terrain tile's window, select the Paint Terrain tool > tool dropdown > Paint Holes.
Inspector
?
Tool options
The Paint Holes tool is brush-based. To learn about working with brushes, refer to Brushes.
Hide or smooth aliased edges
The Paint Holes tool is texture-based, so it can create aliased edges around holes. You can:
-
Hide the aliased edges with geometry, such as rock meshes.
-
Increase the Heightmap Resolution to add more texels. This increases performance requirements.
To try a higher resolution:
- Erease the parts of the hole you want to redraw with the Paint Holes tool.
- In Terrain Settings, increase the Heightmap Resolution.
- Draw the hole again.
For more information, refer to Terrain Settings reference.
Hole collision
A hole in the terrain is automatically excluded from the Terrain Collider, so that characters and objects can fall through it. You don't need to manually adjust the Terrain Collider.
If you are creating holes in a script-based workflow, ensure that the resolution of the hole's mask texture is equal to the resolution of the Terrain's heightmap minus 1 (). For example, if the Terrain's heightmap resolution is , the hole's mask texture needs to be . For more information, refer to TerrainData-holesResolution.
-11025x10251024x1024Using a custom material
The holes functionality depends on the shader. To allow holes in a custom Terrain material, you can either:
-
Use the Terrain shader the Editor provides.
-
Use your own shader with the following code snippet in the fragment shader:#ifdef _ALPHATEST_ON ClipHoles(IN.uvMainAndLM.xy);#endif