Beispiel #1
0
        void Awake()
        {
            revealMaterialController = this.gameObject.AddComponent <RevealMaterialController>();
            revealMaterialController.revealMaterials     = materials;
            revealMaterialController.width               = (int)maskWidth;
            revealMaterialController.height              = (int)maskHeight;
            revealMaterialController.maskPropertyName    = "_RevealMask";
            revealMaterialController.preserveRenderQueue = true;
            revealMaterialController.renderTextureFormat = RenderTextureFormat.ARGB64;

            List <RevealMaterialController.ShaderProperty> shaderProperties = new List <RevealMaterialController.ShaderProperty>();

            foreach (Material material in revealMaterialController.revealMaterials)
            {
                if (!material)
                {
                    continue;
                }
                if (material.HasProperty("_Bitmask") && !shaderProperties.Exists(s => s.name == "_Bitmask"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Bitmask";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Int;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_BaseColor") && !shaderProperties.Exists(s => s.name == "_BaseColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_BaseColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_SecondaryColor") && !shaderProperties.Exists(s => s.name == "_SecondaryColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_SecondaryColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_SpecColor") && !shaderProperties.Exists(s => s.name == "_SpecColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_SpecColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint0") && !shaderProperties.Exists(s => s.name == "_Tint0"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint0";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint1") && !shaderProperties.Exists(s => s.name == "_Tint1"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint1";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint2") && !shaderProperties.Exists(s => s.name == "_Tint2"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint2";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
            }
            revealMaterialController.propertiesToPreserve = shaderProperties.ToArray();
        }
Beispiel #2
0
        void Awake()
        {
            revealMaterialController = this.gameObject.AddComponent <RevealMaterialController>();
            revealMaterialController.revealMaterials     = materials;
            revealMaterialController.width               = (int)maskWidth;
            revealMaterialController.height              = (int)maskHeight;
            revealMaterialController.maskPropertyName    = "_RevealMask";
            revealMaterialController.preserveRenderQueue = true;
            revealMaterialController.renderTextureFormat = RenderTextureFormat.ARGB64;

            List <RevealMaterialController.ShaderProperty> shaderProperties = new List <RevealMaterialController.ShaderProperty>();

            foreach (Material material in revealMaterialController.revealMaterials)
            {
                if (!material)
                {
                    continue;
                }

                // Int
                if (material.HasProperty("_Bitmask") && !shaderProperties.Exists(s => s.name == "_Bitmask"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Bitmask";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Int;
                    shaderProperties.Add(shaderProperty);
                }
                //Float
                if (material.HasProperty("_Smoothness") && !shaderProperties.Exists(s => s.name == "_Smoothness"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Smoothness";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Float;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_OcclusionStrength") && !shaderProperties.Exists(s => s.name == "_OcclusionStrength"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_OcclusionStrength";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Float;
                    shaderProperties.Add(shaderProperty);
                }

                // Colors
                if (material.HasProperty("_BaseColor") && !shaderProperties.Exists(s => s.name == "_BaseColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_BaseColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_SecondaryColor") && !shaderProperties.Exists(s => s.name == "_SecondaryColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_SecondaryColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_SpecColor") && !shaderProperties.Exists(s => s.name == "_SpecColor"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_SpecColor";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint0") && !shaderProperties.Exists(s => s.name == "_Tint0"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint0";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint1") && !shaderProperties.Exists(s => s.name == "_Tint1"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint1";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                if (material.HasProperty("_Tint2") && !shaderProperties.Exists(s => s.name == "_Tint2"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_Tint2";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Color;
                    shaderProperties.Add(shaderProperty);
                }
                // Textures
                if (transferedMaps.HasFlag(TransferedMaps.BaseMap) && material.HasProperty("_BaseMap") && !shaderProperties.Exists(s => s.name == "_BaseMap"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_BaseMap";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
                if (transferedMaps.HasFlag(TransferedMaps.BumpMap) && material.HasProperty("_BumpMap") && !shaderProperties.Exists(s => s.name == "_BumpMap"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_BumpMap";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
                if (transferedMaps.HasFlag(TransferedMaps.ColorMask) && material.HasProperty("_ColorMask") && !shaderProperties.Exists(s => s.name == "_ColorMask"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_ColorMask";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
                if (transferedMaps.HasFlag(TransferedMaps.EmissionMap) && material.HasProperty("_EmissionMap") && !shaderProperties.Exists(s => s.name == "_EmissionMap"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_EmissionMap";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
                if (transferedMaps.HasFlag(TransferedMaps.SSSAOMap) && material.HasProperty("_SSSAOMap") && !shaderProperties.Exists(s => s.name == "_SSSAOMap"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_SSSAOMap";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
                if (transferedMaps.HasFlag(TransferedMaps.MOES) && material.HasProperty("_MetallicGlossMap") && !shaderProperties.Exists(s => s.name == "_MetallicGlossMap"))
                {
                    RevealMaterialController.ShaderProperty shaderProperty = new RevealMaterialController.ShaderProperty();
                    shaderProperty.name = "_MetallicGlossMap";
                    shaderProperty.type = RevealMaterialController.ShaderProperty.ShaderPropertyType.Texture;
                    shaderProperties.Add(shaderProperty);
                }
            }
            revealMaterialController.propertiesToPreserve = shaderProperties.ToArray();
        }