14 public static class AccessShaderOutputExtensions {
16 private static ComputeBuffer _buffer;
18 public static void BeginCollectingVertData(
this LeapGraphicRenderer renderer) {
19 Camera targetCamera = renderer.GetComponentInChildren<Camera>();
20 var renderingMethod = renderer.groups[0].renderingMethod as LeapMesherBase;
21 var material = renderingMethod.material;
23 var graphic = renderer.groups[0].graphics[0] as LeapMeshGraphicBase;
24 graphic.RefreshMeshData();
25 var mesh = graphic.mesh;
27 _buffer =
new ComputeBuffer(mesh.vertexCount,
sizeof(
float) * 3);
28 material.SetBuffer(
"_FinalVertexPositions", _buffer);
31 Graphics.SetRandomWriteTarget(1, _buffer);
33 targetCamera.allowMSAA =
false;
34 targetCamera.enabled =
true;
37 public static Vector3[] FinishCollectingVertData(
this LeapGraphicRenderer renderer) {
38 Camera targetCamera = renderer.GetComponentInChildren<Camera>();
39 var renderingMethod = renderer.groups[0].renderingMethod as LeapMesherBase;
40 var material = renderingMethod.material;
42 var graphic = renderer.groups[0].graphics[0] as LeapMeshGraphicBase;
43 graphic.RefreshMeshData();
44 var mesh = graphic.mesh;
47 _buffer.GetData(array);
52 targetCamera.enabled =
false;