public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue) { if (defaultValueKey == null) throw new ArgumentNullException(nameof(defaultValueKey)); if (computeNode == null) { return; } var streamType = MaterialStreamType.Float; if (defaultValueKey.PropertyType == typeof(Vector4) || defaultValueKey.PropertyType == typeof(Color4)) { streamType = MaterialStreamType.Float4; } else if (defaultValueKey.PropertyType == typeof(Vector3) || defaultValueKey.PropertyType == typeof(Color3)) { streamType = MaterialStreamType.Float3; } else if (defaultValueKey.PropertyType == typeof(Vector2) || defaultValueKey.PropertyType == typeof(Half2)) { streamType = MaterialStreamType.Float2; } else if (defaultValueKey.PropertyType == typeof(float)) { streamType = MaterialStreamType.Float; } else { throw new NotSupportedException("ParameterKey type [{0}] is not supported by SetStream".ToFormat(defaultValueKey.PropertyType)); } var classSource = computeNode.GenerateShaderSource(Context, new MaterialComputeColorKeys(defaultTexturingKey, defaultValueKey, defaultTextureValue)); SetStream(stage, stream, streamType, classSource); }
public MaterialComputeColorKeys(ObjectParameterKey<Texture> textureBaseKey, ParameterKey valueBaseKey, Color? defaultTextureValue = null, bool isColor = true) { //if (textureBaseKey == null) throw new ArgumentNullException("textureBaseKey"); //if (valueBaseKey == null) throw new ArgumentNullException("valueBaseKey"); TextureBaseKey = textureBaseKey; ValueBaseKey = valueBaseKey; DefaultTextureValue = defaultTextureValue; IsColor = isColor; }
public ParameterKey GetParameterKey(ParameterKey key) { if (key == null) throw new ArgumentNullException("key"); var baseKey = key; int parameterKeyIndex; parameterKeyIndices.TryGetValue(baseKey, out parameterKeyIndex); key = parameterKeyIndex == 0 ? baseKey : baseKey.ComposeWith("i"+parameterKeyIndex.ToString(CultureInfo.InvariantCulture)); parameterKeyIndex++; parameterKeyIndices[baseKey] = parameterKeyIndex; return key; }
protected virtual string ResolveParameterValue(string directiveId, string processorName, string parameterName) { var key = new ParameterKey(processorName, directiveId, parameterName); if (parameters.TryGetValue(key, out var value)) { return(value); } if (processorName != null || directiveId != null) { return(ResolveParameterValue(null, null, parameterName)); } return(null); }
internal static string ExpandParameters(string value, Dictionary <ParameterKey, string> parameters) { const char TokenStart = '$'; const char TokenOpen = '('; const char TokenEnd = ')'; var sb = new StringBuilder(); for (int i = 0; i < value.Length; ++i) { if (i < value.Length - 1 && value[i] == TokenStart && value[i + 1] == TokenOpen) { var endTokenIndex = i; while (endTokenIndex < value.Length && value[endTokenIndex] != TokenEnd) { ++endTokenIndex; } if (endTokenIndex >= value.Length || value[endTokenIndex] != TokenEnd) { // We reached the end of the string // Probably not a token, or not closed token sb.Append(value.Substring(i)); break; } var parameterName = value.Substring(i + 2, endTokenIndex - i - 2); var key = new ParameterKey(string.Empty, string.Empty, parameterName); if (parameters.TryGetValue(key, out string parameterValue)) { sb.Append(parameterValue); } else { sb.Append(value.Substring(i, endTokenIndex - i + 1)); } i = endTokenIndex; } else { sb.Append(value[i]); } } return(sb.ToString()); }
public ParameterKey <Texture> GetTextureKey(Texture texture, ParameterKey <Texture> key, Color?defaultTextureValue = null) { var textureKey = (ParameterKey <Texture>)GetParameterKey(key); if (texture != null) { Parameters.Set(textureKey, texture); } else if (defaultTextureValue != null && Assets != null) { texture = GenerateTextureFromColor(defaultTextureValue.Value); Parameters.Set(textureKey, texture); } return(textureKey); }
/// <summary> /// Serializes a <see cref="Parameter"/> value according to its components. /// </summary> /// <param name="key">The <see cref="ParameterKey"/> component to serialize.</param> /// <param name="value">The <see cref="ParameterBody"/> component to serialize.</param> /// <returns>The <see cref="JsonValue"/>.</returns> protected virtual JsonValue SerializeParameter(ParameterKey key, ParameterBody value) { if (value is null) { return(null); } var json = new JsonObject(); SetJsonValue(json, PropertyConstants.Name, key.Name, true); SetJsonValue(json, PropertyConstants.In, ToJsonValue(key.Location)); SerializeParameterBody(value, json); return(json); }
public LightingUpdateInfo() { Index = -1; Type = LightingUpdateType.Directional; Count = 0; Semantic = 0; PositionKey = null; DirectionKey = null; ColorKey = null; IntensityKey = null; DecayKey = null; SpotBeamAngleKey = null; SpotFieldAngleKey = null; LightCountKey = null; }
public void SetParam <T>(ParameterKey <T> key, T value) { if (key == null) { throw new ArgumentNullException("key"); } var propertyContainer = propertyContainers.Count > 0 ? propertyContainers.Peek() : currentPropertyContainers.Peek(); propertyContainer.Set(key, value); if (propertyContainers.Count == 0) // in currentDefaultContainer? { blackListKeys.Peek().Add(key); } }
/// <summary> /// Gets a parameter value for the specified key. /// </summary> /// <typeparam name="T">Type of the parameter value</typeparam> /// <param name="key">The key.</param> /// <returns>The value or default value associated to this parameter key.</returns> /// <exception cref="System.ArgumentNullException">key</exception> public T GetParam <T>(ParameterKey <T> key) { if (key == null) { throw new ArgumentNullException("key"); } ParameterCollection sourcePropertyContainer = null; T value; // Try to get a value from registered containers foreach (var propertyContainer in propertyContainers) { if (propertyContainer.TryGet(key, out value)) { sourcePropertyContainer = propertyContainer; goto valueFound; // Use goto to speedup the code and avoid usage of additionnal bool state } } // Else gets the value (or default value) from the default property container sourcePropertyContainer = defaultPropertyContainer; value = currentPropertyContainers.Peek().Get(key); // do not store the keys behind a ParameterKey<ShaderMixinParameters>, only when it comes from defaultPropertyContainer if (!blackListKeys.Peek().Contains(key)) { currentUsedParameters.Peek().Set(key, value); } valueFound: // Cache the strip property container var stripPropertyContainer = (ParameterCollection)ReplicateContainer(sourcePropertyContainer); if (!stripPropertyContainer.ContainsKey(key)) { var stripValue = value; if (IsPropertyContainer(value)) { stripValue = (T)ReplicateContainer(value); } stripPropertyContainer.Set(key, stripValue); } return(value); }
public ParameterKey GetParameterKey(ParameterKey key) { if (key == null) { throw new ArgumentNullException("key"); } var baseKey = key; int parameterKeyIndex; parameterKeyIndices.TryGetValue(baseKey, out parameterKeyIndex); key = parameterKeyIndex == 0 ? baseKey : baseKey.ComposeWith("i" + parameterKeyIndex.ToString(CultureInfo.InvariantCulture)); parameterKeyIndex++; parameterKeyIndices[baseKey] = parameterKeyIndex; return(key); }
/// <summary> /// Initializes a new instance of the <see cref="LightDirectionalShadowMapGroupShaderData" /> class. /// </summary> /// <param name="compositionKey">The composition key.</param> /// <param name="shadowType">Type of the shadow.</param> /// <param name="lightCountMax">The light count maximum.</param> public LightDirectionalShadowMapGroupShaderData(string compositionKey, LightShadowType shadowType, int lightCountMax) { this.shadowType = shadowType; this.cascadeCount = 1 << ((int)(shadowType & LightShadowType.CascadeMask) - 1); cascadeSplits = new float[cascadeCount * lightCountMax]; worldToShadowCascadeUV = new Matrix[cascadeCount * lightCountMax]; depthBiases = new float[lightCountMax]; offsetScales = new float[lightCountMax]; var mixin = new ShaderMixinSource(); var isDepthRangeAuto = (this.shadowType & LightShadowType.DepthRangeAuto) != 0; mixin.Mixins.Add(new ShaderClassSource(ShaderName, cascadeCount, lightCountMax, (this.shadowType & LightShadowType.BlendCascade) != 0 && !isDepthRangeAuto, isDepthRangeAuto, (this.shadowType & LightShadowType.Debug) != 0)); // TODO: Temporary passing filter here switch (shadowType & LightShadowType.FilterMask) { case LightShadowType.PCF3x3: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 3)); break; case LightShadowType.PCF5x5: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 5)); break; case LightShadowType.PCF7x7: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 7)); break; default: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterDefault")); break; } shadowShader = mixin; shadowMapTextureKey = ShadowMapKeys.Texture.ComposeWith(compositionKey); shadowMapTextureSizeKey = ShadowMapKeys.TextureSize.ComposeWith(compositionKey); shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey); cascadeSplitsKey = ShadowMapReceiverDirectionalKeys.CascadeDepthSplits.ComposeWith(compositionKey); worldToShadowCascadeUVsKey = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey); depthBiasesKey = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey); offsetScalesKey = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey); }
/// <summary> /// Gets a parameter value for the specified key. /// </summary> /// <typeparam name="T">Type of the parameter value</typeparam> /// <param name="paramKey">The parameter key.</param> /// <returns>The value or default value associated to this parameter key.</returns> /// <exception cref="System.ArgumentNullException">key</exception> public T GetParam <T>(ParameterKey <T> paramKey) { if (paramKey == null) { throw new ArgumentNullException("paramKey"); } var globalKey = paramKey; var composeKey = GetComposeKey(paramKey); var selectedKey = globalKey; ParameterCollection sourceParameters = null; // Try first if a composite key with a value is available for the key if (composeKey != globalKey) { sourceParameters = FindKeyValue(composeKey, out selectedKey); } // Else try using global key if (sourceParameters == null) { sourceParameters = FindKeyValue(globalKey, out selectedKey); } // If nothing found, use composeKey and global compiler parameters if (sourceParameters == null) { selectedKey = composeKey; sourceParameters = compilerParameters; } // Gets the value from a source parameters var value = sourceParameters.Get(selectedKey); // Sore only used parameters when they are taken from compilerParameters if (sourceParameters == compilerParameters) { currentMixinSourceTree.UsedParameters.Set(selectedKey, value); } return(value); }
public static IVLPin CreatePin(ParameterCollection parameters, ParameterKey key, int count, bool isPermutationKey) { var argument = key.GetType().GetGenericArguments()[0]; if (isPermutationKey) { var createPinMethod = typeof(EffectPins).GetMethod(nameof(CreatePermutationPin), BindingFlags.Static | BindingFlags.Public); return(createPinMethod.MakeGenericMethod(argument).Invoke(null, new object[] { parameters, key }) as IVLPin); } else if (argument.IsValueType) { var createPinMethod = typeof(EffectPins).GetMethod(nameof(CreateValuePin), BindingFlags.Static | BindingFlags.Public); return(createPinMethod.MakeGenericMethod(argument).Invoke(null, new object[] { parameters, key, count }) as IVLPin); } else { var createPinMethod = typeof(EffectPins).GetMethod(nameof(CreateResourcePin), BindingFlags.Static | BindingFlags.Public); return(createPinMethod.MakeGenericMethod(argument).Invoke(null, new object[] { parameters, key }) as IVLPin); } }
private ParameterCollection FindKeyValue <T>(ParameterKey <T> key, out ParameterKey <T> selectedKey) { // Try to get a value from registered containers selectedKey = null; foreach (var parameterCollection in parameterCollections) { if (parameterCollection.ContainsKey(key)) { selectedKey = key; return(parameterCollection); } } if (compilerParameters.ContainsKey(key)) { selectedKey = key; return(compilerParameters); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="LightSpotShadowMapGroupShaderData" /> class. /// </summary> /// <param name="compositionKey">The composition key.</param> /// <param name="shadowType">Type of the shadow.</param> /// <param name="lightCountMax">The light count maximum.</param> public LightSpotShadowMapGroupShaderData(string compositionKey, LightShadowType shadowType, int lightCountMax) { this.shadowType = shadowType; worldToShadowCascadeUV = new Matrix[lightCountMax]; depthBiases = new float[lightCountMax]; offsetScales = new float[lightCountMax]; var mixin = new ShaderMixinSource(); mixin.Mixins.Add(new ShaderClassSource(ShaderName, lightCountMax, (this.shadowType & LightShadowType.Debug) != 0)); // TODO: Temporary passing filter here switch (shadowType & LightShadowType.FilterMask) { case LightShadowType.PCF3x3: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 3)); break; case LightShadowType.PCF5x5: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 5)); break; case LightShadowType.PCF7x7: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 7)); break; default: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterDefault")); break; } shadowShader = mixin; shadowMapTextureKey = ShadowMapKeys.Texture.ComposeWith(compositionKey); shadowMapTextureSizeKey = ShadowMapKeys.TextureSize.ComposeWith(compositionKey); shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey); worldToShadowCascadeUVsKey = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey); depthBiasesKey = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey); offsetScalesKey = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey); }
/// <summary> /// Compares the value behind a key in two ParameterCollection. /// </summary> /// <param name="parameters0">The first ParameterCollection.</param> /// <param name="parameters1">The second ParameterCollection.</param> /// <param name="key">The ParameterKey.</param> /// <returns>True</returns> private static bool CompareKeyValue <T>(ParameterCollection parameters0, ParameterCollection parameters1, ParameterKey <T> key) { var value0 = parameters0 != null && parameters0.ContainsKey(key) ? parameters0[key] : key.DefaultValueMetadataT.DefaultValue; var value1 = parameters1 != null && parameters1.ContainsKey(key) ? parameters1[key] : key.DefaultValueMetadataT.DefaultValue; return(value0 == value1); }
/// <summary> /// The check event param exists. /// </summary> /// <param name = "eventArgs"> /// The event args. /// </param> /// <param name = "paramKey"> /// The param key. /// </param> protected static void CheckEventParamExists(EventData eventArgs, ParameterKey paramKey) { Assert.Contains((short)paramKey, eventArgs.Parameters.Keys, "Parameter '{0}' is missing in event.", paramKey); }
/// <summary> /// The check param. /// </summary> /// <param name="response"> /// The response. /// </param> /// <param name="paramKey"> /// The param key. /// </param> /// <param name="expectedValue"> /// The expected value. /// </param> protected static void CheckParam(OperationResponse response, ParameterKey paramKey, object expectedValue) { CheckParamExists(response, paramKey); object value = response.Parameters[(byte)paramKey]; Assert.AreEqual(expectedValue, value, "Parameter '{0} has an unexpected value", paramKey); }
/// <summary> /// The check event param. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> /// <param name="paramKey"> /// The param key. /// </param> /// <param name="expectedValue"> /// The expected value. /// </param> protected static void CheckEventParam(EventData eventArgs, ParameterKey paramKey, object expectedValue) { CheckEventParamExists(eventArgs, paramKey); Assert.AreEqual(expectedValue, eventArgs.Parameters[(byte)paramKey], "Event param '{0}' has unexpected value", paramKey); }
public LightAmbientShaderGroupData(LightAmbientShaderGroup group) : base(null) { ambientLightKey = group.AmbientLightKey; }
/// <summary> /// Get the value of a compilation parameter. Creates a new entry if necessary. /// </summary> /// <param name="parameterKey">The parameter key.</param> /// <returns>The value of the parameter.</returns> public T GetParameter <T>(ParameterKey <T> parameterKey) { return((T)Parameters[parameterKey]); }
/// <summary> /// Initializes a new instance of the <see cref="LightSpotShadowMapGroupShaderData" /> class. /// </summary> /// <param name="compositionKey">The composition key.</param> /// <param name="shadowType">Type of the shadow.</param> /// <param name="lightCountMax">The light count maximum.</param> public LightSpotShadowMapGroupShaderData(string compositionKey, LightShadowType shadowType, int lightCountMax) { this.shadowType = shadowType; worldToShadowCascadeUV = new Matrix[lightCountMax]; depthBiases = new float[lightCountMax]; offsetScales = new float[lightCountMax]; var mixin = new ShaderMixinSource(); mixin.Mixins.Add(new ShaderClassSource(ShaderName,lightCountMax, (this.shadowType & LightShadowType.Debug) != 0)); // TODO: Temporary passing filter here switch (shadowType & LightShadowType.FilterMask) { case LightShadowType.PCF3x3: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 3)); break; case LightShadowType.PCF5x5: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 5)); break; case LightShadowType.PCF7x7: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 7)); break; default: mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterDefault")); break; } shadowShader = mixin; shadowMapTextureKey = ShadowMapKeys.Texture.ComposeWith(compositionKey); shadowMapTextureSizeKey = ShadowMapKeys.TextureSize.ComposeWith(compositionKey); shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey); worldToShadowCascadeUVsKey = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey); depthBiasesKey = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey); offsetScalesKey = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey); }
private void UpdateRequiredKeys(HashSet <ParameterKey> requiredKeys, Dictionary <ParameterKey, ParameterDependency> allDependencies, ParameterKey key, HashSet <ParameterDependency> requiredDependencies) { if (requiredKeys.Add(key)) { ParameterDependency dependency; if (allDependencies.TryGetValue(key, out dependency)) { requiredDependencies.Add(dependency); foreach (var source in dependency.Sources) { // Add Dependencies (if not already overriden) // This is done only at this level because top-level keys dependencies are supposed to be present. var sourceMetadata = source.Metadatas.OfType <ParameterKeyValueMetadata>().FirstOrDefault(); if (sourceMetadata != null && sourceMetadata.DefaultDynamicValue != null && !allDependencies.ContainsKey(source)) { allDependencies[source] = new ParameterDependency { Destination = source, Dynamic = sourceMetadata.DefaultDynamicValue, Sources = sourceMetadata.DefaultDynamicValue.Dependencies }; } UpdateRequiredKeys(requiredKeys, allDependencies, source, requiredDependencies); } } } }
public bool HasParameter(ParameterKey parameterKey) { return(defaultParameters.ContainsKey(parameterKey)); }
public Parameter(PropertyInfo pinfo) { _propertyInfo = pinfo; object[] attrs = pinfo.GetCustomAttributes(false); _parameterType = pinfo.PropertyType; /* * Не является ли этот параметр наследником, если да, то копируем значения * После, установка значений на новый параметр */ foreach (object attr in attrs) { if (!(attr is ParameterFromAttribute)) { continue; } ParameterFromAttribute psource = attr as ParameterFromAttribute; if (psource.ClassType == pinfo.DeclaringType) { _error |= FlagError.ParameterFromCycleLink; break; } Parameter[] prms = ClassBuilder.GetParameters(psource.ClassType); Parameter paramSource = null; foreach (Parameter prm in prms) { if (prm.Name == psource.ParameterName) { if (prm.ParameterType != _parameterType) { _error |= FlagError.ParameterFromBadType; break; } paramSource = prm; break; } } if (prms == null) { _error |= FlagError.ParameterFromNotFound; break; } paramSource.CopyTo(this); break; } _name = pinfo.Name; foreach (object attr in attrs) { if (attr is BrowsableAttribute) { _browsable = (attr as BrowsableAttribute).Browsable; } else if (attr is ParameterAttribute) { ParameterAttribute pattr = attr as ParameterAttribute; _name = pattr.Name; _order = pattr.Order; _defaultType = pattr.DefaultType; _error |= ~FlagError.NotParameter; } else if (attr is DisplayNameAttribute) { _display = (attr as DisplayNameAttribute).DisplayName; } else if (attr is CategoryAttribute) { _category = (attr as CategoryAttribute).Category; } else if (attr is DescriptionAttribute) { _description = (attr as DescriptionAttribute).Description; } else if (attr is DefaultValueAttribute) { DefaultValueAttribute dattr = attr as DefaultValueAttribute; _defaultValue = dattr.Value; } } if (_display == "") { _display = _name; } _key = new ParameterKey(_name); _value = _defaultValue; }
/// <summary> /// The check event param. /// </summary> /// <param name = "eventArgs"> /// The event args. /// </param> /// <param name = "paramKey"> /// The param key. /// </param> /// <param name = "expectedValue"> /// The expected value. /// </param> protected static void CheckEventParam(EventData eventArgs, ParameterKey paramKey, object expectedValue) { CheckEventParamExists(eventArgs, paramKey); object value = eventArgs.Parameters[(byte)paramKey]; if (value is Hashtable) { // does not like synchronized hashtables for some reason value = new Hashtable((Hashtable)value); } Assert.AreEqual(expectedValue, value, "Event param '{0}' has unexpected value", paramKey); }
public Proxy(ParameterKey o) : base(o) { (this as IGH_GooProxy).UserString = FormatInstance(); }
void IEffectParameterValueGenerator.AddValue(ParameterKey key, object value) { // do nothing }
public string ResolveParameterValue(string directiveId, string processorName, string parameterName) { var key = new ParameterKey(processorName, directiveId, parameterName); string value; if (parameters.TryGetValue(key, out value)) return value; if (processorName != null || directiveId != null) return ResolveParameterValue(null, null, parameterName); return null; }
public LightAmbientShaderGroup(ShaderMixinSource mixin, string compositionName) : base(mixin, compositionName, null) { AmbientLightKey = LightSimpleAmbientKeys.AmbientLight.ComposeWith(compositionName); }
public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue = null) { currentLayerContext.SetStream(stage, stream, computeNode, defaultTexturingKey, defaultValueKey, defaultTextureValue); }
public void SetStream(string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue = null) { SetStream(MaterialShaderStage.Pixel, stream, computeNode, defaultTexturingKey, defaultValueKey, defaultTextureValue); }
public ObjectParameterCollectionAccessor(ParameterKey parameterKey) { this.parameterKey = parameterKey; }
/// <summary> /// The check event param exists. /// </summary> /// <param name="eventArgs"> /// The event args. /// </param> /// <param name="paramKey"> /// The param key. /// </param> protected static void CheckEventParamExists(EventData eventArgs, ParameterKey paramKey) { Assert.Contains((short)paramKey, eventArgs.Parameters.Keys, "Parameter '{0}' is missing in event.", paramKey); }
/// <summary> /// Sets a struct value for the specified key in the <see cref="ParameterCollection"/> /// </summary> /// <typeparam name="T">A valuetype</typeparam> /// <param name="key">The key.</param> /// <param name="value">The value.</param> public void SetParameter <T>(ParameterKey <T> key, T value) => parameters.Set(key, value);
/// <summary> /// The check param exists. /// </summary> /// <param name="response"> /// The response. /// </param> /// <param name="paramKey"> /// The param key. /// </param> protected static void CheckParamExists(OperationResponse response, ParameterKey paramKey) { Assert.Contains((short)paramKey, response.Parameters.Keys, "Parameter '{0}' is missing in operation response.", paramKey); }
public void MoveToParameters(dynamic asset, dynamic parameters, object key, string paramName, ParameterKey pk) { var paramValue = asset.MeshParameters[key][paramName]; if (paramValue != null) { parameters[pk.Name] = paramValue; asset.MeshParameters[key].RemoveChild(paramName); } }
public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue) { if (defaultValueKey == null) { throw new ArgumentNullException(nameof(defaultValueKey)); } if (computeNode == null) { return; } var streamType = MaterialStreamType.Float; if (defaultValueKey.PropertyType == typeof(Vector4) || defaultValueKey.PropertyType == typeof(Color4)) { streamType = MaterialStreamType.Float4; } else if (defaultValueKey.PropertyType == typeof(Vector3) || defaultValueKey.PropertyType == typeof(Color3)) { streamType = MaterialStreamType.Float3; } else if (defaultValueKey.PropertyType == typeof(Vector2) || defaultValueKey.PropertyType == typeof(Half2)) { streamType = MaterialStreamType.Float2; } else if (defaultValueKey.PropertyType == typeof(float)) { streamType = MaterialStreamType.Float; } else { throw new NotSupportedException("ParameterKey type [{0}] is not supported by SetStream".ToFormat(defaultValueKey.PropertyType)); } var classSource = computeNode.GenerateShaderSource(Context, new MaterialComputeColorKeys(defaultTexturingKey, defaultValueKey, defaultTextureValue)); SetStream(stage, stream, streamType, classSource); }
/// <summary> /// The check param exists. /// </summary> /// <param name = "response"> /// The response. /// </param> /// <param name = "paramKey"> /// The param key. /// </param> protected static void CheckParamExists(OperationResponse response, ParameterKey paramKey) { Assert.Contains((short)paramKey, response.Parameters.Keys, "Parameter '{0}' is missing in operation response.", paramKey); }