public static void Inputs(LitProperties properties, MaterialEditor materialEditor, Material material)
        {
            DoMetallicSpecularArea(properties, materialEditor, material);
            BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp, properties.bumpScaleProp);

            if (properties.occlusionMap != null)
            {
                materialEditor.TexturePropertySingleLine(Styles.occlusionText, properties.occlusionMap,
                                                         properties.occlusionMap.textureValue != null ? properties.occlusionStrength : null);
            }
        }
        public static void SetMaterialKeywords(Material material)
        {
            // Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation
            // (MaterialProperty value might come from renderer material property block)
            var hasGlossMap        = false;
            var isSpecularWorkFlow = false;
            var opaque             = ((BaseShaderGUI.SurfaceType)material.GetFloat("_Surface") ==
                                      BaseShaderGUI.SurfaceType.Opaque);

            if (material.HasProperty("_WorkflowMode"))
            {
                isSpecularWorkFlow = (WorkflowMode)material.GetFloat("_WorkflowMode") == WorkflowMode.Specular;
                if (isSpecularWorkFlow)
                {
                    hasGlossMap = material.GetTexture("_SpecGlossMap") != null;
                }
                else
                {
                    hasGlossMap = material.GetTexture("_MetallicGlossMap") != null;
                }
            }
            else
            {
                hasGlossMap = material.GetTexture("_MetallicGlossMap") != null;
            }

            BaseShaderGUI.SetKeyword(material, "_SPECULAR_SETUP", isSpecularWorkFlow);

            BaseShaderGUI.SetKeyword(material, "_METALLICSPECGLOSSMAP", hasGlossMap);

            if (material.HasProperty("_SpecularHighlights"))
            {
                BaseShaderGUI.SetKeyword(material, "_SPECULARHIGHLIGHTS_OFF",
                                         material.GetFloat("_SpecularHighlights") == 0.0f);
            }
            if (material.HasProperty("_EnvironmentReflections"))
            {
                BaseShaderGUI.SetKeyword(material, "_ENVIRONMENTREFLECTIONS_OFF",
                                         material.GetFloat("_EnvironmentReflections") == 0.0f);
            }
            if (material.HasProperty("_OcclusionMap"))
            {
                BaseShaderGUI.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap"));
            }

            if (material.HasProperty("_SmoothnessTextureChannel"))
            {
                BaseShaderGUI.SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A",
                                         GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha && opaque);
            }
        }
 public ParticleProperties(MaterialProperty[] properties)
 {
     // Surface Option Props
     colorMode = BaseShaderGUI.FindProperty("_ColorMode", properties, false);
     // Advanced Props
     flipbookMode                  = BaseShaderGUI.FindProperty("_FlipbookBlending", properties);
     softParticlesEnabled          = BaseShaderGUI.FindProperty("_SoftParticlesEnabled", properties);
     cameraFadingEnabled           = BaseShaderGUI.FindProperty("_CameraFadingEnabled", properties);
     distortionEnabled             = BaseShaderGUI.FindProperty("_DistortionEnabled", properties, false);
     softParticlesNearFadeDistance = BaseShaderGUI.FindProperty("_SoftParticlesNearFadeDistance", properties);
     softParticlesFarFadeDistance  = BaseShaderGUI.FindProperty("_SoftParticlesFarFadeDistance", properties);
     cameraNearFadeDistance        = BaseShaderGUI.FindProperty("_CameraNearFadeDistance", properties);
     cameraFarFadeDistance         = BaseShaderGUI.FindProperty("_CameraFarFadeDistance", properties);
     distortionBlend               = BaseShaderGUI.FindProperty("_DistortionBlend", properties, false);
     distortionStrength            = BaseShaderGUI.FindProperty("_DistortionStrength", properties, false);
 }
 public LitProperties(MaterialProperty[] properties)
 {
     // Surface Option Props
     workflowMode = BaseShaderGUI.FindProperty("_WorkflowMode", properties, false);
     // Surface Input Props
     metallic             = BaseShaderGUI.FindProperty("_Metallic", properties);
     specColor            = BaseShaderGUI.FindProperty("_SpecColor", properties, false);
     metallicGlossMap     = BaseShaderGUI.FindProperty("_MetallicGlossMap", properties);
     specGlossMap         = BaseShaderGUI.FindProperty("_SpecGlossMap", properties, false);
     smoothness           = BaseShaderGUI.FindProperty("_Smoothness", properties, false);
     smoothnessMapChannel = BaseShaderGUI.FindProperty("_SmoothnessTextureChannel", properties, false);
     bumpMapProp          = BaseShaderGUI.FindProperty("_BumpMap", properties, false);
     bumpScaleProp        = BaseShaderGUI.FindProperty("_BumpScale", properties, false);
     occlusionStrength    = BaseShaderGUI.FindProperty("_OcclusionStrength", properties, false);
     occlusionMap         = BaseShaderGUI.FindProperty("_OcclusionMap", properties, false);
     // Advanced Props
     highlights  = BaseShaderGUI.FindProperty("_SpecularHighlights", properties, false);
     reflections = BaseShaderGUI.FindProperty("_EnvironmentReflections", properties, false);
 }
        public static void DoMetallicSpecularArea(LitProperties properties, MaterialEditor materialEditor, Material material)
        {
            string[] smoothnessChannelNames;
            bool     hasGlossMap = false;

            if (properties.workflowMode == null ||
                (WorkflowMode)properties.workflowMode.floatValue == WorkflowMode.Metallic)
            {
                hasGlossMap            = properties.metallicGlossMap.textureValue != null;
                smoothnessChannelNames = Styles.metallicSmoothnessChannelNames;
                materialEditor.TexturePropertySingleLine(Styles.metallicMapText, properties.metallicGlossMap,
                                                         hasGlossMap ? null : properties.metallic);
            }
            else
            {
                hasGlossMap            = properties.specGlossMap.textureValue != null;
                smoothnessChannelNames = Styles.specularSmoothnessChannelNames;
                BaseShaderGUI.TextureColorProps(materialEditor, Styles.specularMapText, properties.specGlossMap,
                                                hasGlossMap ? null : properties.specColor);
            }
            EditorGUI.indentLevel++;
            DoSmoothness(properties, material, smoothnessChannelNames);
            EditorGUI.indentLevel--;
        }
 public static void Inputs(BakedLitProperties properties, MaterialEditor materialEditor)
 {
     BaseShaderGUI.DrawNormalArea(materialEditor, properties.bumpMapProp);
 }
 public BakedLitProperties(MaterialProperty[] properties)
 {
     // Surface Input Props
     bumpMapProp = BaseShaderGUI.FindProperty("_BumpMap", properties, false);
 }
        public static void FadingOptions(Material material, MaterialEditor materialEditor, ParticleProperties properties)
        {
            // Z write doesn't work with fading
            bool hasZWrite = (material.GetInt("_ZWrite") != 0);

            if (!hasZWrite)
            {
                // Soft Particles
                {
                    EditorGUI.showMixedValue = properties.softParticlesEnabled.hasMixedValue;
                    var enabled = properties.softParticlesEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.softParticlesEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Soft Particles Enabled");
                        properties.softParticlesEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Surface Fade"),
                                                         properties.softParticlesNearFadeDistance,
                                                         Styles.softParticlesNearFadeDistanceText,
                                                         properties.softParticlesFarFadeDistance,
                                                         Styles.softParticlesFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Camera Fading
                {
                    EditorGUI.showMixedValue = properties.cameraFadingEnabled.hasMixedValue;
                    var enabled = properties.cameraFadingEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.cameraFadingEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Camera Fading Enabled");
                        properties.cameraFadingEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        BaseShaderGUI.TwoFloatSingleLine(new GUIContent("Distance"),
                                                         properties.cameraNearFadeDistance,
                                                         Styles.cameraNearFadeDistanceText,
                                                         properties.cameraFarFadeDistance,
                                                         Styles.cameraFarFadeDistanceText,
                                                         materialEditor);
                        EditorGUI.indentLevel--;
                    }
                }

                // Distortion
                if (properties.distortionEnabled != null)
                {
                    EditorGUI.showMixedValue = properties.distortionEnabled.hasMixedValue;
                    var enabled = properties.distortionEnabled.floatValue;

                    EditorGUI.BeginChangeCheck();
                    enabled = EditorGUILayout.Toggle(Styles.distortionEnabled, enabled != 0.0f) ? 1.0f : 0.0f;
                    if (EditorGUI.EndChangeCheck())
                    {
                        materialEditor.RegisterPropertyChangeUndo("Distortion Enabled");
                        properties.distortionEnabled.floatValue = enabled;
                    }

                    if (enabled >= 0.5f)
                    {
                        EditorGUI.indentLevel++;
                        materialEditor.ShaderProperty(properties.distortionStrength, Styles.distortionStrength);
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = properties.distortionStrength.hasMixedValue;
                        var blend = EditorGUILayout.Slider(Styles.distortionBlend, properties.distortionBlend.floatValue, 0f, 1f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            properties.distortionBlend.floatValue = blend;
                        }
                        EditorGUI.indentLevel--;
                    }
                }

                EditorGUI.showMixedValue = false;
            }
        }