/// <summary>
        /// Common gather texture function.
        /// </summary>
        /// <param name="node">The node to look into.</param>
        /// <param name="materialContext">The visitor context.</param>
        /// <returns>A collection of MaterialTextureNode.</returns>
        private IEnumerable <MaterialTextureNode> GatherTextures(IMaterialNode node, MaterialContext materialContext)
        {
            var textureValues = new List <MaterialTextureNode>();

            node.VisitNodes((context, nodeEntry) =>
            {
                var textureValue = nodeEntry.Node as MaterialTextureNode;
                if (textureValue != null)
                {
                    textureValues.Add(textureValue);
                }
            }, materialContext);
            return(textureValues);
        }
Example #2
0
        /// <summary>
        /// Gather all the parameters in the node hierarchy.
        /// </summary>
        /// <param name="node">The node to look into.</param>
        /// <param name="parameters">The parameter collection to fill.</param>
        private void GetParametersFromNode(IMaterialNode node, ParameterCollectionData parameters)
        {
            if (node == null)
            {
                return;
            }

            node.VisitNodes((context, nodeEntry) =>
            {
                var shaderNode = nodeEntry.Node as MaterialShaderClassNode;
                if (shaderNode != null)
                {
                    //foreach (var member in shaderNode.Members)
                    foreach (var member in shaderNode.GetParameters(context))
                    {
                        parameters.Set(member.Key, member.Value);
                    }
                }
            }, new MaterialContext {
                Material = Material, ExploreGenerics = false
            });
        }
        /// <summary>
        /// Gather all the sampler generics in the node hierarchy.
        /// </summary>
        /// <param name="node">The node to look into.</param>
        /// <returns>A collection of NodeParameterSampler.</returns>
        private IEnumerable <NodeParameterSampler> GatherSamplerValues(IMaterialNode node)
        {
            var samplerValues = new List <NodeParameterSampler>();

            node.VisitNodes((context, nodeEntry) =>
            {
                var shaderClassNode = nodeEntry.Node as MaterialShaderClassNode;
                if (shaderClassNode != null)
                {
                    foreach (var gen in shaderClassNode.Generics)
                    {
                        var genSampler = gen.Value as NodeParameterSampler;
                        if (genSampler != null)
                        {
                            samplerValues.Add(genSampler);
                        }
                    }
                }
            }, new MaterialContext {
                Material = Material, ExploreGenerics = false
            });
            return(samplerValues);
        }