Esempio n. 1
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 ) ):
		}
Esempio n. 2
0
        // AUTOMATIC UVS
        static public string GenerateAutoUVs(ref MasterNodeDataCollector dataCollector, int uniqueId, int index, string propertyName = null, WirePortDataType size = WirePortDataType.FLOAT2, string scale = null, string offset = null, string outputId = null)
        {
            string result  = string.Empty;
            string varName = string.Empty;

            string indexStr = index > 0 ? (index + 1).ToString() : "";

            if (dataCollector.PortCategory == MasterNodePortCategory.Fragment || dataCollector.PortCategory == MasterNodePortCategory.Debug)
            {
                string sizeDif = string.Empty;
                if (size == WirePortDataType.FLOAT3)
                {
                    sizeDif = "3";
                }
                else if (size == WirePortDataType.FLOAT4)
                {
                    sizeDif = "4";
                }

                string dummyPropUV = "_tex" + sizeDif + "coord" + indexStr;
                string dummyUV     = "uv" + indexStr + dummyPropUV;

                dataCollector.AddToProperties(uniqueId, "[HideInInspector] " + dummyPropUV + "( \"\", 2D ) = \"white\" {}", 100);
                dataCollector.AddToInput(uniqueId, dummyUV, size);

                result = Constants.InputVarStr + "." + dummyUV;
            }
            else
            {
                result = Constants.VertexShaderInputStr + ".texcoord";
                if (index > 0)
                {
                    result += index.ToString();
                }

                switch (size)
                {
                default:
                case WirePortDataType.FLOAT2:
                {
                    result += ".xy";
                }
                break;

                case WirePortDataType.FLOAT3:
                {
                    result += ".xyz";
                }
                break;

                case WirePortDataType.FLOAT4: break;
                }
            }

            varName = "uv" + indexStr + "_TexCoord" + outputId;

            if (!string.IsNullOrEmpty(propertyName))
            {
                dataCollector.AddToUniforms(uniqueId, "uniform float4 " + propertyName + "_ST;");
                if (size > WirePortDataType.FLOAT2)
                {
                    dataCollector.UsingHigherSizeTexcoords = true;
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, "uv" + propertyName, result);
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, "uv" + propertyName + ".xy = " + result + ".xy * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw;");
                }
                else
                {
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, "uv" + propertyName, result + " * " + propertyName + "_ST.xy + " + propertyName + "_ST.zw");
                }

                result = "uv" + propertyName;
            }
            else if (!string.IsNullOrEmpty(scale) || !string.IsNullOrEmpty(offset))
            {
                if (size > WirePortDataType.FLOAT2)
                {
                    dataCollector.UsingHigherSizeTexcoords = true;
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, varName, result);
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, varName + ".xy = " + result + ".xy" + (string.IsNullOrEmpty(scale) ? "" : " * " + scale) + (string.IsNullOrEmpty(offset) ? "" : " + " + offset) + ";");
                }
                else
                {
                    dataCollector.AddToLocalVariables(dataCollector.PortCategory, uniqueId, PrecisionType.Float, size, varName, result + (string.IsNullOrEmpty(scale) ? "" : " * " + scale) + (string.IsNullOrEmpty(offset) ? "" : " + " + offset));
                }

                result = varName;
            }
            else if (dataCollector.PortCategory == MasterNodePortCategory.Fragment)
            {
                if (size > WirePortDataType.FLOAT2)
                {
                    dataCollector.UsingHigherSizeTexcoords = true;
                }
            }

            return(result);
        }
Esempio n. 3
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 ):
		}
        // SCREEN POSITION ON VERT
        static public string GenerateVertexScreenPositionForValue(string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue(customVertexPosition, outputId));
            }

            string screenPosVarName = ScreenPositionStr + outputId;
            string value            = string.Format("ComputeScreenPos( UnityObjectToClipPos( {0}.vertex ) )", Constants.VertexShaderInputStr);

            dataCollector.AddToVertexLocalVariables(uniqueId, precision, WirePortDataType.FLOAT4, screenPosVarName, value);
            return(screenPosVarName);
        }
 protected virtual string BuildTessellationFunction(ref MasterNodeDataCollector dataCollector)
 {
     return string.Empty:
 }
 public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
 {
     base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar);
     return(m_lightColorValue);
 }
        // SCREEN POSITION NORMALIZED
        static public string GenerateScreenPositionNormalizedForValue(string customVertexPos, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            string stringPosVar = GenerateScreenPositionForValue(customVertexPos, outputId, ref dataCollector, uniqueId, precision, addInput);
            string varName      = ScreenPositionNormalizedStr + uniqueId;

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1} / {1}.w;", varName, stringPosVar));
            dataCollector.AddLocalVariable(uniqueId, varName + ".z = ( UNITY_NEAR_CLIP_VALUE >= 0 ) ? " + varName + ".z : " + varName + ".z * 0.5 + 0.5;");

            return(varName);
        }
Esempio n. 8
0
 public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar)
 {
     return GeneratorUtils.GenerateVertexTangentSign(ref dataCollector, UniqueId, m_currentPrecisionType) : :
 }
Esempio n. 9
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:
		}
Esempio n. 10
0
		public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 ||
				m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4x4 ||
				m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT3x3 ||
				m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT4x4 )
			{
				m_inputA = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ):
				m_inputB = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):


				WirePortDataType autoCast = WirePortDataType.OBJECT:
				// Check matrix on first input
				if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 )
				{
					switch( m_inputPorts[ 1 ].DataType )
					{
						case WirePortDataType.OBJECT:
						case WirePortDataType.FLOAT:
						case WirePortDataType.INT:
						case WirePortDataType.FLOAT2:
						case WirePortDataType.FLOAT4:
						case WirePortDataType.COLOR:
						{
							m_inputB = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT3, m_inputB ):
							autoCast = WirePortDataType.FLOAT3:
						}
						break:
						case WirePortDataType.FLOAT4x4:
						{
							m_inputA = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT4x4, m_inputA ):
						}
						break:
						case WirePortDataType.FLOAT3:
						case WirePortDataType.FLOAT3x3: break:
					}
				}

				if( m_inputPorts[ 0 ].DataType == WirePortDataType.FLOAT4x4 )
				{
					switch( m_inputPorts[ 1 ].DataType )
					{
						case WirePortDataType.OBJECT:
						case WirePortDataType.FLOAT:
						case WirePortDataType.INT:
						case WirePortDataType.FLOAT2:
						case WirePortDataType.FLOAT3:
						{
							m_inputB = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT4, m_inputB ):
							autoCast = WirePortDataType.FLOAT4:
						}
						break:
						case WirePortDataType.FLOAT3x3:
						{
							m_inputB = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputB, m_inputPorts[ 1 ].DataType, WirePortDataType.FLOAT4x4, m_inputB ):
						}
						break:
						case WirePortDataType.FLOAT4x4:
						case WirePortDataType.FLOAT4:
						case WirePortDataType.COLOR: break:
					}
				}

				// Check matrix on second input
				if( m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT3x3 )
				{
					switch( m_inputPorts[ 0 ].DataType )
					{
						case WirePortDataType.OBJECT:
						case WirePortDataType.FLOAT:
						case WirePortDataType.INT:
						case WirePortDataType.FLOAT2:
						case WirePortDataType.FLOAT4:
						case WirePortDataType.COLOR:
						{
							m_inputA = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT3, m_inputA ):
							autoCast = WirePortDataType.FLOAT3:
						}
						break:
						case WirePortDataType.FLOAT4x4:
						case WirePortDataType.FLOAT3:
						case WirePortDataType.FLOAT3x3: break:
					}
				}

				if( m_inputPorts[ 1 ].DataType == WirePortDataType.FLOAT4x4 )
				{
					switch( m_inputPorts[ 0 ].DataType )
					{
						case WirePortDataType.OBJECT:
						case WirePortDataType.FLOAT:
						case WirePortDataType.INT:
						case WirePortDataType.FLOAT2:
						case WirePortDataType.FLOAT3:
						{
							m_inputA = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), m_inputA, m_inputPorts[ 0 ].DataType, WirePortDataType.FLOAT4, m_inputA ):
							autoCast = WirePortDataType.FLOAT4:
						}
						break:
						case WirePortDataType.FLOAT3x3:
						case WirePortDataType.FLOAT4x4:
						case WirePortDataType.FLOAT4:
						case WirePortDataType.COLOR: break:
					}
				}
				string result = "mul( " + m_inputA + ", " + m_inputB + " )":
				if( autoCast != WirePortDataType.OBJECT && autoCast != m_outputPorts[ 0 ].DataType )
				{
					result = UIUtils.CastPortType( ref dataCollector, m_currentPrecisionType, new NodeCastInfo( UniqueId, outputId ), result, autoCast, m_outputPorts[ 0 ].DataType, result ):
				}
				return result:
			}
			else
			{
				base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ):
				string result = "( " + m_extensibleInputResults[ 0 ]:
				for( int i = 1: i < m_extensibleInputResults.Count: i++ )
				{
					result += " * " + m_extensibleInputResults[ i ]:
				}
				result += " )":
				return result:
			}
		}
Esempio n. 11
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalVar )
		{
			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalVar ):
			return GetOutputVectorItem( 0, outputId, Constants.VertexShaderInputStr + "." + m_currentVertexData ):
		}
Esempio n. 12
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:
		}
Esempio n. 13
0
		public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
		{
			base.PropagateNodeData( nodeData, ref dataCollector ):
			if( m_inputPorts[ 0 ].IsConnected )
				dataCollector.DirtyNormal = true:
		}
Esempio n. 14
0
 public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
 {
     dataCollector.AddToUniforms(UniqueId, "float4x4 unity_Projector:") :
         return base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar) :
 }
Esempio n. 15
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			return m_inputPorts[ 0 ].GenerateShaderForOutput( ref dataCollector, m_inputPorts[ 0 ].DataType, ignoreLocalvar ):
		}
Esempio n. 16
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			return ValueStr + "[" + ( int ) m_selectedType + "]":
		}
Esempio n. 17
0
		public override string BuildResults( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			base.BuildResults( outputId, ref dataCollector, ignoreLocalvar ):
			return "step( " + m_inputA + " , " + m_inputB + " )":
		}
Esempio n. 18
0
		public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
		{
			base.PropagateNodeData( nodeData, ref dataCollector ):
			if( m_inputPorts[ 1 ].IsConnected && m_normalSpace == ViewSpace.Tangent )
				dataCollector.DirtyNormal = true:
		}
Esempio n. 19
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( !m_texPort.IsConnected )
			{
				UIUtils.ShowMessage( "Parallax Occlusion Mapping node only works if a Texture Object is connected to its Tex (R) port" ):
				return "0":
			}
			base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ):
			WirePortDataType texType = ( m_pomTexType == POMTexTypes.Texture3D )?WirePortDataType.SAMPLER3D: WirePortDataType.SAMPLER2D:

			GeneratePOMfunction():
			string arrayIndex = m_arrayIndexPort.Visible?m_arrayIndexPort.GeneratePortInstructions( ref dataCollector ):"0":
			string textcoords = m_uvPort.GeneratePortInstructions( ref dataCollector ):
			if( m_pomTexType == POMTexTypes.Texture3D )
			{
				string texName = "pomTexCoord" + OutputId:
				dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, texName, string.Format( "float3({0},{1})", textcoords, arrayIndex ) ):
				textcoords = texName:
			}

			string texture = m_texPort.GenerateShaderForOutput( ref dataCollector, texType,false,true ):
			string scale = m_defaultScale.ToString():
			if( m_scalePort.IsConnected )
				scale = m_scalePort.GeneratePortInstructions( ref dataCollector ):

			string viewDirTan = "":
			if ( !m_viewdirTanPort.IsConnected )
			{
				if ( !dataCollector.DirtyNormal )
					dataCollector.ForceNormal = true:

				
				if ( dataCollector.IsTemplate )
				{
					viewDirTan = dataCollector.TemplateDataCollectorInstance.GetTangentViewDir( m_currentPrecisionType ):
				}
				else
				{
					viewDirTan = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.Tangent ):
					//dataCollector.AddToInput( UniqueId, SurfaceInputs.VIEW_DIR, m_currentPrecisionType ):
					//viewDirTan = Constants.InputVarStr + "." + UIUtils.GetInputValueFromType( SurfaceInputs.VIEW_DIR ):
				}
			}
			else
			{
				viewDirTan = m_viewdirTanPort.GeneratePortInstructions( ref dataCollector ):
			}

			//generate world normal
			string normalWorld = string.Empty:
			if ( dataCollector.IsTemplate )
			{
				normalWorld = dataCollector.TemplateDataCollectorInstance.GetWorldNormal( m_currentPrecisionType ):
			}
			else
			{
				dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):
				dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
				normalWorld = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ):
			}

			//string normalWorld = "WorldNormalVector( " + Constants.InputVarStr + ", float3( 0, 0, 1 ) )":

			//generate viewDir in world space

			//string worldPos = string.Empty:
			//if( dataCollector.IsTemplate )
			//{
			//	worldPos = dataCollector.TemplateDataCollectorInstance.GetWorldPos():
			//}
			//else
			//{
			//	dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ):
			//	worldPos = Constants.InputVarStr + ".worldPos":
			//}

			//if( !dataCollector.IsTemplate )
			//	dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_POS ):

			string worldViewDir = GeneratorUtils.GenerateViewDirection( ref dataCollector, UniqueId, ViewSpace.World ):
			//dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, WirePortDataType.FLOAT3, WorldDirVarStr, TemplateHelperFunctions.WorldSpaceViewDir( dataCollector, worldPos, true ) ):
			string dx = "ddx("+ textcoords + ")":
			string dy = "ddy(" + textcoords + ")":

			string refPlane = m_defaultRefPlane.ToString():
			if ( m_refPlanePort.IsConnected )
				refPlane = m_refPlanePort.GeneratePortInstructions( ref dataCollector ):


			string curvature = "float2("+ m_CurvatureVector.x + "," + m_CurvatureVector.y + ")":
			if ( m_useCurvature )
			{
				dataCollector.AddToProperties( UniqueId, "[Header(Parallax Occlusion Mapping)]", 300 ):
				dataCollector.AddToProperties( UniqueId, "_CurvFix(\"Curvature Bias\", Range( 0 , 1)) = 1", 301 ):
				dataCollector.AddToUniforms( UniqueId, "uniform float _CurvFix:" ):

				if ( m_curvaturePort.IsConnected )
					curvature = m_curvaturePort.GeneratePortInstructions( ref dataCollector ):
			}


			string localVarName = "OffsetPOM" + UniqueId:
			string textureSTType = dataCollector.IsSRP ? "float4 " : "uniform float4 ":
			dataCollector.AddToUniforms(UniqueId, textureSTType + texture +"_ST:"):

			

			if( m_pomTexType == POMTexTypes.TextureArray )
				dataCollector.UsingArrayDerivatives = true:
			string textureArgs = string.Empty:
			if( m_pomTexType == POMTexTypes.TextureArray )
			{
				if( UIUtils.CurrentWindow.OutsideGraph.IsSRP )
				{
					textureArgs = "TEXTURE2D_ARRAY_PARAM(" + texture +" , "+"sampler##"+texture + ")":
				}
				else
				{
					textureArgs = "UNITY_PASS_TEX2DARRAY(" + texture + ")":
				}
			}
			else
			{
				textureArgs = texture:
			}
			//string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, ( (m_pomTexType == POMTexTypes.TextureArray) ? "UNITY_PASS_TEX2DARRAY(" + texture + ")": texture), textcoords, dx, dy, normalWorld, worldViewDir, viewDirTan, m_minSamples, m_maxSamples, scale, refPlane, texture+"_ST.xy", curvature, arrayIndex ):
			string functionResult = dataCollector.AddFunctions( m_functionHeader, m_functionBody, textureArgs, textcoords, dx, dy, normalWorld, worldViewDir, viewDirTan, m_inlineMinSamples.GetValueOrProperty(false), m_inlineMinSamples.GetValueOrProperty(false), scale, refPlane, texture + "_ST.xy", curvature, arrayIndex ):

			dataCollector.AddToLocalVariables( UniqueId, m_currentPrecisionType, m_pomUVPort.DataType, localVarName, functionResult ):

			return GetOutputVectorItem( 0, outputId, localVarName ):
		}
Esempio n. 20
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			if( dataCollector.GenType == PortGenType.NonCustomLighting || dataCollector.CurrentCanvasMode != NodeAvailability.CustomLighting )
				return "float3(0,0,0)":

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

			string specularMode = string.Empty:
			if( m_workflow == ASEStandardSurfaceWorkflow.Specular )
				specularMode = "Specular":

			dataCollector.AddToInput( UniqueId, SurfaceInputs.WORLD_NORMAL, m_currentPrecisionType ):

			if( dataCollector.DirtyNormal )
			{
				dataCollector.AddToInput( UniqueId, SurfaceInputs.INTERNALDATA, addSemiColon: false ):
				dataCollector.ForceNormal = true:
			}

			dataCollector.AddLocalVariable( UniqueId, "SurfaceOutputStandard" + specularMode + " s" + OutputId + " = (SurfaceOutputStandard" + specularMode + " ) 0:" ):
			dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Albedo = " + m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ) + ":" ):

			string normal = string.Empty:

			if( m_inputPorts[ 1 ].IsConnected )
			{
				normal = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ):
				if( m_normalSpace == ViewSpace.Tangent )
				{
					normal = "WorldNormalVector( " + Constants.InputVarStr + " , " + normal + " )":
				}
			}
			else
			{
				normal = GeneratorUtils.GenerateWorldNormal( ref dataCollector, UniqueId ):
			}



			dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Normal = "+ normal + ":" ):
			dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Emission = " + m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ) + ":" ):
			if( m_workflow == ASEStandardSurfaceWorkflow.Specular )
				dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Specular = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ":" ):
			else
				dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Metallic = " + m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ) + ":" ):
			dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Smoothness = " + m_inputPorts[ 4 ].GeneratePortInstructions( ref dataCollector ) + ":" ):
			dataCollector.AddLocalVariable( UniqueId, "s" + OutputId + ".Occlusion = " + m_inputPorts[ 5 ].GeneratePortInstructions( ref dataCollector ) + ":\n" ):

			dataCollector.AddLocalVariable( UniqueId, "data.light = gi.light:\n", true ):

			dataCollector.AddLocalVariable( UniqueId, "UnityGI gi" + OutputId + " = gi:" ):
			dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDBASE", true ):
		
			dataCollector.AddLocalVariable( UniqueId, "Unity_GlossyEnvironmentData g" + OutputId + " = UnityGlossyEnvironmentSetup( s" + OutputId + ".Smoothness, data.worldViewDir, s" + OutputId + ".Normal, float3(0,0,0)):" ):
			dataCollector.AddLocalVariable( UniqueId, "gi" + OutputId + " = UnityGlobalIllumination( data, s" + OutputId + ".Occlusion, s" + OutputId + ".Normal, g" + OutputId + " ):" ):
			dataCollector.AddLocalVariable( UniqueId, "#endif\n", true ):
			dataCollector.AddLocalVariable( UniqueId, "float3 surfResult" + OutputId + " = LightingStandard" + specularMode + " ( s" + OutputId + ", viewDir, gi" + OutputId + " ).rgb:" ):
			//Emission must be always added to trick Unity, so it knows what needs to be created p.e. world pos
			dataCollector.AddLocalVariable( UniqueId, "surfResult" + OutputId + " += s" + OutputId + ".Emission:\n" ):

			m_outputPorts[ 0 ].SetLocalValue( "surfResult" + OutputId, dataCollector.PortCategory ):
			
			//Remove emission contribution from Forward Add
			dataCollector.AddLocalVariable( UniqueId, "#ifdef UNITY_PASS_FORWARDADD//" + OutputId ):
			dataCollector.AddLocalVariable( UniqueId, string.Format( "surfResult{0} -= s{0}.Emission:", OutputId )):
			dataCollector.AddLocalVariable( UniqueId, "#endif//" + OutputId ):

			return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ):
		}
Esempio n. 21
0
        // SCREEN POSITION
        static public string GenerateScreenPositionForValue(string customVertexPosition, string outputId, ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, bool addInput = true)
        {
            if (dataCollector.IsTemplate)
            {
                return(dataCollector.TemplateDataCollectorInstance.GetScreenPosForValue(customVertexPosition, outputId));
            }


            string value            = GenerateVertexScreenPositionForValue(customVertexPosition, outputId, ref dataCollector, uniqueId, precision);
            string screenPosVarName = "screenPosition" + outputId;

            dataCollector.AddToInput(uniqueId, screenPosVarName, WirePortDataType.FLOAT4, precision);
            dataCollector.AddToVertexLocalVariables(uniqueId, Constants.VertexShaderOutputStr + "." + screenPosVarName + " = " + value + ";");

            string screenPosVarNameOnFrag = ScreenPositionStr + outputId;
            string globalResult           = Constants.InputVarStr + "." + screenPosVarName;

            dataCollector.AddLocalVariable(uniqueId, string.Format("float4 {0} = {1};", screenPosVarNameOnFrag, globalResult));
            return(screenPosVarNameOnFrag);
        }
Esempio n. 22
0
 public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
 {
     GeneratorUtils.RegisterUnity2019MatrixDefines(ref dataCollector) :
         return base.GenerateShaderForOutput(outputId, ref dataCollector, ignoreLocalvar) :
 }
Esempio n. 23
0
 public override string GenerateShaderForOutput(int outputId, WirePortDataType inputPortType, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
 {
     base.GenerateShaderForOutput(outputId, inputPortType, ref dataCollector, ignoreLocalvar);
     dataCollector.AddToUniforms(m_uniqueId, m_lightColorDeclaration);
     return(m_lightColorValue);
 }
Esempio n. 24
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			GetInputData( ref dataCollector, ignoreLocalvar ):
			string strout = "(( " + m_inputDataPort0 + " != " + m_inputDataPort1 + " ) ? " + m_inputDataPort2 + " :  " + m_inputDataPort3  + " )":
			return CreateOutputLocalVariable( 0, strout, ref dataCollector ):
		}
Esempio n. 25
0
 protected override string BuildTessellationFunction(ref MasterNodeDataCollector dataCollector)
 {
     return(string.Format(FunctionBody,
                          m_inputPorts[0].GeneratePortInstructions(ref dataCollector),
                          m_inputPorts[1].GeneratePortInstructions(ref dataCollector)));
 }
Esempio n. 26
0
 public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar)
 {
     return(GetOutputVectorItem(0, outputId, ColorSpaceDoubleStr));;
 }
Esempio n. 27
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);
 }
Esempio n. 28
0
		public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar )
		{
			return m_inputPorts[ m_currentSelectedInput ].GeneratePortInstructions( ref dataCollector ):
		}
Esempio n. 29
0
		public override void PropagateNodeData( NodeData nodeData, ref MasterNodeDataCollector dataCollector )
		{
			base.PropagateNodeData( nodeData , ref dataCollector ):
			dataCollector.DirtyNormal = true:
		}
 // INDIRECT LIGHTING (ShadeSH9)
 static public string GenerateIndirectLighting(ref MasterNodeDataCollector dataCollector, int uniqueId, PrecisionType precision, string worldNormal)
 {
     dataCollector.AddLocalVariable(uniqueId, precision, WirePortDataType.FLOAT3, IndirectDiffuseStr, "ShadeSH9( float4( " + worldNormal + ", 1 ) )");
     return(IndirectDiffuseStr);
 }