private void Set() { computeSystem.data.AddRenderTexture("_Result", render); computeSystem.data.AddBuffer("normals", deferredBuffers[DefferredBufferID.Normals]); computeSystem.data.AddBuffer("position", deferredBuffers[DefferredBufferID.Position]); computeSystem.data.AddBuffer("pids", deferredBuffers[DefferredBufferID.RenderIDs]); computeSystem.AddKernel("FindEdges", new Vector3Int(Screen.width, Screen.height, 1)); computeSystem.BindComputeData(); computeSystem.shader.SetInt("width", Screen.width); }
void OnEnable() { uint[] args = new uint[5] { instanceMesh.GetIndexCount(0), (uint)(num.x * num.y), 0, 0, 0 }; argsBuffer = new ComputeBuffer(1, args.Length * sizeof(uint), ComputeBufferType.IndirectArguments); argsBuffer.SetData(args); system = new ComputeSystem(shader); system.AddKernel("Do", new Vector3Int(num.x, num.y, 1)); system.data.AddRenderTexture("u", GpuUtils.GetRenderTexture(num.x, num.y, 0, true, RenderTextureFormat.RFloat)); system.data.AddRenderTexture("v", GpuUtils.GetRenderTexture(num.x, num.y, 0, true, RenderTextureFormat.RFloat)); system.data.AddBuffer("buff", num.x * num.y, sizeof(float) * 4 * 2); system.data.AddBuffer("test", 1, sizeof(float)); system.BindComputeData(); // instanceMat.SetBuffer("buff", system.data.GetBuffer("buff")); //AAAA Time.fixedDeltaTime = 0.015f; }