public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration(UIUtils.GetChannelName(m_textureCoordChannel), m_textureCoordChannel, m_textureCoordSet);

            dataCollector.AddToInput(m_uniqueId, uvChannelDeclaration, true);

            if (dataCollector.GetChannelUsage(m_textureCoordChannel) != TextureChannelUsage.Used)
            {
                dataCollector.SetChannelUsage(m_textureCoordChannel, TextureChannelUsage.Required);
            }

            string uvTileStr = string.Empty;

            switch (outputId)
            {
            case 0: { uvTileStr = "float2( " + m_tiling.x + " , " + m_tiling.y + " )"; } break;

            case 1: { uvTileStr = m_tiling.x.ToString(); } break;

            case 2: { uvTileStr = m_tiling.y.ToString(); } break;
            }
            string uvChannelName = IOUtils.GetUVChannelName(UIUtils.GetChannelName(m_textureCoordChannel), m_textureCoordSet);

            return(uvTileStr + "*" + GetOutputVectorItem(0, outputId, Constants.InputVarStr + "." + uvChannelName));
        }
Example #2
0
        public override string GenerateShaderForOutput(int outputId, WirePortDataType inputType, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            //if ( SoftValidReference )
            //{
            //	if ( !m_referenceNode.IsConnected )
            //		m_referenceNode.GenerateShaderForOutput( outputId,inputType, ref dataCollector, ignoreLocalVar );
            //}

            string propertyName = CurrentPropertyReference;

            OnPropertyNameChanged();

            if (m_autoUnpackNormals)
            {
                bool isScaledNormal = false;
                if (m_inputPorts[1].IsConnected)
                {
                    isScaledNormal = true;
                }
                else
                {
                    if (m_inputPorts[1].FloatInternalData != 1)
                    {
                        isScaledNormal = true;
                    }
                }
                if (isScaledNormal)
                {
                    string scaleValue = m_inputPorts[1].GenerateShaderForOutput(ref dataCollector, inputType, ignoreLocalVar);
                    dataCollector.AddToIncludes(m_uniqueId, Constants.UnityStandardUtilsLibFuncs);
                    m_normalMapUnpackMode = "UnpackScaleNormal( {0} ," + scaleValue + " )";
                }
                else
                {
                    m_normalMapUnpackMode = "UnpackNormal( {0} )";
                }
            }

            base.GenerateShaderForOutput(outputId, inputType, ref dataCollector, ignoreLocalVar);
            if (!m_inputPorts[0].IsConnected)
            {
                string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration(propertyName, -1, m_textureCoordSet);
                dataCollector.AddToInput(m_uniqueId, uvChannelDeclaration, true);
            }
            string valueName = SetFetchedData(ref dataCollector, ignoreLocalVar, inputType);

            return(GetOutputColorItem(0, outputId, valueName));
        }
Example #3
0
        public override string GenerateShaderForOutput(int outputId, WirePortDataType inputType, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            string propertyName = CurrentPropertyReference;

            OnPropertyNameChanged();

            bool emptyName = string.IsNullOrEmpty(m_propertyInspectorName);

            dataCollector.AddGrabPass(emptyName?string.Empty: propertyName);

            base.GenerateShaderForOutput(outputId, inputType, ref dataCollector, ignoreLocalVar);
            if (!m_inputPorts[0].IsConnected)
            {
                string uvChannelDeclaration = IOUtils.GetUVChannelDeclaration(propertyName, -1, 0);
                dataCollector.AddToInput(m_uniqueId, uvChannelDeclaration, true);
            }
            string valueName = SetFetchedData(ref dataCollector, ignoreLocalVar, inputType);

            return(GetOutputColorItem(0, outputId, valueName));
        }