private void SetupComputeShader(ref RenderTexture renderTexture) { cs = Object.Instantiate(AssetRepository.LoadCalculateSelectAreaComputeShader()); addPointKernelId = cs.FindKernel("CSAddPoint"); addLineKernelId = cs.FindKernel("CSAddLine"); fillKernelId = cs.FindKernel("CSFill"); clearKernelId = cs.FindKernel("CSClear"); inverseFillKernelId = cs.FindKernel("CSInverseFill"); cs.SetTexture(addPointKernelId, CS_VARIABLE_SELECT_AREA_TEX, renderTexture); cs.SetTexture(addLineKernelId, CS_VARIABLE_SELECT_AREA_TEX, renderTexture); cs.SetTexture(fillKernelId, CS_VARIABLE_SELECT_AREA_TEX, renderTexture); cs.SetTexture(clearKernelId, CS_VARIABLE_SELECT_AREA_TEX, renderTexture); cs.SetTexture(inverseFillKernelId, CS_VARIABLE_SELECT_AREA_TEX, renderTexture); buffer = new ComputeBuffer(renderTexture.width * renderTexture.height, sizeof(int)); cs.SetBuffer(addPointKernelId, CS_VARIABLE_SELECT_RESULT, buffer); cs.SetBuffer(addLineKernelId, CS_VARIABLE_SELECT_RESULT, buffer); cs.SetBuffer(fillKernelId, CS_VARIABLE_SELECT_RESULT, buffer); cs.SetBuffer(clearKernelId, CS_VARIABLE_SELECT_RESULT, buffer); cs.SetBuffer(inverseFillKernelId, CS_VARIABLE_SELECT_RESULT, buffer); cs.SetInt(CS_VARIABLE_WIDTH, renderTexture.width); }