Ejemplo n.º 1
0
        private static bool GenerateShaderPass(SGEUnlitMasterNode 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);

            // use standard shader pass generation
            return(GenerationUtils.GenerateShaderPass(masterNode, pass, mode, activeFields, result, sourceAssetDependencyPaths,
                                                      SGEShaderGraphResources.s_Dependencies, SGEShaderGraphResources.s_ResourceClassName, SGEShaderGraphResources.s_AssemblyName));
        }
Ejemplo n.º 2
0
        private static ActiveFields GetActiveFieldsFromMasterNode(SGEUnlitMasterNode masterNode, ShaderPass pass)
        {
            var activeFields     = new ActiveFields();
            var baseActiveFields = activeFields.baseInstance;

            // Graph Vertex
            if (masterNode.IsSlotConnected(SGEUnlitMasterNode.PositionSlotId) ||
                masterNode.IsSlotConnected(SGEUnlitMasterNode.VertNormalSlotId) ||
                masterNode.IsSlotConnected(SGEUnlitMasterNode.VertTangentSlotId))
            {
                baseActiveFields.Add("features.graphVertex");
            }

            // Graph Pixel (always enabled)
            baseActiveFields.Add("features.graphPixel");

            if (masterNode.IsSlotConnected(SGEUnlitMasterNode.AlphaThresholdSlotId) ||
                masterNode.GetInputSlots <Vector1MaterialSlot>().First(x => x.id == SGEUnlitMasterNode.AlphaThresholdSlotId).value > 0.0f)
            {
                baseActiveFields.Add("AlphaClip");
            }

            // 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");
                }
            }

            return(activeFields);
        }
        public SGEUnlitSettingsView(SGEUnlitMasterNode 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("Custom Editor")), (row) =>
            {
                row.Add(new TextField(String.Empty), (field) =>
                {
                    field.value = m_Node.CustomEditor;
                    field.RegisterValueChangedCallback(ChangeCustomEditor);
                });
            });

            Add(ps);
        }