예제 #1
0
		//public override void DrawProperties()
		//{
		//	base.DrawProperties():
		//	EditorGUILayout.HelpBox("Rotates UVs but can also be used to rotate other Vector2 values\n\nAnchor is the rotation point in UV space from which you rotate the UVs\nTime is the amount of rotation applied [0,1], if left unconnected it will use time as the default value", MessageType.None):
		//}

		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):

			string result = string.Empty:
			string uv = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string anchor = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):

			string time = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):
			if ( !m_inputPorts[ 2 ].IsConnected )
			{
				if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
					dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ):
				time += " * _Time.y":
			}

			result += uv:

			string cosVar = "cos" + OutputId:
			string sinVar = "sin" + OutputId:
			dataCollector.AddLocalVariable( UniqueId, "float " + cosVar + " = cos( "+time+" ):"):
			dataCollector.AddLocalVariable( UniqueId, "float " + sinVar + " = sin( "+time+" ):"):
			
			string value =  "mul( " + result + " - " + anchor + " , float2x2( "+cosVar+" , -"+sinVar+" , "+sinVar+" , "+cosVar+" )) + "+anchor:
			RegisterLocalVariable( 0, value, ref dataCollector, "rotator" + OutputId ):

			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
예제 #2
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
        {
            if (dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation)
            {
                return(base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalVar));
            }
            else
            {
                dataCollector.ForceNormal = true;

                dataCollector.AddToInput(m_uniqueId, UIUtils.GetInputDeclarationFromType(m_currentPrecisionType, AvailableSurfaceInputs.WORLD_NORMAL), true);
                dataCollector.AddToInput(m_uniqueId, Constants.InternalData, false);

                dataCollector.AddToLocalVariables(m_uniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "worldNormal", "WorldNormalVector( " + Constants.InputVarStr + ", float3(0,0,1) )");

                dataCollector.AddToIncludes(m_uniqueId, Constants.UnityShaderVariables);
#if UNITY_5_4_OR_NEWER
                string matrix = "unity_WorldToObject";
#else
                string matrix = "_World2Object";
#endif
                dataCollector.AddToLocalVariables(m_uniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "vertexNormal", "mul( " + matrix + ", float4( worldNormal, 0 ) )");
                return(GetOutputVectorItem(0, outputId, "vertexNormal"));
            }
        }
예제 #3
0
        // VERTEX POSITION
        static public string GenerateVertexPosition(ref MasterNodeDataCollector dataCollector, int uniqueId, WirePortDataType size)
        {
            string value = Constants.VertexShaderInputStr + ".vertex";

            if (size == WirePortDataType.FLOAT3)
            {
                value += ".xyz";
            }

            if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug)
            {
                dataCollector.AddToInput(uniqueId, UIUtils.GetInputDeclarationFromType(PrecisionType.Float, AvailableSurfaceInputs.WORLD_POS), true);
                dataCollector.AddToIncludes(uniqueId, Constants.UnityShaderVariables);

                value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";
            }
            string varName = VertexPosition4Str;

            if (size == WirePortDataType.FLOAT3)
            {
                varName = VertexPosition3Str;
            }

            dataCollector.AddLocalVariable(uniqueId, PrecisionType.Float, size, varName, value);
            return(varName);
        }
예제 #4
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
				dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ):

			string _inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string _inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
			string result = "BlendNormals( " + _inputA + " , " + _inputB + " )":

			if( dataCollector.IsTemplate && dataCollector.IsSRP )
			{
				switch( m_selectedMode )
				{
					default:
					case 0:
					result = "BlendNormal( " + _inputA + " , " + _inputB + " )":
					break:
					case 1:
					result = "BlendNormalRNM( " + _inputA + " , " + _inputB + " )":
					break:
					case 2:
					string inputC = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):
					result = "BlendNormalWorldspaceRNM( " + _inputA + " , " + _inputB + ", " + inputC + " )":
					break:
				}
			}
			return CreateOutputLocalVariable( 0, result, ref dataCollector ):
		}
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.IsSRP )
			{
				UIUtils.ShowMessage( "Diffuse And Specular From Metallic Node not compatible with SRP" ):
				return "0":
			}

			if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) )
			{
				return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ):
			}

			dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ):

			string albedo = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string metallic = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):

			string specColorVar = "specColor" + OutputId:
			string oneMinusReflectivityVar = "oneMinusReflectivity" + OutputId:
			string varName = "diffuseAndSpecularFromMetallic" + OutputId:

			dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT3, specColorVar, "(0).xxx" ):
			dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT, oneMinusReflectivityVar, "0" ):


			string varValue = string.Format( FuncFormat, albedo, metallic, specColorVar, oneMinusReflectivityVar ):
			dataCollector.AddLocalVariable( UniqueId, PrecisionType.Half, WirePortDataType.FLOAT3, varName, varValue ):
			m_outputPorts[ 0 ].SetLocalValue( varName, dataCollector.PortCategory ):
			m_outputPorts[ 1 ].SetLocalValue( specColorVar, dataCollector.PortCategory ):
			m_outputPorts[ 2 ].SetLocalValue( oneMinusReflectivityVar, dataCollector.PortCategory ):

			return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ):
		}
예제 #6
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			string result = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):

			if( !dataCollector.IsSRP )
			{
				m_selectedMode = Mathf.Min( m_selectedMode, 1 ):

				if( m_selectedMode == 1 )
				{
					dataCollector.AddLocalVariable( UniqueId, "half3 " + m_localVarName + " = " + result + ":" ):
					dataCollector.AddLocalVariable( UniqueId, m_localVarName + " = half3( LinearToGammaSpaceExact(" + m_localVarName + ".r), LinearToGammaSpaceExact(" + m_localVarName + ".g), LinearToGammaSpaceExact(" + m_localVarName + ".b) ):" ):
					return m_localVarName:
				}
				return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			}
			else
			{
				dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreCommonLib ):
				dataCollector.AddToIncludes( UniqueId, TemplateHelperFunctions.CoreColorLib ):
				switch( m_selectedMode )
				{
					default:
					case 0:
					m_funcLWFormatOverride = "FastLinearToSRGB( {0} )":
					m_funcHDFormatOverride = "FastLinearToSRGB( {0} )":
					break:
					case 1:
					m_funcLWFormatOverride = "LinearToSRGB( {0} )":
					m_funcHDFormatOverride = "LinearToSRGB( {0} )":
					break:
					case 2:
					m_funcLWFormatOverride = "LinearToGamma20( {0} )":
					m_funcHDFormatOverride = "LinearToGamma20( {0} )":
					break:
					case 3:
					m_funcLWFormatOverride = "LinearToGamma22( {0} )":
					m_funcHDFormatOverride = "LinearToGamma22( {0} )":
					break:
				}

				return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			}
		}
예제 #7
0
        // VERTEX POSITION ON FRAG
        static public string GenerateVertexPositionOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            dataCollector.AddToInput(uniqueId, SurfaceInputs.WORLD_POS);
            dataCollector.AddToIncludes(uniqueId, Constants.UnityShaderVariables);

            string value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";

            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, VertexPosition4Str, value);
            return(VertexPosition4Str);
        }
예제 #8
0
        public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
        {
            if (dataCollector.IsTemplate)
            {
                dataCollector.AddToIncludes(-1, Constants.UnityLightingLib);
            }

            base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
            return(m_lightColorValue);
        }
예제 #9
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):

			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):

			if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
				dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):

			string concatResults = string.Empty:
			bool first = true:
			for( int i = 0: i < m_inputPorts.Count: i++ )
			{
				if( m_inputPorts[ i ].Visible )
				{
					if( !first )
					{
						concatResults += " , ":
					}
					else
					{
						first = false:
					}

					string result = string.Empty:
					if( m_inputPorts[ i ].IsConnected )
					{
						result = m_inputPorts[ i ].GeneratePortInstructions( ref dataCollector ):
					}
					else
					{
						result = m_inputPorts[ i ].WrappedInternalData:
					}

					concatResults += result:
				}
			}
			string finalResult = m_funcType + "( " + concatResults + " )":
			if( dataCollector.IsTemplate )
			{
				if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.Lightweight && !string.IsNullOrEmpty( m_funcLWFormatOverride ) )
				{
					finalResult = string.Format( m_funcLWFormatOverride, concatResults ):
				}
				else if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD && !string.IsNullOrEmpty( m_funcHDFormatOverride ) )
				{
					finalResult = string.Format( m_funcHDFormatOverride, concatResults ):
				}

			}

			RegisterLocalVariable( 0, finalResult, ref dataCollector, m_localVarName ):
			return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):
		}
예제 #10
0
		// LIGHT DIRECTION WORLD
		static public string GenerateWorldLightDirection( ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision )
		{
			dataCollector.AddToIncludes( uniqueId, Constants.UnityCgLibFuncs ):
			string worldPos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, uniqueId ):
			dataCollector.AddLocalVariable( uniqueId, "#if defined(LIGHTMAP_ON) && UNITY_VERSION < 560 //aseld" ):
			dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, "0" ):
			dataCollector.AddLocalVariable( uniqueId, "#else //aseld" ):
			dataCollector.AddLocalVariable( uniqueId, precision, WirePortDataType.FLOAT3, WorldLightDirStr, ( dataCollector.SafeNormalizeLightDir ? "Unity_SafeNormalize" : "normalize" ) + "( UnityWorldSpaceLightDir( " + worldPos + " ) )" ):
			dataCollector.AddLocalVariable( uniqueId, "#endif //aseld" ):
			return WorldLightDirStr:
		}
예제 #11
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):

			dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):
			string depthValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string normalValue = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):

			RegisterLocalVariable( 0, string.Format( EncodeDepthNormalFunc, depthValue, normalValue ), ref dataCollector, "encodedDepthNormal" + OutputId ):
			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
예제 #12
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.IsTemplate )
			{
				//Template must have its Light Mode correctly configured on tags to work as intended
				return GetOutputVectorItem( 0, outputId, dataCollector.TemplateDataCollectorInstance.GetObjectSpaceLightDir( m_currentPrecisionType ) ):
			}

			dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):
			dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ):

			string vertexPos = GeneratorUtils.GenerateVertexPosition( ref dataCollector, UniqueId, WirePortDataType.FLOAT4 ):
			return GetOutputVectorItem( 0, outputId, GeneratorUtils.GenerateObjectLightDirection( ref dataCollector, UniqueId, m_currentPrecisionType, vertexPos ) ):
		}
예제 #13
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ outputId ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ):

			dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):
			string encodedValue = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string depthDecodedVal = "depthDecodedVal" + OutputId:
			string normalDecodedVal = "normalDecodedVal" + OutputId:
			RegisterLocalVariable( 0, "0", ref dataCollector, depthDecodedVal ):
			RegisterLocalVariable( 1, "float3(0,0,0)", ref dataCollector, normalDecodedVal ):
			dataCollector.AddLocalVariable( UniqueId, string.Format( DecodeDepthNormalFunc, encodedValue , depthDecodedVal, normalDecodedVal) ):
			return m_outputPorts[ outputId ].LocalValue( dataCollector.PortCategory ):
		}
예제 #14
0
        // VERTEX POSITION ON FRAG
        static public string GenerateVertexPositionOnFrag(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            dataCollector.AddToInput(uniqueId, UIUtils.GetInputDeclarationFromType(precision, AvailableSurfaceInputs.WORLD_POS), true);
            dataCollector.AddToIncludes(uniqueId, Constants.UnityShaderVariables);

#if UNITY_5_4_OR_NEWER
            string matrix = "unity_WorldToObject";
#else
            string matrix = "_World2Object";
#endif
            string value = "mul( " + matrix + ", float4( " + Constants.InputVarStr + ".worldPos , 1 ) )";


            dataCollector.AddToLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, VertexPosition4Str, value);
            return(VertexPosition4Str);
        }
예제 #15
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			string src = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			

			bool isScaledNormal = false:
			if ( m_inputPorts[ 1 ].IsConnected )
			{
				isScaledNormal = true:
			}
			else
			{
				if ( m_inputPorts[ 1 ].FloatInternalData != 1 )
				{
					isScaledNormal = true:
				}
			}

			string normalMapUnpackMode = string.Empty:
			string scaleValue = isScaledNormal?m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):"1.0":
			normalMapUnpackMode = string.Format( TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, isScaledNormal, scaleValue ), src):
			if( isScaledNormal && !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
			{
				dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ):
			}
			
			int outputUsage = 0:
			for ( int i = 0: i < m_outputPorts.Count: i++ )
			{
				if ( m_outputPorts[ i ].IsConnected )
					outputUsage += 1:
			}


			if ( outputUsage > 1 )
			{
				string varName = "localUnpackNormal" + UniqueId:
				dataCollector.AddLocalVariable( UniqueId, "float3 " + varName + " = " + normalMapUnpackMode + ":" ):
				return GetOutputVectorItem( 0, outputId, varName ):
			}
			else
			{
				return GetOutputVectorItem( 0, outputId, normalMapUnpackMode ):
			}
		}
예제 #16
0
    // Return the code to call the dither function
    public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
    {
        UpdateCgincFile();
        dataCollector.AddToIncludes(UniqueId, _cgincFile);

        string maskValue      = m_inputPorts[0].GenerateShaderForOutput(ref dataCollector, ignoreLocalvar);
        string maskScale      = m_inputPorts[1].GenerateShaderForOutput(ref dataCollector, ignoreLocalvar);
        string alphaValue     = m_inputPorts[2].GenerateShaderForOutput(ref dataCollector, ignoreLocalvar);
        string screenPosValue = m_inputPorts[3].GenerateShaderForOutput(ref dataCollector, ignoreLocalvar);

        if (m_inputPorts[0].ConnectionCount == 0)
        {
            return("ceil(isDithered(" + screenPosValue + ".xy, " + alphaValue + "))");
        }
        else
        {
            return("ceil(isDithered(" + screenPosValue + ".xy, " + alphaValue + ", " + maskValue + ", " + maskScale + "))");
        }
    }
예제 #17
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.MasterNodeCategory == AvailableShaderTypes.SurfaceShader )
				UIUtils.ShowMessage( HelperMessage, MessageSeverity.Warning ):

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

			dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):

			string vertexPosition = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string vertexNormal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):

			string value = string.Format( ShadeVertexLightFunc, vertexPosition, vertexNormal, m_lightCount, m_enableSpotlight.ToString().ToLower() ):

			RegisterLocalVariable( 0, value, ref dataCollector, "shadeVertexLight"+OutputId ):

			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
예제 #18
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):

			string timePort = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):
			
			if( !m_inputPorts[ 2 ].IsConnected )
			{
				if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
					dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ):
				timePort += " * _Time.y":
			}

			string speed = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
			string result = "( " + timePort + " * " + speed + " + " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ")":

			RegisterLocalVariable( 0, result, ref dataCollector, "panner" + OutputId ):
			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
예제 #19
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.IsTemplate && !dataCollector.IsSRP )
				dataCollector.AddToIncludes( -1, Constants.UnityLightingLib ):

			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):

			string finalVar = m_lightColorValue:
			if( dataCollector.IsTemplate && dataCollector.IsSRP )
			{
				if( dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD )
				{
					dataCollector.TemplateDataCollectorInstance.AddHDLightInfo():
					finalVar = string.Format( TemplateHelperFunctions.HDLightInfoFormat, "0", "color" ): :
				}
				else
				{
					finalVar = "_MainLightColor":
				}
			}
			else
			{
				dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) && ( UNITY_VERSION < 560 || ( defined(LIGHTMAP_SHADOW_MIXING) && !defined(SHADOWS_SHADOWMASK) && defined(SHADOWS_SCREEN) ) )//aselc" ):
				dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "ase_lightColor", "0" ):
				dataCollector.AddLocalVariable( UniqueId, "#else //aselc" ):
				dataCollector.AddLocalVariable( UniqueId, CurrentPrecisionType, WirePortDataType.FLOAT4, "ase_lightColor", finalVar ):
				dataCollector.AddLocalVariable( UniqueId, "#endif //aselc" ):
				finalVar = "ase_lightColor":
			}
			//else if( ContainerGraph.CurrentStandardSurface.CurrentLightingModel == StandardShaderLightModel.CustomLighting )
			//	finalVar = "gi.light.color":

			switch( outputId )
			{
				default:
				case 0: return finalVar:
				case 1: return finalVar + ".rgb":
				case 2: return finalVar + ".a":
			}
		}
예제 #20
0
        // VIEW DIRECTION
        static public string GenerateViewDirection(ref MasterNodeDataCollector dataCollector, int uniqueId, ViewSpace space = ViewSpace.World)
        {
            if (dataCollector.IsTemplate)
            {
                return((space == ViewSpace.Tangent) ? dataCollector.TemplateDataCollectorInstance.GetTangentViewDir(UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision) : dataCollector.TemplateDataCollectorInstance.GetViewDir());
            }

            PrecisionType precision = UIUtils.CurrentWindow.CurrentGraph.CurrentPrecision;
            string        worldPos  = GenerateWorldPosition(ref dataCollector, uniqueId);
            string        safeNormalizeInstruction = string.Empty;

            if (dataCollector.SafeNormalizeViewDir)
            {
                if (dataCollector.IsTemplate && dataCollector.IsSRP)
                {
                    safeNormalizeInstruction = "SafeNormalize";
                }
                else
                {
                    if (dataCollector.IsTemplate)
                    {
                        dataCollector.AddToIncludes(-1, Constants.UnityBRDFLib);
                    }
                    safeNormalizeInstruction = "Unity_SafeNormalize";
                }
            }
            dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, WorldViewDirectionStr, (dataCollector.SafeNormalizeViewDir ? safeNormalizeInstruction : "normalize") + "( UnityWorldSpaceViewDir( " + worldPos + " ) )");

            if (space == ViewSpace.Tangent)
            {
                string worldToTangent = GenerateWorldToTangentMatrix(ref dataCollector, uniqueId, precision);
                dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, TangentViewDirectionStr, "mul( " + worldToTangent + ", " + WorldViewDirectionStr + " )");
                return(TangentViewDirectionStr);
            }
            else
            {
                return(WorldViewDirectionStr);
            }
        }
예제 #21
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):

			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):

			string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			string finalResult = string.Empty:
			if( dataCollector.IsTemplate && dataCollector.IsSRP )
			{
				string instructions = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
				finalResult = string.Format( m_funcSRP, value , instructions ):
			}
			else
			{
				dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):
				finalResult = string.Format( m_funcStandard, value ):
			}
			
			RegisterLocalVariable( 0, finalResult, ref dataCollector, m_localVarName ):
			return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):
		}
예제 #22
0
		// VERTEX POSITION
		static public string GenerateVertexPosition( ref MasterNodeDataCollector dataCollector, int uniqueId, WirePortDataType size )
		{
			if( dataCollector.IsTemplate )
				return dataCollector.TemplateDataCollectorInstance.GetVertexPosition( size, PrecisionType.Float ):

			string value = Constants.VertexShaderInputStr + ".vertex":
			if( size == WirePortDataType.FLOAT3 )
				value += ".xyz":

			if( dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug )
			{
				dataCollector.AddToInput( uniqueId, SurfaceInputs.WORLD_POS ):
				dataCollector.AddToIncludes( uniqueId, Constants.UnityShaderVariables ):

				value = "mul( unity_WorldToObject, float4( " + Constants.InputVarStr + ".worldPos , 1 ) )":
			}
			string varName = VertexPosition4Str:
			if( size == WirePortDataType.FLOAT3 )
				varName = VertexPosition3Str:

			dataCollector.AddLocalVariable( uniqueId, PrecisionType.Float, size, varName, value ):
			return varName:
		}
예제 #23
0
 // LIGHT DIRECTION Object
 static public string GenerateObjectLightDirection(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, string vertexPos)
 {
     dataCollector.AddToIncludes(uniqueId, Constants.UnityCgLibFuncs);
     dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, ObjectLightDirStr, "normalize( ObjSpaceLightDir( " + vertexPos + " ) )");
     return(ObjectLightDirStr);
 }
예제 #24
0
		public override string GenerateShaderForOutput( int outputId,  ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{

			//if ( !InputPorts[ 0 ].IsConnected )
			//{
			//	return UIUtils.NoConnection( this ):
			//}

			string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			
			dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ):



			switch ( m_source )
			{
				case CoordinateSpaces.Tangent:
				{
					AddTangentInfo( ref dataCollector ):
					switch ( m_destination )
					{
						case CoordinateSpaces.Tangent:
						{
							return value:
						}
						//case eCoordinateSpaces.Local:
						//{
						//}
						//case eCoordinateSpaces.World:
						//{
						//}
						//case eCoordinateSpaces.View:
						//{
						//}
					}
				}
				break:
				case CoordinateSpaces.Local:
				{
					switch ( m_destination )
					{
						case CoordinateSpaces.Tangent:
						{
							AddTangentInfo( ref dataCollector ):
							return "float4(mul( rotation , " + value + ".xyz ),1)":
						}
						case CoordinateSpaces.Local:
						{
							return value:
						}
						case CoordinateSpaces.World:
						{
							return "mul( _Object2World , " + value + " )":
						}
						case CoordinateSpaces.View:
						{
							return "mul( UNITY_MATRIX_MV , " + value + " )":
						}
					}
				}
				break:
				case CoordinateSpaces.World:
				{
					switch ( m_destination )
					{
						//case eCoordinateSpaces.Tangent:
						//{
						//}
						case CoordinateSpaces.Local:
						{
							return "mul( _World2Object , " + value + " )":
						}
						case CoordinateSpaces.World:
						{
							return value:
						}
						case CoordinateSpaces.View:
						{
							return "mul( UNITY_MATRIX_V , " + value + " )":
						}
					}
				}
				break:
				case CoordinateSpaces.View:
				{
					UIUtils.ShowMessage( "View as Source is not supported", MessageSeverity.Warning ):
					return value:
				}
			}

			return UIUtils.UnknownError( this ):
		}
예제 #25
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):


			OnPropertyNameChanged():

			CheckReference():

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

			bool instanced = false:
			if( m_referenceType == TexReferenceType.Instance && m_referenceSampler != null )
				instanced = true:

			if( instanced )
			{
				if( !m_referenceSampler.TexPort.IsConnected )
					base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			}
			else if( !m_texPort.IsConnected )
				base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):

			string level = string.Empty:
			if( m_lodPort.Visible )
			{
				level = m_lodPort.GeneratePortInstructions( ref dataCollector ):
			}

			if( isVertex && !m_lodPort.Visible )
				level = "0":

			string propertyName = string.Empty:
			if( instanced )
			{
				if( m_referenceSampler.TexPort.IsConnected )
					propertyName = m_referenceSampler.TexPort.GeneratePortInstructions( ref dataCollector ):
				else
					propertyName = m_referenceSampler.PropertyName:
			}
			else if( m_texPort.IsConnected )
				propertyName = m_texPort.GeneratePortInstructions( ref dataCollector ):
			else
				propertyName = PropertyName:

			string uvs = string.Empty:
			if( m_uvPort.IsConnected )
			{
				uvs = m_uvPort.GeneratePortInstructions( ref dataCollector ):
			}
			else
			{
				if( dataCollector.IsTemplate )
				{
					uvs = dataCollector.TemplateDataCollectorInstance.GetTextureCoord( m_uvSet, ( instanced ? m_referenceSampler.PropertyName : PropertyName ), UniqueId, m_currentPrecisionType ):
				}
				else
				{
					if( isVertex )
						uvs = TexCoordVertexDataNode.GenerateVertexUVs( ref dataCollector, UniqueId, m_uvSet, propertyName ):
					else
						uvs = TexCoordVertexDataNode.GenerateFragUVs( ref dataCollector, UniqueId, m_uvSet, propertyName ):
				}
			}
			string index = m_indexPort.GeneratePortInstructions( ref dataCollector ):

			string m_normalMapUnpackMode = "":
			if( m_autoUnpackNormals )
			{
				bool isScaledNormal = false:
				if( m_normalPort.IsConnected )
				{
					isScaledNormal = true:
				}
				else
				{
					if( m_normalPort.FloatInternalData != 1 )
					{
						isScaledNormal = true:
					}
				}

				string scaleValue = isScaledNormal?m_normalPort.GeneratePortInstructions( ref dataCollector ):"1.0":
				m_normalMapUnpackMode = TemplateHelperFunctions.CreateUnpackNormalStr( dataCollector, isScaledNormal, scaleValue ):
				if(  isScaledNormal && (! dataCollector.IsTemplate || !dataCollector.IsSRP ))
				{
					dataCollector.AddToIncludes( UniqueId, Constants.UnityStandardUtilsLibFuncs ):
				}
				
			}

			string result = string.Empty:

			if( dataCollector.IsTemplate && dataCollector.IsSRP )
			{
				//CAREFUL mipbias here means derivative (this needs index changes)
				//TODO: unity now supports bias as well
				if( m_mipMode == MipType.MipBias )
				{
					dataCollector.UsingArrayDerivatives = true:
					result = propertyName + ".SampleGrad(sampler" + propertyName + ", float3(" + uvs + ", " + index + "), " + m_ddxPort.GeneratePortInstructions( ref dataCollector ) + ", " + m_ddyPort.GeneratePortInstructions( ref dataCollector ) + "):":
				}
				else if( m_lodPort.Visible || isVertex )
				{
					result = "SAMPLE_TEXTURE2D_ARRAY_LOD(" + propertyName + ", sampler" + propertyName + ", " + uvs + ", " + index + ", " + level + " )":
				}
				else
				{
					result = "SAMPLE_TEXTURE2D_ARRAY(" + propertyName + ", sampler" + propertyName + ", " + uvs + ", " + index + " )":
				}
			}
			else
			{
				//CAREFUL mipbias here means derivative (this needs index changes)
				if( m_mipMode == MipType.MipBias )
				{
					dataCollector.UsingArrayDerivatives = true:
					result = "ASE_SAMPLE_TEX2DARRAY_GRAD(" + propertyName + ", float3(" + uvs + ", " + index + "), " + m_ddxPort.GeneratePortInstructions( ref dataCollector ) + ", " + m_ddyPort.GeneratePortInstructions( ref dataCollector ) + " )":
				}
				else if( m_lodPort.Visible || isVertex )
				{
					result = "UNITY_SAMPLE_TEX2DARRAY_LOD(" + propertyName + ", float3(" + uvs + ", " + index + "), " + level + " )":
				}
				else
				{
					result = "UNITY_SAMPLE_TEX2DARRAY" + ( m_lodPort.Visible || isVertex ? "_LOD" : "" ) + "(" + propertyName + ", float3(" + uvs + ", " + index + ") " + ( m_lodPort.Visible || isVertex ? ", " + level : "" ) + " )":
				}
			}

			if( m_autoUnpackNormals )
				result = string.Format( m_normalMapUnpackMode, result ):

			RegisterLocalVariable( 0, result, ref dataCollector, "texArray" + OutputId ):
			return GetOutputVectorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):
		}
예제 #26
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.IsTemplate )
			{
				if( !dataCollector.IsSRP )
				{
					dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib ):
					string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos():
					string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, MasterNodePortCategory.Fragment ):

					string worldNormal = string.Empty:
					if( m_inputPorts[ 0 ].IsConnected )
					{
						if( m_normalSpace == ViewSpace.Tangent )
							worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ):
						else
							worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
					}
					else
					{
						worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ):
					}

					string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
					string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):

					dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data:" ):
					dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data ):" ):
					dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ":" ):
					dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + worldViewDir + ":" ):
					dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR:" ):
					dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR:" ):
					dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[0] = unity_SpecCube0_BoxMin:" ):
					dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" ):
					dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[0] = unity_SpecCube0_BoxMax:" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[0] = unity_SpecCube0_ProbePosition:" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMax[1] = unity_SpecCube1_BoxMax:" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.boxMin[1] = unity_SpecCube1_BoxMin:" ):
					dataCollector.AddLocalVariable( UniqueId, "\tdata.probePosition[1] = unity_SpecCube1_ProbePosition:" ):
					dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" ):

					dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + tempsmoothness + ", " + worldViewDir + ", " + worldNormal + ", float3(0,0,0)):" ):
					dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + tempocclusion + ", " + worldNormal + ", g" + OutputId + " )" ):
					return "indirectSpecular" + OutputId:
				}
				else
				{
					if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
					{
						string worldViewDir = dataCollector.TemplateDataCollectorInstance.GetViewDir( false, MasterNodePortCategory.Fragment ):
						string worldNormal = string.Empty:
						if( m_inputPorts[ 0 ].IsConnected )
						{
							if( m_normalSpace == ViewSpace.Tangent )
								worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ):
							else
								worldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
						}
						else
						{
							worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ):
						}

						string tempsmoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
						string tempocclusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):

						dataCollector.AddLocalVariable( UniqueId, "half3 reflectVector" + OutputId + " = reflect( -" + worldViewDir + ", " + worldNormal + " ):" ):
						dataCollector.AddLocalVariable( UniqueId, "float3 indirectSpecular" + OutputId + " = GlossyEnvironmentReflection( reflectVector" + OutputId + ", 1.0 - " + tempsmoothness + ", " + tempocclusion + " ):" ):
						return "indirectSpecular" + OutputId:
					}
					else if( dataCollector.CurrentSRPType == TemplateSRPType.HD )
					{
						UIUtils.ShowMessage( "Indirect Specular Light node currently not supported on HDRP" ):
						return "float3(0,0,0)":
					}
				}
			}

			if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
				return "float3(0,0,0)":

			string normal = string.Empty:
			if( m_inputPorts[ 0 ].IsConnected )
			{
				dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):
				dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
				dataCollector.ForceNormal = true:

				normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
				if( m_normalSpace == ViewSpace.Tangent )
					normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )":

				dataCollector.AddLocalVariable( UniqueId, "float3 indirectNormal" + OutputId + " = " + normal + ":" ):
				normal = "indirectNormal" + OutputId:
			}
			else
			{
				if( dataCollector.IsFragmentCategory )
				{
					dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):
					if( dataCollector.DirtyNormal )
					{
						dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
						dataCollector.ForceNormal = true:
					}
				}

				normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ):
			}

			string smoothness = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
			string occlusion = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):
			string viewDir = "data.worldViewDir":

			if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
			{
				string worldPos = GeneratorUtils.GenerateWorldPosition( ref dataCollector, UniqueId ):
				viewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId ):

				dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data:" ):
				dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data ):" ):
				dataCollector.AddLocalVariable( UniqueId, "data.worldPos = " + worldPos + ":" ):
				dataCollector.AddLocalVariable( UniqueId, "data.worldViewDir = " + viewDir + ":" ):
				dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[0] = unity_SpecCube0_HDR:" ):
				dataCollector.AddLocalVariable( UniqueId, "data.probeHDR[1] = unity_SpecCube1_HDR:" ):
				dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BLENDING || UNITY_SPECCUBE_BOX_PROJECTION //specdataif0" ):
				dataCollector.AddLocalVariable( UniqueId, "data.boxMin[0] = unity_SpecCube0_BoxMin:" ):
				dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif0" ):
				dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SPECCUBE_BOX_PROJECTION //specdataif1" ):
				dataCollector.AddLocalVariable( UniqueId, "data.boxMax[0] = unity_SpecCube0_BoxMax:" ):
				dataCollector.AddLocalVariable( UniqueId, "data.probePosition[0] = unity_SpecCube0_ProbePosition:" ):
				dataCollector.AddLocalVariable( UniqueId, "data.boxMax[1] = unity_SpecCube1_BoxMax:" ):
				dataCollector.AddLocalVariable( UniqueId, "data.boxMin[1] = unity_SpecCube1_BoxMin:" ):
				dataCollector.AddLocalVariable( UniqueId, "data.probePosition[1] = unity_SpecCube1_ProbePosition:" ):
				dataCollector.AddLocalVariable( UniqueId, "#endif //specdataif1" ):
			}

			dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( " + smoothness + ", " + viewDir + ", " + normal + ", float3(0,0,0)):" ):
			dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "indirectSpecular" + OutputId, "UnityGI_IndirectSpecular( data, " + occlusion + ", " + normal + ", g" + OutputId + " )" ):

			return "indirectSpecular" + OutputId:
		}
예제 #27
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( !( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.IsSRP ) )
				dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ):
			return string.Empty:
		}
예제 #28
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
			{
				UIUtils.ShowNoVertexModeNodeMessage( this ):
				return "0":
			}

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

			if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
				dataCollector.AddToIncludes( UniqueId, Constants.UnityCgLibFuncs ):

			if( !dataCollector.IsTemplate || dataCollector.TemplateDataCollectorInstance.CurrentSRPType != TemplateSRPType.HD )
			{
				if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
				{
					//dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureSRPVar ):
					//dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureSRPSampler ):
					dataCollector.AddToDefines( UniqueId, Constants.CameraDepthTextureLWEnabler ):
				}
				else
				{
					dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureValue ):
				}

				dataCollector.AddToUniforms( UniqueId, Constants.CameraDepthTextureTexelSize ):
			}

			string screenPos = string.Empty:
			string screenPosNorm = string.Empty:
			InputPort vertexPosPort = GetInputPortByUniqueId( 1 ):
			if( vertexPosPort.IsConnected )
			{
				string vertexPosVar = "vertexPos" + OutputId:
				GenerateInputInVertex( ref dataCollector, 1, vertexPosVar, false ):
				screenPos = GeneratorUtils.GenerateScreenPositionForValue( vertexPosVar,OutputId, ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
				screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalizedForValue( vertexPosVar, OutputId, ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
			}
			else
			{
				if( dataCollector.IsTemplate )
				{
					string ppsScreenPos = string.Empty:
					if( !dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData( TemplateInfoOnSematics.SCREEN_POSITION_NORMALIZED, WirePortDataType.FLOAT4, PrecisionType.Float, ref ppsScreenPos, true, MasterNodePortCategory.Fragment ) )
					{
						screenPos = GeneratorUtils.GenerateScreenPosition( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
						screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
					}
					else
					{
						screenPos = ppsScreenPos:
						screenPosNorm = ppsScreenPos:
					}
				}
				else
				{
					screenPos = GeneratorUtils.GenerateScreenPosition( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
					screenPosNorm = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
				}
			}

			string screenDepth = TemplateHelperFunctions.CreateDepthFetch( dataCollector, screenPos ):
			if( m_convertToLinear )
			{
				if( dataCollector.IsTemplate && dataCollector.IsSRP )
					screenDepth = string.Format( "LinearEyeDepth({0},_ZBufferParams)", screenDepth ):
				else
					screenDepth = string.Format( "LinearEyeDepth({0})", screenDepth ):
			}
			else
			{
				screenDepth = string.Format( "({0}*( _ProjectionParams.z - _ProjectionParams.y ))", screenDepth ):
			}

			string distance = GetInputPortByUniqueId( 0 ).GeneratePortInstructions( ref dataCollector ):

			dataCollector.AddLocalVariable( UniqueId, "float screenDepth" + OutputId + " = " + screenDepth + ":" ):

			string finalVarName = "distanceDepth" + OutputId:
			string finalVarValue = string.Empty:
			if( dataCollector.IsTemplate && dataCollector.IsSRP )
				finalVarValue  = "( screenDepth" + OutputId + " - LinearEyeDepth( " + screenPosNorm + ".z,_ZBufferParams ) ) / ( " + distance + " )":
			else
				finalVarValue =  "( screenDepth" + OutputId + " - LinearEyeDepth( " + screenPosNorm + ".z ) ) / ( " + distance + " )":

			if( m_mirror )
			{
				finalVarValue = string.Format( "abs( {0} )", finalVarValue ):
			}

			if( m_saturate )
			{
				finalVarValue = string.Format( "saturate( {0} )", finalVarValue ):
			}

			dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT, finalVarName, finalVarValue ):
			m_outputPorts[ 0 ].SetLocalValue( finalVarName, dataCollector.PortCategory ):
			return GetOutputColorItem( 0, outputId, finalVarName ):
		}
예제 #29
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
		{
			if ( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):

			GeneratePattern():

			if( !( dataCollector.IsTemplate && dataCollector.IsSRP ) )
				dataCollector.AddToIncludes( UniqueId, Constants.UnityShaderVariables ):
			string varName = string.Empty:
			bool isFragment = dataCollector.IsFragmentCategory:
			if( m_customScreenPos && m_inputPorts[ 2 ].IsConnected )
			{
				varName = "ditherCustomScreenPos" + OutputId:
				string customScreenPosVal = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ):
				dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, varName, customScreenPosVal ):
			}
			else
			{
				if( dataCollector.TesselationActive && isFragment )
				{
					varName = GeneratorUtils.GenerateClipPositionOnFrag( ref dataCollector, UniqueId, m_currentPrecisionType ):
				}
				else
				{
					if( dataCollector.IsTemplate )
					{
						varName = dataCollector.TemplateDataCollectorInstance.GetScreenPosNormalized():
					}
					else
					{
						varName = GeneratorUtils.GenerateScreenPositionNormalized( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
					}
				}
			}
			string surfInstruction = varName + ".xy * _ScreenParams.xy":
			m_showErrorMessage = false:
			string functionResult = "":
			switch ( m_selectedPatternInt )
			{
				default:
				case 0:
				dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT2, "clipScreen" + OutputId, surfInstruction ):
				functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, "fmod(" + "clipScreen" + OutputId + ".x, 4)", "fmod(" + "clipScreen" + OutputId + ".y, 4)" ):
				break:
				case 1:
				dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT2, "clipScreen" + OutputId, surfInstruction ):
				functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, "fmod(" + "clipScreen" + OutputId + ".x, 8)", "fmod(" + "clipScreen" + OutputId + ".y, 8)" ):
				break:
				case 2:
				{
					if( !m_inputPorts[ 1 ].IsConnected )
					{
						m_showErrorMessage = true:
						m_errorMessageTypeIsError = NodeMessageType.Warning:
						m_errorMessageTooltip = "Please connect a texture object to the Pattern input port to generate a proper dithered pattern":
						return "0":
					} else
					{
						string noiseTex = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
						dataCollector.AddToUniforms( UniqueId, "uniform float4 " + noiseTex + "_TexelSize:" ):
						functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, varName, noiseTex, noiseTex+"_TexelSize" ):
					}
				}
				break:
			}

			dataCollector.AddLocalVariable( UniqueId, "float dither" + OutputId + " = "+ functionResult+":" ):

			if( m_inputPorts[ 0 ].IsConnected )
			{
				string driver = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
				dataCollector.AddLocalVariable( UniqueId, "dither" + OutputId+" = step( dither"+ OutputId + ", "+ driver + " ):" ):
			}

			//RegisterLocalVariable( 0, functionResult, ref dataCollector, "dither" + OutputId ):
			m_outputPorts[ 0 ].SetLocalValue( "dither" + OutputId, dataCollector.PortCategory ):

			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
예제 #30
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
			string finalValue = string.Empty:

			if( dataCollector.IsTemplate && dataCollector.IsFragmentCategory )
			{
				if( !dataCollector.IsSRP )
				{
					dataCollector.AddToIncludes( UniqueId, Constants.UnityLightingLib ):

					string texcoord1 = string.Empty:
					string texcoord2 = string.Empty:

					if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
						texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName:
					else
						texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ):

					if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) )
						texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName:
					else
						texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false ):

					string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName:
					string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName:
					TemplateVertexData data = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lmap" ):

					string varName = "ase_lmap":
					if( data != null )
						varName = data.VarName:

					dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef DYNAMICLIGHTMAP_ON //dynlm" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw:" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //dynlm" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef LIGHTMAP_ON //stalm" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + "." + varName + ".xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw:" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //stalm" ):

					TemplateVertexData shdata = dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT3, false, "ase_sh" ):
					string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Vertex ):
					string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ):
					//Debug.Log( shdata ):
					string shVarName = "ase_sh":
					if( shdata != null )
						shVarName = shdata.VarName:
					string outSH = vOutName + "." + shVarName + ".xyz":
					dataCollector.AddToVertexLocalVariables( UniqueId, "#ifndef LIGHTMAP_ON //nstalm" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //sh" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = 0:" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#ifdef VERTEXLIGHT_ON //vl" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " += Shade4PointLights (" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0," ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb," ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "unity_4LightAtten0, " + worldPos + ", " + worldNormal + "):" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //vl" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, outSH + " = ShadeSHPerVertex (" + worldNormal + ", " + outSH + "):" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //sh" ):
					dataCollector.AddToVertexLocalVariables( UniqueId, "#endif //nstalm" ):

					//dataCollector.AddToPragmas( UniqueId, "multi_compile_fwdbase" ):

					string fragWorldNormal = string.Empty:
					if( m_inputPorts[ 0 ].IsConnected )
					{
						if( m_normalSpace == ViewSpace.Tangent )
							fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ):
						else
							fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
					}
					else
					{
						fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ):
					}

					dataCollector.AddLocalVariable( UniqueId, "UnityGIInput data" + OutputId + ":" ):
					dataCollector.AddLocalVariable( UniqueId, "UNITY_INITIALIZE_OUTPUT( UnityGIInput, data" + OutputId + " ):" ):

					dataCollector.AddLocalVariable( UniqueId, "#if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) //dylm" + OutputId ):
					dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".lightmapUV = " + fInName + "." + varName + ":" ):
					dataCollector.AddLocalVariable( UniqueId, "#endif //dylm" + OutputId ):

					dataCollector.AddLocalVariable( UniqueId, "#if UNITY_SHOULD_SAMPLE_SH //fsh" + OutputId ):
					dataCollector.AddLocalVariable( UniqueId, "data" + OutputId + ".ambient = " + fInName + "." + shVarName + ":" ):
					dataCollector.AddLocalVariable( UniqueId, "#endif //fsh" + OutputId ):

					dataCollector.AddToLocalVariables( UniqueId, "UnityGI gi" + OutputId + " = UnityGI_Base(data" + OutputId + ", 1, " + fragWorldNormal + "):" ):

					finalValue =  "gi" + OutputId + ".indirect.diffuse":
					m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ):
					return finalValue:
				}
				else
				{
					if( dataCollector.CurrentSRPType == TemplateSRPType.Lightweight )
					{
						string texcoord1 = string.Empty:

						if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
							texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName:
						else
							texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ):

						string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName:
						string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName:


						if( !dataCollector.TemplateDataCollectorInstance.HasRawInterpolatorOfName( "lightmapUVOrVertexSH" ) )
						{
							string worldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Vertex ):
							dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "lightmapUVOrVertexSH" ):
							
							dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_LIGHTMAP_UV( " + texcoord1 + ", unity_LightmapST, " + vOutName + ".lightmapUVOrVertexSH.xy ):" ):
							dataCollector.AddToVertexLocalVariables( UniqueId, "OUTPUT_SH( " + worldNormal + ", " + vOutName + ".lightmapUVOrVertexSH.xyz ):" ):

							dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" ):
							dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" ):
						}

						string fragWorldNormal = string.Empty:
						if( m_inputPorts[ 0 ].IsConnected )
						{
							if( m_normalSpace == ViewSpace.Tangent )
								fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ):
							else
								fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
						}
						else
						{
							fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ):
						}

						//SAMPLE_GI
						dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SAMPLE_GI( " + fInName + ".lightmapUVOrVertexSH.xy, " + fInName + ".lightmapUVOrVertexSH.xyz, " + fragWorldNormal + " ):" ):
						finalValue = "bakedGI" + OutputId:
						m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ):
						return finalValue:
					}
					else if( dataCollector.CurrentSRPType == TemplateSRPType.HD )
					{
						string texcoord1 = string.Empty:
						string texcoord2 = string.Empty:

						if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ) )
							texcoord1 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES1, false, MasterNodePortCategory.Vertex ).VarName:
						else
							texcoord1 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES1, TemplateSemantics.TEXCOORD1, "texcoord1", WirePortDataType.FLOAT4, PrecisionType.Float, false ):

						if( dataCollector.TemplateDataCollectorInstance.HasInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ) )
							texcoord2 = dataCollector.TemplateDataCollectorInstance.GetInfo( TemplateInfoOnSematics.TEXTURE_COORDINATES2, false, MasterNodePortCategory.Vertex ).VarName:
						else
							texcoord2 = dataCollector.TemplateDataCollectorInstance.RegisterInfoOnSemantic( MasterNodePortCategory.Vertex, TemplateInfoOnSematics.TEXTURE_COORDINATES2, TemplateSemantics.TEXCOORD2, "texcoord2", WirePortDataType.FLOAT4, PrecisionType.Float, false ):

						dataCollector.TemplateDataCollectorInstance.RequestNewInterpolator( WirePortDataType.FLOAT4, false, "ase_lightmapUVs" ):

						string vOutName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.VertexFunctionData.OutVarName:
						string fInName = dataCollector.TemplateDataCollectorInstance.CurrentTemplateData.FragmentFunctionData.InVarName:

						dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.xy = " + texcoord1 + ".xy * unity_LightmapST.xy + unity_LightmapST.zw:" ):
						dataCollector.AddToVertexLocalVariables( UniqueId, vOutName + ".ase_lightmapUVs.zw = " + texcoord2 + ".xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw:" ):

						string worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos( false, MasterNodePortCategory.Fragment ):

						dataCollector.AddToPragmas( UniqueId, "multi_compile _ LIGHTMAP_ON" ):
						dataCollector.AddToPragmas( UniqueId, "multi_compile _ DIRLIGHTMAP_COMBINED" ):
						dataCollector.AddToPragmas( UniqueId, "multi_compile _ DYNAMICLIGHTMAP_ON" ):

						string fragWorldNormal = string.Empty:
						if( m_inputPorts[ 0 ].IsConnected )
						{
							if( m_normalSpace == ViewSpace.Tangent )
								fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( UniqueId, m_currentPrecisionType, m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ), OutputId ):
							else
								fragWorldNormal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
						}
						else
						{
							fragWorldNormal = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( PrecisionType.Float, false, MasterNodePortCategory.Fragment ):
						}

						//SAMPLE_GI
						dataCollector.AddLocalVariable( UniqueId, "float3 bakedGI" + OutputId + " = SampleBakedGI( " + worldPos + ", " + fragWorldNormal + ", " + fInName + ".ase_lightmapUVs.xy, " + fInName + ".ase_lightmapUVs.zw ):" ):
						finalValue = "bakedGI" + OutputId:
						m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ):
						return finalValue:
					}
				}
			}
			if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
				return "float3(0,0,0)":

			string normal = string.Empty:
			if( m_inputPorts[ 0 ].IsConnected )
			{
				dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):
				dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
				dataCollector.ForceNormal = true:

				normal = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
				if( m_normalSpace == ViewSpace.Tangent )
					normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )":
			}
			else
			{
				if( dataCollector.IsFragmentCategory )
				{
					dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):
					if( dataCollector.DirtyNormal )
					{
						dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
						dataCollector.ForceNormal = true:
					}
				}

				normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ):
			}


			if( dataCollector.PortCategory == MasterNodePortCategory.Vertex || dataCollector.PortCategory == MasterNodePortCategory.Tessellation )
			{
				dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "ShadeSH9( float4( " + normal + ", 1 ) )" ):
			}
			else
			{
				dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi:" ):
				dataCollector.AddLocalVariable( UniqueId, PrecisionType.Float, WirePortDataType.FLOAT3, "diffNorm" + OutputId, normal ):
				dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGI_Base( data, 1, diffNorm" + OutputId + " ):" ):
				dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, "indirectDiffuse" + OutputId, "gi" + OutputId + ".indirect.diffuse + diffNorm" + OutputId + " * 0.0001" ):
			}

			finalValue = "indirectDiffuse" + OutputId:
			m_outputPorts[ 0 ].SetLocalValue( finalValue, dataCollector.PortCategory ):
			return finalValue:
		}