5 using SiliconStudio.Core.Diagnostics;
6 using SiliconStudio.Core.IO;
7 using SiliconStudio.Core.Serialization;
8 using SiliconStudio.Paradox.Assets.Materials.Nodes;
9 using SiliconStudio.Paradox.Effects;
10 using SiliconStudio.Paradox.Effects.Data;
11 using SiliconStudio.Paradox.Effects.Modules;
12 using SiliconStudio.Paradox.Graphics;
13 using SiliconStudio.Paradox.Shaders;
15 namespace SiliconStudio.
Paradox.Assets.Materials.Processor.Visitors
21 private string materialUrl;
25 #region Public properties
31 #region Public methods
36 materialUrl = assetUrl;
48 var hasErrors =
false;
51 var shaders = materialShaderCreator.GenerateModelShaders();
54 (materialShaderCreator.Logger).CopyTo(log);
59 Parameters.Set(keyValue.Key, keyValue.Value);
65 Parameters.Set(SiliconStudio.Paradox.Graphics.Effect.BlendStateKey, ContentReference.Create((
BlendState)blendState));
71 Parameters.Set(SiliconStudio.Paradox.Graphics.Effect.RasterizerStateKey, ContentReference.Create((
RasterizerState)rasterizerState));
76 Parameters.Set(SiliconStudio.Paradox.Graphics.Effect.DepthStencilStateKey, ContentReference.Create((
DepthStencilState)depthStencilState));
84 Parameters.Set(SiliconStudio.Paradox.Graphics.Effect.RasterizerStateKey, ContentReference.Create((
RasterizerState)rasterizerState));
89 Parameters.Set(SiliconStudio.Paradox.Graphics.Effect.DepthStencilStateKey, ContentReference.Create((
DepthStencilState)depthStencilState));
94 var allTextures = textureVisitor.GetAllModelTextureValuesWithGenerics();
95 foreach (var texture
in allTextures)
97 if (texture.TextureReference == null || (texture.TextureReference.Id == Guid.Empty && String.IsNullOrEmpty(texture.TextureReference.Location)))
100 log.Error(
"[Material] Material {0} is missing a texture", materialUrl);
105 Parameters.Set(texture.UsedParameterKey,
new ContentReference<Texture2D>(texture.TextureReference.Id, texture.TextureReference.Location));
106 AddSampler(texture.Sampler);
110 var allSamplers = textureVisitor.GetAllSamplerValues();
111 foreach (var sampler
in allSamplers)
115 var parameters = parameterVisitor.GetParameters();
116 foreach (var keyValue
in parameters)
121 var textureNode = (MaterialTextureNode)keyValue.Value;
122 if (textureNode != null)
124 if (textureNode.TextureReference == null || textureNode.TextureReference.Id == Guid.Empty || String.IsNullOrEmpty(textureNode.TextureReference.Location))
127 log.Error(
"[Material] Material {0} is missing a texture", materialUrl);
131 Parameters.Set(keyValue.Key,
new ContentReference<Texture2D>(textureNode.TextureReference.Id, textureNode.TextureReference.Location));
136 var sampler = (NodeParameterSampler)keyValue.Value;
138 sampler.SamplerParameterKey = (ParameterKey<SamplerState>)keyValue.Key;
142 Parameters.Set(keyValue.Key, keyValue.Value);
146 foreach (var keyValue
in shaders)
149 log.Warning(
"[Material] Material {0} contains the key {1} which is not yet handled by the engine.", materialUrl, keyValue.Key);
151 Parameters.Set(keyValue.Key, keyValue.Value);
159 #region Private methods
167 AddressV = sampler.AddressModeV,
168 AddressW = TextureAddressMode.Wrap
171 Parameters.Set(sampler.SamplerParameterKey, ContentReference.Create((
SamplerState)samplerState));
Key of an effect parameter.
ParameterKey< SamplerState > SamplerParameterKey
The sampler key used in the shader.
TextureAddressMode AddressModeU
The texture address mode.
Describes a rasterizer state.
ParameterCollection Parameters
Contains depth-stencil state for the device.
Describes a sampler state.
Description of a material.
Data type for SiliconStudio.Paradox.Effects.ParameterCollection.
bool CreateParameterCollectionData(Logger log=null)
Compute the parameters and store them in the material.
Base implementation for ILogger.
CullMode
Indicates triangles facing a particular direction are not drawn.
static readonly ParameterKey< ShaderMixinSource > BumpMap
Fake sampler state (Description should be valid).
Fake rasterizer state (Description should be valid).
static readonly ParameterKey< ShaderMixinSource > EmissiveMap
static readonly ParameterKey< bool > UseTransparent
MaterialParametersCreator(MaterialDescription mat, string assetUrl)
TextureFilter Filtering
The texture filtering mode.
Describes a depth stencil state.
Blend
Blend option. A blend option identifies the data source and an optional pre-blend operation...
Fake blend state (Description should be valid).
static readonly ParameterKey< ShaderMixinSource > ReflectionMap
static readonly ParameterKey< bool > UseTransparentMask