Exemple #1
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph;

            m_outsideGraph = cachedGraph;
            ContainerGraph.ParentWindow.CustomGraph = m_functionGraph;

            if (m_reordenator != null && m_reordenator.RecursiveCount() > 0 && m_reordenator.HasTitle)
            {
                dataCollector.AddToProperties(UniqueId, "[Header(" + m_reordenator.HeaderTitle + ")]", m_reordenator.OrderIndex);
            }
            string result = string.Empty;

            for (int i = 0; i < m_allFunctionInputs.Count; i++)
            {
                if (m_inputPorts[i].IsConnected)
                {
                    m_allFunctionInputs[i].OnPortGeneration += FunctionNodeOnPortGeneration;
                }
            }

            result += m_allFunctionOutputs[outputId].GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);

            for (int i = 0; i < m_allFunctionInputs.Count; i++)
            {
                if (m_inputPorts[i].IsConnected)
                {
                    m_allFunctionInputs[i].OnPortGeneration -= FunctionNodeOnPortGeneration;
                }
            }

            ContainerGraph.ParentWindow.CustomGraph = cachedGraph;
            return(result);
        }
        private void ReorderList(ref List <PropertyNode> nodes)
        {
            // clear lock list before reordering because of multiple sf being used
            for (int i = 0; i < nodes.Count; i++)
            {
                ReordenatorNode rnode = nodes[i] as ReordenatorNode;
                if (rnode != null)
                {
                    rnode.RecursiveClear();
                }
            }

            int propoffset = 0;
            int count      = 0;

            for (int i = 0; i < m_propertyReordableNodes.Count; i++)
            {
                ReordenatorNode renode = m_propertyReordableNodes[i] as ReordenatorNode;
                if (renode != null)
                {
                    if (!renode.IsInside)
                    {
                        m_propertyReordableNodes[i].OrderIndex = count + propoffset;

                        if (renode.PropertyListCount > 0)
                        {
                            propoffset += renode.RecursiveCount();

                            // the same reordenator can exist multiple times, apply ordering to all of them
                            for (int j = 0; j < nodes.Count; j++)
                            {
                                ReordenatorNode pnode = (nodes[j] as ReordenatorNode);
                                if (pnode != null && pnode.PropertyName.Equals(renode.PropertyName))
                                {
                                    pnode.OrderIndex = renode.RawOrderIndex;
                                    pnode.RecursiveSetOrderOffset(renode.RawOrderIndex, true);
                                }
                            }
                        }
                        else
                        {
                            count++;
                        }
                    }
                    else
                    {
                        m_propertyReordableNodes[i].OrderIndex = 0;
                    }
                }
                else
                {
                    m_propertyReordableNodes[i].OrderIndex = count + propoffset;
                    count++;
                }
            }
        }
Exemple #3
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            OutputPort     outputPort     = GetOutputPortByUniqueId(outputId);
            FunctionOutput functionOutput = GetFunctionOutputByUniqueId(outputId);

            if (outputPort.IsLocalValue(dataCollector.PortCategory))
            {
                return(outputPort.LocalValue(dataCollector.PortCategory));
            }

            m_functionGraph.CurrentPrecision = ContainerGraph.ParentWindow.CurrentGraph.CurrentPrecision;
            ParentGraph cachedGraph = ContainerGraph.ParentWindow.CustomGraph;

            m_outsideGraph = cachedGraph;
            ContainerGraph.ParentWindow.CustomGraph = m_functionGraph;
#if ADD_SHADER_FUNCTION_HEADERS
            if (m_reordenator != null && m_reordenator.RecursiveCount() > 0 && m_reordenator.HasTitle)
            {
                dataCollector.AddToProperties(UniqueId, "[Header(" + m_reordenator.HeaderTitle.Replace("-", " ") + ")]", m_reordenator.OrderIndex);
            }
#endif
            string result = string.Empty;
            for (int i = 0; i < m_allFunctionInputs.Count; i++)
            {
                if (!m_allFunctionInputs[i].InputPorts[0].IsConnected || m_inputPorts[i].IsConnected)
                {
                    m_allFunctionInputs[i].OnPortGeneration += FunctionNodeOnPortGeneration;
                }
            }

            result += functionOutput.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);

            for (int i = 0; i < m_allFunctionInputs.Count; i++)
            {
                if (!m_allFunctionInputs[i].InputPorts[0].IsConnected || m_inputPorts[i].IsConnected)
                {
                    m_allFunctionInputs[i].OnPortGeneration -= FunctionNodeOnPortGeneration;
                }
            }

            ContainerGraph.ParentWindow.CustomGraph = cachedGraph;

            if (outputPort.ConnectionCount > 1)
            {
                RegisterLocalVariable(outputId, result, ref dataCollector);
            }
            else
            {
                outputPort.SetLocalValue(result, dataCollector.PortCategory);
            }

            return(outputPort.LocalValue(dataCollector.PortCategory));
        }
        private void ReorderList(ref List <ParentNode> nodes)
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                ReordenatorNode rnode = nodes[i] as ReordenatorNode;
                if (rnode != null)
                {
                    rnode.RecursiveClear();
                }
            }

            int propoffset = 0;
            //int renodeoffset = 0;
            int count = 0;

            for (int i = 0; i < m_propertyReordableNodes.Count; i++)
            {
                ReordenatorNode renode = m_propertyReordableNodes[i] as ReordenatorNode;
                if (renode != null)
                {
                    if (!renode.IsInside)
                    {
                        m_propertyReordableNodes[i].OrderIndex = count + propoffset;                          // - renodeoffset;

                        if (renode.PropertyListCount > 0)
                        {
                            propoffset += renode.RecursiveCount();
                        }

                        for (int j = 0; j < nodes.Count; j++)
                        {
                            ReordenatorNode pnode = (nodes[j] as ReordenatorNode);
                            if (pnode != null && pnode.PropertyName.Equals(renode.PropertyName))
                            {
                                pnode.OrderIndex = renode.RawOrderIndex;
                                pnode.RecursiveSetOrderOffset(renode.RawOrderIndex, true);
                            }
                        }
                        count++;
                    }
                    else
                    {
                        m_propertyReordableNodes[i].OrderIndex = 0;
                    }
                }
                else
                {
                    m_propertyReordableNodes[i].OrderIndex = count + propoffset;                      // - renodeoffset;
                    count++;
                }
            }
        }