コード例 #1
0
        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);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: TemplateGenerator.cs プロジェクト: ruo2012/t5
        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());
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        /// <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);
        }
コード例 #8
0
 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;
 }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
            /// <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);
            }
コード例 #13
0
        /// <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);
        }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
        }
コード例 #16
0
            /// <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);
            }
コード例 #17
0
ファイル: ImportModelCommand.cs プロジェクト: dhootha/paradox
        /// <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);
        }
コード例 #18
0
ファイル: TcpTests.cs プロジェクト: cernysw/UnityDemo
 /// <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);
 }
コード例 #19
0
 /// <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);
 }
コード例 #20
0
 /// <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);
 }
コード例 #21
0
 public LightAmbientShaderGroupData(LightAmbientShaderGroup group)
     : base(null)
 {
     ambientLightKey = group.AmbientLightKey;
 }
コード例 #22
0
 /// <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]);
 }
コード例 #23
0
            /// <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);
            }
コード例 #24
0
ファイル: Effect.cs プロジェクト: slagusev/paradox
 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);
             }
         }
     }
 }
コード例 #25
0
ファイル: Effect.cs プロジェクト: slagusev/paradox
 public bool HasParameter(ParameterKey parameterKey)
 {
     return(defaultParameters.ContainsKey(parameterKey));
 }
コード例 #26
0
ファイル: Parameter.cs プロジェクト: zeliboba7/gordago
        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;
        }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
 public Proxy(ParameterKey o) : base(o)
 {
     (this as IGH_GooProxy).UserString = FormatInstance();
 }
コード例 #29
0
 void IEffectParameterValueGenerator.AddValue(ParameterKey key, object value)
 {
     // do nothing
 }
コード例 #30
0
ファイル: HostBase.cs プロジェクト: panfalk/AppGen
 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;
 }
コード例 #31
0
 public LightAmbientShaderGroup(ShaderMixinSource mixin, string compositionName)
     : base(mixin, compositionName, null)
 {
     AmbientLightKey = LightSimpleAmbientKeys.AmbientLight.ComposeWith(compositionName);
 }
コード例 #32
0
 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);
 }
コード例 #33
0
 public void SetStream(string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue = null)
 {
     SetStream(MaterialShaderStage.Pixel, stream, computeNode, defaultTexturingKey, defaultValueKey, defaultTextureValue);
 }
コード例 #34
0
 public ObjectParameterCollectionAccessor(ParameterKey parameterKey)
 {
     this.parameterKey = parameterKey;
 }
コード例 #35
0
 /// <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);
 }
コード例 #36
0
 /// <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);
コード例 #37
0
 /// <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);
 }
コード例 #38
0
ファイル: ModelAsset.cs プロジェクト: yongweisun/paradox
            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);
                }
            }
コード例 #39
0
        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);
        }
コード例 #40
0
ファイル: TcpTests.cs プロジェクト: cernysw/UnityDemo
 /// <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);
 }