public void UpdateBuffers(GPUInstancerCameraData renderingCameraData) { if (renderingCameraData != null && renderingCameraData.mainCamera != null && SystemInfo.supportsComputeShaders) { if (isOcclusionCulling && renderingCameraData.hiZOcclusionGenerator == null) { SetupOcclusionCulling(renderingCameraData); } renderingCameraData.CalculateCameraData(); instancingBounds.center = renderingCameraData.mainCamera.transform.position; if (lastDrawCallFrame != Time.frameCount) { lastDrawCallFrame = Time.frameCount; timeSinceLastDrawCall = Time.realtimeSinceStartup - lastDrawCallTime; lastDrawCallTime = Time.realtimeSinceStartup; } UpdateSpatialPartitioningCells(renderingCameraData); GPUInstancerUtility.UpdateGPUBuffers(_cameraComputeShader, _cameraComputeKernelIDs, _visibilityComputeShader, _instanceVisibilityComputeKernelIDs, runtimeDataList, renderingCameraData, isFrustumCulling, isOcclusionCulling, showRenderedAmount, isInitial); isInitial = false; if (GPUInstancerUtility.matrixHandlingType == GPUIMatrixHandlingType.CopyToTexture) { GPUInstancerUtility.DispatchBufferToTexture(runtimeDataList, _bufferToTextureComputeShader, _bufferToTextureComputeKernelID); } GPUInstancerUtility.GPUIDrawMeshInstancedIndirect(runtimeDataList, instancingBounds, renderingCameraData, layerMask, lightProbeDisabled); } }
public void UpdateBuffers(GPUInstancerCameraData renderingCameraData) { if (renderingCameraData != null && renderingCameraData.mainCamera != null && SystemInfo.supportsComputeShaders) { if (isOcclusionCulling && renderingCameraData.hiZOcclusionGenerator == null) { SetupOcclusionCulling(renderingCameraData); } renderingCameraData.CalculateCameraData(); instancingBounds.center = renderingCameraData.mainCamera.transform.position; if (lastDrawCallFrame != Time.frameCount) { lastDrawCallFrame = Time.frameCount; timeSinceLastDrawCall = Time.realtimeSinceStartup - lastDrawCallTime; lastDrawCallTime = Time.realtimeSinceStartup; } UpdateSpatialPartitioningCells(renderingCameraData); GPUInstancerUtility.UpdateGPUBuffers(_visibilityComputeShader, _instanceVisibilityComputeKernelIDs, runtimeDataList, renderingCameraData, isFrustumCulling, isOcclusionCulling, showRenderedAmount, isInitial); isInitial = false; #if !UNITY_EDITOR && UNITY_ANDROID if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan) { GPUInstancerUtility.DispatchBufferToTexture(runtimeDataList, _bufferToTextureComputeShader, _bufferToTextureComputeKernelID); } #endif GPUInstancerUtility.GPUIDrawMeshInstancedIndirect(runtimeDataList, instancingBounds, renderingCameraData); } }