private void Init()
        {
            if (m_IsInit)
            {
                return;
            }
            if (RecordConfig == null)
            {
                NRDebugger.LogError("RecordConfig is null!!!!!");
            }
            BlendMode = RecordConfig.BlendMode;
            var config = RecordConfig.ToNativeConfig();

            if (!Directory.Exists(config.outPutPath))
            {
                Directory.CreateDirectory(config.outPutPath);
            }

            NRDebugger.LogError(config.ToString());
            Encoder     = new NREncoder(config);
            CameraInput = new CameraInput(Encoder, CaptureCamera, BlendMode, false);

            RGBTexture = new NRRGBCamTexture();
            PreviewScreen.SetData(RGBTexture.GetTexture(), false);
            PreviewScreen.gameObject.SetActive(false);
            RGBTexture.OnUpdate += OnFrame;
            m_IsInit             = true;
        }
Beispiel #2
0
        public CameraInput(NREncoder encoder, Camera camera, BlendMode mode, bool islinear = true)
        {
            TargetCamera = camera;
            Encoder      = encoder;

            var width  = Encoder.EncodeConfig.Width;
            var height = Encoder.EncodeConfig.height;

            BlendMode = mode;

            Shader blendshader;

            if (islinear)
            {
                blendshader = Resources.Load <Shader>("Shaders/AlphaBlendLinear");
            }
            else
            {
                blendshader = Resources.Load <Shader>("Shaders/AlphaBlendGamma");
            }

            switch (BlendMode)
            {
            case BlendMode.RGBOnly:
                BlendTexture = new RenderTexture(width, height, 24);
                break;

            case BlendMode.VirtualOnly:
                BlendTexture = new RenderTexture(width, height, 24);
                break;

            case BlendMode.Blend:
                BlendMaterial = new Material(blendshader);
                BlendTexture  = new RenderTexture(width, height, 24);
                break;

            case BlendMode.WidescreenBlend:
                // TODO
                //BlendMaterial = new Material(Resources.Load<Shader>("Shaders/AlphaBlend"));
                //BlendTexture = new RenderTexture(2 * width, height, 24);
                break;

            default:
                break;
            }

            TargetCamera.targetTexture = new RenderTexture(width, height, 24, RenderTextureFormat.ARGB32);
        }