Gets the allocated instance capacity, measured in generated line segments.
Allocated instance capacity, measured in generated line segments. Defaults to zero and grows automatically when required. Setting a smaller value releases unused capacity, but the result is clamped to the number of segments currently required by the owned lines.
Gets whether lines are tested against the depth buffer.
Whether lines are tested against the depth buffer. Defaults to true.
Gets whether lines write to the depth buffer.
Whether lines write to the depth buffer. Defaults to true.
Gets whether this renderer is visible.
Whether this renderer is visible. Defaults to true.
Gets the units used to interpret line widths.
Units used to interpret line widths. Can be LINEWIDTH_SCREEN for screen pixels or LINEWIDTH_WORLD for world units. World-unit lines are camera-facing ribbons, not three-dimensional tubes. Defaults to LINEWIDTH_SCREEN.
Adds a line to this renderer. A line can belong to only one renderer at a time.
The line to add.
Removes all lines. Allocated instance capacity is retained for reuse.
Releases all renderer-owned resources. Lines previously owned by this renderer remain usable and can be added to another renderer.
Removes a line from this renderer without modifying its point data or style.
The line to remove.
True if the line was owned by this renderer and was removed.
Renders a collection of WideLine objects using a single instanced draw call per camera/layer pass. Lines can use different widths, colors, caps, joins and dash patterns while remaining in the same batch, as these properties are stored in per-segment instance data.
Each WideLine describes a connected polyline in world space. Its width can vary per point and is interpreted as screen pixels or world units according to WideLineRenderer#widthUnits. A line can belong to only one WideLineRenderer at a time. Use WideLineRenderer#add and WideLineRenderer#remove to transfer ownership without changing the line data.
Basic usage
The following example creates a three-point line with a color gradient, variable width and rounded ends and joins:
Point data can be updated using WideLine#setPositions, WideLine#setColors and WideLine#setWidths. These methods preserve the point count and reuse the line's existing storage. Use WideLine#set when the point count needs to change.
Performance
Each line segment is rendered as one GPU instance. All segments owned by this renderer are submitted together, so adding more WideLine objects does not add draw calls. A renderer with visible segments issues one draw call for each camera that renders its layer. Multiple renderers therefore provide useful update isolation, but each adds another draw call per camera/layer pass.
Changing any owned line marks the renderer dirty. Before the next render, instance data for all of its lines is rebuilt and uploaded. For mixed workloads, place lines that rarely change in one renderer and frequently updated lines in another. There is no static or dynamic mode; the separation is achieved using two renderer instances. This prevents dynamic updates from repeatedly rebuilding the static segment data:
Buffer WideLineRenderer#capacity is measured in segments and grows automatically as needed. Setting it in advance can avoid GPU buffer reallocations when the expected maximum segment count is known. WideLineRenderer#clear removes the lines but retains this capacity for reuse.
Rendering behavior and limitations
See the following examples for interactive styling and update demonstrations: