Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MaterialTreeShaderCreator.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Globalization;
6 using System.IO;
7 using System.Linq;
8 using SiliconStudio.Assets;
9 using SiliconStudio.Core.Diagnostics;
10 using SiliconStudio.Core.Mathematics;
11 using SiliconStudio.Paradox.Assets.Materials.Nodes;
12 using SiliconStudio.Paradox.Effects;
13 using SiliconStudio.Paradox.Shaders;
14 
15 namespace SiliconStudio.Paradox.Assets.Materials.Processor.Visitors
16 {
18  {
19  #region Private constants
20 
21  //private const string BackgroundCompositionName = "backgroundName";
22  //private const string ForegroundCompositionName = "foregroundName";
23  private const string BackgroundCompositionName = "color1";
24  private const string ForegroundCompositionName = "color2";
25 
26  #endregion
27 
28  #region Private members
29 
30  /// <summary>
31  /// The shader build statuses.
32  /// </summary>
33  private Dictionary<string, ShaderBuildStatus> shaderBuildStatuses;
34 
35  /// <summary>
36  /// Flag to change some shaders.
37  /// </summary>
38  private bool shaderForReduction = false;
39 
40  /// <summary>
41  /// A flag stating if this is for displacement purpose.
42  /// </summary>
43  private bool displacementShader = false;
44 
45  /// <summary>
46  /// The constant values.
47  /// </summary>
48  private ParameterCollection constantValues;
49 
50  #endregion
51 
52  #region Public members
53 
54  /// <summary>
55  /// All the shaders.
56  /// </summary>
57  public Dictionary<string, ShaderSource> ModelShaderSources;
58 
59  /// <summary>
60  /// The error logger.
61  /// </summary>
62  public readonly LoggerResult Logger;
63 
64  #endregion
65 
66  #region Public methods
67 
69  {
70  shaderBuildStatuses = mat.Nodes.ToDictionary(x => x.Key, x => ShaderBuildStatus.None);
71  ModelShaderSources = new Dictionary<string, ShaderSource>();
72  Logger = new LoggerResult();
73  }
74 
75  /// <summary>
76  /// Generate one shader.
77  /// </summary>
79  {
80  shaderForReduction = true;
81 
82  var textureVisitor = new MaterialTextureVisitor(Material);
83  var allTextures = textureVisitor.GetAllTextureValues(materialNode);
84  textureVisitor.AssignDefaultTextureKeys(allTextures.Distinct(), null);
85  return GetShaderMixinSource(GetShaderSource(materialNode));
86  }
87 
88  /// <summary>
89  /// Generate all the shaders for this model, assign keys for texture and samplers.
90  /// </summary>
91  /// <returns>A dictionary of the shaders.</returns>
93  {
94  AssignModelTextureKeys();
95  ModelShaderSources = new Dictionary<string, ShaderSource>();
96  constantValues = new ParameterCollection();
97  shaderBuildStatuses = Material.Nodes.ToDictionary(x => x.Key, x => ShaderBuildStatus.None);
98  var result = new ParameterCollection();
99  shaderForReduction = false;
100  foreach (var reference in Material.ColorNodes)
101  {
102  if (reference.Key != null)
103  {
104  if (reference.Value != null)
105  {
106  BeginShaderCreation(reference.Value, reference.Key == MaterialParameters.DisplacementMap);
107 
108  ShaderSource shaderSource;
109  if (ModelShaderSources.TryGetValue(reference.Value, out shaderSource))
110  {
111  var sms = GetShaderMixinSource(shaderSource);
112  if (sms != null)
113  {
114  result.Add(reference.Key, sms);
115  continue;
116  }
117  }
118  }
119  Logger.Error("[Material] Shader creation failed. The key " + reference.Key.Name + " did not produce any shader.");
120  }
121  else
122  {
123  Logger.Error("[Material] Shader creation failed. The key " + reference.Key.Name + " in ColorNodes is not a ShaderMixinSource parameter key.");
124  }
125  }
126  constantValues.CopyTo(result);
127  return result;
128  }
129 
130  #endregion
131 
132  #region Private methods
133 
134  /// <summary>
135  /// Assign the default texture keys to this model.
136  /// </summary>
137  private void AssignModelTextureKeys()
138  {
139  var textureVisitor = new MaterialTextureVisitor(Material);
140  var allTextures = new List<MaterialTextureNode>();
141  var allSampler = new List<NodeParameterSampler>();
142  foreach (var referenceName in Material.ColorNodes.Select(x => x.Value))
143  {
144  var startNode = Material.FindNode(referenceName);
145  if (startNode != null)
146  {
147  allTextures.AddRange(textureVisitor.GetAllTextureValuesWithGenerics(startNode));
148  allSampler.AddRange(textureVisitor.GetAllSamplerValues(startNode));
149  }
150  }
151  textureVisitor.AssignDefaultTextureKeys(allTextures.Distinct(), allSampler.Distinct());
152  }
153 
154  /// <summary>
155  /// Creates shaders with multiple keys.
156  /// </summary>
157  /// <param name="referenceName">The name of the reference.</param>
158  /// <param name="useForDisplacement">A flag stating that this shader will be used for displacement.</param>
159  private void BeginShaderCreation(string referenceName, bool useForDisplacement)
160  {
161  if (referenceName == null || !shaderBuildStatuses.ContainsKey(referenceName))
162  return;
163 
164  displacementShader = useForDisplacement;
165 
166  var status = shaderBuildStatuses[referenceName];
167 
168  if (status == ShaderBuildStatus.None)
169  {
170  var node = Material.FindNode(referenceName);
171  if (node == null)
172  {
173  Logger.Error("[Material] There is no node with the name " + referenceName + ".");
174  shaderBuildStatuses[referenceName] = ShaderBuildStatus.Completed;
175  return;
176  }
177 
178  shaderBuildStatuses[referenceName] = ShaderBuildStatus.InProgress;
179  ModelShaderSources[referenceName] = GetShaderSource(node);
180  shaderBuildStatuses[referenceName] = ShaderBuildStatus.Completed;
181  }
182  else if (status == ShaderBuildStatus.InProgress)
183  {
184  shaderBuildStatuses[referenceName] = ShaderBuildStatus.Completed;
185  Logger.Error("[Material] The node reference " + referenceName + " is part of a cycle.");
186  }
187  }
188 
189  /// <summary>
190  /// Gets the shader source.
191  /// </summary>
192  /// <param name="node">The node to process.</param>
193  /// <returns>The shader source.</returns>
194  private ShaderSource GetShaderSource(IMaterialNode node)
195  {
196  if (node == null)
197  return new ShaderClassSource("ComputeColor");
198 
199  if (node is MaterialFloatNode)
200  return GetShaderSource(node as MaterialFloatNode);
201  if (node is MaterialFloat4Node)
202  return GetShaderSource(node as MaterialFloat4Node);
203  if (node is MaterialColorNode)
204  return GetShaderSource(node as MaterialColorNode);
205  if (node is MaterialTextureNode)
206  return GetShaderSource(node as MaterialTextureNode);
207  if (node is MaterialShaderClassNode)
208  return GetShaderSource(node as MaterialShaderClassNode);
209  if (node is MaterialBinaryNode)
210  return GetShaderSource(node as MaterialBinaryNode);
211  if (node is MaterialReferenceNode)
212  {
213  var referenceName = (node as MaterialReferenceNode).Name;
214  if (shaderForReduction)
215  {
216  var refNode = Material.FindNode(referenceName);
217  return GetShaderSource(refNode);
218  }
219  else
220  {
221  if (referenceName == null)
222  {
223  Logger.Warning("[Material] The MaterialReferenceNode [" + node + "] doesn't reference anything.");
224  return null;
225  }
226 
227  BeginShaderCreation(referenceName, displacementShader);
228 
229  ShaderSource shaderSource;
230  if (!ModelShaderSources.TryGetValue(referenceName, out shaderSource))
231  return null;
232 
233  return shaderSource;
234  }
235  }
236 
237  // TODO: error?
238  throw new Exception("[Material] An unsupported material node was encountered during shader creation.");
239  }
240 
241  /// <summary>
242  /// Build the ShaderMixinSource to evaluate the binaryNode.
243  /// </summary>
244  /// <param name="node">The MaterialFloatNode binaryNode used as source to find the ShaderMixinSource.</param>
245  /// <returns>The corresponding ShaderMixinSource.</returns>
246  private ShaderSource GetShaderSource(MaterialFloatNode node)
247  {
248  if (!node.IsReducible && node.Key != null)
249  {
250  constantValues.Set(node.Key, node.Value);
251  return new ShaderClassSource("ComputeColorConstantFloatLink", node.Key);
252  }
253 
254  return new ShaderClassSource("ComputeColorFixed", GetAsShaderString(node.Value));
255  }
256 
257  /// <summary>
258  /// Build the ShaderMixinSource to evaluate the binaryNode.
259  /// </summary>
260  /// <param name="node">The MaterialFloat4Node binaryNode used as source to find the ShaderMixinSource.</param>
261  /// <returns>The corresponding ShaderMixinSource.</returns>
262  private ShaderSource GetShaderSource(MaterialColorNode node)
263  {
264  if (!node.IsReducible && node.Key != null)
265  {
266  constantValues.Set(node.Key, node.Value);
267  return new ShaderClassSource("ComputeColorConstantColorLink", node.Key);
268  }
269 
270  return new ShaderClassSource("ComputeColorFixed", GetAsShaderString(node.Value));
271  }
272 
273  /// <summary>
274  /// Build the ShaderMixinSource to evaluate the binaryNode.
275  /// </summary>
276  /// <param name="node">The MaterialFloat4Node binaryNode used as source to find the ShaderMixinSource.</param>
277  /// <returns>The corresponding ShaderMixinSource.</returns>
278  private ShaderSource GetShaderSource(MaterialFloat4Node node)
279  {
280  if (!node.IsReducible && node.Key != null)
281  {
282  constantValues.Set(node.Key, node.Value);
283  return new ShaderClassSource("ComputeColorConstantLink", node.Key);
284  }
285 
286  return new ShaderClassSource("ComputeColorFixed", GetAsShaderString(node.Value));
287  }
288 
289  /// <summary>
290  /// Build the ShaderMixinSource to evaluate the binaryNode.
291  /// </summary>
292  /// <param name="node">The MaterialTextureNode binaryNode used as source to find the ShaderMixinSource.</param>
293  /// <returns>The corresponding ShaderMixinSource.</returns>
294  private ShaderSource GetShaderSource(MaterialTextureNode node)
295  {
296  string usedTexcoord;
297  if (shaderForReduction)
298  usedTexcoord = "TEXCOORD0";
299  else
300  usedTexcoord = "TEXCOORD" + GetTextureIndex(node.TexcoordIndex);
301 
302  // "TTEXTURE", "TStream"
303  ShaderClassSource shaderSource;
304  if (displacementShader)
305  shaderSource = new ShaderClassSource("ComputeColorTextureDisplacement", node.UsedParameterKey, usedTexcoord);
306  else if (node.Offset != Vector2.Zero)
307  shaderSource = new ShaderClassSource("ComputeColorTextureScaledOffsetSampler", node.UsedParameterKey, usedTexcoord, GetAsShaderString(node.Scale), GetAsShaderString(node.Offset), node.Sampler.SamplerParameterKey);
308  else if (node.Scale != Vector2.One)
309  shaderSource = new ShaderClassSource("ComputeColorTextureScaledSampler", node.UsedParameterKey, usedTexcoord, GetAsShaderString(node.Scale), node.Sampler.SamplerParameterKey);
310  else
311  shaderSource = new ShaderClassSource("ComputeColorTextureSampler", node.UsedParameterKey, usedTexcoord, node.Sampler.SamplerParameterKey);
312 
313  return shaderSource;
314  }
315 
316  /// <summary>
317  /// Build the ShaderMixinSource to evaluate the binaryNode.
318  /// </summary>
319  /// <param name="node">The MaterialShaderClassNode binaryNode used as source to find the ShaderMixinSource.</param>
320  /// <returns>The corresponding ShaderMixinSource.</returns>
321  private ShaderSource GetShaderSource(MaterialShaderClassNode node)
322  {
323  if (!node.MixinReference.HasLocation())
324  return new ShaderClassSource("ComputeColor");
325  var mixinName = Path.GetFileNameWithoutExtension(node.MixinReference.Location);
326 
327  object[] generics = null;
328  if (node.Generics.Count > 0)
329  {
330  // TODO: correct generic order
331  var mixinGenerics = new List<object>();
332  foreach (var genericKey in node.Generics.Keys)
333  {
334  var generic = node.Generics[genericKey];
335  if (generic is NodeParameterTexture)
336  {
337  var textureReference = ((NodeParameterTexture)generic).Reference;
338  var foundNode = Material.FindNode(textureReference);
339  while (foundNode != null && !(foundNode is MaterialTextureNode))
340  {
341  var refNode = foundNode as MaterialReferenceNode;
342  if (refNode == null)
343  break;
344 
345  foundNode = Material.FindNode(refNode.Name);
346  }
347 
348  var foundTextureNode = foundNode as MaterialTextureNode;
349  if (foundTextureNode == null || foundTextureNode.UsedParameterKey == null)
350  {
351  Logger.Warning("[Material] The generic texture reference in node [" + node + "] is incorrect.");
352  mixinGenerics.Add("Texturing.Texture0");
353  }
354  else
355  mixinGenerics.Add(foundTextureNode.UsedParameterKey.ToString());
356  }
357  else if (generic is NodeParameterSampler)
358  {
359  var pk = ((NodeParameterSampler)generic).SamplerParameterKey;
360  if (pk == null)
361  {
362  Logger.Warning("[Material] The generic sampler reference in node [" + node + "] is incorrect.");
363  mixinGenerics.Add("Texturing.Sampler");
364  }
365  else
366  mixinGenerics.Add(pk.ToString());
367  }
368  else if (generic is NodeParameterFloat)
369  mixinGenerics.Add(((NodeParameterFloat)generic).Value.ToString(CultureInfo.InvariantCulture));
370  else if (generic is NodeParameterInt)
371  mixinGenerics.Add(((NodeParameterInt)generic).Value.ToString(CultureInfo.InvariantCulture));
372  else if (generic is NodeParameterFloat2)
373  mixinGenerics.Add(GetAsShaderString(((NodeParameterFloat2)generic).Value));
374  else if (generic is NodeParameterFloat3)
375  mixinGenerics.Add(GetAsShaderString(((NodeParameterFloat3)generic).Value));
376  else if (generic is NodeParameterFloat4)
377  mixinGenerics.Add(GetAsShaderString(((NodeParameterFloat4)generic).Value));
378  else if (generic is NodeParameter)
379  mixinGenerics.Add(((NodeParameter)generic).Reference);
380  else
381  throw new Exception("[Material] Unknown node type: " + generic.GetType());
382  }
383  generics = mixinGenerics.ToArray();
384  }
385 
386  var shaderClassSource = new ShaderClassSource(mixinName, generics);
387 
388  if (node.CompositionNodes.Count == 0)
389  return shaderClassSource;
390 
391  var mixin = new ShaderMixinSource();
392  mixin.Mixins.Add(shaderClassSource);
393 
394  foreach (var comp in node.CompositionNodes)
395  {
396  if (comp.Value != null)
397  {
398  var compShader = GetShaderSource(comp.Value);
399  if (compShader != null)
400  mixin.Compositions.Add(comp.Key, compShader);
401  }
402  }
403 
404  return mixin;
405  }
406 
407  /// <summary>
408  /// Build the ShaderMixinSource to evaluate the binaryNode.
409  /// </summary>
410  /// <param name="binaryNode">The MaterialBinaryNode binaryNode used as source to find the ShaderMixinSource.</param>
411  /// <returns>The corresponding ShaderMixinSource.</returns>
412  private ShaderSource GetShaderSource(MaterialBinaryNode binaryNode)
413  {
414  var leftShaderSource = GetShaderSource(binaryNode.LeftChild);
415  var rightShaderSource = GetShaderSource(binaryNode.RightChild);
416 
417  var shaderSource = new ShaderClassSource(GetCorrespondingShaderSourceName(binaryNode.Operand));
418  var mixin = new ShaderMixinSource();
419  mixin.Mixins.Add(shaderSource);
420  if (leftShaderSource != null)
421  mixin.AddComposition(BackgroundCompositionName, leftShaderSource);
422  if (binaryNode.Operand != MaterialBinaryOperand.None && binaryNode.Operand != MaterialBinaryOperand.Opaque && rightShaderSource != null)
423  mixin.AddComposition(ForegroundCompositionName, rightShaderSource);
424 
425  return mixin;
426  }
427 
428  #endregion
429 
430  #region Private static methods
431 
432  private static int GetTextureIndex(TextureCoordinate texcoord)
433  {
434  switch (texcoord)
435  {
436  case TextureCoordinate.Texcoord0:
437  return 0;
438  case TextureCoordinate.Texcoord1:
439  return 1;
440  case TextureCoordinate.Texcoord2:
441  return 2;
442  case TextureCoordinate.Texcoord3:
443  return 3;
444  case TextureCoordinate.Texcoord4:
445  return 4;
446  case TextureCoordinate.Texcoord5:
447  return 5;
448  case TextureCoordinate.Texcoord6:
449  return 6;
450  case TextureCoordinate.Texcoord7:
451  return 7;
452  case TextureCoordinate.Texcoord8:
453  return 8;
454  case TextureCoordinate.Texcoord9:
455  return 9;
456  case TextureCoordinate.TexcoordNone:
457  default:
458  throw new ArgumentOutOfRangeException("texcoord");
459  }
460  }
461 
462  /// <summary>
463  /// Get the name of the ShaderClassSource corresponding to the operation
464  /// </summary>
465  /// <param name="materialBinaryOperand">The operand.</param>
466  /// <returns>The name of the ShaderClassSource.</returns>
467  private static string GetCorrespondingShaderSourceName(MaterialBinaryOperand materialBinaryOperand)
468  {
469  switch (materialBinaryOperand)
470  {
471  case MaterialBinaryOperand.Add:
472  return "ComputeColorAdd3ds"; //TODO: change this (ComputeColorAdd?)
473  case MaterialBinaryOperand.Average:
474  return "ComputeColorAverage";
475  case MaterialBinaryOperand.Color:
476  return "ComputeColorColor";
477  case MaterialBinaryOperand.ColorBurn:
478  return "ComputeColorColorBurn";
479  case MaterialBinaryOperand.ColorDodge:
480  return "ComputeColorColorDodge";
481  case MaterialBinaryOperand.Darken:
482  return "ComputeColorDarken3ds"; //"ComputeColorDarkenMaya" //TODO: change this
483  case MaterialBinaryOperand.Desaturate:
484  return "ComputeColorDesaturate";
485  case MaterialBinaryOperand.Difference:
486  return "ComputeColorDifference3ds"; //"ComputeColorDifferenceMaya" //TODO: change this
487  case MaterialBinaryOperand.Divide:
488  return "ComputeColorDivide";
489  case MaterialBinaryOperand.Exclusion:
490  return "ComputeColorExclusion";
491  case MaterialBinaryOperand.HardLight:
492  return "ComputeColorHardLight";
493  case MaterialBinaryOperand.HardMix:
494  return "ComputeColorHardMix";
495  case MaterialBinaryOperand.Hue:
496  return "ComputeColorHue";
497  case MaterialBinaryOperand.Illuminate:
498  return "ComputeColorIlluminate";
499  case MaterialBinaryOperand.In:
500  return "ComputeColorIn";
501  case MaterialBinaryOperand.Lighten:
502  return "ComputeColorLighten3ds"; //"ComputeColorLightenMaya" //TODO: change this
503  case MaterialBinaryOperand.LinearBurn:
504  return "ComputeColorLinearBurn";
505  case MaterialBinaryOperand.LinearDodge:
506  return "ComputeColorLinearDodge";
507  case MaterialBinaryOperand.Mask:
508  return "ComputeColorMask";
509  case MaterialBinaryOperand.Multiply:
510  return "ComputeColorMultiply"; //return "ComputeColorMultiply3ds"; //"ComputeColorMultiplyMaya" //TODO: change this
511  case MaterialBinaryOperand.None:
512  return "ComputeColorNone";
513  case MaterialBinaryOperand.Opaque:
514  return "ComputeColorOpaque";
515  case MaterialBinaryOperand.Out:
516  return "ComputeColorOut";
517  case MaterialBinaryOperand.Over:
518  return "ComputeColorOver3ds"; //TODO: change this to "ComputeColorLerpAlpha"
519  case MaterialBinaryOperand.Overlay:
520  return "ComputeColorOverlay3ds"; //"ComputeColorOverlayMaya" //TODO: change this
521  case MaterialBinaryOperand.PinLight:
522  return "ComputeColorPinLight";
523  case MaterialBinaryOperand.Saturate:
524  return "ComputeColorSaturate";
525  case MaterialBinaryOperand.Saturation:
526  return "ComputeColorSaturation";
527  case MaterialBinaryOperand.Screen:
528  return "ComputeColorScreen";
529  case MaterialBinaryOperand.SoftLight:
530  return "ComputeColorSoftLight";
531  case MaterialBinaryOperand.Subtract:
532  return "ComputeColorSubtract3ds"; //"ComputeColorOverlayMaya" //TODO: change this
533  case MaterialBinaryOperand.SubstituteAlpha:
534  return "ComputeColorSubstituteAlpha";
535  default:
536  throw new ArgumentOutOfRangeException("materialBinaryOperand");
537  }
538  }
539 
540  private static string GetAsShaderString(Vector2 v)
541  {
542  return String.Format(CultureInfo.InvariantCulture, "float2({0}, {1})", v.X, v.Y);
543  }
544 
545  private static string GetAsShaderString(Vector3 v)
546  {
547  return String.Format(CultureInfo.InvariantCulture, "float3({0}, {1}, {2})", v.X, v.Y, v.Z);
548  }
549 
550  private static string GetAsShaderString(Vector4 v)
551  {
552  return String.Format(CultureInfo.InvariantCulture, "float4({0}, {1}, {2}, {3})", v.X, v.Y, v.Z, v.W);
553  }
554 
555  private static string GetAsShaderString(Color4 c)
556  {
557  return String.Format(CultureInfo.InvariantCulture, "float4({0}, {1}, {2}, {3})", c.R, c.G, c.B, c.A);
558  }
559 
560  private static string GetAsShaderString(float f)
561  {
562  return String.Format(CultureInfo.InvariantCulture, "float4({0}, {0}, {0}, {0})", f);
563  }
564 
565  private static string GetAsShaderString(object obj)
566  {
567  return obj.ToString();
568  }
569 
570  /// <summary>
571  /// Build a encapsuling ShaderMixinSource if necessary.
572  /// </summary>
573  /// <param name="shaderSource">The input ShaderSource.</param>
574  /// <returns>A ShaderMixinSource</returns>
575  private static ShaderMixinSource GetShaderMixinSource(ShaderSource shaderSource)
576  {
577  if (shaderSource is ShaderClassSource)
578  {
579  var mixin = new ShaderMixinSource();
580  mixin.Mixins.Add((ShaderClassSource)shaderSource);
581  return mixin;
582  }
583  if (shaderSource is ShaderMixinSource)
584  return (ShaderMixinSource)shaderSource;
585 
586  return null;
587  }
588 
589  #endregion
590 
591  private enum ShaderBuildStatus
592  {
593  None,
594  InProgress,
595  Completed
596  }
597  }
598 }
ParameterKey< SamplerState > SamplerParameterKey
The sampler key used in the shader.
TextureCoordinate TexcoordIndex
The texture coordinate used to sample the texture.
static readonly Vector2 Zero
A SiliconStudio.Core.Mathematics.Vector2 with all of its components set to zero.
Definition: Vector2.cs:52
A node that describe a binary operation between two IMaterialNode
Represents a two dimensional mathematical vector.
Definition: Vector2.cs:42
A mixin performing a combination of ShaderClassSource and other mixins.
SiliconStudio.Core.Diagnostics.LoggerResult LoggerResult
A logger that stores messages locally useful for internal log scenarios.
Definition: LoggerResult.cs:14
IMaterialNode LeftChild
The left (background) child node.
ParameterCollection GenerateModelShaders()
Generate all the shaders for this model, assign keys for texture and samplers.
Vector2 Offset
The offset in the texture coordinates.
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
TextureCoordinate
The texture coordinate.
NodeParameterSampler Sampler
The sampler of the texture.
Represents a color in the form of rgba.
Definition: Color4.cs:42
Base implementation for ILogger.
Definition: Logger.cs:10
static readonly Vector2 One
A SiliconStudio.Core.Mathematics.Vector2 with all of its components set to one.
Definition: Vector2.cs:67
MaterialBinaryOperand
Operands of the MaterialNode.
Represents a four dimensional mathematical vector.
Definition: Vector4.cs:42
ParameterKey< Graphics.Texture > UsedParameterKey
The parameter key used in the shader.
ShaderMixinSource GenerateShaderForReduction(IMaterialNode materialNode)
Generate one shader.
Base interface for all nodes in the material tree
static readonly ParameterKey< ShaderMixinSource > DisplacementMap
A container to handle a hierarchical collection of effect variables.
bool IsReducible
The flag to allow the node to be reducible.
Dictionary< string, IMaterialNode > CompositionNodes
The compositions of this class.
IMaterialNode RightChild
The right (foreground) child node.
MaterialBinaryOperand Operand
The operation to blend the nodes.