public void Emit(Vector3 p) { uploadPositionList.Clear(); uploadPositionList.Add(p); var counterOffset = 0; ComputeBuffer.CopyCount(deadList.Buffer, args.Buffer, counterOffset); compute.SetBuffer(kernelIDEmit, PROP_POSITION_LIST, positionList.Buffer); compute.SetInt(PROP_COUNTER_OFFSET, counterOffset); compute.SetBuffer(kernelIDEmit, PROP_COUNTER, args.Buffer); compute.SetBuffer(kernelIDEmit, PROP_DEAD_CONSUME_LIST, deadList.Buffer); compute.SetBuffer(kernelIDEmit, PROP_ALIVE_APPEND_LIST, aliveList.Buffer); compute.SetBuffer(kernelIDEmit, PROP_UPLOAD_POSITION_LIST, uploadPositionList.Buffer); compute.Dispatch(kernelIDEmit, uploadPositionList.Count, 1, 1); #if false ComputeBuffer.CopyCount(deadList.Buffer, args.Buffer, 0); Debug.LogFormat("Dead list count={0}, ({1})", args.Data[0], Join(",", deadList.Data)); ComputeBuffer.CopyCount(aliveList.Buffer, args.Buffer, 0); Debug.LogFormat("Alive list count={0}, ({1})", args.Data[0], Join(",", aliveList.Data)); #endif }
private void OnEnable() { we = new WaveEquation1DBuf(); graph = new BarGraphBuf(); v = new GPUList <float>(); u0 = new GPUList <float>(); u1 = new GPUList <float>(); rend = GetComponent <Renderer>(); validator.Reset(); validator.Validation += () => { we.C = speed; we.H = 1000f / count; we.MaxSlope = maxSlope; graph.Peak = maxSlope * 2; time = 0f; dt = Mathf.Min(we.SupDt(), Time.fixedDeltaTime) / (2 * quality); Debug.LogFormat("Set dt={0} for speed={1}", dt, speed); var dw = 4f / count; var offset = dw * 0.5f * count; var dam = Mathf.RoundToInt(0.1f * count); v.Clear(); u0.Clear(); u1.Clear(); for (var i = 0; i < count; i++) { var w = 1f - Mathf.Clamp01(Mathf.Abs(dw * i - offset)); u0.Add(w); u1.Add(0); v.Add(0); } }; }