Exemple #1
0
        private void CalculateVpMatrixOffsetsAndTileRects(Camera camera)
        {
            int   counter = 0;
            int   tileNum = drawInfo.tileX * drawInfo.tileY;
            float aspect  = camera.aspect;

            if (m_VpOffsetParam == null || m_VpOffsetParam.Length != tileNum)
            {
                m_VpOffsetParam = new Vector4[tileNum];
            }
            if (m_ScreenRectParam == null || m_ScreenRectParam.Length != tileNum)
            {
                m_ScreenRectParam = new Vector4[tileNum];
            }

            float width  = 1.0f / (float)drawInfo.tileX;
            float height = 1.0f / (float)drawInfo.tileY;

            for (int i = 0; i < drawInfo.tileY; ++i)
            {
                for (int j = 0; j < drawInfo.tileX; ++j)
                {
                    m_VpOffsetParam[counter] = LookingGlassUtil.GetVPMatrixOffsets(aspect, perCameraInfo.fov, perCameraInfo.size, counter, tileNum);

                    m_ScreenRectParam[counter] = new Vector4(
                        (j / (float)drawInfo.tileX) * 2.0f - 1.0f + width,
                        -((i / (float)drawInfo.tileY) * 2.0f - 1.0f + height),
                        width, height);
                    ++counter;
                }
            }
        }
Exemple #2
0
        private void SetupVPMatrices(ScriptableRenderContext context, CommandBuffer cmd,
                                     Camera camera,
                                     int view, int numViews)
        {
            Matrix4x4 projMatrix = camera.projectionMatrix;
            Matrix4x4 viewMatrix = camera.worldToCameraMatrix;

            var vpOffset = LookingGlassUtil.GetVPMatrixOffsets(
                camera.aspect, perCameraInfo.fov, perCameraInfo.size,
                view, numViews);

            // view matrix
            viewMatrix.m03 -= vpOffset.x;
            viewMatrix.m13 -= vpOffset.y;

            // proj matrix
            projMatrix.m02 -= vpOffset.z;
            projMatrix.m12 -= vpOffset.w;


            cmd.SetViewProjectionMatrices(viewMatrix, projMatrix);
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
        }