void LateUpdate()
    {
        renderTest.ClearBuffers();
        renderTest.SetInitialTransform(camTrs);

        var matrix = Matrix4x4.Scale(float3(1f / scale));

        if (lazyRender)
        {
            renderTest.LazyRender(new TransformData(camTrs), matrix, 0, 0);
        }
        else
        {
            var map = PortalRay.GetPortalMap(cam);
            renderTest.RenderPortalMap(map, new TransformData(camTrs), matrix, 0, 0);             // Fix allocations
            PortalRay.ClearAndReleaseRecursiveDown(map);
        }
        renderTest.Edge();
    }
Example #2
0
    public static Node <Portal> GetPortalMap(Camera cam)    // Allocations...
    {
        var       map = pool.Get();
        const int res = 32;

        for (int i = 0; i < res; i++)
        {
            for (int j = 0; j < res; j++)
            {
                Vector3 uv  = float3(float2(i, j) / (res - 1), 0);
                Ray     ray = cam.ViewportPointToRay(uv);

                if (PortalRay.CastPortalRay(ray, out var rayPath))
                {
                    MergeRayPath(map, rayPath);
                }
            }
        }
        return(map);
    }