private void InitComputeBuffer() { mainBuffer = new ComputeBuffer(count, stride); SetShaderParams(); MainShader.SetBuffer(KERNEL_ID_Init, "Boids", mainBuffer); MainShader.Dispatch(KERNEL_ID_Init, BOID_CYCLE_BLOCK_COUNT, 1, 1); }
public override void Render(RenderTexture destination) { MainShader.SetBuffer(KERNEL_ID_Update, "Boids", mainBuffer); MainShader.SetTexture(KERNEL_ID_Update, "Result", Result); MainShader.SetTexture(KERNEL_ID_Render, "Result", Result); int threadGroupsX = Mathf.CeilToInt(WIDTH / ThreadBlockSize.x); int threadGroupsY = Mathf.CeilToInt(HEIGHT / ThreadBlockSize.y); MainShader.Dispatch(KERNEL_ID_Render, threadGroupsX, threadGroupsY, 1); MainShader.Dispatch(KERNEL_ID_Update, BOID_CYCLE_BLOCK_COUNT, 1, 1); Graphics.Blit(Result, destination); }