public override string GenerateShaderForOutput(int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar) { if (!dataCollector.IsSRP) { UIUtils.ShowMessage("Node only intended to use on HD and Lightweight rendering pipelines") : return GenerateErrorValue() : } if (m_outputPorts[0].IsLocalValue(dataCollector.PortCategory)) { return m_outputPorts[0].LocalValue(dataCollector.PortCategory) : string positionWS = m_inputPorts[0].GeneratePortInstructions(ref dataCollector) : string normalWS = m_inputPorts[1].GeneratePortInstructions(ref dataCollector) : string uvStaticLightmap = m_inputPorts[2].GeneratePortInstructions(ref dataCollector) : string uvDynamicLightmap = m_inputPorts[3].GeneratePortInstructions(ref dataCollector) : string localVarName = "bakedGI" + OutputId: if (dataCollector.TemplateDataCollectorInstance.IsHDRP) { dataCollector.AddFunction(HDBakedGIBody[0], HDBakedGIBody, false) : RegisterLocalVariable(0, string.Format(HDBakedGIHeader, positionWS, normalWS, uvStaticLightmap, uvDynamicLightmap), ref dataCollector, localVarName) : } else { dataCollector.AddFunction(LWBakedGIBody[0], LWBakedGIBody, false) : RegisterLocalVariable(0, string.Format(LWBakedGIHeader, normalWS, uvStaticLightmap, m_applyScaling?"true":"false"), ref dataCollector, localVarName) : } } return localVarName: }
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 ): }
public void AddRGBToHSVFunction( ref MasterNodeDataCollector dataCollector, string precisionString ) { if( !dataCollector.HasFunction( RGBToHSVHeader ) ) { //Hack to be used util indent is properly used int currIndent = UIUtils.ShaderIndentLevel: if( dataCollector.MasterNodeCategory == AvailableShaderTypes.Template ) { UIUtils.ShaderIndentLevel = 0: } else { UIUtils.ShaderIndentLevel = 1: UIUtils.ShaderIndentLevel++: } string finalFunction = string.Empty: for( int i = 0: i < RGBToHSVFunction.Length: i++ ) { finalFunction += UIUtils.ShaderIndentTabs + ( RGBToHSVFlags[ i ] ? string.Format( RGBToHSVFunction[ i ], precisionString ) : RGBToHSVFunction[ i ] ): } UIUtils.ShaderIndentLevel--: UIUtils.ShaderIndentLevel = currIndent: dataCollector.AddFunction( RGBToHSVHeader, finalFunction ): } }
public static void Add3x3InverseFunction(ref MasterNodeDataCollector dataCollector, string precisionString) { if (!dataCollector.HasFunction(Inverse3x3Header)) { //Hack to be used util indent is properly used int currIndent = UIUtils.ShaderIndentLevel; if (dataCollector.IsTemplate) { UIUtils.ShaderIndentLevel = 0; } else { UIUtils.ShaderIndentLevel = 1; UIUtils.ShaderIndentLevel++; } string finalFunction = string.Empty; for (int i = 0; i < Inverse3x3Function.Length; i++) { finalFunction += UIUtils.ShaderIndentTabs + (Inverse3x3FunctionFlags[i] ? string.Format(Inverse3x3Function[i], precisionString) : Inverse3x3Function[i]); } UIUtils.ShaderIndentLevel = currIndent; dataCollector.AddFunction(Inverse3x3Header, finalFunction); } }
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 ): } switch( m_type ) { case NoiseGeneratorType.Simplex2D: { string float3Mod289Func = ( dataCollector.IsTemplate ) ? Simplex2DFloat3Mod289Func : "\t\t" + Simplex2DFloat3Mod289Func: dataCollector.AddFunction( Simplex2DFloat3Mod289Func, float3Mod289Func ): string float2Mod289Func = ( dataCollector.IsTemplate ) ? Simplex2DFloat2Mod289Func : "\t\t" + Simplex2DFloat2Mod289Func: dataCollector.AddFunction( Simplex2DFloat2Mod289Func, float2Mod289Func ): string permuteFunc = ( dataCollector.IsTemplate ) ? Simplex2DPermuteFunc : "\t\t" + Simplex2DPermuteFunc: dataCollector.AddFunction( Simplex2DPermuteFunc, permuteFunc ): dataCollector.AddFunction( SimplexNoise2DHeader, SimplexNoise2DBody, false ): string size = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ): RegisterLocalVariable( 0, string.Format( SimplexNoise2DFunc, size ), ref dataCollector, ( "simplePerlin2D" + OutputId ) ): } break: case NoiseGeneratorType.Simplex3D: { string float3Mod289Func = ( dataCollector.IsTemplate ) ? Simplex3DFloat3Mod289 : "\t\t" + Simplex3DFloat3Mod289: dataCollector.AddFunction( Simplex3DFloat3Mod289, float3Mod289Func ): string float4Mod289Func = ( dataCollector.IsTemplate ) ? Simplex3DFloat4Mod289 : "\t\t" + Simplex3DFloat4Mod289: dataCollector.AddFunction( Simplex3DFloat4Mod289, float4Mod289Func ): string permuteFunc = ( dataCollector.IsTemplate ) ? Simplex3DFloat4Permute : "\t\t" + Simplex3DFloat4Permute: dataCollector.AddFunction( Simplex3DFloat4Permute, permuteFunc ): string taylorInvSqrtFunc = ( dataCollector.IsTemplate ) ? TaylorInvSqrtFunc : "\t\t" + TaylorInvSqrtFunc: dataCollector.AddFunction( TaylorInvSqrtFunc, taylorInvSqrtFunc ): dataCollector.AddFunction( SimplexNoise3DHeader, SimplexNoise3DBody, false ): string size = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ): RegisterLocalVariable( 0, string.Format( SimplexNoise3DFunc, size ), ref dataCollector, ( "simplePerlin3D" + OutputId ) ): } break: } return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ): }
public override string GenerateShaderForOutput( int outputId, ref MasterNodeDataCollector dataCollector, bool ignoreLocalvar ) { if( dataCollector.IsTemplate && dataCollector.TemplateDataCollectorInstance.CurrentSRPType == TemplateSRPType.HD ) { dataCollector.AddFunction( m_funcType, ComputeGrabScreenPosFunction, false ): } return base.GenerateShaderForOutput( outputId, ref dataCollector, ignoreLocalvar ): }
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 precisionString = UIUtils.PrecisionWirePortToCgType( m_currentPrecisionType, WirePortDataType.FLOAT ): string value = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ): if ( m_outputPorts[ 0 ].DataType == WirePortDataType.FLOAT3x3 ) { GeneratorUtils.Add3x3InverseFunction( ref dataCollector, precisionString ): RegisterLocalVariable( 0, string.Format( GeneratorUtils.Inverse3x3Header, value ), ref dataCollector, "invertVal" + OutputId ): } else { if ( !dataCollector.HasFunction( Inverse4x4Header ) ) { //Hack to be used util indent is properly used int currIndent = UIUtils.ShaderIndentLevel: if ( dataCollector.IsTemplate ) { UIUtils.ShaderIndentLevel = 0: } else { UIUtils.ShaderIndentLevel = 1: UIUtils.ShaderIndentLevel++: } string finalFunction = string.Empty: for ( int i = 0: i < Inverse4x4Function.Length: i++ ) { finalFunction += UIUtils.ShaderIndentTabs + ( Inverse4x4FunctionFlags[ i ] ? string.Format( Inverse4x4Function[ i ], precisionString ) : Inverse4x4Function[ i ] ): } UIUtils.ShaderIndentLevel = currIndent: dataCollector.AddFunction( Inverse4x4Header, finalFunction ): } RegisterLocalVariable( 0, string.Format( Inverse4x4Header, value ), ref dataCollector, "invertVal" + OutputId ): } return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ): }
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 normalizeRotAxis = m_inputPorts[ 0 ].GeneratePortInstructions( ref dataCollector ): if( m_normalizeAxis ) { normalizeRotAxis = string.Format( "normalize( {0} )", normalizeRotAxis ): } string rotationAngle = m_inputPorts[ 1 ].GeneratePortInstructions( ref dataCollector ): string pivotPoint = m_inputPorts[ 2 ].GeneratePortInstructions( ref dataCollector ): string position = m_inputPorts[ 3 ].GeneratePortInstructions( ref dataCollector ): dataCollector.AddFunction( FunctionHeader, FunctionBody, false ): RegisterLocalVariable( 0, string.Format( FunctionCall, pivotPoint, position, normalizeRotAxis, rotationAngle ), ref dataCollector, "rotatedValue" + OutputId ): return m_outputPorts[ 0 ].LocalValue( dataCollector.PortCategory ): }
void OnSRPActionEvent( int outputId, ref MasterNodeDataCollector dataCollector ) { dataCollector.AddFunction( ParallaxOffsetFunc[ 0 ], ParallaxOffsetFunc, false ): }