From b005b151f297504b62865740ff81c95703e4f888 Mon Sep 17 00:00:00 2001 From: z3y <33181641+z3y@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:39:19 +0200 Subject: [PATCH 1/3] added more options in the default config, packing error fix --- Editor/FreeImage/FreeImagePackingEditor.cs | 9 ++++++++- Editor/Importer/LitImporterDefaultProperties.cs | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Editor/FreeImage/FreeImagePackingEditor.cs b/Editor/FreeImage/FreeImagePackingEditor.cs index 9c80922..161bee6 100644 --- a/Editor/FreeImage/FreeImagePackingEditor.cs +++ b/Editor/FreeImage/FreeImagePackingEditor.cs @@ -185,7 +185,14 @@ public void OnGUI() { var texture = AssetDatabase.LoadAssetAtPath(unityPath); _packingMaterial.SetTexture(_packingProperty.name, texture); - LitGUI.ApplyChanges(_packingMaterial); + if (_packingMaterial.shader.name == ProjectSettings.ShaderName) + { + LitGUI.ApplyChanges(_packingMaterial); + } + else + { + MaterialEditor.ApplyMaterialPropertyDrawers(_packingMaterial); + } } } EditorGUILayout.EndHorizontal(); diff --git a/Editor/Importer/LitImporterDefaultProperties.cs b/Editor/Importer/LitImporterDefaultProperties.cs index abf4aa6..8c44c97 100644 --- a/Editor/Importer/LitImporterDefaultProperties.cs +++ b/Editor/Importer/LitImporterDefaultProperties.cs @@ -32,7 +32,16 @@ [ToggleGroupEnd] [UnIndent] [ToggleOff] _OpaqueLights(""Opaque Lights"", Float) public const string DefaultConfigFile = @" DEFINES_START - // #define BAKERY_MONOSH // enable mono sh globally + // comment out to set globally + + // #define BAKERY_MONOSH // enable mono + // #define _LIGHTMAPPED_SPECULAR // enable lightmapped specular + // #undef APPROXIMATE_AREALIGHT_SPECULAR // lower the smoothness in areas where theres less directionality in directional lightmaps, defined by default + // #define BICUBIC_LIGHTMAP // enable bicubic lightmap + // #define BAKERY_SHNONLINEAR_OFF // disable non linear lightmap sh, enabled by default + // #define NONLINEAR_LIGHTPROBESH // enable non linear lightprobe sh + // #define DISABLE_LIGHT_PROBE_PROXY_VOLUME // enable LPPV + // #undef UNITY_SPECCUBE_BLENDING // disable blending of 2 reflection probes DEFINES_END "; From e16f8def660095f500f58eb2c8da822c55ac52d7 Mon Sep 17 00:00:00 2001 From: z3y <33181641+z3y@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:49:39 +0200 Subject: [PATCH 2/3] apply on validate callback to enable keywords after packing --- Editor/FreeImage/FreeImagePackingEditor.cs | 3 ++- Editor/Inspector/DefaultInspector.cs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/FreeImage/FreeImagePackingEditor.cs b/Editor/FreeImage/FreeImagePackingEditor.cs index 161bee6..75287ab 100644 --- a/Editor/FreeImage/FreeImagePackingEditor.cs +++ b/Editor/FreeImage/FreeImagePackingEditor.cs @@ -191,8 +191,9 @@ public void OnGUI() } else { - MaterialEditor.ApplyMaterialPropertyDrawers(_packingMaterial); + DefaultInspector.RequestValidate(); } + MaterialEditor.ApplyMaterialPropertyDrawers(_packingMaterial); } } EditorGUILayout.EndHorizontal(); diff --git a/Editor/Inspector/DefaultInspector.cs b/Editor/Inspector/DefaultInspector.cs index 8729763..b48b31b 100644 --- a/Editor/Inspector/DefaultInspector.cs +++ b/Editor/Inspector/DefaultInspector.cs @@ -51,12 +51,14 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] mat materialEditor.EnableInstancingField(); materialEditor.DoubleSidedGIField(); - if (EditorGUI.EndChangeCheck()) + if (EditorGUI.EndChangeCheck() || _requestValidate) { OnValidate(materialEditor, materialProperties); + _requestValidate = false; } } - + private static bool _requestValidate = false; + public static void RequestValidate() => _requestValidate = true; private void OnValidate(MaterialEditor materialEditor, MaterialProperty[] materialProperties) { foreach (Material mat in materialEditor.targets) From 8db786d9304601834765b0026315084191cde2c5 Mon Sep 17 00:00:00 2001 From: z3y <33181641+z3y@users.noreply.github.com> Date: Mon, 26 Jun 2023 21:55:03 +0200 Subject: [PATCH 3/3] disable packing button in multi edit mode, added packing button in details --- Editor/Inspector/DefaultInspector.cs | 19 +++++++++++-------- Shaders/Lit.litshader | 1 + package.json | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Editor/Inspector/DefaultInspector.cs b/Editor/Inspector/DefaultInspector.cs index b48b31b..8b7df98 100644 --- a/Editor/Inspector/DefaultInspector.cs +++ b/Editor/Inspector/DefaultInspector.cs @@ -260,15 +260,18 @@ private void InitializeEditor(MaterialEditor materialEditor, MaterialProperty[] rect = MaterialEditor.GetRectAfterLabelWidth(rect); rect.width = 50; //rect.position = new Vector2(Screen.width / 2, rect.position.y); - if (GUI.Button(rect, "Pack")) + if (editor.targets.Length == 1) { - FreeImagePackingEditor.Init(); - FreeImagePackingEditor.ChannelR.DisplayName = rName; - FreeImagePackingEditor.ChannelG.DisplayName = gName; - FreeImagePackingEditor.ChannelB.DisplayName = bName; - FreeImagePackingEditor.ChannelA.DisplayName = aName; - FreeImagePackingEditor.Linear = isLinear; - FreeImagePackingEditor.AddPackingMaterial((Material)editor.target, unityProperty[property.index]); + if (GUI.Button(rect, "Pack")) + { + FreeImagePackingEditor.Init(); + FreeImagePackingEditor.ChannelR.DisplayName = rName; + FreeImagePackingEditor.ChannelG.DisplayName = gName; + FreeImagePackingEditor.ChannelB.DisplayName = bName; + FreeImagePackingEditor.ChannelA.DisplayName = aName; + FreeImagePackingEditor.Linear = isLinear; + FreeImagePackingEditor.AddPackingMaterial((Material)editor.target, unityProperty[property.index]); + } } }; } diff --git a/Shaders/Lit.litshader b/Shaders/Lit.litshader index ae603ae..8856743 100644 --- a/Shaders/Lit.litshader +++ b/Shaders/Lit.litshader @@ -42,6 +42,7 @@ PROPERTIES_START // Properties FoldoutMainEnd_PropertiesLocal ("", Float) = 0 FoldoutMainStart_Details ("Details", Float) = 0 + [TexturePacking(Abledo R, Albedo G, Albedo B, Mask, false)] [NoScaleOffset] [Toggle(_DETAIL_ALBEDO)] [Tooltip(Albedo (RGB), Mask (A))] [ExtraProperty] _DetailAlbedo ("Detail Albedo", 2D) = "white" {} [Enum(Multiply X2, 0, Overlay, 1, Screen, 3)] [Indent] [UnIndent] _DetailAlbedoBlendMode ("Blend Mode", Int) = 0 [NoScaleOffset] [Normal] [Toggle(_DETAIL_NORMAL)] [ExtraProperty] _DetailBumpMap ("Detail Normal Map", 2D) = "bump" {} diff --git a/package.json b/package.json index 1e4f523..5ba8d4d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.z3y.shaders", "description": "A Standard Shader and Surface Shaders replacement for Unity for Built-In pipeline and forward rendering (VRChat)", - "version": "3.2.2", + "version": "3.2.3", "unity": "2019.4", "displayName": "z3y - Shaders", "hideInEditor": false,