Ejemplo n.º 1
0
        public static ShaderClassSource GenerateTextureLayer(string vfsOutputPath, string sourceTextureFile, int textureUVSetIndex, Vector2 textureUVscaling,
                                                             ref int textureCount, ParameterKey <Texture> surfaceMaterialKey, Mesh meshData, Logger logger)
        {
            ParameterKey <Texture> parameterKey;

            var url = vfsOutputPath + "_" + Path.GetFileNameWithoutExtension(sourceTextureFile);

            if (File.Exists(sourceTextureFile))
            {
                if (logger != null)
                {
                    logger.Warning($"The texture '{sourceTextureFile}' referenced in the mesh material can not be found on the system. Loading will probably fail at run time.", CallerInfo.Get());
                }
            }

            parameterKey = ParameterKeys.IndexedKey(surfaceMaterialKey, textureCount++);
            var uvSetName = "TEXCOORD";

            if (textureUVSetIndex != 0)
            {
                uvSetName += textureUVSetIndex;
            }
            //albedoMaterial->Add(gcnew ShaderClassSource("TextureStream", uvSetName, "TEXTEST" + uvSetIndex));
            var uvScaling          = textureUVscaling;
            var textureName        = parameterKey.Name;
            var needScaling        = uvScaling != Vector2.One;
            var currentComposition = needScaling
                ? new ShaderClassSource("ComputeColorTextureRepeat", textureName, uvSetName, "float2(" + uvScaling.X + ", " + uvScaling.Y + ")")
            : new ShaderClassSource("ComputeColorTexture", textureName, uvSetName);

            return(currentComposition);
        }
Ejemplo n.º 2
0
        protected static void CheckParam(OperationResponse response, ParameterKeys paramKey, object expectedValue)
        {
            CheckParamExists(response, paramKey);
            object value = response.Params[(short)paramKey];

            Assert.AreEqual(expectedValue, value, "Parameter '{0} has an unexpected value", paramKey);
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            ParameterKeys parameterkeys = db.ParameterKeys.Find(id);

            db.ParameterKeys.Remove(parameterkeys);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a dynamic parameter key for texel size updated from the texture size.
 /// </summary>
 /// <param name="textureKey">Key of the texture to take the size from</param>
 /// <returns>A dynamic TexelSize parameter key updated according to the specified texture</returns>
 public static ParameterKey <Vector2> CreateDynamicTexelSizeParameterKey(ParameterKey <Texture> textureKey)
 {
     if (textureKey == null)
     {
         throw new ArgumentNullException("textureKey");
     }
     return(ParameterKeys.NewDynamic(ParameterDynamicValue.New <Vector2, Texture>(textureKey, UpdateTexelSize)));
 }
        private void UpdateLightingParameterSemantics(int index, string compositionName)
        {
            lightingParameterSemantics.Clear();
            var lightGroupSubKey = string.Format("." + compositionName + "[{0}]", index);

            foreach (var param in LightParametersDict)
            {
                lightingParameterSemantics.Add(ParameterKeys.AppendKey(param.Key, lightGroupSubKey), param.Value);
            }
        }
        public LightGroup(int index, string compositionName)
        {
            LightingParameterSemantics = new Dictionary <ParameterKey, LightParamSemantic>();
            var lightGroupSubKey = string.Format("." + compositionName + "[{0}]", index);

            foreach (var param in LightForwardModelRenderer.LightParametersDict)
            {
                LightingParameterSemantics.Add(ParameterKeys.AppendKey(param.Key, lightGroupSubKey), param.Value);
            }
        }
Ejemplo n.º 7
0
        //
        // GET: /ParameterKey/Edit/5

        public ActionResult Edit(int id = 0)
        {
            ParameterKeys parameterkeys = db.ParameterKeys.Find(id);

            if (parameterkeys == null)
            {
                return(HttpNotFound());
            }
            return(View(parameterkeys));
        }
Ejemplo n.º 8
0
 public ActionResult Edit(ParameterKeys parameterkeys)
 {
     if (ModelState.IsValid)
     {
         db.Entry(parameterkeys).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(parameterkeys));
 }
Ejemplo n.º 9
0
        public override object ConvertFrom(ref ObjectContext objectContext, Scalar fromScalar)
        {
            var parameterKey = ParameterKeys.FindByName(fromScalar.Value);

            if (parameterKey == null)
            {
                throw new YamlException(fromScalar.Start, fromScalar.End, "Unable to find registered ParameterKey [{0}]".ToFormat(fromScalar.Value));
            }
            return(parameterKey);
        }
Ejemplo n.º 10
0
        private void LoadDefaultParameters()
        {
            var shaderParameters   = defaultParameters; // Default Parameters contains all registered Parameters used effectively by the effect
            var constantBufferKeys = new Dictionary <string, ParameterKey <ParameterConstantBuffer> >();

            // Create parameter bindings
            for (int i = 0; i < resourceBindings.Length; i++)
            {
                // Update binding key
                var key = UpdateResourceBindingKey(ref resourceBindings[i].Description);

                // ConstantBuffers are handled by next loop
                if (resourceBindings[i].Description.Param.Class != EffectParameterClass.ConstantBuffer)
                {
                    shaderParameters.RegisterParameter(key, false);
                }
            }

            // Create constant buffers from descriptions (previously generated from shader reflection)
            foreach (var constantBuffer in reflection.ConstantBuffers)
            {
                var constantBufferMembers = constantBuffer.Members;

                for (int i = 0; i < constantBufferMembers.Length; ++i)
                {
                    // Update binding key
                    var key = UpdateValueBindingKey(ref constantBufferMembers[i]);

                    // Register ParameterKey with this effect and store its index for direct access during rendering
                    shaderParameters.RegisterParameter(key, false);
                }

                // Handle ConstantBuffer. Share the same key ParameterConstantBuffer with all the stages
                var parameterConstantBuffer = new ParameterConstantBuffer(graphicsDeviceDefault, constantBuffer.Name, constantBuffer);
                var constantBufferKey       = ParameterKeys.New(parameterConstantBuffer, constantBuffer.Name);
                shaderParameters.RegisterParameter(constantBufferKey, false);

                for (int i = 0; i < resourceBindings.Length; i++)
                {
                    if (resourceBindings[i].Description.Param.Class == EffectParameterClass.ConstantBuffer && resourceBindings[i].Description.Param.Key.Name == constantBuffer.Name)
                    {
                        resourceBindings[i].Description.Param.Key = constantBufferKey;
                    }
                }

                // Update constant buffer mapping (to avoid name clashes)
                constantBufferKeys[constantBuffer.Name] = constantBufferKey;
            }

            UpdateKeyIndices();

            // Once we have finished binding, we can fully prepare them
            graphicsDeviceDefault.StageStatus.PrepareBindings(resourceBindings);
        }
Ejemplo n.º 11
0
        private ParameterKey GetComposedKey(ParameterKey key, int transformIndex)
        {
            var compositeKey = new ParameterCompositeKey(key, transformIndex);

            if (!compositeKeys.TryGetValue(compositeKey, out ParameterKey rawCompositeKey))
            {
                rawCompositeKey = ParameterKeys.FindByName($"{key.Name}.Transforms[{transformIndex}]");
                compositeKeys.Add(compositeKey, rawCompositeKey);
            }
            return(rawCompositeKey);
        }
Ejemplo n.º 12
0
        private ParameterKey GetComposedKey(ParameterKey key, int transformIndex)
        {
            var compositeKey = new ParameterCompositeKey(key, transformIndex);

            ParameterKey rawCompositeKey;
            if (!compositeKeys.TryGetValue(compositeKey, out rawCompositeKey))
            {
                rawCompositeKey = ParameterKeys.FindByName(string.Format("{0}.Transforms[{1}]", key.Name, transformIndex));
                compositeKeys.Add(compositeKey, rawCompositeKey);
            }
            return rawCompositeKey;
        }
Ejemplo n.º 13
0
        public override object ConvertFrom(ref ObjectContext objectContext, Scalar fromScalar)
        {
            var parameterKey = ParameterKeys.FindByName(fromScalar.Value);

            if (parameterKey == null)
            {
                parameterKey = ParameterKeys.New <object>(null, fromScalar.Value);
                // Dont' throw an exception if keys was not found
                //throw new YamlException(fromScalar.Start, fromScalar.End, "Unable to find registered ParameterKey [{0}]".ToFormat(fromScalar.Value));
            }
            return(parameterKey);
        }
Ejemplo n.º 14
0
        private static ParameterKey FindOrCreateValueKey <T>(ref EffectValueDescription binding) where T : struct
        {
            var name = binding.KeyInfo.KeyName;
            var key  = ParameterKeys.FindByName(name) as ValueParameterKey <T> ?? ParameterKeys.NewValue <T>(name: name);

            // Update the default value with the one from the shader
            if (binding.DefaultValue is T defaultValue)
            {
                key.DefaultValueMetadataT.DefaultValue = defaultValue;
            }
            return(key);
        }
Ejemplo n.º 15
0
 static TransformationKeys()
 {
     View                = ParameterKeys.Value(Matrix.Identity);
     Projection          = ParameterKeys.Value(Matrix.Identity);
     World               = ParameterKeys.Value(Matrix.Identity);
     ViewProjection      = ParameterKeys.Value(ParameterDynamicValue.New <Matrix, Matrix, Matrix>(View, Projection, Matrix.Multiply));
     WorldView           = ParameterKeys.Value(ParameterDynamicValue.New <Matrix, Matrix, Matrix>(World, View, Matrix.Multiply));
     WorldViewProjection = ParameterKeys.Value(ParameterDynamicValue.New <Matrix, Matrix, Matrix>(World, ViewProjection, Matrix.Multiply));
     ProjScreenRay       = ParameterKeys.Value(ParameterDynamicValue.New <Vector2, Matrix>(Projection, ExtractProjScreenRay));
     Eye              = ParameterKeys.Value(ParameterDynamicValue.New <Vector4, Matrix>(View, ViewToEye));
     ViewInverse      = ParameterKeys.Value(ParameterDynamicValue.New <Matrix, Matrix>(View, InvertMatrix));
     WorldViewInverse = ParameterKeys.Value(ParameterDynamicValue.New <Matrix, Matrix>(WorldView, InvertMatrix));
 }
Ejemplo n.º 16
0
        // TODO this is not reusable outside this class (in other generators?)
        private KeyValuePair <ParameterKey, object> CreateKeyValue(ParameterKey key, object value)
        {
            // Find the real key instead of key loaded from yaml
            // as it can be later change at runtime
            var keyName = key.Name;

            key = ParameterKeys.FindByName(keyName);
            if (key == null)
            {
                throw new InvalidOperationException("ParameterKey [{0}] was not found from assemblies".ToFormat(keyName));
            }

            return(new KeyValuePair <ParameterKey, object>(key, key.ConvertValue(value)));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Get the correct parameter key.
        /// </summary>
        /// <typeparam name="TValue">The type of the parameter.</typeparam>
        /// <param name="linkName">The name of the parameter key.</param>
        /// <returns>The parameter key.</returns>
        private static ParameterKey <TValue> GetTypedParameterKey <TValue>(string linkName)
        {
            var pk = ParameterKeys.FindByName(linkName);

            if (pk != null)
            {
                if (pk.PropertyType == typeof(TValue))
                {
                    return((ParameterKey <TValue>)pk);
                }
            }
            //TODO: log error
            return(null);
        }
Ejemplo n.º 18
0
        public ActionResult Create(ParameterKeys parameterkeys)
        {
            if (ModelState.IsValid)
            {
                db.ParameterKeys.Add(parameterkeys);
                db.SaveChanges();

                Lookup(parameterkeys.TermValue);

                return(RedirectToAction("Index", "Home"));
            }

            return(View(parameterkeys));
        }
Ejemplo n.º 19
0
        protected virtual TENTITY DoSaveToDatabase(
            TENTITY entity,
            List <string> includes,
            IObjectsDataSet context,
            Parameters parameters)
        {
            // Ensure got a dataset
            if (entity.ObjectsDataSet == null)
            {
                entity.ObjectsDataSet = ApplicationSettings.Resolve <IObjectsDataSet>();
            }

            // Ensure entity is in its own dataset
            var self = entity.ObjectsDataSet.GetObject(entity);

            if (self == null)
            {
                entity.ObjectsDataSet.AddObject(entity);
            }

            // Note: We can skip objects marked for deletion, because before arriving here, the delete resolution algorithm will already have processed them
            // Wee just need to remove the marked-for-deletion objects so that they aren't mapped or returned to caller
            foreach (var deletedObj in entity.ObjectsDataSet.GetObjectsMarkedForDeletion().ToArray())
            {
                entity.ObjectsDataSet.RemoveObject(deletedObj);

                // Remove from the context too
                if (context != null)
                {
                    context.RemoveObject(deletedObj);
                }
            }

            // Get data mapping setting from the parameters (deep is the default)
            // Deep mapping means we'll explore all relations, else will only treat the specified entity (i.e. a 'flat' single entity save)
            bool deepMapping = parameters == null || !parameters.ContainsKey(ParameterKeys.DeepDataMapping) || (bool)parameters[ParameterKeys.DeepDataMapping] == true;

            // entity returned from SaveToDatabaseThroughORM can be null (e.g. if nothing dirty/new in the saveset, or if deleted)
            entity = SaveToDatabaseThroughORM(entity, deepMapping);


            // for the refetch, security can be skipped if no related data requested (since we just wrote it, it's just a flat re-sync)
            bool canRefetchSkipSecurity = includes == null || !includes.Any() || ParameterKeys.IsOptionEnabled(parameters, ParameterKeys.ORMSaveRefetchSkipSecurity);

            return(entity == null ? null : Get(entity, includes: includes, parameters: parameters, skipSecurity: canRefetchSkipSecurity));
        }
Ejemplo n.º 20
0
        public static ShadowUpdateInfo CreateShadowUpdateInfo(int index, int level)
        {
            var info = new ShadowUpdateInfo {
                CascadeCount = level
            };

            // Prepare keys for this shadow map type
            var shadowSubKey = string.Format(".shadows[{0}]", index);

            info.ShadowMapReceiverInfoKey      = ParameterKeys.AppendKey(ShadowMapRenderer.Receivers, shadowSubKey);
            info.ShadowMapReceiverVsmInfoKey   = ParameterKeys.AppendKey(ShadowMapRenderer.ReceiversVsm, shadowSubKey);
            info.ShadowMapLevelReceiverInfoKey = ParameterKeys.AppendKey(ShadowMapRenderer.LevelReceivers, shadowSubKey);
            info.ShadowMapLightCountKey        = ParameterKeys.AppendKey(ShadowMapRenderer.ShadowMapLightCount, shadowSubKey);
            info.ShadowMapTextureKey           = ParameterKeys.AppendKey(ShadowMapKeys.Texture, shadowSubKey);

            return(info);
        }
Ejemplo n.º 21
0
        public override UpdatableMember ResolveIndexer(string indexerName)
        {
            var key = ParameterKeys.FindByName(indexerName);

            if (key == null)
            {
                throw new InvalidOperationException($"Property Key path parse error: could not parse indexer value '{indexerName}'");
            }

            switch (key.Type)
            {
            case ParameterKeyType.Value:
                var accessorType = typeof(ValueParameterCollectionAccessor <>).MakeGenericType(key.PropertyType);
                return((UpdatableMember)Activator.CreateInstance(accessorType, key));

            case ParameterKeyType.Object:
                return(new ObjectParameterCollectionAccessor(key));

            default:
                throw new NotSupportedException($"{nameof(ParameterCollectionResolver)} can only handle Value and Object keys");
            }
        }
Ejemplo n.º 22
0
        // filterExpression is used to filter data, when filter is statically known. dynamicFilterExpression is used for dynamic filtering, when filter is not known at compile time. Both can be used at the same time
        protected override DataObjectCollection <UserProfileDataObject> DoGetCollectionFromDatabase(
            LambdaExpression filterExpression,
            string dynamicFilterExpression,
            object[] dynamicFilterArguments,
            string orderByPredicate,
            int pageNumber,
            int pageSize,
            List <string> includes,
            IObjectsDataSet context,
            Parameters parameters)
        {
            var query = Query(dynamicFilterExpression, dynamicFilterArguments, filterExpression);

            if (!String.IsNullOrEmpty(orderByPredicate))
            {
                query = query.OrderBy(orderByPredicate);
            }

            // Normal (default generated) behaviour is:
            // includes not treated by orm but with dispatcher mechanism to allow for proper security and extension calls on all objects
            // But the following allows custom implementations to prefetch associations
            ApplicationSettings.TryResolve <IPrefetch <ORMUserProfile> >()?.Fetch(query, includes, parameters);

            // Do Paging (unless late-paging option is enabled)
            if (!ParameterKeys.IsOptionEnabled(parameters, ParameterKeys.DataProviderGetCollectionLatePaging))
            {
                if (pageNumber != 0 && pageSize > 0)
                {
                    query = query.Skip((pageNumber - 1) * pageSize).Take(pageSize);
                }
            }

            var dataset    = ApplicationSettings.Resolve <IObjectsDataSet>();
            var collection = query.Select(x => x.ToDataObject(dataset)).Cast <UserProfileDataObject>().ToList();

            return(new DataObjectCollection <UserProfileDataObject>(collection));
        }
Ejemplo n.º 23
0
        private static void UpdateValueBindingKey(ref EffectValueDescription binding)
        {
            switch (binding.Type.Class)
            {
            case EffectParameterClass.Scalar:
                switch (binding.Type.Type)
                {
                case EffectParameterType.Bool:
                    binding.KeyInfo.Key = FindOrCreateValueKey <bool>(binding);
                    break;

                case EffectParameterType.Int:
                    binding.KeyInfo.Key = FindOrCreateValueKey <int>(binding);
                    break;

                case EffectParameterType.UInt:
                    binding.KeyInfo.Key = FindOrCreateValueKey <uint>(binding);
                    break;

                case EffectParameterType.Float:
                    binding.KeyInfo.Key = FindOrCreateValueKey <float>(binding);
                    break;
                }
                break;

            case EffectParameterClass.Color:
            {
                var componentCount = binding.Type.RowCount != 1 ? binding.Type.RowCount : binding.Type.ColumnCount;
                switch (binding.Type.Type)
                {
                case EffectParameterType.Float:
                    binding.KeyInfo.Key = componentCount == 4
                                                        ? FindOrCreateValueKey <Color4>(binding)
                                                        : (componentCount == 3 ? FindOrCreateValueKey <Color3>(binding) : null);
                    break;
                }
            }
            break;

            case EffectParameterClass.Vector:
            {
                var componentCount = binding.Type.RowCount != 1 ? binding.Type.RowCount : binding.Type.ColumnCount;
                switch (binding.Type.Type)
                {
                case EffectParameterType.Bool:
                case EffectParameterType.Int:
                    binding.KeyInfo.Key = componentCount == 4 ? (ParameterKey)FindOrCreateValueKey <Int4>(binding) : (componentCount == 3 ? FindOrCreateValueKey <Int3>(binding) : null);
                    break;

                case EffectParameterType.UInt:
                    binding.KeyInfo.Key = componentCount == 4 ? FindOrCreateValueKey <UInt4>(binding) : null;
                    break;

                case EffectParameterType.Float:
                    binding.KeyInfo.Key = componentCount == 4
                                                        ? FindOrCreateValueKey <Vector4>(binding)
                                                        : (componentCount == 3 ? (ParameterKey)FindOrCreateValueKey <Vector3>(binding) : (componentCount == 2 ? FindOrCreateValueKey <Vector2>(binding) : null));
                    break;
                }
            }
            break;

            case EffectParameterClass.MatrixRows:
            case EffectParameterClass.MatrixColumns:
                binding.KeyInfo.Key = FindOrCreateValueKey <Matrix>(binding);
                break;

            case EffectParameterClass.Struct:
                binding.KeyInfo.Key = ParameterKeys.FindByName(binding.KeyInfo.KeyName);
                break;
            }

            if (binding.KeyInfo.Key == null)
            {
                throw new InvalidOperationException(string.Format("Unable to find/generate key [{0}] with unsupported type [{1}/{2}]", binding.KeyInfo.KeyName, binding.Type.Class, binding.Type.Type));
            }
        }
Ejemplo n.º 24
0
 private static ParameterKey FindOrCreateResourceKey <T>(string name)
 {
     return(ParameterKeys.FindByName(name) ?? ParameterKeys.NewObject <T>(default(T), name));
 }
Ejemplo n.º 25
0
        private ParameterKey FindOrCreateValueKey <T>(EffectParameterValueData binding) where T : struct
        {
            var name = binding.Param.KeyName;

            return(ParameterKeys.FindByName(name) ?? (binding.Count > 1 ? (ParameterKey)ParameterKeys.New <T[]>(name) : ParameterKeys.New <T>(name)));
        }
Ejemplo n.º 26
0
 static LightSimpleAmbientKeys()
 {
     AmbientLight = ParameterKeys.NewValue(new Color3(1.0f, 1.0f, 1.0f));
 }
Ejemplo n.º 27
0
 static ImageScalerShaderKeys()
 {
     // Default value of 1.0f
     Color = ParameterKeys.New(Color4.White);
 }
Ejemplo n.º 28
0
 protected static void CheckEventParam(EventReceivedEventArgs eventArgs, ParameterKeys paramKey, object expectedValue)
 {
     CheckEventParamExists(eventArgs, paramKey);
     Assert.AreEqual(expectedValue, eventArgs.EventData[(short)paramKey], "Event param '{0}' has unexpected value", paramKey);
 }
Ejemplo n.º 29
0
 protected static void CheckParamExists(OperationResponse response, ParameterKeys paramKey)
 {
     Assert.Contains((short)paramKey, response.Params.Keys, "Parameter '{0}' is missing in operation response.", paramKey);
 }
Ejemplo n.º 30
0
 protected static void CheckParam(OperationResponse response, ParameterKeys paramKey, object expectedValue)
 {
     CheckParamExists(response, paramKey);
     object value = response.Params[(short)paramKey];
     Assert.AreEqual(expectedValue, value, "Parameter '{0} has an unexpected value", paramKey);
 }
Ejemplo n.º 31
0
 protected static void CheckEventParamExists(EventReceivedEventArgs eventArgs, ParameterKeys paramKey)
 {
     Assert.Contains((short)paramKey, eventArgs.EventData.Keys, "Parameter '{0}' is missing in event.", paramKey);
 }
Ejemplo n.º 32
0
        private static ParameterKey FindOrCreateValueKey <T>(EffectParameterValueData binding) where T : struct
        {
            var name = binding.Param.KeyName;

            return(ParameterKeys.FindByName(name) ?? ParameterKeys.NewValue <T>(default(T), name));
        }
Ejemplo n.º 33
0
        private static ParameterKey FindOrCreateValueKey <T>(EffectValueDescription binding) where T : struct
        {
            var name = binding.KeyInfo.KeyName;

            return(ParameterKeys.FindByName(name) ?? ParameterKeys.NewValue <T>(default(T), name));
        }
Ejemplo n.º 34
0
 private ParameterKey FindOrCreateResourceKey <T>(string name)
 {
     return(ParameterKeys.FindByName(name) ?? ParameterKeys.New <T>(name));
 }