Beispiel #1
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (!m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                string propertyOrOptions = string.Empty;
                if (m_texPort.IsConnected)
                {
                    propertyOrOptions = m_texPort.GeneratePortInstructions(ref dataCollector);
                }
                else if (m_referenceNode != null)
                {
                    m_referenceNode.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                    propertyOrOptions = m_referenceNode.PropertyName;
                }
                else
                {
                    propertyOrOptions = GenerateSamplerAttributes();
                }

                string sampler = GeneratorUtils.GenerateSamplerState(ref dataCollector, UniqueId, propertyOrOptions);

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

            return(m_outputPorts[outputId].LocalValue(dataCollector.PortCategory));
        }
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
            m_inputPorts[0].GeneratePortInstructions(ref dataCollector);
            string texTransform = string.Empty;

            if (m_inputPorts[0].IsConnected)
            {
                texTransform = m_inputPorts[0].GeneratePortInstructions(ref dataCollector) + "_ST";
            }
            else if (m_referenceNode != null)
            {
                m_referenceNode.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                texTransform = m_referenceNode.PropertyName + "_ST";
            }
            else
            {
                texTransform = "_ST";
                UIUtils.ShowMessage("Please specify a texture sample on the Texture Transform Size node", MessageSeverity.Warning);
            }

            dataCollector.AddToUniforms(UniqueId, "uniform float4 " + texTransform + ";");

            switch (outputId)
            {
            case 0: return(texTransform + ".xy");

            case 1: return(texTransform + ".zw");
            }

            return(string.Empty);
        }
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (!m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                m_inputPorts[0].GeneratePortInstructions(ref dataCollector);
                string texTransform = string.Empty;

                if (m_inputPorts[0].IsConnected)
                {
                    texTransform = m_inputPorts[0].GeneratePortInstructions(ref dataCollector) + "_ST";
                }
                else if (m_referenceNode != null)
                {
                    m_referenceNode.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                    texTransform = m_referenceNode.PropertyName + "_ST";
                }
                else
                {
                    texTransform = "_ST";
                    UIUtils.ShowMessage(UniqueId, "Please specify a texture sample on the Texture Transform Size node", MessageSeverity.Warning);
                }

                //bool excludeUniformKeyword = UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader || UIUtils.CurrentWindow.OutsideGraph.IsSRP;
                //string uniformRegister = UIUtils.GenerateUniformName( excludeUniformKeyword, WirePortDataType.FLOAT4, texTransform );
                //dataCollector.AddToUniforms( UniqueId, uniformRegister, true );
                if (m_texCoordsHelper == null)
                {
                    m_texCoordsHelper = CreateInstance <Vector4Node>();
                    m_texCoordsHelper.ContainerGraph = ContainerGraph;
                    m_texCoordsHelper.SetBaseUniqueId(UniqueId, true);
                    m_texCoordsHelper.RegisterPropertyOnInstancing = false;
                    m_texCoordsHelper.AddGlobalToSRPBatcher        = true;
                }

                if (m_instanced)
                {
                    m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty;
                }
                else
                {
                    m_texCoordsHelper.CurrentParameterType = PropertyType.Global;
                }
                m_texCoordsHelper.ResetOutputLocals();
                m_texCoordsHelper.SetRawPropertyName(texTransform);
                texTransform = m_texCoordsHelper.GenerateShaderForOutput(0, ref dataCollector, false);

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

            switch (outputId)
            {
            case 0: return(m_outputPorts[0].LocalValue(dataCollector.PortCategory) + ".xy");

            case 1: return(m_outputPorts[0].LocalValue(dataCollector.PortCategory) + ".zw");
            }

            return(string.Empty);
        }
Beispiel #4
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (!m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                m_inputPorts[0].GeneratePortInstructions(ref dataCollector);
                string texTransform = string.Empty;

                if (m_inputPorts[0].IsConnected)
                {
                    texTransform = m_inputPorts[0].GeneratePortInstructions(ref dataCollector) + "_ST";
                }
                else if (m_referenceNode != null)
                {
                    m_referenceNode.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
                    texTransform = m_referenceNode.PropertyName + "_ST";
                }
                else
                {
                    texTransform = "_ST";
                    UIUtils.ShowMessage(UniqueId, "Please specify a texture sample on the Texture Transform Size node", MessageSeverity.Warning);
                }

                bool excludeUniformKeyword = UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader || UIUtils.CurrentWindow.OutsideGraph.IsSRP;

                string uniformRegister = UIUtils.GenerateUniformName(excludeUniformKeyword, WirePortDataType.FLOAT4, texTransform);

                dataCollector.AddToUniforms(UniqueId, uniformRegister, true);
                m_outputPorts[0].SetLocalValue(texTransform, dataCollector.PortCategory);
            }

            switch (outputId)
            {
            case 0: return(m_outputPorts[0].LocalValue(dataCollector.PortCategory) + ".xy");

            case 1: return(m_outputPorts[0].LocalValue(dataCollector.PortCategory) + ".zw");
            }

            return(string.Empty);
        }
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation)
            {
                UIUtils.ShowMessage(UniqueId, m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port");
                return("-1");
            }

            //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation );

            string tiling = string.Empty;
            string offset = string.Empty;

            string portProperty = string.Empty;

            if (m_texPort.IsConnected)
            {
                portProperty = m_texPort.GeneratePortInstructions(ref dataCollector);
            }
            else if (m_referenceArrayId > -1)
            {
                TexturePropertyNode temp = UIUtils.GetTexturePropertyNode(m_referenceArrayId);
                if (temp != null)
                {
                    portProperty = temp.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar);
                }
            }

            //TEMPLATES
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
                {
                    return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
                }

                string uvName   = string.Empty;
                string result   = string.Empty;
                string indexStr = m_textureCoordChannel > 0 ? (m_textureCoordChannel + 1).ToString() : "";
                string sizeDif  = string.Empty;
                if (m_texcoordSize == 3)
                {
                    sizeDif = "3";
                }
                else if (m_texcoordSize == 4)
                {
                    sizeDif = "4";
                }

                if (dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData(TemplateHelperFunctions.IntToUVChannelInfo[m_textureCoordChannel], m_outputPorts[0].DataType, PrecisionType.Float, ref result, false, dataCollector.PortCategory))
                {
                    uvName = result;
                }
                else if (dataCollector.TemplateDataCollectorInstance.HasUV(m_textureCoordChannel))
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.GetUVName(m_textureCoordChannel, m_outputPorts[0].DataType);
                }
                else
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV(m_textureCoordChannel, m_outputPorts[0].DataType);
                }
                string currPropertyName = GetValidPropertyName();
                if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
                {
                    currPropertyName = portProperty;
                }
                if (!string.IsNullOrEmpty(currPropertyName))
                {
                    string finalTexCoordName      = "uv" + indexStr + (m_texcoordSize > 2 ? "s" + sizeDif : "") + currPropertyName;
                    string dummyPropertyTexcoords = currPropertyName + "_ST";

                    if (m_texCoordsHelper == null)
                    {
                        m_texCoordsHelper = CreateInstance <Vector4Node>();
                        m_texCoordsHelper.ContainerGraph = ContainerGraph;
                        m_texCoordsHelper.SetBaseUniqueId(UniqueId, true);
                        m_texCoordsHelper.RegisterPropertyOnInstancing = false;
                        m_texCoordsHelper.AddGlobalToSRPBatcher        = true;
                    }

                    if (UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader)
                    {
                        m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty;
                    }
                    else
                    {
                        m_texCoordsHelper.CurrentParameterType = PropertyType.Global;
                    }
                    m_texCoordsHelper.ResetOutputLocals();
                    m_texCoordsHelper.SetRawPropertyName(dummyPropertyTexcoords);
                    dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput(0, ref dataCollector, false);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, CurrentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw") + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw"), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName );
                }
                else
                {
                    string finalTexCoordName = "texCoord" + OutputId;
                    tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector);
                    offset = m_offsetPort.GeneratePortInstructions(ref dataCollector);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, CurrentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset) + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, tiling, offset), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName );
                }
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            //SURFACE
            string propertyName = GetValidPropertyName();

            if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
            {
                propertyName = portProperty;
            }

            if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            if (!m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one)
            {
                tiling = null;
            }
            else
            {
                tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector);
            }

            if (!m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero)
            {
                offset = null;
            }
            else
            {
                offset = m_offsetPort.GeneratePortInstructions(ref dataCollector);
            }

            if (!string.IsNullOrEmpty(propertyName) /*m_referenceArrayId > -1*/)
            {
                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }
            else
            {
                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }

            m_outputPorts[0].SetLocalValue(m_surfaceTexcoordName, dataCollector.PortCategory);
            return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
        }
Beispiel #6
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation)
            {
                UIUtils.ShowMessage(m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port");
                return("-1");
            }

            //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation );

            string tiling = string.Empty;
            string offset = string.Empty;

            string portProperty = string.Empty;

            if (m_texPort.IsConnected)
            {
                portProperty = m_texPort.GenerateShaderForOutput(ref dataCollector, m_texPort.DataType, ignoreLocalVar);
            }

            if (m_referenceArrayId > -1)
            {
                TexturePropertyNode temp = UIUtils.GetTexturePropertyNode(m_referenceArrayId);
                if (temp != null)
                {
                    portProperty = temp.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar);
                }
            }

            //TEMPLATES
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                if (m_outputPorts[0].IsLocalValue)
                {
                    return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue));
                }

                string uvName = string.Empty;
                if (dataCollector.TemplateDataCollectorInstance.HasUV(m_textureCoordChannel))
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.GetUVName(m_textureCoordChannel);
                }
                else
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV(m_textureCoordChannel);
                    //string uvName = TemplateHelperFunctions.GenerateTextureSemantic( ref dataCollector, m_textureCoordChannel );
                    //uvName = ( dataCollector.IsFragmentCategory ? Constants.InputVarStr : Constants.VertexShaderInputStr ) + "." + uvName;
                }
                string currPropertyName = GetValidPropertyName();
                if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
                {
                    currPropertyName = portProperty;
                }
                if (!string.IsNullOrEmpty(currPropertyName))
                {
                    string finalTexCoordName      = "uv" + currPropertyName;
                    string dummyPropertyTexcoords = currPropertyName + "_ST";
                    dataCollector.AddToUniforms(UniqueId, "float4", dummyPropertyTexcoords);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw") + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw"), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName );
                }
                else
                {
                    string finalTexCoordName = "uv" + OutputId;
                    tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector);
                    offset = m_offsetPort.GeneratePortInstructions(ref dataCollector);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset) + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, tiling, offset), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName );
                }
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue));
            }

            //SURFACE
            string propertyName = GetValidPropertyName();

            if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
            {
                propertyName = portProperty;
            }

            if (m_outputPorts[0].IsLocalValue)
            {
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue));
            }

            tiling = m_tilingPort.GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true);
            offset = m_offsetPort.GenerateShaderForOutput(ref dataCollector, WirePortDataType.FLOAT2, false, true);
            if (!string.IsNullOrEmpty(propertyName) /*m_referenceArrayId > -1*/)
            {
                ////m_referenceNode = UIUtils.GetTexturePropertyNode( m_referenceArrayId );
                ////if ( m_referenceNode != null )
                ////{
                ////string propertyName = m_referenceNode.PropertyName;
                //int coordSet = ( ( m_textureCoordChannel < 0 ) ? 0 : m_textureCoordChannel );
                //string uvName = string.Empty;

                //string dummyPropUV = "_tex" + ( m_texcoordSize > 2 ? "" + m_texcoordSize : "" ) + "coord" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" );
                //string dummyUV = "uv" + ( coordSet > 0 ? ( coordSet + 1 ).ToString() : "" ) + dummyPropUV;

                //if ( isVertex )
                //{
                //	uvName = IOUtils.GetUVChannelName( propertyName, coordSet ) + m_texcoordSize.ToString() + coordSet.ToString();
                //	string vertexInput = Constants.VertexShaderInputStr + ".texcoord";
                //	if ( coordSet > 0 )
                //	{
                //		vertexInput += coordSet.ToString();
                //	}

                //	dataCollector.AddToVertexLocalVariables( UniqueId, "float" + m_texcoordSize + " " + uvName + " = " + vertexInput + ";" );
                //	dataCollector.AddToVertexLocalVariables( UniqueId, uvName + ".xy = " + vertexInput + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" );
                //}
                //else
                //{
                //	uvName = IOUtils.GetUVChannelName( propertyName, coordSet );
                //	if ( m_texcoordSize > 2 )
                //	{
                //		uvName += m_texcoordSize;
                //		dataCollector.UsingHigherSizeTexcoords = true;
                //		dataCollector.AddToLocalVariables( UniqueId, "float" + m_texcoordSize + " " + uvName + " = " + Constants.InputVarStr + "." + dummyUV + ";" );
                //		dataCollector.AddToLocalVariables( UniqueId, uvName + ".xy = " + Constants.InputVarStr + "." + dummyUV + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;" );
                //	}
                //	else
                //	{
                //		dataCollector.AddToLocalVariables( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT2, uvName, Constants.InputVarStr + "." + dummyUV + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw" );
                //	}
                //}

                //dataCollector.AddToUniforms( UniqueId, "uniform float4 " + propertyName + "_ST;" );
                //dataCollector.AddToProperties( UniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100 );
                //dataCollector.AddToInput( UniqueId, "float" + m_texcoordSize + " " + dummyUV, true );

                //return GetOutputVectorItem( 0, outputId, uvName );
                ////}

                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }
            else
            {
                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }
            //{
            //	if ( !isVertex && dataCollector.TesselationActive )
            //	{
            //		return GenerateFragShaderForOutput( outputId, ref dataCollector, ignoreLocalVar );
            //	}

            //	bool tessVertexMode = isVertex && dataCollector.TesselationActive;

            //	string texcoordName = TexCoordStr + OutputId;

            //	string uvChannel = m_textureCoordChannel == 0 ? ".xy" : m_textureCoordChannel + ".xy";

            //	MasterNodePortCategory portCategory = dataCollector.PortCategory;
            //	if ( dataCollector.PortCategory != MasterNodePortCategory.Vertex && dataCollector.PortCategory != MasterNodePortCategory.Tessellation )
            //		dataCollector.PortCategory = MasterNodePortCategory.Vertex;

            //	// We need to reset local variables if there are already created to force them to be created in the vertex function
            //	ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex );

            //	bool dirtySpecialVarsBefore = dataCollector.DirtySpecialLocalVariables;
            //	bool dirtyVertexVarsBefore = dataCollector.DirtyVertexVariables;

            //	string tiling = m_tilingPort.GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT2, false, true );
            //	string offset = m_offsetPort.GenerateShaderForOutput( ref dataCollector, WirePortDataType.FLOAT2, false, true );
            //	dataCollector.PortCategory = portCategory;

            //	string vertexUV = Constants.VertexShaderInputStr + ".texcoord" + uvChannel;

            //	if ( !tessVertexMode )
            //		dataCollector.AddToInput( UniqueId, "float" + m_texcoordSize + " " + texcoordName, true );

            //	bool resetLocals = false;
            //	// new texture coordinates are calculated on the vertex shader so we need to register its local vars
            //	if ( !dirtySpecialVarsBefore && dataCollector.DirtySpecialLocalVariables )
            //	{
            //		dataCollector.AddVertexInstruction( dataCollector.SpecialLocalVariables, UniqueId, false );
            //		dataCollector.ClearSpecialLocalVariables();
            //		resetLocals = true;
            //	}

            //	if ( !dirtyVertexVarsBefore && dataCollector.DirtyVertexVariables )
            //	{
            //		dataCollector.AddVertexInstruction( dataCollector.VertexLocalVariables, UniqueId, false );
            //		dataCollector.ClearVertexLocalVariables();
            //		resetLocals = true;
            //	}

            //	//Reset local variables again so they wont be caught on the fragment shader
            //	if ( resetLocals )
            //		ContainerGraph.ResetNodesLocalVariablesIfNot( this, MasterNodePortCategory.Vertex );

            //	if ( tessVertexMode )
            //	{
            //		dataCollector.AddToVertexLocalVariables(UniqueId, vertexUV + " = " + vertexUV + " * " + tiling + " + " + offset+";");
            //		m_surfaceTexcoordName = Constants.VertexShaderInputStr + "." + IOUtils.GetVertexUVChannelName( m_textureCoordChannel ) + ".xy";
            //	}
            //	else if( dataCollector.TesselationActive )
            //	{
            //		string texCoordPrefix = ( m_textureCoordChannel == 0 ) ? string.Empty : ( m_textureCoordChannel + 1 ).ToString();

            //		dataCollector.AddToProperties( UniqueId, string.Format( DummyPropertyDec, texCoordPrefix ) + " {}", -1 );
            //		dataCollector.AddToUniforms( UniqueId, string.Format( DummyUniformDec, texCoordPrefix ) );

            //		dataCollector.AddToInput( UniqueId, "float2 " + string.Format( DummyTexCoordDef, texCoordPrefix ), true );
            //		dataCollector.AddToSpecialLocalVariables( UniqueId, string.Format( DummyTexCoordSurfDef, OutputId, Constants.InputVarStr, texCoordPrefix, tiling, offset ) );
            //		m_surfaceTexcoordName = string.Format( DummyTexCoordSurfVar, OutputId );
            //	}
            //	else
            //	{
            //		//m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_texcoordSize == 2 ? WirePortDataType.FLOAT2 : WirePortDataType.FLOAT3, tiling, offset, OutputId );
            //		dataCollector.AddToVertexLocalVariables( UniqueId, Constants.VertexShaderOutputStr + "." + texcoordName + ".xy = " + vertexUV + " * " + tiling + " + " + offset + ";" );
            //		m_surfaceTexcoordName = ( isVertex ? Constants.VertexShaderOutputStr : Constants.InputVarStr ) + "." + texcoordName;
            //	}
            //}

            m_outputPorts[0].SetLocalValue(m_surfaceTexcoordName, dataCollector.PortCategory);
            return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue));
        }
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
		{
			if( dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
			{
				UIUtils.ShowMessage( m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port" ):
				return "-1":
			}

			//bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation ):

			string tiling = string.Empty:
			string offset = string.Empty:

			string portProperty = string.Empty:
			if( m_texPort.IsConnected )
				portProperty = m_texPort.GeneratePortInstructions( ref dataCollector ):

			if( m_referenceArrayId > -1 )
			{
				TexturePropertyNode temp = UIUtils.GetTexturePropertyNode( m_referenceArrayId ):
				if( temp != null )
				{
					portProperty = temp.BaseGenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ):
				}
			}

			//TEMPLATES
			if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template )
			{
				if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
					return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):

				string uvName = string.Empty:
				if( dataCollector.TemplateDataCollectorInstance.HasUV( m_textureCoordChannel ) )
				{
					uvName = dataCollector.TemplateDataCollectorInstance.GetUVName( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ):
				}
				else
				{
					uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV( m_textureCoordChannel, m_outputPorts[ 0 ].DataType ):
				}
				string currPropertyName = GetValidPropertyName():
				if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" )
				{
					currPropertyName = portProperty:
				}
				if( !string.IsNullOrEmpty( currPropertyName ) )
				{
					string finalTexCoordName = "uv" + m_textureCoordChannel + currPropertyName:
					string dummyPropertyTexcoords = currPropertyName + "_ST":

					if( m_texCoordsHelper == null )
					{
						m_texCoordsHelper = CreateInstance<Vector4Node>():
						m_texCoordsHelper.ContainerGraph = ContainerGraph:
						m_texCoordsHelper.SetBaseUniqueId( UniqueId, true ):
						m_texCoordsHelper.RegisterPropertyOnInstancing = false:
					}

					if( UIUtils.CurrentWindow.OutsideGraph.IsInstancedShader )
					{
						m_texCoordsHelper.CurrentParameterType = PropertyType.InstancedProperty:
					}
					else
					{
						m_texCoordsHelper.CurrentParameterType = PropertyType.Global:
					}
					m_texCoordsHelper.ResetOutputLocals():
					m_texCoordsHelper.SetRawPropertyName( dummyPropertyTexcoords ):
					dummyPropertyTexcoords = m_texCoordsHelper.GenerateShaderForOutput( 0, ref dataCollector, false ):

					if( m_texcoordSize > 2 )
					{
						dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ):
						dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ) + ":" ):
						m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ):
					}
					else
					{
						RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw" ), ref dataCollector, finalTexCoordName ):
					}
					//RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName ):
				}
				else
				{
					string finalTexCoordName = "uv" + m_textureCoordChannel + OutputId:
					tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ):
					offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ):

					if( m_texcoordSize > 2 )
					{
						dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, m_outputPorts[ 0 ].DataType, finalTexCoordName, uvName ):
						dataCollector.AddLocalVariable( UniqueId, finalTexCoordName + ".xy", string.Format( Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset ) + ":" ):
						m_outputPorts[ 0 ].SetLocalValue( finalTexCoordName, dataCollector.PortCategory ):
					}
					else
					{
						RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ):
					}
					//RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName ):
				}
				return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):
			}

			//SURFACE
			string propertyName = GetValidPropertyName():
			if( !string.IsNullOrEmpty( portProperty ) && portProperty != "0.0" )
			{
				propertyName = portProperty:
			}

			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):

			if( !m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one )
				tiling = null:
			else
				tiling = m_tilingPort.GeneratePortInstructions( ref dataCollector ):

			if( !m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero )
				offset = null:
			else
				offset = m_offsetPort.GeneratePortInstructions( ref dataCollector ):

			if( !string.IsNullOrEmpty( propertyName ) /*m_referenceArrayId > -1*/ )
			{
				m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ):
			}
			else
			{
				m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs( ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[ 0 ].DataType, tiling, offset, OutputId ):
			}

			m_outputPorts[ 0 ].SetLocalValue( m_surfaceTexcoordName, dataCollector.PortCategory ):
			return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):
		}
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            if (dataCollector.PortCategory == MasterNodePortCategory.Tessellation)
            {
                UIUtils.ShowMessage(m_nodeAttribs.Name + " cannot be used on Master Node Tessellation port");
                return("-1");
            }

            //bool isVertex = ( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation );

            string tiling = string.Empty;
            string offset = string.Empty;

            string portProperty = string.Empty;

            if (m_texPort.IsConnected)
            {
                portProperty = m_texPort.GeneratePortInstructions(ref dataCollector);
            }

            if (m_referenceArrayId > -1)
            {
                TexturePropertyNode temp = UIUtils.GetTexturePropertyNode(m_referenceArrayId);
                if (temp != null)
                {
                    portProperty = temp.BaseGenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar);
                }
            }

            //TEMPLATES
            if (dataCollector.MasterNodeCategory == AvailableShaderTypes.Template)
            {
                if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
                {
                    return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
                }

                string uvName = string.Empty;
                if (dataCollector.TemplateDataCollectorInstance.HasUV(m_textureCoordChannel))
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.GetUVName(m_textureCoordChannel, m_outputPorts[0].DataType);
                }
                else
                {
                    uvName = dataCollector.TemplateDataCollectorInstance.RegisterUV(m_textureCoordChannel, m_outputPorts[0].DataType);
                }
                string currPropertyName = GetValidPropertyName();
                if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
                {
                    currPropertyName = portProperty;
                }
                if (!string.IsNullOrEmpty(currPropertyName))
                {
                    string finalTexCoordName      = "uv" + currPropertyName;
                    string dummyPropertyTexcoords = currPropertyName + "_ST";
                    dataCollector.AddToUniforms(UniqueId, "float4", dummyPropertyTexcoords);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw") + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords + ".xy", dummyPropertyTexcoords + ".zw"), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, dummyPropertyTexcoords+".xy", dummyPropertyTexcoords+".zw" ), ref dataCollector, finalTexCoordName );
                }
                else
                {
                    string finalTexCoordName = "uv" + OutputId;
                    tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector);
                    offset = m_offsetPort.GeneratePortInstructions(ref dataCollector);

                    if (m_texcoordSize > 2)
                    {
                        dataCollector.AddLocalVariable(UniqueId, m_currentPrecisionType, m_outputPorts[0].DataType, finalTexCoordName, uvName);
                        dataCollector.AddLocalVariable(UniqueId, finalTexCoordName + ".xy", string.Format(Constants.TilingOffsetFormat, uvName + ".xy", tiling, offset) + ";");
                        m_outputPorts[0].SetLocalValue(finalTexCoordName, dataCollector.PortCategory);
                    }
                    else
                    {
                        RegisterLocalVariable(0, string.Format(Constants.TilingOffsetFormat, uvName, tiling, offset), ref dataCollector, finalTexCoordName);
                    }
                    //RegisterLocalVariable( 0, string.Format( Constants.TilingOffsetFormat, uvName, tiling, offset ), ref dataCollector, finalTexCoordName );
                }
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            //SURFACE
            string propertyName = GetValidPropertyName();

            if (!string.IsNullOrEmpty(portProperty) && portProperty != "0.0")
            {
                propertyName = portProperty;
            }

            if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory))
            {
                return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
            }

            if (!m_tilingPort.IsConnected && m_tilingPort.Vector2InternalData == Vector2.one)
            {
                tiling = null;
            }
            else
            {
                tiling = m_tilingPort.GeneratePortInstructions(ref dataCollector);
            }

            if (!m_offsetPort.IsConnected && m_offsetPort.Vector2InternalData == Vector2.zero)
            {
                offset = null;
            }
            else
            {
                offset = m_offsetPort.GeneratePortInstructions(ref dataCollector);
            }

            if (!string.IsNullOrEmpty(propertyName) /*m_referenceArrayId > -1*/)
            {
                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, propertyName, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }
            else
            {
                m_surfaceTexcoordName = GeneratorUtils.GenerateAutoUVs(ref dataCollector, UniqueId, m_textureCoordChannel, null, m_outputPorts[0].DataType, tiling, offset, OutputId);
            }

            m_outputPorts[0].SetLocalValue(m_surfaceTexcoordName, dataCollector.PortCategory);
            return(GetOutputVectorItem(0, outputId, m_outputPorts[0].LocalValue(dataCollector.PortCategory)));
        }