diff --git a/Editor/Scripts/Internal/GLTFMaterialHelper.cs b/Editor/Scripts/Internal/GLTFMaterialHelper.cs index a83af4abd..213c562bd 100644 --- a/Editor/Scripts/Internal/GLTFMaterialHelper.cs +++ b/Editor/Scripts/Internal/GLTFMaterialHelper.cs @@ -85,7 +85,8 @@ public static void ValidateMaterialKeywords(Material material) // var needsSpecular = material.HasProperty(specularFactor) && material.GetFloat(specularFactor) > 0; // material.SetKeyword("_SPECULAR", needsSpecular); var isImplicitBlendMode = true; - const string blendModeProp = "_AutoSurfaceMode"; + + const string blendModeProp = "_OverrideSurfaceMode"; if (material.HasProperty(blendModeProp)) { var blendMode = material.GetInt(blendModeProp); diff --git a/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs b/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs index 9b8a53acf..87d0c35e2 100644 --- a/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs +++ b/Editor/Scripts/ShaderGraph/InternalShaderGraph/PBRGraphGUI.cs @@ -529,9 +529,31 @@ private void DrawProperties(Material targetMaterial, MaterialProperty[] properti { propertyList.RemoveAll(x => x.name == "alphaCutoff"); } + + // remove advanced properties that we want to draw a foldout for + var overrideSurfaceMode = propertyList.FirstOrDefault(x => x.name == "_OverrideSurfaceMode"); + var normalMapFormatXYZ = propertyList.FirstOrDefault(x => x.name == "_NormalMapFormatXYZ"); + if (overrideSurfaceMode != null) propertyList.Remove(overrideSurfaceMode); + if (normalMapFormatXYZ != null) propertyList.Remove(normalMapFormatXYZ); + // TODO we probably want full manual control, all this internal access is horrible... // E.g. impossible to render inline texture properties... ShaderGraphHelpers.DrawShaderGraphGUI(materialEditor, propertyList); + + // draw a foldout with the advanced properties + const string key = nameof(PBRGraphGUI) + "_AdvancedFoldout"; + var val = SessionState.GetBool(key, false); + var newVal = EditorGUILayout.Foldout(val, "Mode Overrides", true); + if (newVal != val) SessionState.SetBool(key, newVal); + if (newVal) + { + EditorGUI.indentLevel++; + if (overrideSurfaceMode != null) materialEditor.ShaderProperty(overrideSurfaceMode, + new GUIContent(overrideSurfaceMode.displayName, "When disabled, surface mode and queue are set by default based on material options. For example, transmissive objects will be set to \"transparent\". For some cases, explicit control over the surface mode helps with render order, e.g. nested transparency sorting.")); + if (normalMapFormatXYZ != null) materialEditor.ShaderProperty(normalMapFormatXYZ, + new GUIContent(normalMapFormatXYZ.displayName, "When disabled, normal maps are assumed to be in the specified project format (XYZ or DXT5nm). Normal maps imported at runtime are always in XYZ, so this option is enabled for materials imported at runtime.")); + EditorGUI.indentLevel--; + } } public override void AssignNewShaderToMaterial(Material material, Shader oldShader, Shader newShader) diff --git a/Runtime/Shaders/ShaderGraph/PBRGraph.shadergraph b/Runtime/Shaders/ShaderGraph/PBRGraph.shadergraph index eb63f2cc1..c60882345 100644 --- a/Runtime/Shaders/ShaderGraph/PBRGraph.shadergraph +++ b/Runtime/Shaders/ShaderGraph/PBRGraph.shadergraph @@ -7596,7 +7596,7 @@ "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", "m_ObjectId": "2090fe25b14c4580b73042885a983527", "m_Id": 0, - "m_DisplayName": "NormalMapFormatXYZ", + "m_DisplayName": "Override Normal Map is XYZ", "m_SlotType": 1, "m_Hidden": false, "m_ShaderOutputName": "Out", @@ -7640,11 +7640,11 @@ "m_Guid": { "m_GuidSerialized": "8caf300e-d530-4793-835f-30b40abbc6f2" }, - "m_Name": "NormalMapFormatXYZ", + "m_Name": "Override Normal Map is XYZ", "m_DefaultRefNameVersion": 1, - "m_RefNameGeneratedByDisplayName": "NormalMapFormatXYZ", - "m_DefaultReferenceName": "_NormalMapFormatXYZ", - "m_OverrideReferenceName": "", + "m_RefNameGeneratedByDisplayName": "Override Normal Map is XYZ", + "m_DefaultReferenceName": "_Override_Normal_Map_is_XYZ", + "m_OverrideReferenceName": "_NormalMapFormatXYZ", "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", @@ -12915,16 +12915,16 @@ { "m_SGVersion": 1, - "m_Type": "UnityEditor.ShaderGraph.Internal.Vector1ShaderProperty", + "m_Type": "UnityEditor.ShaderGraph.Internal.BooleanShaderProperty", "m_ObjectId": "5959c998527d4aaf8a3653895a8d1279", "m_Guid": { "m_GuidSerialized": "dab1ea9d-9855-4409-ae49-b4a26815c9f9" }, - "m_Name": "Auto Surface and Queue", + "m_Name": "Override Surface Type and Queue", "m_DefaultRefNameVersion": 1, - "m_RefNameGeneratedByDisplayName": "Auto Surface and Queue", - "m_DefaultReferenceName": "_Auto_Surface_and_Queue", - "m_OverrideReferenceName": "_AutoSurfaceMode", + "m_RefNameGeneratedByDisplayName": "Override Surface Type and Queue", + "m_DefaultReferenceName": "_Override_Surface_Type_and_Queue", + "m_OverrideReferenceName": "_OverrideSurfaceMode", "m_GeneratePropertyBlock": true, "m_UseCustomSlotLabel": false, "m_CustomSlotLabel": "", @@ -12932,12 +12932,7 @@ "overrideHLSLDeclaration": false, "hlslDeclarationOverride": 2, "m_Hidden": false, - "m_Value": 0.0, - "m_FloatType": 2, - "m_RangeValues": { - "x": 0.0, - "y": 1.0 - } + "m_Value": false } {