public unsafe void DrawWorld(Material blitMaterial, World[] worldLODs, Camera camera, Camera actualCamera, float[] LODDistances) { Mesh blitMesh = blitMeshes[bufferIndex]; Debug.DrawLine(new Vector2(0f, 0f), new Vector2(screenWidth, 0f)); Debug.DrawLine(new Vector2(screenWidth, 0f), new Vector2(screenWidth, screenHeight)); Debug.DrawLine(new Vector2(screenWidth, screenHeight), new Vector2(0f, screenHeight)); Debug.DrawLine(new Vector2(0f, screenHeight), new Vector2(0f, 0f)); Profiler.BeginSample("Setup VP"); float3 vanishingPointWorldSpace = CalculateVanishingPointWorld(camera); float2 vanishingPointScreenSpace = ProjectVanishingPointScreenToWorld(camera, vanishingPointWorldSpace); Profiler.EndSample(); float2 screen = new float2(screenWidth, screenHeight); NativeArray <SegmentData> segments = new NativeArray <SegmentData>(4, Allocator.Temp, NativeArrayOptions.ClearMemory); Profiler.BeginSample("Setup segment params"); if (vanishingPointScreenSpace.y < screenHeight) { segments[0] = GetGenericSegmentParameters(camera, screen, vanishingPointScreenSpace, screenHeight - vanishingPointScreenSpace.y, new float2(0, 1), 1, worldLODs[0].DimensionY); } if (vanishingPointScreenSpace.y > 0f) { segments[1] = GetGenericSegmentParameters(camera, screen, vanishingPointScreenSpace, vanishingPointScreenSpace.y, new float2(0, -1), 1, worldLODs[0].DimensionY); } if (vanishingPointScreenSpace.x < screenWidth) { segments[2] = GetGenericSegmentParameters(camera, screen, vanishingPointScreenSpace, screenWidth - vanishingPointScreenSpace.x, new float2(1, 0), 0, worldLODs[0].DimensionY); } if (vanishingPointScreenSpace.x > 0f) { segments[3] = GetGenericSegmentParameters(camera, screen, vanishingPointScreenSpace, vanishingPointScreenSpace.x, new float2(-1, 0), 0, worldLODs[0].DimensionY); } Profiler.EndSample(); RayBuffer activeRaybufferTopDown = rayBufferTopDown[bufferIndex]; RayBuffer activeRaybufferLeftRight = rayBufferLeftRight[bufferIndex]; RayBuffer.Native topDownNative = activeRaybufferTopDown.GetNativeData(Allocator.TempJob); RayBuffer.Native leftRightNative = activeRaybufferLeftRight.GetNativeData(Allocator.TempJob); commandBuffer.Clear(); CameraData camData = new CameraData(camera, LODDistances, screen); Profiler.BeginSample("Draw planes"); fixed(World *worldPtr = worldLODs) { DrawSegments(segments, worldPtr, camData, screenWidth, screenHeight, vanishingPointScreenSpace, topDownNative, leftRightNative, activeRaybufferTopDown, activeRaybufferLeftRight ); } Profiler.EndSample(); topDownNative.Dispose(); leftRightNative.Dispose(); Profiler.BeginSample("Apply textures"); activeRaybufferTopDown.ApplyPartials(commandBuffer); activeRaybufferLeftRight.ApplyPartials(commandBuffer); Profiler.EndSample(); Profiler.BeginSample("Blit raybuffer"); BlitSegments( camera, blitMaterial, blitMesh, activeRaybufferTopDown.FinalTexture, activeRaybufferLeftRight.FinalTexture, segments, vanishingPointScreenSpace, screen, commandBuffer ); Profiler.EndSample(); actualCamera.RemoveAllCommandBuffers(); actualCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, commandBuffer); }