public void Execute()
 {
     if (isOrtho)
     {
         OrthoCam cam = new OrthoCam
         {
             forward  = forward,
             up       = up,
             right    = right,
             position = 0
         };
         cam.UpdateTRSMatrix();
         viewProj = mul(proj, cam.worldToCameraMatrix);
     }
     else
     {
         PerspCam cam = new PerspCam
         {
             forward  = forward,
             up       = up,
             right    = right,
             position = 0
         };
         cam.UpdateTRSMatrix();
         viewProj = mul(proj, cam.worldToCameraMatrix);
     }
     invViewProj = inverse(viewProj);
 }
        public override void FrameUpdate(PipelineCamera camera, ref PipelineCommandData data)
        {
            float4x4 proj = GL.GetGPUProjectionMatrix(camera.cam.nonJitteredProjectionMatrix, false);
            float4x4 viewProj;

            if (camera.cam.orthographic)
            {
                OrthoCam cam = new OrthoCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            else
            {
                PerspCam cam = new PerspCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            CommandBuffer buffer = data.buffer;

            buffer.SetGlobalMatrix(_InvSkyVP, inverse(viewProj));
            buffer.SetRenderTarget(color: camera.targets.renderTargetIdentifier, depth: ShaderIDs._DepthBufferTexture);
            buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, skyboxMaterial, 0, 0);
        }
        public override void FrameUpdate(PipelineCamera camera, ref PipelineCommandData data)
        {
            SkyboxMatrixData skyData = IPerCameraData.GetProperty(camera, () => new SkyboxMatrixData(), this);
            float4x4         proj    = GL.GetGPUProjectionMatrix(camera.cam.nonJitteredProjectionMatrix, false);
            float4x4         viewProj;

            if (camera.cam.orthographic)
            {
                OrthoCam cam = new OrthoCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            else
            {
                PerspCam cam = new PerspCam
                {
                    forward  = camera.cam.transform.forward,
                    up       = camera.cam.transform.up,
                    right    = camera.cam.transform.right,
                    position = 0
                };
                cam.UpdateTRSMatrix();
                viewProj = mul(proj, cam.worldToCameraMatrix);
            }
            CommandBuffer buffer = data.buffer;

            buffer.SetGlobalMatrix(_InvSkyVP, inverse(viewProj));
            buffer.SetGlobalMatrix(_LastSkyVP, skyData.lastVP);
            targets[0] = camera.targets.renderTargetIdentifier;
            targets[1] = camera.targets.motionVectorTexture;
            buffer.SetRenderTarget(colors: targets, depth: camera.targets.depthBuffer);
            buffer.DrawMesh(GraphicsUtility.mesh, Matrix4x4.identity, skyboxMaterial, 0, 0);
            skyData.lastVP = viewProj;
        }