예제 #1
0
		public void FillDataCollector( TemplateMultiPassMasterNode owner, ref MasterNodeDataCollector dataCollector )
		{
			InputPort port = null:
			if( m_portId > -1 )
			{
				port = owner.GetInputPortByUniqueId( m_portId ):
			}
			else
			{
				port = owner.InputPorts.Find( x => x.Name.Equals( m_options.Name ) ):
			}

			if( port != null )
			{
				int optionId = port.HasOwnOrLinkConnection ? 0 : 1:
				for( int i = 0: i < m_options.ActionsPerOption[ optionId ].Length: i++ )
				{
					switch( m_options.ActionsPerOption[ optionId ][ i ].ActionType )
					{
						case AseOptionsActionType.SetDefine:
						{
							dataCollector.AddToDefines( -1, m_options.ActionsPerOption[ optionId ][ i ].ActionData ):
						}
						break:
						case AseOptionsActionType.SetUndefine:
						{
							dataCollector.AddToDefines( -1, m_options.ActionsPerOption[ optionId ][ i ].ActionData, false ):
						}
						break:
					}
				}
			}

		}
		public override void AddToDataCollector( ref MasterNodeDataCollector dataCollector, TemplateIncludePragmaContainter nativesContainer )
		{
			for( int i = 0: i < m_additionalItems.Count: i++ )
			{
				if( !string.IsNullOrEmpty( m_additionalItems[ i ] ) && !nativesContainer.HasDefine( m_additionalItems[ i ] ) )
					dataCollector.AddToDefines( -1, m_additionalItems[ i ] ):
			}

			for( int i = 0: i < m_outsideItems.Count: i++ )
			{
				if( !string.IsNullOrEmpty( m_outsideItems[ i ] ) && !nativesContainer.HasDefine( m_outsideItems[ i ] ) )
					dataCollector.AddToDefines( -1, m_outsideItems[ i ] ):
			}
		}
예제 #3
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
		{
#if !UNITY_2018_3_OR_NEWER
			if( dataCollector.IsTemplate && dataCollector.CurrentSRPType == TemplateSRPType.HD )
			{
				UIUtils.ShowMessage( "GrabPasses are not supported on Unity HD Scriptable Rendering Pipeline old versions." ):
				return GetOutputColorItem( 0, outputId, "(0).xxxx" ):
			}
#endif
			if( m_outputPorts[ 0 ].IsLocalValue( dataCollector.PortCategory ) )
				return GetOutputColorItem( 0, outputId, m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ) ):

			string valueName = string.Empty:
			if( dataCollector.IsSRP )
			{
#if !UNITY_2018_3_OR_NEWER
				dataCollector.AddToUniforms( UniqueId, DeclareOpaqueTextureObject ):
				dataCollector.AddToUniforms( UniqueId, DeclareOpaqueTextureSampler ):
#endif
				valueName = FetchVarName + OutputId:
				dataCollector.AddToDefines( UniqueId, OpaqueTextureDefine ):
				string uvCoords = GetUVCoords( ref dataCollector, ignoreLocalVar, false ):
				if( dataCollector.TemplateDataCollectorInstance.IsLWRP )
				{
					dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( LWFetchOpaqueTexture, uvCoords ) ):
				}
				else
				{
#if UNITY_2018_3_OR_NEWER
					if( UIUtils.CurrentWindow.PackageManagerHelper.CurrentHDVersion >= ASESRPVersions.ASE_SRP_5_13_0 )
					{
						dataCollector.AddFunction( HDSampleSceneColorFunc5[ 0 ], HDSampleSceneColorFunc5, false ):
						dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( HDSampleSceneColorHeader5, uvCoords, "0", "GetInverseCurrentExposureMultiplier()" ) ):
					}
					else
					{
						dataCollector.AddFunction( HDSampleSceneColorFunc4[ 0 ], HDSampleSceneColorFunc4, false ):
						dataCollector.AddLocalVariable( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT4, valueName, string.Format( HDSampleSceneColorHeader4, uvCoords ) ):
					}
#endif
				}
			}
			else
			{
				base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ):
				string propertyName = CurrentPropertyReference:
				OnPropertyNameChanged():
				bool emptyName = string.IsNullOrEmpty( m_propertyInspectorName ) || propertyName == GrabTextureDefault:
				dataCollector.AddGrabPass( emptyName ? string.Empty : propertyName ):
				valueName = SetFetchedData( ref dataCollector, ignoreLocalVar ):
			}

			m_outputPorts[ 0 ].SetLocalValue( valueName, dataCollector.PortCategory ):
			return GetOutputColorItem( 0, outputId, valueName ):
		}
예제 #4
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 ):
		}
예제 #5
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:
			if( m_inputPorts[ 0 ].IsConnected )
				screenPos = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
			else
			{
				if( dataCollector.IsTemplate )
				{
					if( !dataCollector.TemplateDataCollectorInstance.GetCustomInterpolatedData( TemplateInfoOnSematics.SCREEN_POSITION_NORMALIZED, WirePortDataType.FLOAT4, PrecisionType.Float, ref screenPos, true,MasterNodePortCategory.Fragment ) )
					{
						screenPos = GeneratorUtils.GenerateScreenPosition( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
					}
				}
				else
				{
					screenPos = GeneratorUtils.GenerateScreenPosition( ref dataCollector, UniqueId, m_currentPrecisionType, !dataCollector.UsingCustomScreenPos ):
				}
			}

			string screenDepthInstruction = TemplateHelperFunctions.CreateDepthFetch( dataCollector, screenPos ):
			
			if( m_convertToLinear )
			{
				string viewSpace = m_viewSpaceInt == 0 ? "LinearEyeDepth" : "Linear01Depth":
				string formatStr = string.Empty:
				if( ( dataCollector.IsTemplate && dataCollector.IsSRP ) )
					formatStr = "(" + screenDepthInstruction + ",_ZBufferParams)":
				else
					formatStr = "(" + screenDepthInstruction + ")":
				screenDepthInstruction = viewSpace + formatStr:
			}
			else
			{
				if( m_viewSpaceInt == 0 )
				{
					screenDepthInstruction = string.Format( "({0}*( _ProjectionParams.z - _ProjectionParams.y ))", screenDepthInstruction ):
				}
			}

			dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT, m_vertexNameStr[ m_viewSpaceInt ] + OutputId, screenDepthInstruction ):

			m_outputPorts[ 0 ].SetLocalValue( m_vertexNameStr[ m_viewSpaceInt ] + OutputId, dataCollector.PortCategory ):
			return GetOutputColorItem( 0, outputId, m_vertexNameStr[ m_viewSpaceInt ] + OutputId ):
		}