# Projecting a Road Curve onto a Heightfield

calendar_today

03.04.2022

label

Modeling, Environment, Video

mouse

18.5

### 1 Introduction

In this example we are going to blend a road into a terrain. Both the road and the terrain will mutually affect each other. First, the road curve will smoothly adapt to the height of the landscape, next, the landscape merges with the flow of the road. Thus we can ensure neither the landscape appears clipped nor the road turns out too bumpy.

### 2 Process

A point wrangle samples height values from the heightfield to the road curve. To maintain a smooth drive, these values are blurred along the curve.

``````float lift = chf('lift');

f@height = volumesample(1, 'height', v@P) + lift;``````

Next, a volume wrangle is reapplying the blurred height information from the curve back to the heightfield, but only inside a smooth mask close to the road curve.

``````float width_min = chf('min_width');
float width_max = chf('max_width');
float ease = chf('roll_off');

int prim;
vector uvw;
float dist_crv = xyzdist(1, v@P, prim, uvw);
float height_crv = primuv(1, 'height', prim, uvw);
float mask = 1.0 - smooth(width_min, width_max, dist_crv, ease);

f@height = lerp(f@height, height_crv, mask);

### 3 Outlook

Further steps could include projecting a whole set of curves or a entire road network onto a landscape. Each curve may contain scale attributes to change the width, height and blend values of any given part of the road.

smart_display

## videos

#### Integrating a Road into a Heightfield - Houdini Tutorial

Available formatting commands

Use Markdown commands or their HTML equivalents to add simple formatting to your comment:

Text markup
*italic*, **bold**, ~~strikethrough~~, ``code`` and <mark>marked text</mark>.
Lists
``- Unordered item 1- Unordered list item 2``
``1. Ordered list item 12. Ordered list item 2``
Quotations
``> Quoted text``
Code blocks
`````// A simple code block`````
`````php// Some PHP codephpinfo();`````
`[Link text](https://example.com)`