4 using System.Collections.Generic;
6 using SiliconStudio.Assets;
7 using SiliconStudio.Core;
8 using SiliconStudio.Core.Serialization.Contents;
9 using SiliconStudio.Paradox.Assets.Materials.Nodes;
10 using SiliconStudio.Paradox.Effects;
11 using SiliconStudio.Paradox.Effects.Data;
12 using SiliconStudio.Paradox.Shaders;
14 namespace SiliconStudio.
Paradox.Assets.Materials
19 [ContentSerializer(typeof(DataContentSerializer<MaterialDescription>))]
20 [DataContract(
"Material")]
30 public Dictionary<string, IMaterialNode> Nodes {
get; set; }
39 public Dictionary<ParameterKey<ShaderMixinSource>,
string> ColorNodes {
get; set; }
56 Nodes =
new Dictionary<string, IMaterialNode>();
57 ColorNodes =
new Dictionary<ParameterKey<ShaderMixinSource>,
string>();
68 if (Nodes.ContainsKey(referenceName))
69 throw new Exception(
"A reference with name " + referenceName +
" already exists");
70 Nodes.Add(referenceName, node);
81 if (ColorNodes.ContainsKey(key))
82 ColorNodes[key] = referenceName;
84 ColorNodes.Add(key, referenceName);
86 AddNode(referenceName, node);
97 if (ColorNodes.TryGetValue(key, out treeName))
100 if (Nodes.TryGetValue(treeName, out materialTree))
114 if (referenceName != null && Nodes.TryGetValue(referenceName, out materialTree))
127 if (Nodes.TryGetValue(referenceName, out prevNode))
129 if (!ReferenceEquals(node, prevNode))
130 throw new Exception(
"Unable to create a reference with the name " + referenceName +
" because there is already a reference with that name.");
135 foreach (var tree
in Nodes.Select(x => x.Value))
139 Nodes.Add(referenceName, node);
150 Parameters.Set(parameterKey, value);
160 return (T)Parameters[parameterKey];
Key of an effect parameter.
void SetParameter(ParameterKey parameterKey, object value)
Set the value of a compilation parameter. Creates a new entry if necessary.
IMaterialNode GetMaterialNode(ParameterKey< ShaderMixinSource > key)
Returns the material node corresponding to the brdf slot.
void AddColorNode(ParameterKey< ShaderMixinSource > key, string referenceName, IMaterialNode node)
Adds a tree in the model.
MaterialDescription()
Initializes a new instance of the MaterialDescription class.
Description of a material.
void MakeReference(IMaterialNode node, string referenceName)
Create a reference to a node.
IMaterialNode FindNode(string referenceName)
Returns the material node corresponding to the reference
Key of an gereric effect parameter.
MaterialDescription Clone()
Data type for SiliconStudio.Paradox.Effects.ParameterCollection.
void AddNode(string referenceName, IMaterialNode node)
Inserts a new tree in the material
ParameterCollectionData GetParameters()
Get all the Compilation parameters for this model.
Base interface for all nodes in the material tree