private void DrawAdvancedShading() { string prefKey = GEditorCommon.GetProjectRelatedEditorPrefsKey("foldout", "shading", "properties-name", data.Id); bool expanded = EditorPrefs.GetBool(prefKey, false); expanded = EditorGUILayout.Foldout(expanded, "Properties Name"); EditorPrefs.SetBool(prefKey, expanded); if (expanded) { EditorGUI.indentLevel += 1; GShading settings = data.Shading; settings.AlbedoMapPropertyName = EditorGUILayout.DelayedTextField("Albedo Map", settings.AlbedoMapPropertyName); settings.MetallicMapPropertyName = EditorGUILayout.DelayedTextField("Metallic Map", settings.MetallicMapPropertyName); settings.ColorByHeightPropertyName = EditorGUILayout.DelayedTextField("Color By Height", settings.ColorByHeightPropertyName); settings.ColorByNormalPropertyName = EditorGUILayout.DelayedTextField("Color By Normal", settings.ColorByNormalPropertyName); settings.ColorBlendPropertyName = EditorGUILayout.DelayedTextField("Color Blend", settings.ColorBlendPropertyName); settings.DimensionPropertyName = EditorGUILayout.DelayedTextField("Dimension", settings.DimensionPropertyName); settings.SplatControlMapPropertyName = EditorGUILayout.DelayedTextField("Splat Control Map", settings.SplatControlMapPropertyName); settings.SplatMapPropertyName = EditorGUILayout.DelayedTextField("Splat Map", settings.SplatMapPropertyName); settings.SplatNormalPropertyName = EditorGUILayout.DelayedTextField("Splat Normal Map", settings.SplatNormalPropertyName); settings.SplatMetallicPropertyName = EditorGUILayout.DelayedTextField("Splat Metallic", settings.SplatMetallicPropertyName); settings.SplatSmoothnessPropertyName = EditorGUILayout.DelayedTextField("Splat Smoothness", settings.SplatSmoothnessPropertyName); EditorGUI.indentLevel -= 1; } }
public static void DeleteTextures() { Object o = Selection.activeObject; if (o is GShading) { GShading shading = o as GShading; GUtilities.DestroyObject(shading.AlbedoMap); GUtilities.DestroyObject(shading.MetallicMap); Texture2D[] controls = shading.SplatControls; for (int i = 0; i < controls.Length; ++i) { if (controls[i] != null) { GUtilities.DestroyObject(controls[i]); } } } }
public void CopyTo(GShading des) { des.AlbedoMapResolution = AlbedoMapResolution; des.MetallicMapResolution = MetallicMapResolution; des.AlbedoMapPropertyName = AlbedoMapPropertyName; des.MetallicMapPropertyName = MetallicMapPropertyName; des.ColorByHeight = GUtilities.Clone(ColorByHeight); des.ColorByNormal = GUtilities.Clone(ColorByNormal); des.ColorBlendCurve = GUtilities.Clone(ColorBlendCurve); des.ColorByHeightPropertyName = ColorByHeightPropertyName; des.ColorByNormalPropertyName = ColorByNormalPropertyName; des.ColorBlendPropertyName = ColorBlendPropertyName; des.DimensionPropertyName = DimensionPropertyName; des.Splats = Splats; des.SplatControlResolution = SplatControlResolution; des.SplatControlMapPropertyName = SplatControlMapPropertyName; des.SplatMapPropertyName = SplatMapPropertyName; des.SplatNormalPropertyName = SplatNormalPropertyName; des.SplatMetallicPropertyName = SplatMetallicPropertyName; des.SplatSmoothnessPropertyName = SplatSmoothnessPropertyName; }
private void DrawShadingGUI() { string label = "Shading"; string id = "shading" + data.Id; GenericMenu menu = new GenericMenu(); menu.AddItem( new GUIContent("Reset"), false, () => { data.Shading.ResetFull(); }); menu.AddItem( new GUIContent("Refresh"), false, () => { data.Shading.UpdateLookupTextures(); data.Shading.UpdateMaterials(); }); menu.AddItem( new GUIContent("Set Shader"), false, () => { GWizardWindow.ShowSetShaderTab(terrain); }); menu.AddSeparator(null); menu.AddItem( new GUIContent("Advanced/Convert Splats To Albedo"), false, () => { data.Shading.ConvertSplatsToAlbedo(); }); menu.AddSeparator("Advanced/"); menu.AddItem( new GUIContent("Advanced/Remove Albedo Map"), false, () => { ConfirmAndRemoveAlbedoMap(); }); menu.AddItem( new GUIContent("Advanced/Remove Metallic Map"), false, () => { ConfirmAndRemoveMetallicMap(); }); menu.AddItem( new GUIContent("Advanced/Remove Splat Control Maps"), false, () => { ConfirmAndRemoveControlMaps(); }); menu.AddItem( new GUIContent("Advanced/Remove Gradient Lookup Maps"), false, () => { ConfirmAndRemoveGradientLookupMaps(); }); GEditorCommon.Foldout(label, false, id, () => { GShading settings = data.Shading; EditorGUI.BeginChangeCheck(); #if __MICROSPLAT_POLARIS__ GEditorCommon.Header("System"); settings.ShadingSystem = (GShadingSystem)EditorGUILayout.EnumPopup("Shading System", settings.ShadingSystem); #endif GEditorCommon.Header("Material & Shader"); settings.CustomMaterial = EditorGUILayout.ObjectField("Material", settings.CustomMaterial, typeof(Material), false) as Material; if (settings.CustomMaterial != null) { GUI.enabled = false; EditorGUILayout.LabelField("Shader", settings.CustomMaterial.shader.name); GUI.enabled = true; } #if __MICROSPLAT_POLARIS__ if (settings.ShadingSystem == GShadingSystem.MicroSplat) { settings.MicroSplatTextureArrayConfig = EditorGUILayout.ObjectField("Texture Array Config", settings.MicroSplatTextureArrayConfig, typeof(TextureArrayConfig), false) as TextureArrayConfig; } #endif if (settings.ShadingSystem == GShadingSystem.Polaris) { GEditorCommon.Header("Color Map & Gradient Lookup"); settings.AlbedoMapResolution = EditorGUILayout.DelayedIntField("Albedo Map Resolution", settings.AlbedoMapResolution); settings.MetallicMapResolution = EditorGUILayout.DelayedIntField("Metallic Map Resolution", settings.MetallicMapResolution); if (EditorGUI.EndChangeCheck()) { data.SetDirty(GTerrainData.DirtyFlags.Shading); } EditorGUI.BeginChangeCheck(); SerializedObject so = new SerializedObject(settings); SerializedProperty colorByNormalProps = so.FindProperty("colorByNormal"); EditorGUILayout.PropertyField(colorByNormalProps); settings.ColorBlendCurve = EditorGUILayout.CurveField("Blend By Height", settings.ColorBlendCurve, Color.red, new Rect(0, 0, 1, 1)); SerializedProperty colorByHeightProps = so.FindProperty("colorByHeight"); EditorGUILayout.PropertyField(colorByHeightProps); if (EditorGUI.EndChangeCheck()) { so.ApplyModifiedProperties(); settings.UpdateLookupTextures(); data.SetDirty(GTerrainData.DirtyFlags.Shading); } colorByHeightProps.Dispose(); colorByNormalProps.Dispose(); so.Dispose(); } EditorGUI.BeginChangeCheck(); GEditorCommon.Header("Splats"); if (settings.ShadingSystem == GShadingSystem.Polaris) { settings.Splats = EditorGUILayout.ObjectField("Prototypes", settings.Splats, typeof(GSplatPrototypeGroup), false) as GSplatPrototypeGroup; } settings.SplatControlResolution = EditorGUILayout.DelayedIntField("Control Map Resolution", settings.SplatControlResolution); if (settings.ShadingSystem == GShadingSystem.Polaris) { GEditorCommon.Header("Advanced"); DrawAdvancedShading(); } if (EditorGUI.EndChangeCheck()) { data.SetDirty(GTerrainData.DirtyFlags.Shading); } }, menu); }
private void DrawShadingGUI() { string label = "Shading"; string id = "shading" + data.Id; GenericMenu menu = new GenericMenu(); menu.AddItem( new GUIContent("Reset"), false, () => { data.Shading.ResetFull(); }); menu.AddItem( new GUIContent("Refresh"), false, () => { data.Shading.UpdateLookupTextures(); data.Shading.UpdateMaterials(); }); menu.AddItem( new GUIContent("Set Shader"), false, () => { GTerrainWizardWindow.ShowWindowSetShaderMode(data); }); #if __MICROSPLAT_POLARIS__ if (microSplatSetupMenu != null) { menu.AddSeparator(null); menu.AddItem( new GUIContent(microSplatSetupMenu.Name), microSplatSetupMenu.IsOn, microSplatSetupMenu.Action); } #endif GEditorCommon.Foldout(label, false, id, () => { GShading settings = data.Shading; EditorGUI.BeginChangeCheck(); #if __MICROSPLAT_POLARIS__ settings.ShadingSystem = (GShadingSystem)EditorGUILayout.EnumPopup("Shading System", settings.ShadingSystem); #endif settings.CustomMaterial = EditorGUILayout.ObjectField("Material", settings.CustomMaterial, typeof(Material), false) as Material; if (settings.CustomMaterial != null) { GUI.enabled = false; EditorGUILayout.LabelField("Shader", settings.CustomMaterial.shader.name); GUI.enabled = true; } settings.AlbedoMapResolution = EditorGUILayout.DelayedIntField("Albedo Map Resolution", settings.AlbedoMapResolution); settings.MetallicMapResolution = EditorGUILayout.DelayedIntField("Metallic Map Resolution", settings.MetallicMapResolution); if (EditorGUI.EndChangeCheck()) { data.SetDirty(GTerrainData.DirtyFlags.Shading); } EditorGUI.BeginChangeCheck(); SerializedObject so = new SerializedObject(settings); SerializedProperty colorByNormalProps = so.FindProperty("colorByNormal"); EditorGUILayout.PropertyField(colorByNormalProps); settings.ColorBlendCurve = EditorGUILayout.CurveField("Blend By Height", settings.ColorBlendCurve, Color.red, new Rect(0, 0, 1, 1)); SerializedProperty colorByHeightProps = so.FindProperty("colorByHeight"); EditorGUILayout.PropertyField(colorByHeightProps); if (EditorGUI.EndChangeCheck()) { so.ApplyModifiedProperties(); settings.UpdateLookupTextures(); data.SetDirty(GTerrainData.DirtyFlags.Shading); } colorByHeightProps.Dispose(); colorByNormalProps.Dispose(); so.Dispose(); EditorGUI.BeginChangeCheck(); settings.Splats = EditorGUILayout.ObjectField("Splats", settings.Splats, typeof(GSplatPrototypeGroup), false) as GSplatPrototypeGroup; settings.SplatControlResolution = EditorGUILayout.DelayedIntField("Splat Control Resolution", settings.SplatControlResolution); DrawAdvancedShading(); if (EditorGUI.EndChangeCheck()) { data.SetDirty(GTerrainData.DirtyFlags.Shading); } }, menu); }