protected override void OnRenderUpdate(GPUContext context)
        {
            base.OnRenderUpdate(context);
            var inputTexture = InputTexture;

            if (_materialInstance)
            {
                for (int i = 0; i < _inputParameters.Length; i++)
                {
                    if (!HasInput(i + 2))
                    {
                        continue;
                    }
                    _inputParameters[i].Value = GetInput(i + 2);
                }

                context.DrawPostFxMaterial(_materialInstance, Output, inputTexture);
            }
            else
            {
                context.Clear(Output, Color.Zero);
            }

            Return(0, Output);
        }
Exemple #2
0
        protected override void OnRenderUpdate(GPUContext context)
        {
            var input = GetInputOrDefault <GPUTexture>(0, null);

            if (input)
            {
                context.Draw(Output, input);
            }
            else
            {
                context.Clear(Output, Color.Black);
            }
        }
Exemple #3
0
        private void OnRender(RenderTask task, GPUContext context)
        {
            lock (_requests)
            {
                // Check if there is ready next asset to render thumbnail for it
                // But don't check whole queue, only a few items
                var request = GetReadyRequest(10);
                if (request == null)
                {
                    // Disable task
                    _task.Enabled = false;
                    return;
                }

                // Find atlas with an free slot
                var atlas = GetValidAtlas();
                if (atlas == null)
                {
                    // Error
                    _task.Enabled = false;
                    _requests.Clear();
                    Editor.LogError("Failed to get atlas.");
                    return;
                }

                // Wait for atlas being loaded
                if (!atlas.IsReady)
                {
                    return;
                }

                // Setup
                _guiRoot.RemoveChildren();
                _guiRoot.AccentColor = request.Proxy.AccentColor;

                // Call proxy to prepare for thumbnail rendering
                request.Proxy.OnThumbnailDrawBegin(request, _guiRoot, context);
                _guiRoot.UnlockChildrenRecursive();

                // Draw preview
                context.Clear(_output.View(), Color.Black);
                Render2D.CallDrawing(_guiRoot, context, _output);

                // Call proxy and cleanup UI (delete create controls, shared controls should be unlinked during OnThumbnailDrawEnd event)
                request.Proxy.OnThumbnailDrawEnd(request, _guiRoot);
                _guiRoot.DisposeChildren();

                // Copy backbuffer with rendered preview into atlas
                SpriteHandle icon = atlas.OccupySlot(_output, request.Item.ID);
                if (!icon.IsValid)
                {
                    // Error
                    _task.Enabled = false;
                    _requests.Clear();
                    Editor.LogError("Failed to occupy previews cache atlas slot.");
                    return;
                }

                // End
                request.FinishRender(ref icon);
                RemoveRequest(request);
            }
        }