Example #1
0
        public static void GeometryInputs(LitTessellationProperties properties, MaterialEditor materialEditor, Material material)
        {
            // vertex color
            DoVertexColor(properties, materialEditor, material);

            // tesellation
            DoTessellation(properties, materialEditor, material);

            // height
            DoHeight(properties, materialEditor, material);
        }
Example #2
0
        public static void SurfaceInputs(LitTessellationProperties 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);
            }
        }
Example #3
0
        public static void DoVertexColor(LitTessellationProperties properties, MaterialEditor materialEditor, Material material)
        {
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = properties.vertexColorMode.hasMixedValue;
            var vertexColorMode = (LitTessellationGUI.VertexColorMode)properties.vertexColorMode.floatValue;

            vertexColorMode = (LitTessellationGUI.VertexColorMode)EditorGUILayout.EnumPopup(LitTessellationGUI.Styles.vertexColorModeText, vertexColorMode);
            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(LitTessellationGUI.Styles.vertexColorModeText.text);
                properties.vertexColorMode.floatValue = (float)vertexColorMode;
                SetMaterialKeywords(material);
            }
            EditorGUI.showMixedValue = false;
        }
Example #4
0
        public static void DoSmoothness(LitTessellationProperties properties, Material material, string[] smoothnessChannelNames)
        {
            var opaque = ((BaseShaderGUI.SurfaceType)material.GetFloat("_Surface") ==
                          BaseShaderGUI.SurfaceType.Opaque);

            EditorGUI.indentLevel++;
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = properties.smoothness.hasMixedValue;
            var smoothness = EditorGUILayout.Slider(Styles.smoothnessText, properties.smoothness.floatValue, 0f, 1f);

            if (EditorGUI.EndChangeCheck())
            {
                properties.smoothness.floatValue = smoothness;
            }
            EditorGUI.showMixedValue = false;

            if (properties.smoothnessMapChannel != null) // smoothness channel
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginDisabledGroup(!opaque);
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.smoothnessMapChannel.hasMixedValue;
                var smoothnessSource = (int)properties.smoothnessMapChannel.floatValue;
                if (opaque)
                {
                    smoothnessSource = EditorGUILayout.Popup(Styles.smoothnessMapChannelText, smoothnessSource,
                                                             smoothnessChannelNames);
                }
                else
                {
                    EditorGUILayout.Popup(Styles.smoothnessMapChannelText, 0, smoothnessChannelNames);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    properties.smoothnessMapChannel.floatValue = smoothnessSource;
                }
                EditorGUI.showMixedValue = false;
                EditorGUI.EndDisabledGroup();
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }
Example #5
0
        public static void DoMetallicSpecularArea(LitTessellationProperties 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--;
        }
Example #6
0
        public static void DoHeight(LitTessellationProperties properties, MaterialEditor materialEditor, Material material)
        {
            if (properties.heightMap != null)
            {
                materialEditor.TexturePropertySingleLine(Styles.heightText, properties.heightMap, properties.heightMap.textureValue != null ? properties.heightStrength : null);

                EditorGUI.indentLevel++;
                EditorGUI.indentLevel++;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.heightBase.hasMixedValue;
                var heightBase = EditorGUILayout.Slider(Styles.heightBaseText, properties.heightBase.floatValue, -1f, 1f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.heightBase.floatValue = heightBase;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.heightBlurMode.hasMixedValue;
                var heightBlurMode = (LitTessellationGUI.HeightmapBlurMode)properties.heightBlurMode.floatValue;
                heightBlurMode = (LitTessellationGUI.HeightmapBlurMode)EditorGUILayout.EnumPopup(LitTessellationGUI.Styles.heightBlurModeText, heightBlurMode);
                if (EditorGUI.EndChangeCheck())
                {
                    materialEditor.RegisterPropertyChangeUndo(LitTessellationGUI.Styles.heightBlurModeText.text);
                    properties.heightBlurMode.floatValue = (float)heightBlurMode;
                    SetMaterialKeywords(material);
                }
                EditorGUI.showMixedValue = false;

                if (heightBlurMode != HeightmapBlurMode.None)
                {
                    EditorGUI.indentLevel++;

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = properties.heightBlurSize.hasMixedValue;
                    var heightBlurSize = EditorGUILayout.Slider(Styles.heightBlurSizeText, properties.heightBlurSize.floatValue, 0f, 1.0f);
                    if (EditorGUI.EndChangeCheck())
                    {
                        properties.heightBlurSize.floatValue = heightBlurSize;
                    }
                    EditorGUI.showMixedValue = false;

                    EditorGUI.BeginChangeCheck();
                    EditorGUI.showMixedValue = properties.heightBlurSamples.hasMixedValue;
                    var heightBlurSamples = EditorGUILayout.IntSlider(Styles.heightBlurSamplesText, (int)properties.heightBlurSamples.floatValue, 1, 60);
                    if (EditorGUI.EndChangeCheck())
                    {
                        properties.heightBlurSamples.floatValue = heightBlurSamples;
                    }
                    EditorGUI.showMixedValue = false;

                    if (heightBlurMode == HeightmapBlurMode.Gaussian)
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUI.showMixedValue = properties.heightBlurGaussStandardDeviation.hasMixedValue;
                        var heightBlurGaussStandardDeviation = EditorGUILayout.Slider(Styles.heightBlurGaussStandardDeviationText, properties.heightBlurGaussStandardDeviation.floatValue, 0.001f, 0.1f);
                        if (EditorGUI.EndChangeCheck())
                        {
                            properties.heightBlurGaussStandardDeviation.floatValue = heightBlurGaussStandardDeviation;
                        }
                        EditorGUI.showMixedValue = false;
                    }

                    EditorGUILayout.HelpBox("Heightmap blur may cause performance issues on heavy tessellated meshes. Avoid using it if possible.", MessageType.Warning);

                    EditorGUI.indentLevel--;
                }

                EditorGUI.indentLevel--;
                EditorGUI.indentLevel--;
            }
        }
Example #7
0
        public static void DoTessellation(LitTessellationProperties properties, MaterialEditor materialEditor, Material material)
        {
            // mask
            materialEditor.TexturePropertySingleLine(LitTessellationGUI.Styles.tessellationMapText, properties.tessellationMap, properties.tessellationScale);

            EditorGUI.indentLevel++;
            EditorGUI.indentLevel++;

            // mode
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = properties.tessellationMode.hasMixedValue;
            var tessellationMode = (LitTessellationGUI.TessellationMode)properties.tessellationMode.floatValue;

            tessellationMode = (LitTessellationGUI.TessellationMode)EditorGUILayout.EnumPopup(LitTessellationGUI.Styles.tessellationModeText, tessellationMode);
            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(LitTessellationGUI.Styles.tessellationModeText.text);
                properties.tessellationMode.floatValue = (float)tessellationMode;
            }
            EditorGUI.showMixedValue = false;

            // modes
            if (tessellationMode == LitTessellationGUI.TessellationMode.Uniform)
            {
                // uniform
                EditorGUI.indentLevel++;

                // factor
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationFactor.hasMixedValue;
                var tessellationFactor = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationFactorText, properties.tessellationFactor.floatValue, 1f, 64f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationFactor.floatValue = tessellationFactor;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.indentLevel--;
            }
            else if (tessellationMode == LitTessellationGUI.TessellationMode.EdgeLength)
            {
                // edge length
                EditorGUI.indentLevel++;

                // edge length
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationEdgeLength.hasMixedValue;
                var tessellationEdgeLength = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationEdgeLengthText, properties.tessellationEdgeLength.floatValue, .05f, 32f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationEdgeLength.floatValue = tessellationEdgeLength;
                }
                EditorGUI.showMixedValue = false;

                // distance offset
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationEdgeDistanceOffset.hasMixedValue;
                var tessellationDistanceOffset = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationEdgeDistanceOffsetText, properties.tessellationEdgeDistanceOffset.floatValue, 0f, 10f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationEdgeDistanceOffset.floatValue = tessellationDistanceOffset;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.indentLevel--;
            }
            else if (tessellationMode == LitTessellationGUI.TessellationMode.Distance)
            {
                // distance
                EditorGUI.indentLevel++;

                // factor min
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationFactorMin.hasMixedValue;
                var tessellationFactorMin = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationFactorMinText, properties.tessellationFactorMin.floatValue, 1f, 64f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationFactorMin.floatValue = tessellationFactorMin;
                }
                EditorGUI.showMixedValue = false;

                // factor max
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationFactorMax.hasMixedValue;
                var tessellationFactorMax = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationFactorMaxText, properties.tessellationFactorMax.floatValue, 1f, 64f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationFactorMax.floatValue = tessellationFactorMax;
                }
                EditorGUI.showMixedValue = false;

                // distance min
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationDistanceMin.hasMixedValue;
                var tessellationDistanceMin = EditorGUILayout.FloatField(LitTessellationGUI.Styles.tessellationDistanceMinText, properties.tessellationDistanceMin.floatValue);
                tessellationDistanceMin = Mathf.Max(0, tessellationDistanceMin);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationDistanceMin.floatValue = tessellationDistanceMin;
                }
                EditorGUI.showMixedValue = false;

                // distance max
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationDistanceMax.hasMixedValue;
                var tessellationDistanceMax = EditorGUILayout.FloatField(LitTessellationGUI.Styles.tessellationDistanceMaxText, properties.tessellationDistanceMax.floatValue);
                tessellationDistanceMax = Mathf.Max(tessellationDistanceMin, tessellationDistanceMax);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationDistanceMax.floatValue = tessellationDistanceMax;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.indentLevel--;
            }

            // postpro
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = properties.tessellationPostPro.hasMixedValue;
            var tessellationPostPro = (LitTessellationGUI.TessellationPostPro)properties.tessellationPostPro.floatValue;

            tessellationPostPro = (LitTessellationGUI.TessellationPostPro)EditorGUILayout.EnumPopup(LitTessellationGUI.Styles.tessellationPostProText, tessellationPostPro);
            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(LitTessellationGUI.Styles.tessellationPostProText.text);
                properties.tessellationPostPro.floatValue = (float)tessellationPostPro;
            }
            EditorGUI.showMixedValue = false;

            // phong postpro
            if (tessellationPostPro == TessellationPostPro.Phong)
            {
                // phong tessellation
                EditorGUI.indentLevel++;

                // factor
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationPhongShape.hasMixedValue;
                var tessellationPhongShape = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationPhongShapeText, properties.tessellationPhongShape.floatValue, 0f, 1f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationPhongShape.floatValue = tessellationPhongShape;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.indentLevel--;
            }

            // triangle clipping
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = properties.tessellationTriangleClipping.hasMixedValue;
            var tessellationTriangleClipping = properties.tessellationTriangleClipping.floatValue == 1f;

            tessellationTriangleClipping = EditorGUILayout.Toggle(LitTessellationGUI.Styles.tessellationTriangleClippingText, tessellationTriangleClipping);
            if (EditorGUI.EndChangeCheck())
            {
                materialEditor.RegisterPropertyChangeUndo(LitTessellationGUI.Styles.tessellationTriangleClippingText.text);
                properties.tessellationTriangleClipping.floatValue = tessellationTriangleClipping ? 1f : 0f;
            }
            EditorGUI.showMixedValue = false;

            // triangle clip bias
            if (tessellationTriangleClipping)
            {
                EditorGUI.indentLevel++;

                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = properties.tessellationTriangleClipBias.hasMixedValue;
                var tessellationTriangleClipBias = EditorGUILayout.Slider(LitTessellationGUI.Styles.tessellationTriangleClipBiasText, properties.tessellationTriangleClipBias.floatValue, -1f, 1f);
                if (EditorGUI.EndChangeCheck())
                {
                    properties.tessellationTriangleClipBias.floatValue = tessellationTriangleClipBias;
                }
                EditorGUI.showMixedValue = false;

                EditorGUI.indentLevel--;
            }

            EditorGUI.indentLevel--;
            EditorGUI.indentLevel--;
        }