IN THIS ARTICLE
Road
Road
This feature is in preview release and is subject to change. |
Use the Road component to create paths in Lumberyard Editor. You can create roads that follow the curvature of existing terrain by applying a texture over the terrain texture. You can also use the Align heightmap feature with the Road component to shape the terrain to the height and curvature of the road you placed.
To enable the Road component, you must enable the Roads and Rivers gem. For more information, see Add modular features and assets with Gems.
The Road requires the Spline component to shape its path along the X, Y, and Z axes. After you place a road, you can edit the points in the road’s spline.
Note
You can rebuild roads at runtime by modifying the spline. However, this method can be slow. We recommended that you avoid modifying the spline continuously at runtime.
Topics
- Road Properties
- Creating a Road
- Modifying Road Width
- Setting Road Material Properties
- Using Roads to Modify Terrain
- Erasing Vegetation
- RoadRequestBus Interface
- RoadsAndRiversGeometryRequestsBus Interface
Road Properties
See the following Road properties:
Name | Description |
---|---|
Global width | Width of the road. |
Per-Vertex Width Modifiers | Width at a specific vertex that is added to or subtracted from the global width. For more information, see Modifying Road Width. |
Elements | The road’s vertices or points. Specify a positive or negative number for each vertex. |
Segment length | Length of each segment. Smaller segment lengths increase the polycount used for the road surface. To create a road with smooth corners, use smaller segment lengths. |
Tile length | Length of the road texture. Adjust Tile length with Segment length to avoid stretching textures. |
Sort priority | Priority that you can use if the road is drawn over or under another road. |
View distance multiplier | Distance at which the road is visible. A higher number indicates a longer visibility distance. The default value is 1 . |
Minimum spec | Specifies the minimum system configuration level for the effect. If the configuration is lower than the set value, the road will not appear. Choose from Low, Medium, High, VeryHigh, and Never.Default value: Low |
Road material | Sets the material for the road. For more information, see Setting Road Material Properties. |
Ignore terrain holes | If enabled, the road texture is rendered over terrain holes. |
Border width | Width of the border extending from the sides of the road. Use with the Align heightmap feature. |
Erase width | Distance from the road edges in which the vegetation should be removed. Specifying a value of 0 removes only vegetation that is on the road. Specify positive values to remove vegetation in a wider border from the road’s edge. Specify negative values to leave some vegetation within the borders of the road. For more information, see
Erasing Vegetation. |
Erase variance | Randomizes the removal of vegetation so that the road edges appear more natural. |
Creating a Road
To create a road
Add the Road component.
Add the Spline component.
The Spline component defines the path and shape of the road. For information about how to add, remove, and edit individual points, see Spline.
The road is created with the default material defaultRoad. The Spline component defaults to the Linear Spline Type and contains four vertices (0, 1, 2, 3). For a road that curves smoothly, specify the Bezier Spline Type.
Modifying Road Width
You can modify the road’s width by adjusting the road’s Global width property. Adjusting this property modifies all the points on the road.
For more granular control over the road’s width, you can adjust individual points with the Per-Vertex Width Modifiers property.
To adjust the width of individual points
In the Road component properties, enter a negative or positive number for the property that you want to modify.
Negative numbers subtract from the Global width property, while positive numbers add to it. A value of
0
means that point is at global width.
ExampleThe global width of this road is
2
, and the width at the selected point is set to5
. The total width at the selected point is7
.
Setting Road Material Properties
Roads are Decals placed along a spline. This makes the material setup of a road similar to that of decals.
The road material must use the Illum Shader and should also enable the Decal and Vertex Colors parameters in the Shader Generation Params.
To open the Material Editor
In Lumberyard Editor, choose Tools, Material Editor or press M.
Select the road material and expand the Shader Generation Params, and select the following parameters:
Vertex Colors
Activates a blend fadeout at each end of the road. This is a 100% to 0% fadeout over the length of the final step. The textures and alpha channel have no influence on the fadeout.
Decal
Enables alpha blending on the sides of the road, which comes from the diffuse texture’s alpha channel.
Example
In the left image, Vertex Colors is enabled. In the right image, the parameter is disabled.
Using Roads to Modify Terrain
You can use roads to modify the shape of the terrain.
To modify the terrain with roads
Manipulate the individual vertices to shape the road. For more information, see Spline.
In the Road component’s properties, under Terrain Editing, set the Border width. This parameter defines the width of the slope at the edges of the road.
Click Align heightmap.
Example
The following image shows a road that has been created and shaped, but not yet aligned.
Example
The following image shows the road and terrain after alignment with a Border width of 5
.
Example
The following image shows the road and terrain after alignment with a Border width of 20
.
Erasing Vegetation
You can erase vegetation around the road’s borders.
To erase vegetation
In the Road component’s properties, under Vegetation Editing, specify the Erase width. This parameter defines the amount of vegetation to erase at the road’s edges.
Specify the Erase variance. This parameter randomizes the removal of vegetation, so that the edge looks more natural.
Example
The following image shows the road with no vegetation erased.
Example
The following image shows the road with Erase width set to 0
.
Example
The following image shows the road with Erase width set to 1
and Erase variance set to 5
.
RoadRequestBus Interface
Use the following request functions with the RoadRequestBus
EBus interface to communicate with other components of your game.
For more information about using the event bus (EBus) interface, see Working with the Event Bus (EBus) system.
Request Name | Description | Parameters | Return | Scriptable |
---|---|---|---|---|
Rebuild | Triggers full rebuild of the road object, including geometry and render node generation. | None | None | Yes |
SetIgnoreTerrainHoles | Sets whether to allow the road texture to be rendered over terrain holes. | Boolean | None | Yes |
RoadsAndRiversGeometryRequestsBus Interface
Use the following request functions with the RoadsAndRiversGeometryRequestsBus
EBus interface to communicate with other components of your game.
For more information about using the event bus (EBus) interface, see Working with the Event Bus (EBus) system.
Request Name | Description | Parameters | Return | Scriptable |
---|---|---|---|---|
SetVariableWidth | Sets the variable width along the river using the index of spline. | AZ::u32, float | None | Yes |
SetGlobalWidth | Sets the uniform global width along the road or river. This value is added to the variable width specified by the spline width attribute. If no width attribute specified, the width of the spline geometry is uniform and equal to this parameter. | float | None | Yes |
SetTileLength | Sets the tile length, which is the texture mapping scale along the geometry spline. | float | None | Yes |
SetDesiredGranularity | Sets the desired granularity, which is the size of the polygon along the road or river. Lower numbers generate more polygons. | float | None | Yes |