示例#1
0
 public void SetInlineNodeValue()
 {
     if (IsValid)
     {
         RangedFloatNode fnode = UIUtils.GetNode(m_nodeId) as RangedFloatNode;
         if (fnode != null)
         {
             fnode.Value = m_value;
             fnode.SetMaterialValueFromInline(m_value);
         }
         else
         {
             IntNode inode = UIUtils.GetNode(m_nodeId) as IntNode;
             inode.Value = (int)m_value;
             inode.SetMaterialValueFromInline((int)m_value);
         }
     }
 }
示例#2
0
 public void SetInlineNodeValue()
 {
     if (Active && NodeId > -1)
     {
         RangedFloatNode fnode = UIUtils.GetNode(NodeId) as RangedFloatNode;
         if (fnode != null)
         {
             fnode.Value = Value;
             fnode.SetMaterialValueFromInline(Value);
         }
         else
         {
             IntNode inode = UIUtils.GetNode(NodeId) as IntNode;
             inode.Value = Value;
             inode.SetMaterialValueFromInline(Value);
         }
     }
 }
示例#3
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (dataCollector.IsTemplate)
            {
                return("0");
            }

            if (dataCollector.IsFragmentCategory)
            {
                UIUtils.ShowMessage(ErrorMessage);
                return("0");
            }
            if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                return("0");
            }

            m_outputPorts[0].SetLocalValue("0", dataCollector.PortCategory);

            StandardSurfaceOutputNode masterNode = m_containerGraph.CurrentMasterNode as StandardSurfaceOutputNode;

            MasterNodeDataCollector outlineDataCollector = new MasterNodeDataCollector();

            outlineDataCollector.IsOutlineDataCollector = true;
            outlineDataCollector.DirtyNormal            = true;
            InputPort colorPort  = GetInputPortByUniqueId(0);
            InputPort alphaPort  = GetInputPortByUniqueId(2);
            InputPort vertexPort = GetInputPortByUniqueId(1);

            if (vertexPort.IsConnected)
            {
                outlineDataCollector.PortCategory = MasterNodePortCategory.Vertex;
                string outlineWidth = vertexPort.GenerateShaderForOutput(ref outlineDataCollector, vertexPort.DataType, true, true);
                outlineDataCollector.AddToVertexLocalVariables(UniqueId, PrecisionType.Float, vertexPort.DataType, "outlineVar", outlineWidth);

                outlineDataCollector.AddVertexInstruction(outlineDataCollector.SpecialLocalVariables, UniqueId, false);
                outlineDataCollector.ClearSpecialLocalVariables();

                outlineDataCollector.AddVertexInstruction(outlineDataCollector.VertexLocalVariables, UniqueId, false);
                outlineDataCollector.ClearVertexLocalVariables();

                // need to check whether this breaks other outputs or not
                ContainerGraph.ResetNodesLocalVariables();
            }

            outlineDataCollector.PortCategory = MasterNodePortCategory.Fragment;
            string outlineColor = colorPort.GeneratePortInstructions(ref outlineDataCollector);              // "\to.Emission = " + colorPort.GeneratePortInstructions( ref outlineDataCollector ) + ";";
            string alphaValue   = alphaPort.Visible ? alphaPort.GeneratePortInstructions(ref outlineDataCollector) : string.Empty;

            bool addTabs = outlineDataCollector.DirtySpecialLocalVariables || alphaPort.Available;

            outlineDataCollector.AddInstructions("\t" + outlineDataCollector.SpecialLocalVariables.TrimStart('\t'));
            outlineDataCollector.ClearSpecialLocalVariables();
            outlineDataCollector.AddInstructions((addTabs ? "\t\t\t" : "") + "o.Emission = " + outlineColor + ";");
            if (alphaPort.Visible)
            {
                if (m_currentAlphaMode == OutlineAlphaModes.Masked)
                {
                    float maskClipValue = 0.5f;

                    if (masterNode != null)
                    {
                        maskClipValue = masterNode.OpacityMaskClipValue;
                    }

                    if (masterNode.InlineOpacityMaskClipValue.IsValid)
                    {
                        RangedFloatNode fnode = UIUtils.GetNode(masterNode.InlineOpacityMaskClipValue.NodeId) as RangedFloatNode;
                        if (fnode != null)
                        {
                            outlineDataCollector.AddToProperties(fnode.UniqueId, fnode.GetPropertyValue(), fnode.OrderIndex);
                            outlineDataCollector.AddToUniforms(fnode.UniqueId, fnode.GetUniformValue());
                        }
                        else
                        {
                            IntNode inode = UIUtils.GetNode(masterNode.InlineOpacityMaskClipValue.NodeId) as IntNode;
                            outlineDataCollector.AddToProperties(inode.UniqueId, inode.GetPropertyValue(), inode.OrderIndex);
                            outlineDataCollector.AddToUniforms(inode.UniqueId, inode.GetUniformValue());
                        }
                    }
                    else
                    {
                        outlineDataCollector.AddToProperties(-1, string.Format(IOUtils.MaskClipValueProperty, OpacityMaskClipValueStr, maskClipValue), -1);
                        outlineDataCollector.AddToUniforms(-1, string.Format(IOUtils.MaskClipValueUniform, maskClipValue));
                    }

                    outlineDataCollector.AddInstructions((addTabs ? "\n\t\t\t" : "") + "clip( " + alphaValue + " - " + masterNode.InlineOpacityMaskClipValue.GetValueOrProperty(IOUtils.MaskClipValueName, false) + " );");
                }
                else
                {
                    outlineDataCollector.AddInstructions((addTabs ? "\n\t\t\t" : "") + "o.Alpha = " + alphaValue + ";");
                }
            }

            if (outlineDataCollector.UsingWorldNormal)
            {
                outlineDataCollector.AddInstructions((addTabs ? "\n\t\t\t" : "") + "o.Normal = float3(0,0,-1);");
            }

            if (masterNode != null)
            {
                //masterNode.AdditionalIncludes.AddToDataCollector( ref outlineDataCollector );
                //masterNode.AdditionalPragmas.AddToDataCollector( ref outlineDataCollector );
                //masterNode.AdditionalDefines.AddToDataCollector( ref outlineDataCollector );
                masterNode.AdditionalDirectives.AddAllToDataCollector(ref outlineDataCollector);
            }

            ContainerGraph.CurrentStandardSurface.OutlineHelper.InputList       = outlineDataCollector.InputList;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Inputs          = outlineDataCollector.Inputs;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.DirtyInput      = outlineDataCollector.DirtyInputs;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Includes        = outlineDataCollector.Includes;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Pragmas         = outlineDataCollector.Pragmas;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Defines         = outlineDataCollector.Defines;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Uniforms        = outlineDataCollector.Uniforms;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.UniformList     = outlineDataCollector.UniformsList;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.VertexData      = outlineDataCollector.VertexData;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Instructions    = outlineDataCollector.Instructions;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.Functions       = outlineDataCollector.Functions;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.LocalFunctions  = outlineDataCollector.LocalFunctions;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.OutlineCullMode = m_cullMode;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.ZTestMode       = m_zTestMode;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.ZWriteMode      = m_zWriteMode;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.OffsetMode      = m_currentSelectedMode;
            ContainerGraph.CurrentStandardSurface.OutlineHelper.CustomNoFog     = m_noFog;
            dataCollector.CustomOutlineSelectedAlpha = (int)m_currentAlphaMode;

            for (int i = 0; i < outlineDataCollector.PropertiesList.Count; i++)
            {
                dataCollector.AddToProperties(UniqueId, outlineDataCollector.PropertiesList[i].PropertyName, outlineDataCollector.PropertiesList[i].OrderIndex);
            }

            ContainerGraph.ResetNodesLocalVariablesIfNot(MasterNodePortCategory.Vertex);
            return("0");
        }