|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace UltraCombos
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ParticleViewerProcedural : ParticleViewer
|
|
|
|
|
|
{
|
|
|
|
|
|
ComputeBuffer args_buffer = null;
|
|
|
|
|
|
public int VertexCount { set { vertex_count = value; } }
|
|
|
|
|
|
int vertex_count = -1;
|
|
|
|
|
|
public bool cullingMask = false;
|
|
|
|
|
|
|
|
|
|
|
|
private void OnRenderObject()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Initialized == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
if (Utilities.SkipCamera(Camera.current.name))
|
|
|
|
|
|
return;
|
|
|
|
|
|
int mask = Camera.current.cullingMask;
|
|
|
|
|
|
if (cullingMask && mask > -1 && mask != 1 << gameObject.layer)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
material.SetPass(0);
|
|
|
|
|
|
material.SetMatrix("model_matrix", transform.localToWorldMatrix);
|
|
|
|
|
|
material.SetBuffer(buffer.bufferName, buffer.obj);
|
|
|
|
|
|
if (vertex_count < 0)
|
|
|
|
|
|
Graphics.DrawProceduralIndirect(MeshTopology.Points, args_buffer);
|
|
|
|
|
|
else
|
|
|
|
|
|
Graphics.DrawProcedural(MeshTopology.Points, vertex_count, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override IEnumerator Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
var args = new uint[4] { (uint)buffer.count, 1, 0, 0 };
|
|
|
|
|
|
args_buffer = new ComputeBuffer(1, args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);
|
|
|
|
|
|
args_buffer.SetData(args);
|
|
|
|
|
|
|
|
|
|
|
|
yield return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Release()
|
|
|
|
|
|
{
|
|
|
|
|
|
Utilities.Release(ref args_buffer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|