Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Lerp

Interpolates between two vertices, writing into result a new vertex a fraction t of the way from a to b.
Read time 2 minutesLast updated 12 days ago

Definition

Lerp(Vertex, Vertex, float, Vertex)

Interpolates between two vertices, writing into
result
a new vertex a fraction
t
of the way from
a
to
b
.
public static void Lerp(in Vertex a, in Vertex b, float t, out Vertex result)

Parameters

The vertex written to
result
when
t
is 0.

The vertex written to
result
when
t
is 1.

The interpolation factor. 0 selects
a
, 1 selects
b
.

result

Receives the interpolated vertex.

Remarks

Use this when a mesh modifier adds vertices between existing ones — for example when subdividing, tessellating, or clipping geometry. The continuous vertex data (position, tint, texture coordinate, and the internal anti-aliasing data) is blended; the discrete per-vertex data that identifies the draw (clipping, element, texture, and gradient identifiers, and flags) is taken from
a
.
Because that discrete data is copied rather than blended,
a
and
b
must belong to the same fill (the same draw within one VisualElement) — which is always the case when resampling the triangles of a single mesh.
t
is not clamped: values outside the 0..1 range extrapolate beyond the endpoints.

Lerp(Vertex, Vertex, float)

Interpolates between two vertices, returning a new vertex a fraction
t
of the way from
a
to
b
. Convenience overload that returns the result instead of writing to an out parameter — handy when the value is temporary.
public static Vertex Lerp(in Vertex a, in Vertex b, float t)

Parameters

The vertex returned when
t
is 0.

The vertex returned when
t
is 1.

The interpolation factor. 0 returns
a
, 1 returns
b
.

Returns

Type

Description

VertexThe interpolated vertex.