private void OnGUI() { if (Shader == null) { EditorGUILayout.LabelField("No subshader open."); return; } _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); _showPassSettings = SwGuiLayout.BeginControlGroup(_showPassSettings, new GUIContent("Passes", HelpText.Passes)); if (_showPassSettings) { _passList.DoLayoutList(); } SwGuiLayout.EndControlGroup(); _showSubshaderSettings = SwGuiLayout.BeginControlGroup(_showSubshaderSettings, "Subshader Settings"); if (_showSubshaderSettings) { Shader.ForceNoShadowCasting = EditorGUILayout.ToggleLeft(new GUIContent("Force no shadow casting", HelpText.ForceNoShadow), Shader.ForceNoShadowCasting); Shader.IgnoreProjector = EditorGUILayout.ToggleLeft(new GUIContent("Ignore projector", HelpText.IgnoreProjector), Shader.IgnoreProjector); Shader.RenderPosition = (RenderPosition)EditorGUILayout.EnumPopup(new GUIContent("Rendering order position:", HelpText.RenderingOrder), Shader.RenderPosition); } SwGuiLayout.EndControlGroup(); EditorGUILayout.EndScrollView(); }
private void OnGUI() { if (Pass == null) { EditorGUILayout.LabelField("No pass open."); return; } _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); // Depth test _showDepthTestSettings = SwGuiLayout.BeginControlGroup(_showDepthTestSettings, "Depth Test"); if (_showDepthTestSettings) { Pass.WriteToDepthBuffer = EditorGUILayout.ToggleLeft(new GUIContent("Write to depth buffer", HelpText.WriteToDepthBuffer), Pass.WriteToDepthBuffer); Pass.ZTestFunc = (CompareFunction)EditorGUILayout.EnumPopup(new GUIContent("Depth test function:", HelpText.DepthTestFunc), Pass.ZTestFunc); Pass.UseDepthOffset = SwGuiLayout.BeginToggleGroup(new GUIContent("Use offset", HelpText.UseDepthOffset), Pass.UseDepthOffset); Pass.DepthFactor = EditorGUILayout.FloatField(new GUIContent("Factor:", HelpText.DepthFactor), Pass.DepthFactor); Pass.DepthUnit = EditorGUILayout.FloatField(new GUIContent("Unit:", HelpText.DepthUnit), Pass.DepthUnit); SwGuiLayout.EndToggleGroup(); } SwGuiLayout.EndControlGroup(); // Alpha test (not used in programmable pipeline) // _showAlphaTestSettings = SwGuiLayout.BeginControlGroup(_showAlphaTestSettings, "Alpha Test"); // if (_showAlphaTestSettings) { // Pass.UseAlphaTest = SwGuiLayout.BeginToggleGroup("Use alpha test", Pass.UseAlphaTest); // Pass.AlphaTestFunc = (CompareFunction) EditorGUILayout.EnumPopup("Test function:", Pass.AlphaTestFunc); // Pass.AlphaTestValue = Mathf.Clamp01(EditorGUILayout.FloatField("Test against:", Pass.AlphaTestValue)); // SwGuiLayout.EndToggleGroup(); // } // SwGuiLayout.EndControlGroup(); // Blending options _showBlendingSettings = SwGuiLayout.BeginControlGroup(_showBlendingSettings, new GUIContent("Blending", HelpText.Blending)); if (_showBlendingSettings) { Pass.ApplyBlending = SwGuiLayout.BeginToggleGroup(new GUIContent("Apply blending", HelpText.ApplyBlending), Pass.ApplyBlending); Pass.SourceBlendFactor = (BlendMode)EditorGUILayout.EnumPopup(new GUIContent("Source factor:", HelpText.SrcFactor), Pass.SourceBlendFactor); Pass.DestBlendFactor = (BlendMode)EditorGUILayout.EnumPopup(new GUIContent("Destionation factor:", HelpText.DstFactor), Pass.DestBlendFactor); Pass.BlendAlphaSeparately = SwGuiLayout.BeginToggleGroup("Blend alpha separately", Pass.BlendAlphaSeparately); Pass.AlphaSourceBlendFactor = (BlendMode)EditorGUILayout.EnumPopup("Source factor:", Pass.AlphaSourceBlendFactor); Pass.AlphaDestBlendFactor = (BlendMode)EditorGUILayout.EnumPopup("Destionation factor:", Pass.AlphaDestBlendFactor); SwGuiLayout.EndToggleGroup(); Pass.BlendOp = (BlendOp)EditorGUILayout.EnumPopup("Blend operation", Pass.BlendOp); SwGuiLayout.EndToggleGroup(); } SwGuiLayout.EndControlGroup(); //Vertex Attributes _showVertexAttributes = SwGuiLayout.BeginControlGroup(_showVertexAttributes, new GUIContent("Vertex Attributes", HelpText.VertexAttributes)); if (_showVertexAttributes) { Pass.UsePresetInput = SwGuiLayout.BeginToggleGroup(new GUIContent("Use preset", HelpText.UsePresetInput), Pass.UsePresetInput); Pass.InputPreset = (VertexInputPreset)EditorGUILayout.EnumPopup(new GUIContent("Preset:", HelpText.InputPreset), Pass.InputPreset); SwGuiLayout.EndToggleGroup(); Pass.UsePresetInput = !SwGuiLayout.BeginToggleGroup(new GUIContent("Use custom", HelpText.UseCustomInput), !Pass.UsePresetInput); Pass.UsePosition = EditorGUILayout.ToggleLeft("Position", Pass.UsePosition); Pass.UseNormal = EditorGUILayout.ToggleLeft("Normal", Pass.UseNormal); Pass.UseTexcoord = EditorGUILayout.ToggleLeft("First UV set", Pass.UseTexcoord); Pass.UseTexcoord1 = EditorGUILayout.ToggleLeft("Second UV set", Pass.UseTexcoord1); Pass.UseTangent = EditorGUILayout.ToggleLeft("Tangent", Pass.UseTangent); Pass.UseColor = EditorGUILayout.ToggleLeft("Color", Pass.UseColor); SwGuiLayout.EndToggleGroup(); } SwGuiLayout.EndControlGroup(); // Shader Options _showShaderSettings = SwGuiLayout.BeginControlGroup(_showShaderSettings, "Shader Options"); if (_showShaderSettings) { Pass.UseGeometryShader = SwGuiLayout.BeginToggleGroup("Use geometry shader", Pass.UseGeometryShader); Pass.InputTopology = (InputTopology)EditorGUILayout.EnumPopup("Input topology:", Pass.InputTopology); Pass.OutputTopology = (OutputTopology)EditorGUILayout.EnumPopup("Output topology:", Pass.OutputTopology); Pass.MaxVertCount = Mathf.Max(EditorGUILayout.IntField("Max vertex count:", Pass.MaxVertCount), 0); SwGuiLayout.EndToggleGroup(); Pass.CompileToGlsl = EditorGUILayout.ToggleLeft(new GUIContent("Compile to GLSL for desktop", HelpText.CompileToGlsl), Pass.CompileToGlsl); Pass.AutoNormalizeVectors = EditorGUILayout.ToggleLeft(new GUIContent("Auto-normalize normal/tangent vectors", HelpText.AutoNormalizeVectors), Pass.AutoNormalizeVectors); Pass.GenerateDebugInfo = EditorGUILayout.ToggleLeft(new GUIContent("Generate debug info for DX11", HelpText.GenerateDebugInfo), Pass.GenerateDebugInfo); Pass.ShaderTarget = (ShaderTarget)EditorGUILayout.EnumPopup("Shader target:", Pass.ShaderTarget); } SwGuiLayout.EndControlGroup(); // Misc Settings _showMiscSettings = SwGuiLayout.BeginControlGroup(_showMiscSettings, "Misc Settings"); if (_showMiscSettings) { Pass.LightMode = (LightMode)EditorGUILayout.EnumPopup(new GUIContent("Light mode:", HelpText.LightMode), Pass.LightMode); Pass.FaceCullMode = (CullMode)EditorGUILayout.EnumPopup(new GUIContent("Face culling:", HelpText.FaceCullMode), Pass.FaceCullMode); Pass.RequireSoftVegatation = EditorGUILayout.ToggleLeft(new GUIContent("Require soft vegetation", HelpText.RequireSoftVegetation), Pass.RequireSoftVegatation); Pass.ApplyFog = EditorGUILayout.ToggleLeft(new GUIContent("Apply fog", HelpText.ApplyFog), Pass.ApplyFog); Pass.AllowExternalReference = EditorGUILayout.ToggleLeft(new GUIContent("Allow pass to be referenced externally", HelpText.AllowExternalReference), Pass.AllowExternalReference); } SwGuiLayout.EndControlGroup(); // Include group _showIncludeSettings = SwGuiLayout.BeginControlGroup(_showIncludeSettings, "Include"); if (_showIncludeSettings) { Pass.CgincUnityCg = EditorGUILayout.ToggleLeft(new GUIContent("UnityCg.cginc", HelpText.UnityCGInclude), Pass.CgincUnityCg); Pass.CgincTerrainEngine = EditorGUILayout.ToggleLeft(new GUIContent("TerrainEngine.cginc", HelpText.TerrainInclude), Pass.CgincTerrainEngine); Pass.CgincTessellation = EditorGUILayout.ToggleLeft(new GUIContent("Tessellation.cginc", HelpText.TessellationInclude), Pass.CgincTessellation); Pass.CgincAutoLight = EditorGUILayout.ToggleLeft(new GUIContent("AutoLight.cginc", HelpText.AutoLightInclude), Pass.CgincAutoLight); Pass.CgincLighting = EditorGUILayout.ToggleLeft(new GUIContent("Lighting.cginc", HelpText.LightingInclude), Pass.CgincLighting); } SwGuiLayout.EndControlGroup(); EditorGUILayout.EndScrollView(); }
private void OnGUI() { //Debug.Log(position); _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); // Shader name _shaderSettings.Name = EditorGUILayout.TextField(new GUIContent("Name", HelpText.ShaderName), _shaderSettings.Name); // Properies group _showProperties = SwGuiLayout.BeginControlGroup(_showProperties, new GUIContent("Properties", HelpText.ShaderProperties)); if (_showProperties) { _propertyList.DoLayoutList(); } SwGuiLayout.EndControlGroup(); // Subshaders group _showSubshaders = SwGuiLayout.BeginControlGroup(_showSubshaders, new GUIContent("Subshaders", HelpText.Subshaders)); if (_showSubshaders) { _subshaderList.DoLayoutList(); } SwGuiLayout.EndControlGroup(); // Fallback group _showFallbackSettings = SwGuiLayout.BeginControlGroup(_showFallbackSettings, new GUIContent("Fallback", HelpText.Fallback)); if (_showFallbackSettings) { _shaderSettings.UseFallback = SwGuiLayout.BeginToggleGroup("Use fallback shader", _shaderSettings.UseFallback); _shaderSettings.Fallback = SwGuiLayout.ShaderPopup("Fallback", _shaderSettings.Fallback); SwGuiLayout.EndToggleGroup(); } SwGuiLayout.EndControlGroup(); // Comments group _showCommentSettings = SwGuiLayout.BeginControlGroup(_showCommentSettings, "Comments"); if (_showCommentSettings) { _shaderSettings.CommentShader = EditorGUILayout.ToggleLeft("Put helper comments in generated shader", _shaderSettings.CommentShader); } SwGuiLayout.EndControlGroup(); if (GUILayout.Button("Generate", "LargeButton")) { // Debug.Log(ShaderGenerator.Generate(_shaderSettings, " ")); if (!IsCorrect()) { EditorUtility.DisplayDialog("Error", "Invalid property name.", "Ok"); } else { var path = EditorUtility.SaveFilePanel( "Save shader", "Assets", _shaderSettings.Name + ".shader", "shader"); if (path.Length != 0) { File.WriteAllText(path, ShaderGenerator.Generate(_shaderSettings, " ")); } } } EditorGUILayout.EndScrollView(); }
private void OnGUI() { if (Shader == null) { EditorGUILayout.LabelField("No subshader open."); return; } _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition); // Custom functions group _showFunctionsSettings = SwGuiLayout.BeginControlGroup(_showFunctionsSettings, "Custom Functions"); if (_showFunctionsSettings) { Shader.UseVertexModifier = SwGuiLayout.BeginToggleGroup(new GUIContent("Use vertex modifier", HelpText.VertexModifier), Shader.UseVertexModifier); Shader.CustomDataPerVertex = EditorGUILayout.ToggleLeft( new GUIContent("Calculate custom data per-vertex", HelpText.CustomDataPerVertex), Shader.CustomDataPerVertex); SwGuiLayout.EndToggleGroup(); Shader.UseFinalColorModifier = EditorGUILayout.ToggleLeft(new GUIContent("Use final color modifier", HelpText.FinalColorModifier), Shader.UseFinalColorModifier); Shader.UseTessellation = EditorGUILayout.ToggleLeft(new GUIContent("Use DX11 tessellation", HelpText.Tessellation), Shader.UseTessellation); Shader.PassHalfDirInLighting = EditorGUILayout.ToggleLeft( new GUIContent("Pass half-direction vector into ligthing function", HelpText.HalfDirInLighting), Shader.PassHalfDirInLighting); Shader.UseBuiltinLighting = SwGuiLayout.BeginToggleGroup( new GUIContent("Use built-in lighting model", HelpText.BuiltinLighting), Shader.UseBuiltinLighting); Shader.LightingModel = (LightingModel)EditorGUILayout.EnumPopup("Lighting model:", Shader.LightingModel); SwGuiLayout.EndToggleGroup(); Shader.UseBuiltinLighting = !SwGuiLayout.BeginToggleGroup(new GUIContent("Use custom lighting model", HelpText.CustomLighting), !Shader.UseBuiltinLighting); Shader.ViewDirInLighting = EditorGUILayout.ToggleLeft("Include view direction parameter", Shader.ViewDirInLighting); Shader.UsePrePass = EditorGUILayout.ToggleLeft("Use prepass function (deferred lighting)", Shader.UsePrePass); SwGuiLayout.EndToggleGroup(); // Custom lightmap decoders EditorGUILayout.LabelField("Use custom lightmap decoder function:"); EditorGUI.indentLevel++; Shader.UseSingleLightMap = SwGuiLayout.BeginToggleGroup(new GUIContent("Single", HelpText.SingleLightmap), Shader.UseSingleLightMap); Shader.ViewDirInSingle = EditorGUILayout.ToggleLeft("Include view direction parameter", Shader.ViewDirInSingle); SwGuiLayout.EndToggleGroup(); Shader.UseDualLightMap = SwGuiLayout.BeginToggleGroup(new GUIContent("Dual", HelpText.DualLightmap), Shader.UseDualLightMap); Shader.ViewDirInDual = EditorGUILayout.ToggleLeft("Include view direction parameter", Shader.ViewDirInDual); SwGuiLayout.EndToggleGroup(); Shader.UseDirectionalLightMap = SwGuiLayout.BeginToggleGroup(new GUIContent("Directional", HelpText.DirectionalLightmap), Shader.UseDirectionalLightMap); Shader.ViewDirInDirectional = EditorGUILayout.ToggleLeft("Include view direction parameter", Shader.ViewDirInDirectional); SwGuiLayout.EndToggleGroup(); EditorGUI.indentLevel--; } SwGuiLayout.EndControlGroup(); // Shader input _showInputSettings = SwGuiLayout.BeginControlGroup(_showInputSettings, "Shader Input Values"); if (_showInputSettings) { Shader.ViewDirInInput = EditorGUILayout.ToggleLeft("View direction", Shader.ViewDirInInput); Shader.VertColorInInput = EditorGUILayout.ToggleLeft("Per-vertex color", Shader.VertColorInInput); Shader.SsPositionInInput = EditorGUILayout.ToggleLeft("Screen space position", Shader.SsPositionInInput); Shader.WsPositionInInput = EditorGUILayout.ToggleLeft("World space position", Shader.WsPositionInInput); Shader.WorldReflectionVectorInInput = EditorGUILayout.ToggleLeft("World reflection vector", Shader.WorldReflectionVectorInInput); Shader.WorldNormalInInput = EditorGUILayout.ToggleLeft("World normal vector", Shader.WorldNormalInInput); SwGuiLayout.Separator(); Shader.OutNormalSpecified = EditorGUILayout.ToggleLeft( new GUIContent("Surface function writes to output normal", HelpText.OutputNormalSpecified), Shader.OutNormalSpecified); } SwGuiLayout.EndControlGroup(); // Lighting group _showLightingSettings = SwGuiLayout.BeginControlGroup(_showLightingSettings, "Lighting"); if (_showLightingSettings) { Shader.ApplyAmbient = EditorGUILayout.ToggleLeft("Apply ambient lights", Shader.ApplyAmbient); Shader.ApplyVertexLights = EditorGUILayout.ToggleLeft("Apply per-vertex lights in forward rendering", Shader.ApplyVertexLights); Shader.EnableAdditivePass = EditorGUILayout.ToggleLeft( new GUIContent("Enable forward rendering additive pass", HelpText.ForwardAdditive), Shader.EnableAdditivePass); Shader.ViewDirPerVert = EditorGUILayout.ToggleLeft("Compute view direction per-vertex", Shader.ViewDirPerVert); } SwGuiLayout.EndControlGroup(); //Lightmaps group _showLightmapSettings = SwGuiLayout.BeginControlGroup(_showLightmapSettings, "Lightmaps"); if (_showLightmapSettings) { Shader.SupportLightmaps = SwGuiLayout.BeginToggleGroup("Support lightmaps", Shader.SupportLightmaps); Shader.SupportDirectionalLightmaps = EditorGUILayout.ToggleLeft( new GUIContent("Support directional lightmaps", HelpText.DirectionalLightmap), Shader.SupportDirectionalLightmaps); Shader.DualForward = EditorGUILayout.ToggleLeft( new GUIContent("Dual lightmaps in forward rendering", HelpText.DualLightmap), Shader.DualForward); SwGuiLayout.EndToggleGroup(); } SwGuiLayout.EndControlGroup(); // Shadows group _showShadowSettings = SwGuiLayout.BeginControlGroup(_showShadowSettings, "Shadows"); if (_showShadowSettings) { Shader.AddShadowPasses = EditorGUILayout.ToggleLeft("Add shadow passes", Shader.AddShadowPasses); Shader.SupportAllShadowTypes = EditorGUILayout.ToggleLeft("Support all shadow types in forward rendering", Shader.SupportAllShadowTypes); } SwGuiLayout.EndControlGroup(); // Miscellaneous group _showMiscSettings = SwGuiLayout.BeginControlGroup(_showMiscSettings, "Misc Settings"); if (_showMiscSettings) { Shader.AlphaBlended = EditorGUILayout.ToggleLeft("Alpha blended", Shader.AlphaBlended); Shader.DisableWhenSoftVegIsOff = EditorGUILayout.ToggleLeft("Disable subshader when soft vegetation is off", Shader.DisableWhenSoftVegIsOff); Shader.ForceNoShadowCasting = EditorGUILayout.ToggleLeft(new GUIContent("Force no shadow casting", HelpText.ForceNoShadow), Shader.ForceNoShadowCasting); Shader.IgnoreProjector = EditorGUILayout.ToggleLeft(new GUIContent("Ignore projector", HelpText.IgnoreProjector), Shader.IgnoreProjector); Shader.RenderPosition = (RenderPosition)EditorGUILayout.EnumPopup(new GUIContent("Rendering order position:", HelpText.RenderingOrder), Shader.RenderPosition); Shader.CommentFinal = EditorGUILayout.ToggleLeft("Put debug comments in compiled surface shader", Shader.CommentFinal); } SwGuiLayout.EndControlGroup(); // Include group _showIncludeSettings = SwGuiLayout.BeginControlGroup(_showIncludeSettings, "Include"); if (_showIncludeSettings) { Shader.CgincTerrainEngine = EditorGUILayout.ToggleLeft(new GUIContent("TerrainEngine.cginc", HelpText.TerrainInclude), Shader.CgincTerrainEngine); Shader.CgincTessellation = EditorGUILayout.ToggleLeft(new GUIContent("Tessellation.cginc", HelpText.TessellationInclude), Shader.CgincTessellation); } SwGuiLayout.EndControlGroup(); EditorGUILayout.EndScrollView(); }