protected void Start()
        {
            // Initialize particle buffer
            particleBuffer = new PingPongBuffer(count, typeof(Particle_t));

            // Initialize object pool buffer
            poolBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(int)), ComputeBufferType.Append);
            poolBuffer.SetCounterValue(0);
            countBuffer = new ComputeBuffer(4, Marshal.SizeOf(typeof(int)), ComputeBufferType.IndirectArguments);
            countBuffer.SetData(countArgs);

            // Initialize dividable object pool buffer
            dividablePoolBuffer = new ComputeBuffer(count, Marshal.SizeOf(typeof(int)), ComputeBufferType.Append);
            dividablePoolBuffer.SetCounterValue(0);

            // Execute kernel to initialize particle and pool buffers
            InitParticlesKernel();

            // Initialize for gpu-instancing
            mesh        = BuildQuad();
            drawArgs[0] = mesh.GetIndexCount(0);
            drawArgs[1] = (uint)count;
            argsBuffer  = new ComputeBuffer(1, sizeof(uint) * drawArgs.Length, ComputeBufferType.IndirectArguments);
            argsBuffer.SetData(drawArgs);

            pallete = CreatePallete(gradient, 128);
            material.SetTexture("_Gradient", pallete);

            StartCoroutine(IDivider());
        }
Beispiel #2
0
 public GPUObjectPoolPingPong(int count, System.Type type) : base(count, type)
 {
     pingpong = new PingPongBuffer(count, type);
 }