void DoTessellation() { GUILayout.Label("Tessellation", EditorStyles.boldLabel); EditorGUI.indentLevel += 2; TesselationMode mode = TesselationMode.Uniform; if (IsKeywordEnabled("_TESSELLATION_EDGE")) { mode = TesselationMode.Edge; } EditorGUI.BeginChangeCheck(); mode = (TesselationMode)EditorGUILayout.EnumPopup(MakeLabel("Mode"), mode); if (EditorGUI.EndChangeCheck()) { RecordAction("Tessellation_Mode"); SetKeyword("_TESSELLATION_EDGE", mode == TesselationMode.Edge); } if (mode == TesselationMode.Uniform) { editor.ShaderProperty( FindProperty("_TessellationUniform"), MakeLabel("Uniform")); } else { editor.ShaderProperty( FindProperty("_TessellationEdgeLength"), MakeLabel("Edge Length")); } EditorGUI.indentLevel -= 2; }
void guiForTesselation() { showTesselationSettings = targetMat.GetFloat("_showTesselation") == 1; showTesselationSettings = EditorGUILayout.Foldout(showTesselationSettings, "Tesselation Settings"); targetMat.SetFloat("_showTesselation", showTesselationSettings ? 1f : 0f); if (!showTesselationSettings) { return; } tesselationMode = (TesselationMode)targetMat.GetFloat("_TesselationMode"); tesselationMode = (TesselationMode)EditorGUILayout.EnumPopup("Mode:", tesselationMode); targetMat.SetFloat("_TesselationMode", (float)tesselationMode); switch (tesselationMode) { case TesselationMode.Distance: matEditor.RangeProperty(getProperty("_TesselationAmount"), "Tesselation Steps"); matEditor.FloatProperty(getProperty("_TesselationMin"), "Falloff Begin Distance"); matEditor.FloatProperty(getProperty("_TesselationMax"), "Falloff End Distance"); targetMat.EnableKeyword("_TESSELATIONMODE_DISTANCE"); targetMat.DisableKeyword("_TESSELATIONMODE_EDGE"); targetMat.DisableKeyword("_TESSELATIONMODE_FIXED"); break; case TesselationMode.Edge: matEditor.RangeProperty(getProperty("_EdgeLength"), "Desired Edge Length"); targetMat.EnableKeyword("_TESSELATIONMODE_EDGE"); targetMat.DisableKeyword("_TESSELATIONMODE_DISTANCE"); targetMat.DisableKeyword("_TESSELATIONMODE_FIXED"); break; case TesselationMode.Fixed: matEditor.RangeProperty(getProperty("_TessFix"), "Tesselation Steps"); targetMat.EnableKeyword("_TESSELATIONMODE_FIXED"); targetMat.DisableKeyword("_TESSELATIONMODE_DISTANCE"); targetMat.DisableKeyword("_TESSELATIONMODE_EDGE"); break; default: break; } recalculateNormals = targetMat.GetFloat("_RecalcNormals") == 1; recalculateNormals = EditorGUILayout.Toggle("Recalculate Normals", recalculateNormals); targetMat.SetFloat("_RecalcNormals", recalculateNormals ? 1f : 0f); if (recalculateNormals) { targetMat.EnableKeyword("_RECALC_MESH"); } else { targetMat.DisableKeyword("_RECALC_MESH"); } }