Exemplo n.º 1
0
            public static void ValidateNode(AbstractMaterialNode node)
            {
                Type t = node.GetType();

                node.ValidateNode();
                if (!(node is BlockNode))
                {
                    bool disallowedByAnyTargets  = false;
                    bool disallowedByAllTargets  = true;
                    IEnumerable <Target> targets = node.owner.activeTargets;
                    if (node.owner.isSubGraph)
                    {
                        targets = node.owner.validTargets;
                    }
                    foreach (var target in targets)
                    {
                        //if at least one target doesnt allow a node, it is considered invalid
                        if (!target.IsNodeAllowedByTarget(t))
                        {
                            disallowedByAnyTargets = true;
                            node.isValid           = false;
                            node.owner.AddValidationError(node.objectId, $"{node.name} Node is not allowed by {target.displayName} implementation", Rendering.ShaderCompilerMessageSeverity.Warning);
                            node.owner.m_UnsupportedTargets.Add(target);
                        }
                        //at least one target does allow node, not going to be explicitly set inactive
                        else
                        {
                            disallowedByAllTargets = false;
                        }
                    }
                    if (!disallowedByAnyTargets)
                    {
                        node.isValid = true;
                    }

                    //Set ActiveState based on if all targets disallow this node
                    if (disallowedByAllTargets)
                    {
                        node.SetOverrideActiveState(AbstractMaterialNode.ActiveState.ExplicitInactive);
                        node.owner.AddValidationError(node.objectId, $"{node.name} Node is not allowed by any active targets, and will not be used in generation", Rendering.ShaderCompilerMessageSeverity.Warning);
                    }
                    else
                    {
                        node.SetOverrideActiveState(AbstractMaterialNode.ActiveState.Implicit);
                    }
                }
            }