/// <summary>
 /// Gets latest frame from the frame stream.
 /// Frames update only if stream has been started.
 /// May be called from main thread only.
 /// </summary>
 /// <returns>Latest Distorted color stream frame.</returns>
 public VarjoDistortedColorFrame GetFrame()
 {
     lock (mutex)
     {
         var frame = new VarjoDistortedColorFrame();
         frame.timestamp               = data.timestamp;
         frame.ev                      = data.ev;
         frame.exposureTime            = data.exposureTime;
         frame.whiteBalanceTemperature = data.whiteBalanceTemperature;
         frame.whiteBalanceGains       = new Color(
             (float)data.whiteBalanceColorGainR,
             (float)data.whiteBalanceColorGainG,
             (float)data.whiteBalanceColorGainB
             );
         frame.leftTexture  = leftBuffer.GetTexture2D();
         frame.rightTexture = rightBuffer.GetTexture2D();
         return(frame);
     }
 }
예제 #2
0
        private void UpdateCubemap()
        {
            Texture2D texture = buffer.GetTexture2D();

            if (texture == null)
            {
                cubemap = null;
                return;
            }
            int resolution = texture.width;

            if (!cubemap || cubemap.width != resolution)
            {
                UnityEngine.Object.Destroy(cubemap);
                cubemap = new Cubemap(resolution, TextureFormat.RGBAHalf, false);
            }
            for (int faceIdx = 0; faceIdx < 6; ++faceIdx)
            {
                Graphics.CopyTexture(
                    src: texture, srcElement: 0, srcMip: 0, srcX: 0, srcY: faceIdx * resolution, srcWidth: resolution, srcHeight: resolution,
                    dst: cubemap, dstElement: faceIdx, dstMip: 0, dstX: 0, dstY: 0
                    );
            }
        }