Segments is a lightweight line renderer for DOTS tech stack.
- You create and then fill the
Segment
buffer (pairs of points) plotting shapes you want,SegmentUpdateSystem
then pushes this data to the GPU wheregeometry shader
creates output triangles on screen. Segment
buffer's lifetime control and plotting, being part of anEntity
, can happen either in a system, job, editor window or a monobehaviour - your choice.- Can be used for runtime shapes only or in the editor for debug gizmos as well.
- To develop the look of the lines to your specific needs you are expected to know shader programming basics to be able to fork and modify the base shader on your own

Here is a minimum code that will draw lines on screen:
Entity _segments;
void OnEnable () => Segments.Core.Create(out _segments);// creates an Entity that will hold all the vertex data and will be responsible for drawing them
void OnDisable () => Segments.Core.Destroy(_segments);// destroys the entity and all data associated with it
void Update ()
{
DynamicBuffer<float3x2> segments = Segments.Core.GetBuffer(_segments);
segments.Length = 3;
Vector3 pos = transform.position;
segments[0] = new float3x2( pos , pos+transform.right );
segments[1] = new float3x2( pos , pos+transform.up );
segments[2] = new float3x2( pos , pos+transform.forward );
}
Code above is just an illustration of the workflow to get you started. The best way of doing this is with use of job system as these will result in the best performance. Look into Samples to learn more.
Stress tested with 300k segments on my laptop (i7-7700HQ, GTX1060M) and bottleneck turned out to be the GPU (shader).
RenderDoc debugger shows that stress test scene generates very high amount of PS invocations (at 1920x876 res). I thought about maybe adding depth-only prepass to reduce this but that would require changes to URP renderer which is something I don't find fitting for this project - I want it to be plug&play, with minimum dependencies.

I'm investigating whenever replacing geometry shader with a compute shader will reduce the GPU time.
Also, this exact test scene is provided as one of the samples so you can test it yourself.
- stress test

- mesh wireframe

- drawing mesh bounding boxes

- Unity 6000.0
- URP (not tested with HDRP yet)
Add this line in manifest.json
/ dependencies
:
"com.andrewraphaellukasik.segments": "https://github.com/andrew-raphael-lukasik/segments.git#upm",
Or via Package Manager
/ Add package from git URL
:
https://github.com/andrew-raphael-lukasik/segments.git#upm