コード例 #1
0
 public void SetMaterialValues(NUD.Material nudMaterial)
 {
     material = new GenericMaterial();
     NudUniforms.SetMaterialPropertyUniforms(material, nudMaterial);
 }
コード例 #2
0
ファイル: NudUniforms.cs プロジェクト: y4my4my4m/Smash-Forge
        private static void HasMatPropertyShaderUniform(GenericMaterial genericMaterial, NUD.Material mat, string propertyName, string uniformName)
        {
            bool hasValue = mat.entries.ContainsKey(propertyName) || mat.anims.ContainsKey(propertyName);

            if (hasValue)
            {
                genericMaterial.AddInt(uniformName, 1);
            }
            else
            {
                genericMaterial.AddInt(uniformName, 0);
            }
        }
コード例 #3
0
ファイル: NudUniforms.cs プロジェクト: y4my4my4m/Smash-Forge
        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]));
        }
コード例 #4
0
ファイル: NudUniforms.cs プロジェクト: y4my4my4m/Smash-Forge
        public static void SetMaterialPropertyUniforms(GenericMaterial genericMaterial, NUD.Material mat)
        {
            foreach (var property in defaultValueByProperty)
            {
                MatPropertyShaderUniform(genericMaterial, mat, property.Key, property.Value);
            }

            // Create some conditionals rather than using different shaders.
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_softLightingParams", "hasSoftLight");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_customSoftLightParams", "hasCustomSoftLight");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_specularParams", "hasSpecularParams");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_dualNormalScrollParams", "hasDualNormal");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_normalSamplerAUV", "hasNrmSamplerAUV");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_normalSamplerBUV", "hasNrmSamplerBUV");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_finalColorGain", "hasFinalColorGain");
            HasMatPropertyShaderUniform(genericMaterial, mat, "NU_effUniverseParam", "hasUniverseParam");
        }