You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.3 KiB
41 lines
1.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace UltraCombos
|
|
{
|
|
public class ParticleViewerInstanced : ParticleViewer
|
|
{
|
|
public Mesh reference;
|
|
Bounds bounds;
|
|
ComputeBuffer args_buffer = null;
|
|
MaterialPropertyBlock props = null;
|
|
|
|
protected override void OnUpdate()
|
|
{
|
|
props.SetMatrix("model_matrix", transform.localToWorldMatrix);
|
|
Graphics.DrawMeshInstancedIndirect(reference, 0, material, bounds, args_buffer, 0, props);
|
|
}
|
|
|
|
protected override IEnumerator Initialize()
|
|
{
|
|
bounds = new Bounds(Vector3.zero, Vector3.one * 100);
|
|
|
|
// index count per instance, instance count, start index location, base vertex location, start instance location
|
|
var args = new uint[5] { reference.GetIndexCount(0), (uint)buffer.count, 0, 0, 0 };
|
|
args_buffer = new ComputeBuffer(1, args.Length * sizeof(uint), ComputeBufferType.IndirectArguments);
|
|
args_buffer.SetData(args);
|
|
|
|
props = new MaterialPropertyBlock();
|
|
props.SetBuffer(buffer.bufferName, buffer.obj);
|
|
|
|
yield return null;
|
|
}
|
|
|
|
protected override void Release()
|
|
{
|
|
Utilities.Release(ref args_buffer);
|
|
}
|
|
}
|
|
}
|
|
|
|
|