Ejemplo n.º 1
0
        protected override void OnAssetPropertyChanged(string propertyName, IGraphNode node, NodeIndex index, object oldValue, object newValue)
        {
            base.OnAssetPropertyChanged(propertyName, node, index, oldValue, newValue);

            var memberNode = node as IMemberNode;

            if (memberNode != null && !PropertyGraph.UpdatingPropertyFromBase && !UndoRedoService.UndoRedoInProgress)
            {
                // If Dither changed, clamp Quality to the new valid range
                // Note: other part of the behavior is in GraphicsCompositorAssetNodeUpdater (hide Quality if Dither set to None)
                // TODO: This should be moved to FXAA-specific code to be plugin-ready (asset property changed works only at asset level)
                var ownerNode = memberNode.Parent;
                if (typeof(FXAAEffect).IsAssignableFrom(ownerNode.Type) && propertyName == nameof(FXAAEffect.Dither))
                {
                    var qualityNode = ownerNode[nameof(FXAAEffect.Quality)];
                    var dither      = (FXAAEffect.DitherType)memberNode.Retrieve();

                    // Get new valid quality range
                    var(minQuality, maxQuality) = FXAAEffect.GetQualityRange(dither);

                    // Clamp and set it back (if different)
                    var quality = (int)qualityNode.Retrieve();
                    if (quality < minQuality)
                    {
                        qualityNode.Update(minQuality);
                    }
                    else if (quality > maxQuality)
                    {
                        qualityNode.Update(maxQuality);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public override void UpdateNode(INodePresenter node)
        {
            // Adjust Quality range depending on Dither mode
            // Note: other part of the behavior is in GraphicsCompositorViewModel.OnAssetPropertyChanged (clamp Quality based on Dither)
            var fxaaEffect = node.Value as FXAAEffect;

            if (fxaaEffect != null)
            {
                var ditherNode = node[nameof(FXAAEffect.Dither)];

                // If dither type changes, we will need to update quality sliders again
                node.AddDependency(ditherNode, false);

                // Adjust quality range according to dither level
                var(minQuality, maxQuality) = FXAAEffect.GetQualityRange(fxaaEffect.Dither);
                node[nameof(FXAAEffect.Quality)].AttachedProperties[NumericData.MinimumKey] = minQuality;
                node[nameof(FXAAEffect.Quality)].AttachedProperties[NumericData.MaximumKey] = maxQuality;

                // FXAA: Hide Quality if Dither is set to None (only 9 is a valid value)
                if (fxaaEffect.Dither == FXAAEffect.DitherType.None)
                {
                    node[nameof(FXAAEffect.Quality)].IsVisible = false;
                }
            }
        }