Exemple #1
0
 private void AddVec4(string name, GenericMaterial genericMaterial, long paramId, Vector4 defaultValue)
 {
     // Convert parameters into colors for easier visualization.
     if (vec4ByParamId.ContainsKey(paramId))
     {
         var value = vec4ByParamId[paramId];
         genericMaterial.AddVector4(name, value);
     }
     else if (boolByParamId.ContainsKey(paramId))
     {
         var value = boolByParamId[paramId];
         if (value)
         {
             genericMaterial.AddVector4(name, new Vector4(1, 0, 1, 0));
         }
         else
         {
             genericMaterial.AddVector4(name, new Vector4(0, 0, 1, 0));
         }
     }
     else if (floatByParamId.ContainsKey(paramId))
     {
         var value = floatByParamId[paramId];
         genericMaterial.AddVector4(name, new Vector4(value, value, value, 0));
     }
     else
     {
         genericMaterial.AddVector4(name, defaultValue);
     }
 }
Exemple #2
0
        private static void MatPropertyShaderUniform(GenericMaterial genericMaterial, NUD.Material mat, string propertyName, float default1,
                                                     float default2, float default3, float default4)
        {
            // Attempt to get the values from the material's properties.
            // Otherwise, use the specified default values.
            float[] values;
            mat.entries.TryGetValue(propertyName, out values);
            if (mat.anims.ContainsKey(propertyName))
            {
                values = mat.anims[propertyName];
            }
            if (values == null)
            {
                values = new float[] { default1, default2, default3, default4 }
            }
            ;

            string uniformName = propertyName.Substring(3); // remove the NU_ from name

            if (values.Length == 4)
            {
                genericMaterial.AddVector4(uniformName, new Vector4(values[0], values[1], values[2], values[3]));
            }
            else
            {
                Debug.WriteLine(uniformName + " invalid parameter count: " + values.Length);
            }
        }
Exemple #3
0
        private static void MatPropertyShaderUniform(GenericMaterial genericMaterial, NUD.Material mat, string propertyName, Vector4 defaultValue)
        {
            // Attempt to get the values from the material.
            float[] values = null;
            mat.entries.TryGetValue(propertyName, out values);
            if (mat.anims.ContainsKey(propertyName))
            {
                values = mat.anims[propertyName];
            }

            if (values == null || values.Length != 4)
            {
                values = new float[] { defaultValue.X, defaultValue.Y, defaultValue.Z, defaultValue.W }
            }
            ;

            string uniformName = propertyName.Replace("NU_", "");

            genericMaterial.AddVector4(uniformName, new Vector4(values[0], values[1], values[2], values[3]));
        }
Exemple #4
0
        private void AddVec4(GenericMaterial genericMaterial, long paramId, Vector4 defaultValue, bool isDebug = false)
        {
            // Convert parameters into colors for easier visualization.
            var name = $"param{paramId.ToString("X")}";

            if (isDebug)
            {
                name = "vec4Param";
            }

            if (MaterialAnimation.ContainsKey(paramId))
            {
                var value = MaterialAnimation[paramId];
                genericMaterial.AddVector4(name, value);
            }
            else if (vec4ByParamId.ContainsKey(paramId))
            {
                var value = vec4ByParamId[paramId];
                genericMaterial.AddVector4(name, value);
            }
            else if (boolByParamId.ContainsKey(paramId))
            {
                var value = boolByParamId[paramId];
                if (value)
                {
                    genericMaterial.AddVector4(name, new Vector4(1, 0, 1, 0));
                }
                else
                {
                    genericMaterial.AddVector4(name, new Vector4(0, 0, 1, 0));
                }
            }
            else if (floatByParamId.ContainsKey(paramId))
            {
                var value = floatByParamId[paramId];
                genericMaterial.AddVector4(name, new Vector4(value, value, value, 0));
            }
            else
            {
                genericMaterial.AddVector4(name, defaultValue);
            }
        }