bool GenerateShaderPass(SGESimpleLitMasterNode masterNode, ShaderPass pass, GenerationMode mode, ShaderGenerator result, List <string> sourceAssetDependencyPaths) { var options = masterNode.GetMaterialOptions(); SGEShaderGraphUtilities.SetRenderState(options, ref pass); // apply master node options to active fields var activeFields = GetActiveFieldsFromMasterNode(masterNode, pass); return(SGEGenerationUtils.GenerateShaderPass(masterNode, pass, mode, activeFields, result, sourceAssetDependencyPaths, SGEShaderGraphResources.s_Dependencies, SGEShaderGraphResources.s_ResourceClassName, SGEShaderGraphResources.s_AssemblyName)); }
ActiveFields GetActiveFieldsFromMasterNode(SGESimpleLitMasterNode masterNode, ShaderPass pass) { var activeFields = new ActiveFields(); var baseActiveFields = activeFields.baseInstance; // Graph Vertex if (masterNode.IsSlotConnected(SGESimpleLitMasterNode.PositionSlotId) || masterNode.IsSlotConnected(SGESimpleLitMasterNode.VertNormalSlotId) || masterNode.IsSlotConnected(SGESimpleLitMasterNode.VertTangentSlotId)) { baseActiveFields.Add("features.graphVertex"); } // Graph Pixel (always enabled) baseActiveFields.Add("features.graphPixel"); if (masterNode.IsSlotConnected(SGESimpleLitMasterNode.AlphaThresholdSlotId) || masterNode.GetInputSlots <Vector1MaterialSlot>().First(x => x.id == SGESimpleLitMasterNode.AlphaThresholdSlotId).value > 0.0f) { baseActiveFields.Add("AlphaClip"); } if (masterNode.IsSlotConnected(SGESimpleLitMasterNode.NormalSlotId)) { baseActiveFields.Add("Normal"); } switch (masterNode.normalDropOffSpace) { case NormalDropOffSpace.Tangent: baseActiveFields.AddAll("features.NormalDropOffTS"); break; case NormalDropOffSpace.Object: baseActiveFields.AddAll("features.NormalDropOffOS"); break; case NormalDropOffSpace.World: baseActiveFields.AddAll("features.NormalDropOffWS"); break; default: UnityEngine.Debug.LogError("Unknown normal drop off space: " + masterNode.normalDropOffSpace); break; } // Keywords for transparent // #pragma shader_feature _SURFACE_TYPE_TRANSPARENT if (masterNode.BlendMode != BlendMode.Off) { // transparent-only defines baseActiveFields.Add("SurfaceType.Transparent"); // #pragma shader_feature _ _BLENDMODE_ALPHA _BLENDMODE_ADD _BLENDMODE_PRE_MULTIPLY if (masterNode.BlendMode == BlendMode.Alpha) { baseActiveFields.Add("BlendMode.Alpha"); } else if (masterNode.BlendMode == BlendMode.Additive) { baseActiveFields.Add("BlendMode.Add"); } else if (masterNode.BlendMode == BlendMode.Premultiply) { baseActiveFields.Add("BlendMode.Premultiply"); } } baseActiveFields.Add("SpecularColor"); return(activeFields); }
public SGESimpleLitSettingsView(SGESimpleLitMasterNode node) { m_Node = node; PropertySheet ps = new PropertySheet(); ps.Add(new PropertyRow(new Label("Render Type")), (row) => { row.Add(new EnumField(SurfaceMaterialTags.RenderType.Opaque), (field) => { field.value = m_Node.RenderType; field.RegisterValueChangedCallback(ChangeRenderType); }); }); ps.Add(new PropertyRow(new Label("Render Queue")), (row) => { row.Add(new EnumField(SurfaceMaterialTags.RenderQueue.Geometry), (field) => { field.value = m_Node.RenderQueue; field.RegisterValueChangedCallback(ChangeRenderQueue); }); }); ps.Add(new PropertyRow(new Label("Blend")), (row) => { row.Add(new EnumField(BlendMode.Off), (field) => { field.value = m_Node.BlendMode; field.RegisterValueChangedCallback(ChangeBlendMode); }); }); ps.Add(new PropertyRow(new Label("Cull")), (row) => { row.Add(new EnumField(SurfaceMaterialOptions.CullMode.Back), (field) => { field.value = m_Node.CullMode; field.RegisterValueChangedCallback(ChangeCullMode); }); }); ps.Add(new PropertyRow(new Label("ZWrite")), (row) => { row.Add(new EnumField(SurfaceMaterialOptions.ZWrite.On), (field) => { field.value = m_Node.ZWrite; field.RegisterValueChangedCallback(ChangeZWrite); }); }); ps.Add(new PropertyRow(new Label("ZTest")), (row) => { row.Add(new EnumField(SurfaceMaterialOptions.ZTest.LEqual), (field) => { field.value = m_Node.ZTest; field.RegisterValueChangedCallback(ChangeZTest); }); }); ps.Add(new PropertyRow(new Label("Fragment Normal Space")), (row) => { row.Add(new EnumField(NormalDropOffSpace.Tangent), (field) => { field.value = m_Node.normalDropOffSpace; field.RegisterValueChangedCallback(ChangeSpaceOfNormalDropOffMode); }); }); ps.Add(new PropertyRow(new Label("Custom Editor")), (row) => { row.Add(new TextField(String.Empty), (field) => { field.value = m_Node.CustomEditor; field.RegisterValueChangedCallback(ChangeCustomEditor); }); }); Add(ps); }