Segments is a lightweight line renderer for DOTS tech stack.
It works by creating mesh batches formatted as MeshTopology.Lines
, SystemBase
job system schedules updates with MeshDataArray
. Geometry shader
creates output triangles on the GPU.
Segments.Batch _batch;
void OnEnable () => Segments.Core.CreateBatch( out _batch );
void OnDisable () => _batch.Dispose();
void Update ()
{
_batch.Dependency.Complete();
var buffer = _batch.buffer;
buffer.Length = 3;
Vector3 position = transform.position;
buffer[0] = new float3x2( position , position+transform.right );
buffer[1] = new float3x2( position , position+transform.up );
buffer[2] = new float3x2( position , position+transform.forward );
}
100_000 segments? No problem!
@todo: details
- Unity 2020.1
- Hybrid Renderer (tested with URP, HDRP will require few more lines here and there to be fully compatible)
- mesh wireframe (runtime)
- drawing mesh bounding boxes (runtime)
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