void Update() { if (_plugin == null) { return; } var frame = EncodeFrame(TargetCamera.targetTexture); if (frame != null) { PushFrame(frame); RenderTexture.ReleaseTemporary(frame); } ProcessFrameQueue(_lowLatencyMode); _dropDetector.Update(_plugin.DropCount); }
void Update() { if (_plugin == null) { return; } // Update input queue; Break if it's not ready. if (!UpdateQueue()) { return; } // Renew texture objects when the frame dimensions were changed. var dimensions = _plugin.FrameDimensions; if (_sourceTexture != null && (_sourceTexture.width != dimensions.x / 2 || _sourceTexture.height != dimensions.y)) { Util.Destroy(_sourceTexture); Util.Destroy(_receivedTexture); _sourceTexture = null; _receivedTexture = null; } // Source texture lazy initialization if (_sourceTexture == null) { _sourceTexture = new Texture2D( dimensions.x / 2, dimensions.y, TextureFormat.RGBA32, false ); _sourceTexture.filterMode = FilterMode.Point; } // Request texture update via the command buffer. Util.IssueTextureUpdateEvent( _plugin.TextureUpdateCallback, _sourceTexture, _plugin.ID ); // Receiver texture lazy initialization if (_targetTexture == null && _receivedTexture == null) { _receivedTexture = new RenderTexture(dimensions.x, dimensions.y, 0); _receivedTexture.wrapMode = TextureWrapMode.Clamp; } // Chroma upsampling var receiver = _targetTexture != null ? _targetTexture : _receivedTexture; var pass = _plugin.IsProgressive ? 0 : 1 + _fieldCount; Graphics.Blit(_sourceTexture, receiver, _upsampler, pass); receiver.IncrementUpdateCount(); // Renderer override if (_targetRenderer != null) { // Material property block lazy initialization if (_propertyBlock == null) { _propertyBlock = new MaterialPropertyBlock(); } // Read-modify-write _targetRenderer.GetPropertyBlock(_propertyBlock); _propertyBlock.SetTexture(_targetMaterialProperty, receiver); _targetRenderer.SetPropertyBlock(_propertyBlock); } _dropDetector.Update(_plugin.DropCount); }