{"TotalCount":116,"Files":[{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/ClassNodeType.cs","FileName":"ClassNodeType.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic class TextureNodeType : ClassNodeType\r\n{\r\n\tstring ImagePath;\r\n\r\n\tpublic TextureNodeType( TypeDescription type, string imagePath ) : base( type )\r\n\t{\r\n\t\tImagePath = imagePath;\r\n\t}\r\n\tpublic override INode CreateNode( IGraph graph )\r\n\t{\r\n\t\tvar node = base.CreateNode( graph );\r\n\t\tif ( node is ITextureParameterNode textureNode )\r\n\t\t{\r\n\t\t\ttextureNode.Image = ImagePath;\r\n\t\t}\r\n\t\treturn node;\r\n\t}\r\n}\r\n\r\npublic class ClassNodeType : INodeType\r\n{\r\n\tpublic virtual string Identifier =\u003E Type.FullName;\r\n\r\n\tpublic TypeDescription Type { get; }\r\n\tpublic DisplayInfo DisplayInfo { get; protected set; }\r\n\r\n\tpublic Menu.PathElement[] Path =\u003E Menu.GetSplitPath( DisplayInfo );\r\n\r\n\tpublic ClassNodeType( TypeDescription type )\r\n\t{\r\n\t\tType = type;\r\n\t\tif ( Type is not null )\r\n\t\t\tDisplayInfo = DisplayInfo.ForType( Type.TargetType );\r\n\t\telse\r\n\t\t\tDisplayInfo = new DisplayInfo();\r\n\t}\r\n\r\n\tpublic bool TryGetInput( Type valueType, out string name )\r\n\t{\r\n\t\tvar property = Type.Properties\r\n\t\t\t.Select( x =\u003E (Property: x, Attrib: x.GetCustomAttribute\u003CBaseNode.InputAttribute\u003E()) )\r\n\t\t\t.Where( x =\u003E x.Attrib != null )\r\n\t\t\t.FirstOrDefault( x =\u003E x.Attrib.Type?.IsAssignableFrom( valueType ) ?? true )\r\n\t\t\t.Property;\r\n\r\n\t\tname = property?.Name;\r\n\t\treturn name is not null;\r\n\t}\r\n\r\n\tpublic bool TryGetOutput( Type valueType, out string name )\r\n\t{\r\n\t\tvar property = Type.Properties\r\n\t\t\t.Select( x =\u003E (Property: x, Attrib: x.GetCustomAttribute\u003CBaseNode.OutputAttribute\u003E()) )\r\n\t\t\t.Where( x =\u003E x.Attrib != null )\r\n\t\t\t.FirstOrDefault( x =\u003E x.Attrib.Type?.IsAssignableTo( valueType ) ?? true )\r\n\t\t\t.Property;\r\n\r\n\t\tname = property?.Name;\r\n\t\treturn name is not null;\r\n\t}\r\n\r\n\tpublic virtual INode CreateNode( IGraph graph )\r\n\t{\r\n\t\tvar node = Type.Create\u003CBaseNode\u003E();\r\n\r\n\t\tnode.Graph = graph;\r\n\r\n\t\treturn node;\r\n\t}\r\n}\r\n\r\npublic class SubgraphNodeType : ClassNodeType\r\n{\r\n\tpublic override string Identifier =\u003E AssetPath;\r\n\tstring AssetPath { get; }\r\n\r\n\tpublic SubgraphNodeType( string assetPath, TypeDescription type ) : base( type )\r\n\t{\r\n\t\tAssetPath = assetPath;\r\n\t}\r\n\r\n\tpublic void SetDisplayInfo( ShaderGraph subgraph )\r\n\t{\r\n\t\tvar info = DisplayInfo;\r\n\t\tif ( !string.IsNullOrEmpty( subgraph.Title ) )\r\n\t\t\tinfo.Name = subgraph.Title;\r\n\t\telse\r\n\t\t\tinfo.Name = System.IO.Path.GetFileNameWithoutExtension( AssetPath );\r\n\t\tif ( !string.IsNullOrEmpty( subgraph.Description ) )\r\n\t\t\tinfo.Description = subgraph.Description;\r\n\t\tif ( !string.IsNullOrEmpty( subgraph.Icon ) )\r\n\t\t\tinfo.Icon = subgraph.Icon;\r\n\t\tif ( !string.IsNullOrEmpty( subgraph.Category ) )\r\n\t\t\tinfo.Group = subgraph.Category;\r\n\t\tDisplayInfo = info;\r\n\t}\r\n\r\n\tpublic override INode CreateNode( IGraph graph )\r\n\t{\r\n\t\tvar node = base.CreateNode( graph );\r\n\r\n\t\tif ( node is SubgraphNode subgraphNode )\r\n\t\t{\r\n\t\t\tsubgraphNode.SubgraphPath = AssetPath;\r\n\t\t\tsubgraphNode.OnNodeCreated();\r\n\t\t}\r\n\r\n\t\treturn node;\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/Compiler/ShaderTemplate.cs","FileName":"ShaderTemplate.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic static class ShaderTemplate\r\n{\r\n\t// Cache for template types to avoid expensive reflection lookups\r\n\tprivate static readonly Dictionary\u003Cstring, Type\u003E _templateTypeCache = new();\r\n\r\n\tpublic static string LoadTemplate( string templatePath )\r\n\t{\r\n\t\tif ( string.IsNullOrWhiteSpace( templatePath ) )\r\n\t\t\treturn SurfaceTemplate.Code;\r\n\r\n\t\tvar templateType = FindTemplateType( templatePath );\r\n\t\tif ( templateType != null )\r\n\t\t{\r\n\t\t\tvar property = templateType.GetProperty( \u0022Code\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\t\tif ( property != null \u0026\u0026 property.PropertyType == typeof( string ) )\r\n\t\t\t{\r\n\t\t\t\tvar templateCode = (string)property.GetValue( null );\r\n\t\t\t\tif ( !string.IsNullOrWhiteSpace( templateCode ) )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn templateCode;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tLog.Warning( $\u0022Shader template at \u0027{templatePath}\u0027 not found, using default template\u0022 );\r\n\t\treturn SurfaceTemplate.Code;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Find a template type by searching for classes with a Code property in the Editor.ShaderGraph namespace\r\n\t/// \u003C/summary\u003E\r\n\tprivate static Type FindTemplateType( string templatePath )\r\n\t{\r\n\t\tif ( string.IsNullOrWhiteSpace( templatePath ) )\r\n\t\t\treturn null;\r\n\r\n\t\t// Check cache first\r\n\t\tif ( _templateTypeCache.TryGetValue( templatePath, out var cachedType ) )\r\n\t\t\treturn cachedType;\r\n\r\n\t\t// Extract class name from file path as a hint\r\n\t\tstring className = Path.GetFileNameWithoutExtension( templatePath );\r\n\r\n\t\tstring[] searchNamespaces = [ \u0022Editor.ShaderGraphExtras\u0022 ];\r\n\r\n\t\ttry\r\n\t\t{\r\n\t\t\tforeach ( var assembly in AppDomain.CurrentDomain.GetAssemblies() )\r\n\t\t\t{\r\n\t\t\t\ttry\r\n\t\t\t\t{\r\n\t\t\t\t\t// First try exact class name match in known namespaces\r\n\t\t\t\t\tforeach ( var ns in searchNamespaces )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar templateType = assembly.GetType( $\u0022{ns}.{className}\u0022 );\r\n\t\t\t\t\t\tif ( templateType != null \u0026\u0026 HasCodeProperty( templateType ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_templateTypeCache[templatePath] = templateType;\r\n\t\t\t\t\t\t\treturn templateType;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Search types in known namespaces for one whose name contains the filename\r\n\t\t\t\t\tforeach ( var type in assembly.GetTypes() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( !type.IsClass || !type.IsPublic || !HasCodeProperty( type ) )\r\n\t\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\t\tif ( searchNamespaces.Contains( type.Namespace ) \u0026\u0026\r\n\t\t\t\t\t\t\ttype.Name.Contains( className, StringComparison.OrdinalIgnoreCase ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_templateTypeCache[templatePath] = type;\r\n\t\t\t\t\t\t\treturn type;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Fallback: search all types for exact class name match\r\n\t\t\t\t\tforeach ( var type in assembly.GetTypes() )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( type.Name == className \u0026\u0026 HasCodeProperty( type ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t_templateTypeCache[templatePath] = type;\r\n\t\t\t\t\t\t\treturn type;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tcatch { continue; }\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch { }\r\n\r\n\t\t// Cache null result to avoid repeated failed lookups\r\n\t\t_templateTypeCache[templatePath] = null;\r\n\t\treturn null;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Check if a type has a static Code property that returns a string\r\n\t/// \u003C/summary\u003E\r\n\tprivate static bool HasCodeProperty( Type type )\r\n\t{\r\n\t\tvar property = type.GetProperty( \u0022Code\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\treturn property != null \u0026\u0026 property.PropertyType == typeof( string );\r\n\t}\r\n\r\n\tpublic static Dictionary\u003Cstring, bool\u003E GetTemplateFeatures( string templatePath )\r\n\t{\r\n\t\tvar features = new Dictionary\u003Cstring, bool\u003E();\r\n\r\n\t\tif ( string.IsNullOrWhiteSpace( templatePath ) )\r\n\t\t\treturn features;\r\n\r\n\t\tvar templateType = FindTemplateType( templatePath );\r\n\t\tif ( templateType != null )\r\n\t\t{\r\n\t\t\tvar property = templateType.GetProperty( \u0022Features\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\t\tif ( property != null \u0026\u0026 property.PropertyType == typeof( Dictionary\u003Cstring, bool\u003E ) )\r\n\t\t\t{\r\n\t\t\t\tvar templateFeatures = (Dictionary\u003Cstring, bool\u003E)property.GetValue( null );\r\n\t\t\t\tif ( templateFeatures != null )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn templateFeatures;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn features;\r\n\t}\r\n\r\n\tpublic static Dictionary\u003Cstring, bool\u003E GetShadingModelFeatures( string shadingModelPath )\r\n\t{\r\n\t\tvar features = new Dictionary\u003Cstring, bool\u003E();\r\n\r\n\t\tif ( string.IsNullOrWhiteSpace( shadingModelPath ) )\r\n\t\t\treturn features;\r\n\r\n\t\tvar shadingModelType = FindTemplateType( shadingModelPath );\r\n\t\tif ( shadingModelType != null )\r\n\t\t{\r\n\t\t\tvar property = shadingModelType.GetProperty( \u0022Features\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\t\tif ( property != null \u0026\u0026 property.PropertyType == typeof( Dictionary\u003Cstring, bool\u003E ) )\r\n\t\t\t{\r\n\t\t\t\tvar shadingModelFeatures = (Dictionary\u003Cstring, bool\u003E)property.GetValue( null );\r\n\t\t\t\tif ( shadingModelFeatures != null )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn shadingModelFeatures;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn features;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Load a custom shading model from a class with static Code and Include properties.\r\n\t/// Code: The pixel shader return statement (e.g., \u0022return ShadingModelToon::Shade( m );\u0022)\r\n\t/// Include: Optional HLSL include path for the shading model implementation\r\n\t/// \u003C/summary\u003E\r\n\tpublic static (string Code, string Include) LoadShadingModel( string shadingModelPath )\r\n\t{\r\n\t\tif ( string.IsNullOrWhiteSpace( shadingModelPath ) )\r\n\t\t\treturn (\u0022return ShadingModelStandard::Shade( m );\u0022, null);\r\n\r\n\t\tvar shadingModelType = FindTemplateType( shadingModelPath );\r\n\t\tif ( shadingModelType != null )\r\n\t\t{\r\n\t\t\tvar codeProperty = shadingModelType.GetProperty( \u0022Code\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\t\tif ( codeProperty != null \u0026\u0026 codeProperty.PropertyType == typeof( string ) )\r\n\t\t\t{\r\n\t\t\t\tvar shadingModelCode = (string)codeProperty.GetValue( null );\r\n\t\t\t\tif ( !string.IsNullOrWhiteSpace( shadingModelCode ) )\r\n\t\t\t\t{\r\n\t\t\t\t\t// Check for optional Include property\r\n\t\t\t\t\tstring includePath = null;\r\n\t\t\t\t\tvar includeProperty = shadingModelType.GetProperty( \u0022Include\u0022, BindingFlags.Public | BindingFlags.Static );\r\n\t\t\t\t\tif ( includeProperty != null \u0026\u0026 includeProperty.PropertyType == typeof( string ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tincludePath = (string)includeProperty.GetValue( null );\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn (shadingModelCode, includePath);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tLog.Warning( $\u0022Shading model at \u0027{shadingModelPath}\u0027 not found, using default Lit shading model\u0022 );\r\n\t\treturn (\u0022return ShadingModelStandard::Shade( m );\u0022, null);\r\n\t}\r\n\r\n\t[Function( \u0022ColorBurn_blend\u0022 )]\r\n\tpublic static string ColorBurn_blend =\u003E @\u0022\r\nfloat ColorBurn_blend( float a, float b )\r\n{\r\n    if ( a \u003E= 1.0f ) return 1.0f;\r\n    if ( b \u003C= 0.0f ) return 0.0f;\r\n    return 1.0f - saturate( ( 1.0f - a ) / b );\r\n}\r\n\r\nfloat3 ColorBurn_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        ColorBurn_blend( a.r, b.r ),\r\n        ColorBurn_blend( a.g, b.g ),\r\n        ColorBurn_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 ColorBurn_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        ColorBurn_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? ColorBurn_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022LinearBurn_blend\u0022 )]\r\n\tpublic static string LinearBurn_blend =\u003E @\u0022\r\nfloat LinearBurn_blend( float a, float b )\r\n{\r\n    return max( 0.0f, a \u002B b - 1.0f );\r\n}\r\n\r\nfloat3 LinearBurn_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        LinearBurn_blend( a.r, b.r ),\r\n        LinearBurn_blend( a.g, b.g ),\r\n        LinearBurn_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 LinearBurn_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        LinearBurn_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? LinearBurn_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022ColorDodge_blend\u0022 )]\r\n\tpublic static string ColorDodge_blend =\u003E @\u0022\r\nfloat ColorDodge_blend( float a, float b )\r\n{\r\n    if ( a \u003C= 0.0f ) return 0.0f;\r\n    if ( b \u003E= 1.0f ) return 1.0f;\r\n    return saturate( a / ( 1.0f - b ) );\r\n}\r\n\r\nfloat3 ColorDodge_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        ColorDodge_blend( a.r, b.r ),\r\n        ColorDodge_blend( a.g, b.g ),\r\n        ColorDodge_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 ColorDodge_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        ColorDodge_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? ColorDodge_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022LinearDodge_blend\u0022 )]\r\n\tpublic static string LinearDodge_blend =\u003E @\u0022\r\nfloat LinearDodge_blend( float a, float b )\r\n{\r\n    return min( 1.0f, a \u002B b );\r\n}\r\n\r\nfloat3 LinearDodge_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        LinearDodge_blend( a.r, b.r ),\r\n        LinearDodge_blend( a.g, b.g ),\r\n        LinearDodge_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 LinearDodge_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        LinearDodge_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? LinearDodge_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Overlay_blend\u0022 )]\r\n\tpublic static string Overlay_blend =\u003E @\u0022\r\nfloat Overlay_blend( float a, float b )\r\n{\r\n    if ( a \u003C= 0.5f )\r\n        return 2.0f * a * b;\r\n    else\r\n        return 1.0f - 2.0f * ( 1.0f - a ) * ( 1.0f - b );\r\n}\r\n\r\nfloat3 Overlay_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        Overlay_blend( a.r, b.r ),\r\n        Overlay_blend( a.g, b.g ),\r\n        Overlay_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 Overlay_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        Overlay_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? Overlay_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022SoftLight_blend\u0022 )]\r\n\tpublic static string SoftLight_blend =\u003E @\u0022\r\nfloat SoftLight_blend( float a, float b )\r\n{\r\n    if ( b \u003C= 0.5f )\r\n        return 2.0f * a * b \u002B a * a * ( 1.0f * 2.0f * b );\r\n    else \r\n        return sqrt( a ) * ( 2.0f * b - 1.0f ) \u002B 2.0f * a * (1.0f - b);\r\n}\r\n\r\nfloat3 SoftLight_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        SoftLight_blend( a.r, b.r ),\r\n        SoftLight_blend( a.g, b.g ),\r\n        SoftLight_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 SoftLight_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        SoftLight_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? SoftLight_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022HardLight_blend\u0022 )]\r\n\tpublic static string HardLight_blend =\u003E @\u0022\r\nfloat HardLight_blend( float a, float b )\r\n{\r\n    if(b \u003C= 0.5f)\r\n        return 2.0f * a * b;\r\n    else\r\n        return 1.0f - 2.0f * (1.0f - a) * (1.0f - b);\r\n}\r\n\r\nfloat3 HardLight_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        HardLight_blend( a.r, b.r ),\r\n        HardLight_blend( a.g, b.g ),\r\n        HardLight_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 HardLight_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        HardLight_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? HardLight_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022VividLight_blend\u0022 )]\r\n\tpublic static string VividLight_blend =\u003E @\u0022\r\nfloat VividLight_blend( float a, float b )\r\n{\r\n    if ( b \u003C= 0.5f )\r\n\t{\r\n\t\tb *= 2.0f;\r\n\t\tif ( a \u003E= 1.0f ) return 1.0f;\r\n\t\tif ( b \u003C= 0.0f ) return 0.0f;\r\n\t\treturn 1.0f - saturate( ( 1.0f - a ) / b );\r\n\t}\r\n    else\r\n\t{\r\n\t\tb = 2.0f * ( b - 0.5f );\r\n\t\tif ( a \u003C= 0.0f ) return 0.0f;\r\n\t\tif ( b \u003E= 1.0f ) return 1.0f;\r\n\t\treturn saturate( a / ( 1.0f - b ) );\r\n\t}\r\n}\r\n\r\nfloat3 VividLight_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        VividLight_blend( a.r, b.r ),\r\n        VividLight_blend( a.g, b.g ),\r\n        VividLight_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 VividLight_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        VividLight_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? VividLight_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022LinearLight_blend\u0022 )]\r\n\tpublic static string LinearLight_blend =\u003E @\u0022\r\nfloat LinearLight_blend( float a, float b )\r\n{\r\n    if ( b \u003C= 0.5f )\r\n\t{\r\n\t\tb *= 2.0f;\r\n\t\treturn max( 0.0f, a \u002B b - 1.0f );\r\n\t}\r\n    else\r\n\t{\r\n\t\tb = 2.0f * ( b - 0.5f );\r\n\t\treturn min( 1.0f, a \u002B b );\r\n\t}\r\n}\r\n\r\nfloat3 LinearLight_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        LinearLight_blend( a.r, b.r ),\r\n        LinearLight_blend( a.g, b.g ),\r\n        LinearLight_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 LinearLight_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        LinearLight_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? LinearLight_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022HardMix_blend\u0022 )]\r\n\tpublic static string HardMix_blend =\u003E @\u0022\r\nfloat HardMix_blend( float a, float b )\r\n{\r\n    if(a \u002B b \u003E= 1.0f) return 1.0f;\r\n    else return 0.0f;\r\n}\r\n\r\nfloat3 HardMix_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        HardMix_blend( a.r, b.r ),\r\n        HardMix_blend( a.g, b.g ),\r\n        HardMix_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 HardMix_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        HardMix_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? HardMix_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Divide_blend\u0022 )]\r\n\tpublic static string Divide_blend =\u003E @\u0022\r\nfloat Divide_blend( float a, float b )\r\n{\r\n    if( b \u003E 0.0f )\r\n        return saturate( a / b );\r\n    else\r\n        return 0.0f;\r\n}\r\n\r\nfloat3 Divide_blend( float3 a, float3 b )\r\n{\r\n    return float3(\r\n        Divide_blend( a.r, b.r ),\r\n        Divide_blend( a.g, b.g ),\r\n        Divide_blend( a.b, b.b )\r\n\t);\r\n}\r\n\r\nfloat4 Divide_blend( float4 a, float4 b, bool blendAlpha = false )\r\n{\r\n    return float4(\r\n        Divide_blend( a.rgb, b.rgb ).rgb,\r\n        blendAlpha ? Divide_blend( a.a, b.a ) : max( a.a, b.a )\r\n    );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022RGB2HSV\u0022 )]\r\n\tpublic static string RGB2HSV =\u003E @\u0022\r\nfloat3 RGB2HSV( float3 c )\r\n{\r\n    float4 K = float4( 0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0 );\r\n    float4 p = lerp( float4( c.bg, K.wz ), float4( c.gb, K.xy ), step( c.b, c.g ) );\r\n    float4 q = lerp( float4( p.xyw, c.r ), float4( c.r, p.yzx ), step( p.x, c.r ) );\r\n\r\n    float d = q.x - min( q.w, q.y );\r\n    float e = 1.0e-10;\r\n    return float3( abs( q.z \u002B ( q.w - q.y ) / ( 6.0 * d \u002B e ) ), d / ( q.x \u002B e ), q.x );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022HSV2RGB\u0022 )]\r\n\tpublic static string HSV2RGB =\u003E @\u0022\r\nfloat3 HSV2RGB( float3 c )\r\n{\r\n    float4 K = float4( 1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0 );\r\n    float3 p = abs( frac( c.xxx \u002B K.xyz ) * 6.0 - K.www );\r\n    return c.z * lerp( K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y );\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022TexTriplanar_Color\u0022 )]\r\n\tpublic static string TexTriplanar_Color =\u003E @\u0022\r\nfloat4 TexTriplanar_Color( in Texture2D tTex, in SamplerState sSampler, float3 vPosition, float3 vNormal )\r\n{\r\n\tfloat2 uvX = vPosition.zy;\r\n\tfloat2 uvY = vPosition.xz;\r\n\tfloat2 uvZ = vPosition.xy;\r\n\r\n\tfloat3 triblend = saturate(pow(abs(vNormal), 4));\r\n\ttriblend /= max(dot(triblend, half3(1,1,1)), 0.0001);\r\n\r\n\thalf3 axisSign = vNormal \u003C 0 ? -1 : 1;\r\n\r\n\tuvX.x *= axisSign.x;\r\n\tuvY.x *= axisSign.y;\r\n\tuvZ.x *= -axisSign.z;\r\n\r\n\tfloat4 colX = Tex2DS( tTex, sSampler, uvX );\r\n\tfloat4 colY = Tex2DS( tTex, sSampler, uvY );\r\n\tfloat4 colZ = Tex2DS( tTex, sSampler, uvZ );\r\n\r\n\treturn colX * triblend.x \u002B colY * triblend.y \u002B colZ * triblend.z;\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022TexTriplanar_Normal\u0022 )]\r\n\tpublic static string TexTriplanar_Normal =\u003E @\u0022\r\nfloat3 TexTriplanar_Normal( in Texture2D tTex, in SamplerState sSampler, float3 vPosition, float3 vNormal )\r\n{\r\n\tfloat2 uvX = vPosition.zy;\r\n\tfloat2 uvY = vPosition.xz;\r\n\tfloat2 uvZ = vPosition.xy;\r\n\r\n\tfloat3 triblend = saturate( pow( abs( vNormal ), 4 ) );\r\n\ttriblend /= max( dot( triblend, half3( 1, 1, 1 ) ), 0.0001 );\r\n\r\n\thalf3 axisSign = vNormal \u003C 0 ? -1 : 1;\r\n\r\n\tuvX.x *= axisSign.x;\r\n\tuvY.x *= axisSign.y;\r\n\tuvZ.x *= -axisSign.z;\r\n\r\n\tfloat3 tnormalX = DecodeNormal( Tex2DS( tTex, sSampler, uvX ).xyz );\r\n\tfloat3 tnormalY = DecodeNormal( Tex2DS( tTex, sSampler, uvY ).xyz );\r\n\tfloat3 tnormalZ = DecodeNormal( Tex2DS( tTex, sSampler, uvZ ).xyz );\r\n\r\n\ttnormalX.x *= axisSign.x;\r\n\ttnormalY.x *= axisSign.y;\r\n\ttnormalZ.x *= -axisSign.z;\r\n\r\n\ttnormalX = half3( tnormalX.xy \u002B vNormal.zy, vNormal.x );\r\n\ttnormalY = half3( tnormalY.xy \u002B vNormal.xz, vNormal.y );\r\n\ttnormalZ = half3( tnormalZ.xy \u002B vNormal.xy, vNormal.z );\r\n\r\n\treturn normalize(\r\n\t\ttnormalX.zyx * triblend.x \u002B\r\n\t\ttnormalY.xzy * triblend.y \u002B\r\n\t\ttnormalZ.xyz * triblend.z \u002B\r\n\t\tvNormal\r\n\t);\r\n}\r\n\u0022;\r\n\t[Function( \u0022Quaternion_FromAngles\u0022 )]\r\n\tpublic static string Quaternion_FromAngles =\u003E @\u0022\r\nfloat4 Quaternion_FromAngles( float3 vAngles )\r\n{\r\n\tfloat4 rot = { 0.0, 0.0, 0.0, 1.0 };\r\n\r\n\tconst float ANGLE_CONVERSION = 3.14159265 / 360.0;\r\n\r\n\tfloat pitch = vAngles.x * ANGLE_CONVERSION;\r\n\tfloat yaw = vAngles.y * ANGLE_CONVERSION;\r\n\tfloat roll = vAngles.z * ANGLE_CONVERSION;\r\n\r\n\tfloat sp = sin( pitch );\r\n\tfloat cp = cos( pitch );\r\n\r\n\tfloat sy = sin( yaw );\r\n\tfloat cy = cos( yaw );\r\n\r\n\tfloat sr = sin( roll );\r\n\tfloat cr = cos( roll );\r\n\r\n\tfloat srXcp = sr * cp;\r\n\tfloat crXsp = cr * sp;\r\n\r\n\trot.x = srXcp * cy - crXsp * sy; // X\r\n\trot.y = crXsp * cy \u002B srXcp * sy; // Y\r\n\r\n\tfloat crXcp = cr * cp;\r\n\tfloat srXsp = sr * sp;\r\n\r\n\trot.z = crXcp * sy - srXsp * cy; // Z\r\n\trot.w = crXcp * cy \u002B srXsp * sy; // W (real component)\r\n\r\n\treturn rot;\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Matrix_Identity\u0022 )]\r\n\tpublic static string Matrix_Identity =\u003E @\u0022\r\nfloat4x4 Matrix_Identity()\r\n{\r\n\treturn\r\n\t{\r\n\t\t1.0, 0.0, 0.0, 0.0,\r\n\t\t0.0, 1.0, 0.0, 0.0,\r\n\t\t0.0, 0.0, 1.0, 0.0,\r\n\t\t0.0, 0.0, 0.0, 1.0\r\n\t};\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Matrix_FromQuaternion\u0022 )]\r\n\tpublic static string Matrix_FromQuaternion =\u003E @\u0022\r\nfloat4x4 Matrix_FromQuaternion( float4 qRotation )\r\n{\r\n\tfloat xx = qRotation.x * qRotation.x;\r\n\tfloat yy = qRotation.y * qRotation.y;\r\n\tfloat zz = qRotation.z * qRotation.z;\r\n\r\n\tfloat xy = qRotation.x * qRotation.y;\r\n\tfloat wz = qRotation.z * qRotation.w;\r\n\tfloat xz = qRotation.z * qRotation.x;\r\n\tfloat wy = qRotation.y * qRotation.w;\r\n\tfloat yz = qRotation.y * qRotation.z;\r\n\tfloat wx = qRotation.x * qRotation.w;\r\n\r\n\tfloat4x4 result =\r\n\t{\r\n\t\t1.0, 0.0, 0.0, 0.0,\r\n\t\t0.0, 1.0, 0.0, 0.0,\r\n\t\t0.0, 0.0, 1.0, 0.0,\r\n\t\t0.0, 0.0, 0.0, 1.0\r\n\t};\r\n\r\n\tresult._11 = 1.0 - 2.0 * (yy \u002B zz);\r\n\tresult._21 = 2.0 * (xy \u002B wz);\r\n\tresult._31 = 2.0 * (xz - wy);\r\n\r\n\tresult._12 = 2.0 * (xy - wz);\r\n\tresult._22 = 1.0 - 2.0 * (zz \u002B xx);\r\n\tresult._32 = 2.0 * (yz \u002B wx);\r\n\r\n\tresult._13 = 2.0 * (xz \u002B wy);\r\n\tresult._23 = 2.0 * (yz - wx);\r\n\tresult._33 = 1.0 - 2.0 * (yy \u002B xx);\r\n\r\n\treturn result;\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Matrix_FromScale\u0022 )]\r\n\tpublic static string Matrix_FromScale =\u003E @\u0022\r\nfloat4x4 Matrix_FromScale( float3 vScale )\r\n{\r\n\tfloat4x4 result =\r\n\t{\r\n\t\t1.0, 0.0, 0.0, 0.0,\r\n\t\t0.0, 1.0, 0.0, 0.0,\r\n\t\t0.0, 0.0, 1.0, 0.0,\r\n\t\t0.0, 0.0, 0.0, 1.0\r\n\t};\r\n\r\n\tresult._11 = vScale.x;\r\n\tresult._22 = vScale.y;\r\n\tresult._33 = vScale.z;\r\n\r\n\treturn result;\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Matrix_FromTranslation\u0022 )]\r\n\tpublic static string Matrix_FromTranslation =\u003E @\u0022\r\nfloat4x4 Matrix_FromTranslation( float3 vTranslation )\r\n{\r\n\tfloat4x4 result =\r\n\t{\r\n\t\t1.0, 0.0, 0.0, 0.0,\r\n\t\t0.0, 1.0, 0.0, 0.0,\r\n\t\t0.0, 0.0, 1.0, 0.0,\r\n\t\t0.0, 0.0, 0.0, 1.0\r\n\t};\r\n\r\n\tresult._14 = vTranslation.x;\r\n\tresult._24 = vTranslation.y;\r\n\tresult._34 = vTranslation.z;\r\n\r\n\treturn result;\r\n}\r\n\u0022;\r\n\r\n\t[Function( \u0022Vec3OsToTs\u0022 )]\r\n\tpublic static string Vec3OsToTs =\u003E @\u0022\r\nfloat3 Vec3OsToTs( float3 vVectorOs, float3 vNormalOs, float3 vTangentUOs, float3 vTangentVOs )\r\n{\r\n\tfloat3 vVectorTs;\r\n\tvVectorTs.x = dot( vVectorOs.xyz, vTangentUOs.xyz );\r\n\tvVectorTs.y = dot( vVectorOs.xyz, vTangentVOs.xyz );\r\n\tvVectorTs.z = dot( vVectorOs.xyz, vNormalOs.xyz );\r\n\treturn vVectorTs.xyz;\r\n}\r\n\u0022;\r\n\r\n\tpublic static string TextureDefinition =\u003E @\u0022\u003C!-- dmx encoding keyvalues2_noids 1 format vtex 1 --\u003E\r\n\u0022\u0022CDmeVtex\u0022\u0022\r\n{{\r\n    \u0022\u0022m_inputTextureArray\u0022\u0022 \u0022\u0022element_array\u0022\u0022 \r\n    [\r\n        \u0022\u0022CDmeInputTexture\u0022\u0022\r\n        {{\r\n            \u0022\u0022m_name\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u00220\u0022\u0022\r\n            \u0022\u0022m_fileName\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022{0}\u0022\u0022\r\n            \u0022\u0022m_colorSpace\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022{1}\u0022\u0022\r\n            \u0022\u0022m_typeString\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u00222D\u0022\u0022\r\n            \u0022\u0022m_imageProcessorArray\u0022\u0022 \u0022\u0022element_array\u0022\u0022 \r\n            [\r\n                \u0022\u0022CDmeImageProcessor\u0022\u0022\r\n                {{\r\n                    \u0022\u0022m_algorithm\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022{3}\u0022\u0022\r\n                    \u0022\u0022m_stringArg\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022\u0022\u0022\r\n                    \u0022\u0022m_vFloat4Arg\u0022\u0022 \u0022\u0022vector4\u0022\u0022 \u0022\u00220 0 0 0\u0022\u0022\r\n                }}\r\n            ]\r\n        }}\r\n    ]\r\n    \u0022\u0022m_outputTypeString\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u00222D\u0022\u0022\r\n    \u0022\u0022m_outputFormat\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022{2}\u0022\u0022\r\n    \u0022\u0022m_textureOutputChannelArray\u0022\u0022 \u0022\u0022element_array\u0022\u0022\r\n    [\r\n        \u0022\u0022CDmeTextureOutputChannel\u0022\u0022\r\n        {{\r\n            \u0022\u0022m_inputTextureArray\u0022\u0022 \u0022\u0022string_array\u0022\u0022\r\n            [\r\n                \u0022\u00220\u0022\u0022\r\n            ]\r\n            \u0022\u0022m_srcChannels\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022rgba\u0022\u0022\r\n            \u0022\u0022m_dstChannels\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022rgba\u0022\u0022\r\n            \u0022\u0022m_mipAlgorithm\u0022\u0022 \u0022\u0022CDmeImageProcessor\u0022\u0022\r\n            {{\r\n                \u0022\u0022m_algorithm\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022Box\u0022\u0022\r\n                \u0022\u0022m_stringArg\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022\u0022\u0022\r\n                \u0022\u0022m_vFloat4Arg\u0022\u0022 \u0022\u0022vector4\u0022\u0022 \u0022\u00220 0 0 0\u0022\u0022\r\n            }}\r\n            \u0022\u0022m_outputColorSpace\u0022\u0022 \u0022\u0022string\u0022\u0022 \u0022\u0022{1}\u0022\u0022\r\n        }}\r\n    ]\r\n}}\u0022;\r\n\r\n\t[AttributeUsage( AttributeTargets.Property )]\r\n\tprivate class FunctionAttribute : Attribute\r\n\t{\r\n\t\tpublic string Name { get; set; }\r\n\r\n\t\tpublic FunctionAttribute( string name )\r\n\t\t{\r\n\t\t\tName = name;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate static Dictionary\u003Cstring, string\u003E Functions;\r\n\r\n\tpublic static bool TryGetFunction( string name, out string func )\r\n\t{\r\n\t\treturn Functions.TryGetValue( name, out func );\r\n\t}\r\n\r\n\tpublic static bool HasFunction( string name )\r\n\t{\r\n\t\treturn Functions.ContainsKey( name );\r\n\t}\r\n\r\n\tinternal static bool RegisterFunction( string name, string code )\r\n\t{\r\n\t\tif ( Functions.ContainsKey( name ) )\r\n\t\t\treturn false;\r\n\t\tFunctions[name] = code;\r\n\t\treturn true;\r\n\t}\r\n\r\n\tstatic ShaderTemplate()\r\n\t{\r\n\t\tCreateFunctions();\r\n\t}\r\n\r\n\t[EditorEvent.Hotload]\r\n\tprivate static void CreateFunctions()\r\n\t{\r\n\t\tFunctions = new Dictionary\u003Cstring, string\u003E();\r\n\t\tvar properties = typeof( ShaderTemplate ).GetProperties( BindingFlags.Public | BindingFlags.Static );\r\n\r\n\t\tforeach ( var property in properties )\r\n\t\t{\r\n\t\t\tif ( property.PropertyType == typeof( string ) )\r\n\t\t\t{\r\n\t\t\t\tvar attr = (FunctionAttribute)Attribute.GetCustomAttribute( property, typeof( FunctionAttribute ) );\r\n\t\t\t\tif ( attr != null )\r\n\t\t\t\t{\r\n\t\t\t\t\tFunctions[attr.Name] = (string)property.GetValue( null );\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/Compiler/Templates/PostProcess.cs","FileName":"PostProcess.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\npublic static class PostProcessTemplate\r\n{\r\n\tpublic static Dictionary\u003Cstring, bool\u003E Features =\u003E new()\r\n\t{\r\n\t\t{ \u0022SupportsAlbedo\u0022, true },\r\n\t\t{ \u0022SupportsEmission\u0022, false },\r\n\t\t{ \u0022SupportsOpacity\u0022, true },\r\n\t\t{ \u0022SupportsNormal\u0022, false },\r\n\t\t{ \u0022SupportsRoughness\u0022, false },\r\n\t\t{ \u0022SupportsMetalness\u0022, false },\r\n\t\t{ \u0022SupportsAmbientOcclusion\u0022, false },\r\n\t\t{ \u0022SupportsPositionOffset\u0022, false },\r\n\t\t{ \u0022SupportsPixelDepthOffset\u0022, false },\r\n\r\n\t\t{ \u0022SupportsLitShadingModel\u0022, false },\r\n\t\t{ \u0022SupportsUnlitShadingModel\u0022, true },\r\n\t\t{ \u0022SupportsCustomShadingModel\u0022, false },\r\n\r\n\t\t{ \u0022SupportsOpaqueBlendMode\u0022, false },\r\n\t\t{ \u0022SupportsMaskedBlendMode\u0022, false },\r\n\t\t{ \u0022SupportsTranslucentBlendMode\u0022, false },\r\n\t\t{ \u0022SupportsDynamicBlendMode\u0022, false },\r\n\t\t{ \u0022SupportsCustomBlendMode\u0022, true }\r\n\t};\r\n\tpublic static string Code =\u003E @\u0022\r\nHEADER\r\n{{\r\n\tDescription = \u0022\u0022{0}\u0022\u0022;\r\n}}\r\n\r\nFEATURES\r\n{{\r\n\t#include \u0022\u0022common/features.hlsl\u0022\u0022\r\n{1}\r\n}}\r\n\r\nMODES\r\n{{\r\n\tForward();\r\n\tDepth();\r\n\tToolsShadingComplexity( \u0022\u0022tools_shading_complexity.shader\u0022\u0022 );\r\n}}\r\n\r\nCOMMON\r\n{{\r\n{2}\r\n\t#include \u0022\u0022common/shared.hlsl\u0022\u0022\r\n\t#include \u0022\u0022procedural.hlsl\u0022\u0022\r\n\r\n\t#define S_UV2 1\r\n}}\r\n\r\nstruct VertexInput\r\n{{\r\n\t#include \u0022\u0022common/vertexinput.hlsl\u0022\u0022\r\n\tfloat4 vColor : COLOR0 \u003C Semantic( Color ); \u003E;\r\n{3}\r\n}};\r\n\r\nstruct PixelInput\r\n{{\r\n\t#include \u0022\u0022common/pixelinput.hlsl\u0022\u0022\r\n\tfloat3 vPositionOs : TEXCOORD14;\r\n\tfloat3 vNormalOs : TEXCOORD15;\r\n\tfloat4 vTangentUOs_flTangentVSign : TANGENT\t\u003C Semantic( TangentU_SignV ); \u003E;\r\n\tfloat4 vColor : COLOR0;\r\n\tfloat4 vTintColor : COLOR1;\r\n\t#if ( PROGRAM == VFX_PROGRAM_PS )\r\n\t\tbool vFrontFacing : SV_IsFrontFace;\r\n\t#endif\r\n{4}\r\n}};\r\n\r\nVS\r\n{{\r\n\t#include \u0022\u0022common/vertex.hlsl\u0022\u0022\r\n{5}{6}{7}\r\n\tPixelInput MainVs( VertexInput v )\r\n\t{{\r\n\r\n\t\tPixelInput i;\r\n\t\ti.vPositionPs = float4(v.vPositionOs.xy, 0.0f, 1.0f );\r\n\t\ti.vPositionWs = float3(v.vTexCoord, 0.0f);\r\n{8}\t\t\t\t\t\r\n\t\treturn i;\r\n\t}}\r\n}}\r\n\r\nPS\r\n{{\r\n\t#include \u0022\u0022common/pixel.hlsl\u0022\u0022\r\n\t#include \u0022\u0022postprocess/functions.hlsl\u0022\u0022\r\n\t#include \u0022\u0022postprocess/common.hlsl\u0022\u0022\r\n\r\n{9}{10}{11}\r\n\r\n\tTexture2D g_tColorBuffer \u003C Attribute( \u0022\u0022ColorBuffer\u0022\u0022 ); SrgbRead ( true ); \u003E;\r\n\r\n\tfloat4 MainPs( PixelInput i ) : SV_Target0\r\n\t{{\r\n\t\tMaterial m = Material::Init( i );\r\n\t\tm.Albedo = float3( 1, 1, 1 );\r\n\t\tm.Opacity = 1;\r\n{12}\r\n\t\tm.Opacity = saturate( m.Opacity );\r\n{13}\r\n\r\n\t}}\r\n}}\r\n\u0022;\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/NodeInput.cs","FileName":"NodeInput.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic struct NodeInput : IValid\r\n{\r\n\t[Hide, Browsable( false )]\r\n\tpublic string Identifier { get; set; }\r\n\r\n\t[Hide, Browsable( false )]\r\n\tpublic string Output { get; set; }\r\n\r\n\t[Hide, Browsable( false )]\r\n\t[JsonIgnore]\r\n\tpublic string Subgraph { get; set; }\r\n\r\n\t[Hide, Browsable( false )]\r\n\t[JsonIgnore]\r\n\tpublic string SubgraphNode { get; set; }\r\n\r\n\t[Browsable( false )]\r\n\t[JsonIgnore, Hide]\r\n\tpublic readonly bool IsValid =\u003E !string.IsNullOrWhiteSpace( Identifier ) \u0026\u0026 !string.IsNullOrWhiteSpace( Output );\r\n\r\n\tpublic override readonly string ToString()\r\n\t{\r\n\t\tvar subgraph = (Subgraph is not null) ? (\u0022.\u0022 \u002B Subgraph) : \u0022\u0022;\r\n\t\tvar subgraphNode = (SubgraphNode is not null) ? (\u0022.\u0022 \u002B SubgraphNode) : \u0022\u0022;\r\n\t\treturn IsValid ? $\u0022{Identifier}.{Output}{subgraph}{subgraphNode}\u0022 : \u0022null\u0022;\r\n\t}\r\n\r\n\tpublic NodeInput()\r\n\t{\r\n\t\tIdentifier = \u0022\u0022;\r\n\t\tOutput = \u0022\u0022;\r\n\t\tSubgraph = null;\r\n\t}\r\n\r\n\tpublic static bool operator ==( NodeInput a, NodeInput b ) =\u003E a.Identifier == b.Identifier \u0026\u0026 a.Output == b.Output \u0026\u0026 a.Subgraph == b.Subgraph \u0026\u0026 a.SubgraphNode == b.SubgraphNode;\r\n\tpublic static bool operator !=( NodeInput a, NodeInput b ) =\u003E a.Identifier != b.Identifier || a.Output != b.Output || a.Subgraph != b.Subgraph || a.SubgraphNode != b.SubgraphNode;\r\n\tpublic override bool Equals( object obj ) =\u003E obj is NodeInput input \u0026\u0026 this == input;\r\n\tpublic override int GetHashCode() =\u003E System.HashCode.Combine( Identifier, Output, Subgraph, SubgraphNode );\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/BaseNodes/Time.cs","FileName":"Time.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"\r\nnamespace Editor.ShaderGraphExtras.Nodes;\r\n/// \u003Csummary\u003E\r\n/// Current time\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Time\u0022 ), Category( \u0022Variables\u0022 ), Icon( \u0022timer\u0022 )]\r\npublic sealed class Time : ShaderNode\r\n{\r\n\t[JsonIgnore]\r\n\tpublic float Value =\u003E RealTime.Now;\r\n\r\n\t[Output( typeof( float ) ), Title( \u0022Time\u0022 )]\r\n\t[Hide]\r\n\tpublic NodeResult.Func Result =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\treturn new NodeResult( 1, compiler.IsPreview ? \u0022g_flPreviewTime\u0022 : \u0022g_flTime\u0022, compiler.IsNotPreview );\r\n\t};\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/UniversalNodes/Noise.cs","FileName":"Noise.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras.Nodes;\r\n\r\n[Title(\u0022SGE - Noise\u0022), Category( \u0022Shader Graph Extras - Universal\u0022 ), Icon(\u0022grain\u0022)]\r\npublic sealed class SGENoiseNode : ShaderNode\r\n{\r\n\tpublic enum SGENoiseMode\r\n\t{\r\n\t\tStatic,\r\n\t\tValue,\r\n\t\tSimplex,\r\n\t\t[Title(\u0022fBM\u0022)]\r\n\t\tfBM,\r\n\t\tVoronoi\r\n\t}\r\n\r\n\tpublic SGENoiseMode Mode { get; set; } = SGENoiseMode.fBM;\r\n\r\n\tpublic enum SGENoiseDimension\r\n\t{\r\n\t\t[Title(\u00222D\u0022)]\r\n\t\tNoise2D,\r\n\t\t[Title(\u00223D\u0022)]\r\n\t\tNoise3D\r\n\t}\r\n\r\n\tpublic SGENoiseDimension Dimension { get; set; } = SGENoiseDimension.Noise2D;\r\n\r\n\t[Hide, JsonIgnore]\r\n\tint _lastHashCode = 0;\r\n\r\n\tpublic override void OnFrame()\r\n\t{\r\n\t\tbase.OnFrame();\r\n\r\n\t\tvar hashCode = new HashCode();\r\n\t\thashCode.Add(Mode);\r\n\t\thashCode.Add(Dimension);\r\n\t\tvar hc = hashCode.ToHashCode();\r\n\t\tif (hc != _lastHashCode)\r\n\t\t{\r\n\t\t\t_lastHashCode = hc;\r\n\t\t\tCreateInputs();\r\n\t\t\tUpdate();\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void CreateInputs()\r\n\t{\r\n\t\tvar plugs = new List\u003CIPlugIn\u003E();\r\n\t\tvar serialized = this.GetSerialized();\r\n\t\tforeach (var property in serialized)\r\n\t\t{\r\n\t\t\tif (property.TryGetAttribute\u003CInputAttribute\u003E(out var inputAttr))\r\n\t\t\t{\r\n\t\t\t\tif (property.TryGetAttribute\u003CConditionalVisibilityAttribute\u003E(out var conditionalVisibilityAttr))\r\n\t\t\t\t{\r\n\t\t\t\t\tif (conditionalVisibilityAttr.TestCondition(this.GetSerialized()))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tvar propertyInfo = typeof(SGENoiseNode).GetProperty(property.Name);\r\n\t\t\t\tif (propertyInfo is null) continue;\r\n\t\t\t\tvar info = new PlugInfo(propertyInfo);\r\n\t\t\t\tvar displayInfo = info.DisplayInfo;\r\n\t\t\t\tdisplayInfo.Name = property.DisplayName;\r\n\t\t\t\tinfo.DisplayInfo = displayInfo;\r\n\r\n\t\t\t\t// Try to find existing plug to preserve connections\r\n\t\t\t\tvar oldPlug = Inputs.FirstOrDefault(x =\u003E x is BasePlugIn plugIn \u0026\u0026 plugIn.Info.Name == property.Name) as BasePlugIn;\r\n\t\t\t\tif (oldPlug is not null)\r\n\t\t\t\t{\r\n\t\t\t\t\toldPlug.Info.Name = info.Name;\r\n\t\t\t\t\toldPlug.Info.Type = info.Type;\r\n\t\t\t\t\toldPlug.Info.DisplayInfo = info.DisplayInfo;\r\n\t\t\t\t\tplugs.Add(oldPlug);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tvar plug = new BasePlugIn(this, info, info.Type);\r\n\t\t\t\t\tplugs.Add(plug);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tInputs = plugs;\r\n\t}\r\n\r\n\t[Hide]\r\n\tprivate bool IsNoisefBMMode =\u003E Mode == SGENoiseMode.fBM;\r\n\t[Hide]\r\n\tprivate bool IsNoiseVoronoiMode =\u003E Mode == SGENoiseMode.Voronoi;\r\n\r\n\t[Hide]\r\n\t[Input(typeof(Vector3))]\r\n\tpublic NodeInput Coordinates { get; set; }\r\n\r\n\t[Hide]\r\n\t[Input(typeof(int))]\r\n\t[ShowIf(nameof(IsNoisefBMMode), true)]\r\n\tpublic NodeInput Octaves { get; set; }\r\n\r\n\t[InputDefault(nameof(Octaves))]\r\n\t[ShowIf(nameof(IsNoisefBMMode), true)]\r\n\tpublic float DefaultOctaves { get; set; } = 6;\r\n\r\n\t[Hide]\r\n\t[Input(typeof(float))]\r\n\t[ShowIf(nameof(IsNoiseVoronoiMode), true)]\r\n\tpublic NodeInput Offset { get; set; }\r\n\r\n\t[InputDefault(nameof(Offset))]\r\n\t[ShowIf(nameof(IsNoiseVoronoiMode), true)]\r\n\tpublic float DefaultOffset { get; set; } = 3.14159265359f;\r\n\r\n\t[Hide]\r\n\t[Output(typeof(float))]\r\n\tpublic NodeResult.Func Output =\u003E (GraphCompiler compiler) =\u003E\r\n\t{\r\n\t\tvar coordinates = compiler.Result(Coordinates);\r\n\r\n\t\tcompiler.RegisterInclude(\u0022shaders/HLSL/Functions/FUNC-noise.hlsl\u0022);\r\n\r\n\t\tNodeResult result = new NodeResult();\r\n\r\n\t\tswitch (Mode)\r\n\t\t{\r\n\t\t\tcase SGENoiseMode.Static:\r\n\t\t\t\tif (Dimension == SGENoiseDimension.Noise2D)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEStaticNoise2D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEStaticNoise3D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase SGENoiseMode.Value:\r\n\t\t\t\tif (Dimension == SGENoiseDimension.Noise2D)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEValueNoise2D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEValueNoise3D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase SGENoiseMode.Simplex:\r\n\t\t\t\tif (Dimension == SGENoiseDimension.Noise2D)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGESimplexNoise2D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGESimplexNoise3D({coordinates})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase SGENoiseMode.fBM:\r\n\t\t\t\tvar octaves = compiler.ResultOrDefault(Octaves, DefaultOctaves);\r\n\r\n\t\t\t\tif (Dimension == SGENoiseDimension.Noise2D)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEfBMNoise2D({coordinates}, {octaves})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEfBMNoise3D({coordinates}, {octaves})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase SGENoiseMode.Voronoi:\r\n\t\t\t\tvar offset = compiler.ResultOrDefault(Offset,DefaultOffset);\r\n\t\t\t\tif (Dimension == SGENoiseDimension.Noise2D)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEVoronoiNoise2D({coordinates}, {offset})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = new NodeResult(NodeResultType.Float, $\u0022SGEVoronoiNoise3D({coordinates}, {offset})\u0022);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t};\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/UI/ControlWidgets/ComboControlWidgets.cs","FileName":"ComboControlWidgets.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\ninternal static class ComboControlWidgetHelper\r\n{\r\n\tpublic static ShaderNode GetShaderNode( SerializedProperty property )\r\n\t{\r\n\t\tif ( property is null )\r\n\t\t\treturn null;\r\n\r\n\t\tif ( property.Parent.Targets.First() is ShaderNode shaderNode )\r\n\t\t\treturn shaderNode;\r\n\r\n\t\treturn GetShaderNode( property.Parent?.ParentProperty );\r\n\t}\r\n\r\n\tpublic static void SetupComboBox\u003CT\u003E(\r\n\t\tComboBox comboBox,\r\n\t\tSerializedProperty property,\r\n\t\tstring currentValue,\r\n\t\tFunc\u003CSGEComboNode, string\u003E getValue,\r\n\t\tFunc\u003Cstring, T\u003E createValue )\r\n\t{\r\n\t\tList\u003Cstring\u003E namesSoFar = [currentValue];\r\n\r\n\t\tcomboBox.AddItem( \u0022\u0022 );\r\n\t\tif ( !string.IsNullOrEmpty( currentValue ) )\r\n\t\t{\r\n\t\t\tcomboBox.AddItem( currentValue );\r\n\t\t\tcomboBox.CurrentIndex = 1;\r\n\t\t}\r\n\r\n\t\tvar parentNode = GetShaderNode( property );\r\n\t\tif ( parentNode is not null )\r\n\t\t{\r\n\t\t\tforeach ( var node in parentNode.Graph.Nodes )\r\n\t\t\t{\r\n\t\t\t\tif ( node is SGEComboNode comboNode )\r\n\t\t\t\t{\r\n\t\t\t\t\tstring value = getValue( comboNode );\r\n\t\t\t\t\tif ( !string.IsNullOrEmpty( value ) \u0026\u0026 !namesSoFar.Contains( value ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcomboBox.AddItem( value );\r\n\t\t\t\t\t\tnamesSoFar.Add( value );\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tcomboBox.Editable = true;\r\n\t\tcomboBox.Insertion = ComboBox.InsertMode.Skip;\r\n\r\n\t\tcomboBox.TextChanged \u002B= () =\u003E\r\n\t\t{\r\n\t\t\tproperty.SetValue( createValue( comboBox.CurrentText ) );\r\n\t\t};\r\n\t}\r\n}\r\n\r\n[CustomEditor( typeof( ComboName ) )]\r\ninternal class ComboNameControlWidget : ControlWidget\r\n{\r\n\tpublic override bool SupportsMultiEdit =\u003E false;\r\n\r\n\tpublic ComboNameControlWidget( SerializedProperty property ) : base( property )\r\n\t{\r\n\t\tLayout = Layout.Row();\r\n\t\tvar comboBox = Layout.Add( new ComboBox( this ) );\r\n\t\tvar currentValue = SerializedProperty.GetValue\u003CComboName\u003E().Name;\r\n\r\n\t\tComboControlWidgetHelper.SetupComboBox(\r\n\t\t\tcomboBox, property, currentValue,\r\n\t\t\tnode =\u003E node.Name,\r\n\t\t\ttext =\u003E new ComboName { Name = text } );\r\n\t}\r\n}\r\n\r\n[CustomEditor( typeof( ComboGroup ) )]\r\ninternal class ComboGroupControlWidget : ControlWidget\r\n{\r\n\tpublic override bool SupportsMultiEdit =\u003E false;\r\n\r\n\tpublic ComboGroupControlWidget( SerializedProperty property ) : base( property )\r\n\t{\r\n\t\tLayout = Layout.Row();\r\n\t\tvar comboBox = Layout.Add( new ComboBox( this ) );\r\n\t\tvar currentValue = SerializedProperty.GetValue\u003CComboGroup\u003E().Group;\r\n\r\n\t\tComboControlWidgetHelper.SetupComboBox(\r\n\t\t\tcomboBox, property, currentValue,\r\n\t\t\tnode =\u003E node.Group,\r\n\t\t\ttext =\u003E new ComboGroup { Group = text } );\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/UI/ControlWidgets/ShaderGraphGroupControlWidget.cs","FileName":"ShaderGraphGroupControlWidget.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\n[CustomEditor( typeof( string ), NamedEditor = \u0022shadergraphgroup\u0022 )]\r\ninternal class ShaderGraphGroupControlWidget : ControlWidget\r\n{\r\n\tpublic override bool SupportsMultiEdit =\u003E false;\r\n\r\n\tComboBox _comboBox;\r\n\r\n\tpublic ShaderGraphGroupControlWidget( SerializedProperty property ) : base( property )\r\n\t{\r\n\t\tLayout = Layout.Row();\r\n\r\n\t\t_comboBox = Layout.Add( new ComboBox( this ) );\r\n\r\n\t\tvar currentVal = SerializedProperty.GetValue\u003Cstring\u003E();\r\n\t\tList\u003Cstring\u003E namesSoFar = [currentVal];\r\n\r\n\t\t_comboBox.AddItem( \u0022\u0022 );\r\n\t\tif ( !string.IsNullOrEmpty( currentVal ) )\r\n\t\t{\r\n\t\t\t_comboBox.AddItem( currentVal );\r\n\t\t\t_comboBox.CurrentIndex = 1;\r\n\t\t}\r\n\r\n\t\tvar groupProperty = GetGroupProperty( property );\r\n\t\tvar parentNode = GetShaderNode( property );\r\n\t\tif ( groupProperty is not null \u0026\u0026 parentNode is not null )\r\n\t\t{\r\n\t\t\tforeach ( var node in parentNode.Graph.Nodes )\r\n\t\t\t{\r\n\t\t\t\tvar serialized = node.GetSerialized();\r\n\t\t\t\tforeach ( var prop in serialized )\r\n\t\t\t\t{\r\n\t\t\t\t\tif ( prop.PropertyType == typeof( ParameterUI ) || prop.PropertyType == typeof( TextureInput ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif ( prop.TryGetAsObject( out var propObj ) )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Get same property name so groups only show group names, sub-groups only show sub-group names, ect\r\n\t\t\t\t\t\t\tvar innerProp = propObj.GetProperty( groupProperty?.Name );\r\n\t\t\t\t\t\t\tvar groupVal = innerProp?.GetValue\u003CUIGroup\u003E();\r\n\t\t\t\t\t\t\tif ( !string.IsNullOrEmpty( groupVal?.Name ) \u0026\u0026 !namesSoFar.Contains( groupVal?.Name ) )\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t_comboBox.AddItem( groupVal?.Name );\r\n\t\t\t\t\t\t\t\tnamesSoFar.Add( groupVal?.Name );\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_comboBox.Editable = true;\r\n\t\t_comboBox.Insertion = ComboBox.InsertMode.Skip;\r\n\r\n\t\t_comboBox.TextChanged \u002B= () =\u003E\r\n\t\t{\r\n\t\t\tSerializedProperty.SetValue\u003Cstring\u003E( _comboBox.CurrentText );\r\n\t\t};\r\n\t}\r\n\r\n\tSerializedProperty GetGroupProperty( SerializedProperty originalProperty )\r\n\t{\r\n\t\tif ( originalProperty is null )\r\n\t\t{\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tif ( originalProperty.PropertyType == typeof( UIGroup ) )\r\n\t\t{\r\n\t\t\treturn originalProperty;\r\n\t\t}\r\n\t\treturn GetGroupProperty( originalProperty.Parent?.ParentProperty );\r\n\t}\r\n\r\n\tShaderNode GetShaderNode( SerializedProperty originalProperty )\r\n\t{\r\n\t\tif ( originalProperty is null )\r\n\t\t{\r\n\t\t\treturn null;\r\n\t\t}\r\n\t\tif ( originalProperty.Parent.Targets.First() is ShaderNode shaderNode )\r\n\t\t{\r\n\t\t\treturn shaderNode;\r\n\t\t}\r\n\t\treturn GetShaderNode( originalProperty.Parent?.ParentProperty );\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/UI/PerformanceBar.cs","FileName":"PerformanceBar.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"\r\nnamespace Editor.ShaderGraphExtras;\r\n\r\ninternal class GamePerformanceBar : Widget\r\n{\r\n\tprivate readonly Func\u003Cstring\u003E _getValue;\r\n\tprivate RealTimeSince _timeSinceUpdate;\r\n\r\n\tpublic GamePerformanceBar( Func\u003Cstring\u003E val ) : base( null )\r\n\t{\r\n\t\t_getValue = val;\r\n\r\n\t\tMinimumHeight = Theme.RowHeight;\r\n\t\tMinimumWidth = 60;\r\n\t}\r\n\r\n\tprotected override void DoLayout()\r\n\t{\r\n\t\tbase.DoLayout();\r\n\t}\r\n\r\n\tprotected override void OnPaint()\r\n\t{\r\n\t\tbase.OnPaint();\r\n\r\n\t\tPaint.ClearPen();\r\n\t\tPaint.SetBrush( Theme.ControlBackground );\r\n\t\tPaint.DrawRect( LocalRect, Theme.ControlRadius );\r\n\r\n\t\tPaint.SetPen( Theme.Green.WithAlpha( 0.4f ) );\r\n\t\tPaint.DrawText( LocalRect.Shrink( 8, 0 ), _getValue(), TextFlag.RightCenter );\r\n\t}\r\n\r\n\t[EditorEvent.Frame]\r\n\tpublic void Frame()\r\n\t{\r\n\t\tif ( _timeSinceUpdate \u003C 0.6f )\r\n\t\t\treturn;\r\n\r\n\t\t_timeSinceUpdate = Random.Shared.Float( 0, 0.1f );\r\n\r\n\t\tUpdate();\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UniversalNodes/Checkerboard.cs","FileName":"Checkerboard.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraph.Nodes;\r\n\r\n[Title( \u0022SGE - Checkerboard\u0022 ), Category( \u0022Shader Graph Extras - Universal\u0022 ), Icon( \u0022grid_on\u0022 )]\r\npublic sealed class SGECheckerboardNode : ShaderNode\r\n{\r\n\t[Hide]\r\n\tpublic static string SGECheckerboard =\u003E @\u0022\r\n\t\tfloat SGECheckerboard(float2 coordinates)\r\n\t\t{\r\n\t\t\tcoordinates *= 0.5f;\r\n\t\t\tfloat2 derivative = fwidth(coordinates);\r\n\t\t\tfloat2 derivativeScale = 0.35f / derivative;\r\n\t\t\tfloat2 distanceToEdge = 4.0f * abs(frac(coordinates \u002B 0.25f) - 0.5f) - 1.0f;\r\n\t\t\tfloat2 checkerAlpha = clamp(distanceToEdge * derivativeScale, -1.0f, 1.0f);\r\n\t\t\treturn saturate(0.5f \u002B 0.5f * checkerAlpha.x * checkerAlpha.y);\r\n\t\t}\r\n\t\t\u0022;\r\n\r\n\t[Input( typeof( Vector2 ) )]\r\n\t[Hide]\r\n\tpublic NodeInput Coordinates { get; set; }\r\n\r\n\t[Output( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic NodeResult.Func Output =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar coordinates = compiler.Result(Coordinates).Cast(2);\r\n\r\n\t\treturn new NodeResult(NodeResultType.Float, compiler.ResultFunction( compiler.RegisterFunction( SGECheckerboard ), $\u0022{coordinates}\u0022));\r\n\t};\r\n}"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UniversalNodes/RandomRange.cs","FileName":"RandomRange.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraph.Nodes;\r\n\r\n[Title( \u0022SGE - Random Range\u0022 ), Category( \u0022Shader Graph Extras - Universal\u0022 ), Icon(\u0022shuffle\u0022)]\r\npublic sealed class SGERandomRangeNode : ShaderNode\r\n{\r\n\t[Hide]\r\n\tpublic static string SGERandomRange =\u003E @\u0022\r\n\t\tfloat SGERandomRange(float2 input, float minimum, float maximum)\r\n\t\t{\r\n\t\t\treturn lerp(minimum, maximum, frac(sin(dot(input, float2(12.9898, 78.233)))*43758.5453));\r\n\t\t}\r\n\t\t\u0022;\r\n\r\n\t[Input( typeof( Vector2 ) )]\r\n\t[Hide]\r\n\tpublic NodeInput Input {get; set;}\r\n\t\r\n\t[Input( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic NodeInput Minimum {get; set;}\r\n\t\r\n\t[Input( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic NodeInput Maximum {get; set;}\r\n\r\n\t[InputDefault (nameof( Minimum ))]\r\n\tpublic float DefaultMinimum {get; set;} = 0f;\r\n\r\n\t[InputDefault (nameof( Maximum ))]\r\n\tpublic float DefaultMaximum {get; set;} = 1f;\r\n\t\r\n\t[Output( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic NodeResult.Func Output =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar input = compiler.Result(Input).Cast(2);\r\n\t\tvar minimum = compiler.ResultOrDefault(Minimum, DefaultMinimum);\r\n\t\tvar maximum = compiler.ResultOrDefault(Maximum, DefaultMaximum);\r\n\t\t\r\n\t\treturn new NodeResult( NodeResultType.Float, compiler.ResultFunction( compiler.RegisterFunction( SGERandomRange ), $\u0022{input}, {minimum}, {maximum}\u0022 ) );\r\n\t};\r\n}"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/ShaderGraph.cs","FileName":"ShaderGraph.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic enum BlendMode\r\n{\r\n\t[Icon( \u0022circle\u0022 )]\r\n\tOpaque,\r\n\t[Icon( \u0022radio_button_unchecked\u0022 )]\r\n\tMasked,\r\n\t[Icon( \u0022blur_on\u0022 )]\r\n\tTranslucent,\r\n\t[Icon( \u0022tune\u0022 )]\r\n\tDynamic,\r\n\t[Icon( \u0022build\u0022 )]\r\n\tCustom,\r\n}\r\n\r\npublic enum ShadingModel\r\n{\r\n\t[Icon( \u0022tungsten\u0022 )]\r\n\tLit,\r\n\t[Icon( \u0022brightness_3\u0022 )]\r\n\tUnlit,\r\n\t[Icon( \u0022palette\u0022 )]\r\n\tCustom,\r\n}\r\n\r\npublic enum ShaderDomain\r\n{\r\n\t[Icon( \u0022view_in_ar\u0022 )]\r\n\tSurface,\r\n\t[Icon( \u0022desktop_windows\u0022 )]\r\n\tPostProcess,\r\n\t[Icon( \u0022gradient\u0022 )]\r\n\tCustom,\r\n}\r\n\r\npublic class PreviewSettings\r\n{\r\n\tpublic bool RenderBackfaces { get; set; } = false;\r\n\tpublic bool EnableShadows { get; set; } = true;\r\n\tpublic bool ShowGround { get; set; } = false;\r\n\tpublic bool ShowSkybox { get; set; } = true;\r\n\tpublic Color BackgroundColor { get; set; } = Color.Black;\r\n\tpublic Color Tint { get; set; } = Color.White;\r\n}\r\n\r\npublic sealed partial class ShaderGraph : IGraph\r\n{\r\n\t[Hide, JsonIgnore]\r\n\tpublic IEnumerable\u003CBaseNode\u003E Nodes =\u003E _nodes.Values;\r\n\r\n\t[Hide, JsonIgnore]\r\n\tprivate readonly Dictionary\u003Cstring, BaseNode\u003E _nodes = new();\r\n\r\n\t[Hide, JsonIgnore]\r\n\tIEnumerable\u003CINode\u003E IGraph.Nodes =\u003E Nodes;\r\n\r\n\t[Hide]\r\n\tpublic bool IsSubgraph { get; set; }\r\n\r\n\t[Hide]\r\n\tpublic string Path { get; set; }\r\n\r\n\t[Hide]\r\n\tpublic string Model { get; set; }\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// The name of the Node when used in ShaderGraph\r\n\t/// \u003C/summary\u003E\r\n\t[ShowIf( nameof( IsSubgraph ), true )]\r\n\tpublic string Title { get; set; }\r\n\r\n\tpublic string Description { get; set; }\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// The category of the Node when browsing the Node Library (optional)\r\n\t/// \u003C/summary\u003E\r\n\t[ShowIf( nameof( AddToNodeLibrary ), true )]\r\n\tpublic string Category { get; set; }\r\n\r\n\t[IconName, ShowIf( nameof( IsSubgraph ), true )]\r\n\tpublic string Icon { get; set; }\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Whether or not this Node should appear when browsing the Node Library.\r\n\t/// Otherwise can only be referenced by dragging the Subgraph asset into the graph.\r\n\t/// \u003C/summary\u003E\r\n\t[ShowIf( nameof( IsSubgraph ), true )]\r\n\tpublic bool AddToNodeLibrary { get; set; }\r\n\r\n\tpublic BlendMode BlendMode { get; set; }\r\n\r\n\tpublic ShadingModel ShadingModel { get; set; }\r\n\r\n\t[ShowIf( nameof( ShadingModel ), ShadingModel.Custom )]\r\n\tpublic string ShadingModelPath { get; set; }\r\n\r\n\tpublic ShaderDomain Domain { get; set; }\r\n\r\n\t[ShowIf( nameof( Domain ), ShaderDomain.Custom )]\r\n\tpublic string TemplatePath { get; set; }\r\n\r\n\t// Feature helpers for shading model support (used by custom editors)\r\n\t[Hide]\r\n\tpublic bool SupportsLitShadingModel =\u003E GetFeature( \u0022SupportsLitShadingModel\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsUnlitShadingModel =\u003E GetFeature( \u0022SupportsUnlitShadingModel\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsCustomShadingModel =\u003E GetFeature( \u0022SupportsCustomShadingModel\u0022, true );\r\n\r\n\t// Feature helpers for blend mode support (used by custom editors)\r\n\t[Hide]\r\n\tpublic bool SupportsOpaqueBlendMode =\u003E GetFeature( \u0022SupportsOpaqueBlendMode\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsMaskedBlendMode =\u003E GetFeature( \u0022SupportsMaskedBlendMode\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsTranslucentBlendMode =\u003E GetFeature( \u0022SupportsTranslucentBlendMode\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsDynamicBlendMode =\u003E GetFeature( \u0022SupportsDynamicBlendMode\u0022, true );\r\n\t[Hide]\r\n\tpublic bool SupportsCustomBlendMode =\u003E GetFeature( \u0022SupportsCustomBlendMode\u0022, true );\r\n\r\n\tprivate bool GetFeature( string featureName, bool defaultValue )\r\n\t{\r\n\t\t// Get template path based on domain\r\n\t\tstring templatePath = Domain switch\r\n\t\t{\r\n\t\t\tShaderDomain.Surface =\u003E \u0022Compiler/Templates/Surface.cs\u0022,\r\n\t\t\tShaderDomain.PostProcess =\u003E \u0022Compiler/Templates/PostProcess.cs\u0022,\r\n\t\t\tShaderDomain.Custom =\u003E TemplatePath,\r\n\t\t\t_ =\u003E null\r\n\t\t};\r\n\r\n\t\t// Get shading model path based on selection\r\n\t\tstring shadingModelPath = ShadingModel switch\r\n\t\t{\r\n\t\t\tShadingModel.Lit =\u003E \u0022Compiler/ShadingModels/Lit.cs\u0022,\r\n\t\t\tShadingModel.Unlit =\u003E \u0022Compiler/ShadingModels/Unlit.cs\u0022,\r\n\t\t\tShadingModel.Custom =\u003E ShadingModelPath,\r\n\t\t\t_ =\u003E null\r\n\t\t};\r\n\r\n\t\tbool templateValue = defaultValue;\r\n\t\tbool shadingModelValue = defaultValue;\r\n\r\n\t\t// Check template features\r\n\t\tif ( !string.IsNullOrWhiteSpace( templatePath ) )\r\n\t\t{\r\n\t\t\tvar templateFeatures = ShaderTemplate.GetTemplateFeatures( templatePath );\r\n\t\t\tif ( templateFeatures.TryGetValue( featureName, out var value ) )\r\n\t\t\t\ttemplateValue = value;\r\n\t\t}\r\n\r\n\t\t// Check shading model features\r\n\t\tif ( !string.IsNullOrWhiteSpace( shadingModelPath ) )\r\n\t\t{\r\n\t\t\tvar shadingModelFeatures = ShaderTemplate.GetShadingModelFeatures( shadingModelPath );\r\n\t\t\tif ( shadingModelFeatures.TryGetValue( featureName, out var value ) )\r\n\t\t\t\tshadingModelValue = value;\r\n\t\t}\r\n\r\n\t\t// Both template and shading model must support the feature\r\n\t\treturn templateValue \u0026\u0026 shadingModelValue;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Validates and auto-corrects BlendMode and ShadingModel if current values are not supported\r\n\t/// \u003C/summary\u003E\r\n\tpublic void ValidateSettings()\r\n\t{\r\n\t\t// Auto-correct BlendMode if current is not supported\r\n\t\tbool currentBlendModeSupported = BlendMode switch\r\n\t\t{\r\n\t\t\tBlendMode.Opaque =\u003E SupportsOpaqueBlendMode,\r\n\t\t\tBlendMode.Masked =\u003E SupportsMaskedBlendMode,\r\n\t\t\tBlendMode.Translucent =\u003E SupportsTranslucentBlendMode,\r\n\t\t\tBlendMode.Dynamic =\u003E SupportsDynamicBlendMode,\r\n\t\t\tBlendMode.Custom =\u003E SupportsCustomBlendMode,\r\n\t\t\t_ =\u003E false\r\n\t\t};\r\n\r\n\t\tif ( !currentBlendModeSupported )\r\n\t\t{\r\n\t\t\t// Find the first supported blend mode\r\n\t\t\tif ( SupportsOpaqueBlendMode ) BlendMode = BlendMode.Opaque;\r\n\t\t\telse if ( SupportsMaskedBlendMode ) BlendMode = BlendMode.Masked;\r\n\t\t\telse if ( SupportsTranslucentBlendMode ) BlendMode = BlendMode.Translucent;\r\n\t\t\telse if ( SupportsDynamicBlendMode ) BlendMode = BlendMode.Dynamic;\r\n\t\t\telse if ( SupportsCustomBlendMode ) BlendMode = BlendMode.Custom;\r\n\t\t}\r\n\r\n\t\t// Auto-correct ShadingModel if current is not supported\r\n\t\tbool currentShadingModelSupported = ShadingModel switch\r\n\t\t{\r\n\t\t\tShadingModel.Lit =\u003E SupportsLitShadingModel,\r\n\t\t\tShadingModel.Unlit =\u003E SupportsUnlitShadingModel,\r\n\t\t\tShadingModel.Custom =\u003E SupportsCustomShadingModel,\r\n\t\t\t_ =\u003E false\r\n\t\t};\r\n\r\n\t\tif ( !currentShadingModelSupported )\r\n\t\t{\r\n\t\t\t// Find the first supported shading model\r\n\t\t\tif ( SupportsLitShadingModel ) ShadingModel = ShadingModel.Lit;\r\n\t\t\telse if ( SupportsUnlitShadingModel ) ShadingModel = ShadingModel.Unlit;\r\n\t\t\telse if ( SupportsCustomShadingModel ) ShadingModel = ShadingModel.Custom;\r\n\t\t}\r\n\t}\r\n\r\n\t[Hide]\r\n\tpublic PreviewSettings PreviewSettings { get; set; } = new();\r\n\r\n\t[Hide]\r\n\tpublic int Version { get; set; } = 1;\r\n\r\n\tpublic ShaderGraph()\r\n\t{\r\n\t}\r\n\r\n\tpublic void AddNode( BaseNode node )\r\n\t{\r\n\t\tnode.Graph = this;\r\n\t\t_nodes.Add( node.Identifier, node );\r\n\t}\r\n\r\n\tpublic void RemoveNode( BaseNode node )\r\n\t{\r\n\t\tif ( node.Graph != this )\r\n\t\t\treturn;\r\n\r\n\t\t_nodes.Remove( node.Identifier );\r\n\t}\r\n\r\n\tpublic BaseNode FindNode( string name )\r\n\t{\r\n\t\t_nodes.TryGetValue( name, out var node );\r\n\t\treturn node;\r\n\t}\r\n\r\n\tpublic void ClearNodes()\r\n\t{\r\n\t\t_nodes.Clear();\r\n\t}\r\n\r\n\tstring IGraph.SerializeNodes( IEnumerable\u003CINode\u003E nodes )\r\n\t{\r\n\t\treturn SerializeNodes( nodes.Cast\u003CBaseNode\u003E() );\r\n\t}\r\n\r\n\tIEnumerable\u003CINode\u003E IGraph.DeserializeNodes( string serialized )\r\n\t{\r\n\t\treturn DeserializeNodes( serialized );\r\n\t}\r\n\r\n\tvoid IGraph.AddNode( INode node )\r\n\t{\r\n\t\tAddNode( (BaseNode)node );\r\n\t}\r\n\r\n\tvoid IGraph.RemoveNode( INode node )\r\n\t{\r\n\t\tRemoveNode( (BaseNode)node );\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/SubgraphNode.cs","FileName":"SubgraphNode.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic sealed class SubgraphNode : ShaderNode, IErroringNode\r\n{\r\n\t[Hide]\r\n\tpublic string SubgraphPath { get; set; }\r\n\r\n\t[Hide, JsonIgnore]\r\n\tpublic ShaderGraph Subgraph { get; set; }\r\n\r\n\t[Hide]\r\n\tprivate List\u003CIPlugIn\u003E InternalInputs = new();\r\n\r\n\t[Hide]\r\n\tpublic override IEnumerable\u003CIPlugIn\u003E Inputs =\u003E InternalInputs;\r\n\r\n\t[Hide]\r\n\tprivate List\u003CIPlugOut\u003E InternalOutputs = new();\r\n\r\n\t[Hide]\r\n\tpublic override IEnumerable\u003CIPlugOut\u003E Outputs =\u003E InternalOutputs;\r\n\r\n\t[Editor( \u0022subgraphnode\u0022 ), WideMode( HasLabel = false )]\r\n\tpublic Dictionary\u003Cstring, object\u003E DefaultValues { get; set; } = new();\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic override Color PrimaryColor =\u003E Color.Lerp( Theme.Blue, Theme.Green, 0.5f );\r\n\r\n\t[Hide]\r\n\tpublic override DisplayInfo DisplayInfo =\u003E new()\r\n\t{\r\n\t\tName = Subgraph?.Title ?? (string.IsNullOrEmpty( Subgraph.Title ) ? \u0022Untitled Subgraph\u0022 : Subgraph.Title),\r\n\t\tDescription = Subgraph?.Description ?? \u0022\u0022,\r\n\t\tIcon = Subgraph?.Icon ?? \u0022\u0022\r\n\t};\r\n\r\n\tpublic void OnNodeCreated()\r\n\t{\r\n\t\tif ( Subgraph is not null ) return;\r\n\r\n\t\tif ( SubgraphPath != null )\r\n\t\t{\r\n\t\t\tSubgraph = new ShaderGraph();\r\n\t\t\tif ( !FileSystem.Content.FileExists( SubgraphPath ) ) return;\r\n\t\t\tvar json = FileSystem.Content.ReadAllText( SubgraphPath );\r\n\t\t\tSubgraph.Deserialize( json, SubgraphPath );\r\n\t\t\tSubgraph.Path = SubgraphPath;\r\n\r\n\t\t\tCreateInputs();\r\n\t\t\tCreateOutputs();\r\n\r\n\t\t\tforeach ( var node in Subgraph.Nodes )\r\n\t\t\t{\r\n\t\t\t\tif ( node is ITextureParameterNode texNode \u0026\u0026 DefaultValues.TryGetValue( $\u0022__tex_{texNode.UI.Name}\u0022, out var defaultTexVal ) )\r\n\t\t\t\t{\r\n\t\t\t\t\ttexNode.Image = defaultTexVal.ToString();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tUpdate();\r\n\t\t}\r\n\t}\r\n\r\n\t[Hide, JsonIgnore]\r\n\tinternal Dictionary\u003CIPlugIn, (SubgraphInput, Type)\u003E InputReferences = new();\r\n\tpublic void CreateInputs()\r\n\t{\r\n\t\tvar plugs = new List\u003CIPlugIn\u003E();\r\n\t\tInputReferences.Clear();\r\n\r\n\t\t// Get all SubgraphInput nodes only - no more legacy IParameterNode support\r\n\t\tvar subgraphInputs = Subgraph.Nodes.OfType\u003CSubgraphInput\u003E()\r\n\t\t\t.Where( x =\u003E !string.IsNullOrWhiteSpace( x.InputName ) )\r\n\t\t\t.OrderBy( x =\u003E x.PortOrder )\r\n\t\t\t.ThenBy( x =\u003E x.InputName );\r\n\r\n\t\tforeach ( var subgraphInput in subgraphInputs )\r\n\t\t{\r\n\t\t\tvar type = subgraphInput.InputType switch\r\n\t\t\t{\r\n\t\t\t\tInputType.Float =\u003E typeof( float ),\r\n\t\t\t\tInputType.Float2 =\u003E typeof( Vector2 ),\r\n\t\t\t\tInputType.Float3 =\u003E typeof( Vector3 ),\r\n\t\t\t\tInputType.Color =\u003E typeof( Color ),\r\n\t\t\t\tInputType.Sampler =\u003E typeof( Sampler ),\r\n\t\t\t\tInputType.Texture2D =\u003E typeof( Texture2DObject ),\r\n\t\t\t\tInputType.TextureCube =\u003E typeof( TextureCubemapObject ),\r\n\t\t\t\t_ =\u003E typeof( float )\r\n\t\t\t};\r\n\r\n\t\t\tvar info = new PlugInfo()\r\n\t\t\t{\r\n\t\t\t\tName = subgraphInput.InputName,\r\n\t\t\t\tType = type,\r\n\t\t\t\tDisplayInfo = new DisplayInfo()\r\n\t\t\t\t{\r\n\t\t\t\t\tName = subgraphInput.InputName,\r\n\t\t\t\t\tFullname = type.FullName\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tvar plug = new BasePlugIn( this, info, type );\r\n\t\t\tvar oldPlug = InternalInputs.FirstOrDefault( x =\u003E x is BasePlugIn plugIn \u0026\u0026 plugIn.Info.Name == info.Name \u0026\u0026 plugIn.Info.Type == info.Type ) as BasePlugIn;\r\n\t\t\tif ( oldPlug is not null )\r\n\t\t\t{\r\n\t\t\t\toldPlug.Info.Name = info.Name;\r\n\t\t\t\toldPlug.Info.Type = info.Type;\r\n\t\t\t\toldPlug.Info.DisplayInfo = info.DisplayInfo;\r\n\t\t\t\tplug = oldPlug;\r\n\t\t\t}\r\n\t\t\tplugs.Add( plug );\r\n\t\t\tInputReferences[plug] = (subgraphInput, type);\r\n\r\n\t\t\tif ( !DefaultValues.ContainsKey( plug.Identifier ) )\r\n\t\t\t{\r\n\t\t\t\tDefaultValues[plug.Identifier] = subgraphInput.GetValue();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tInternalInputs = plugs;\r\n\t}\r\n\r\n\t[Hide, JsonIgnore]\r\n\tinternal Dictionary\u003CIPlugOut, IPlugIn\u003E OutputReferences = new();\r\n\tpublic void CreateOutputs()\r\n\t{\r\n\t\tvar resultNode = Subgraph.Nodes.OfType\u003CFunctionResult\u003E().FirstOrDefault();\r\n\t\tif ( resultNode is null ) return;\r\n\r\n\t\tvar plugs = new List\u003CIPlugOut\u003E();\r\n\t\tforeach ( var output in resultNode.FunctionOutputs.OrderBy( x =\u003E x.Priority ) )\r\n\t\t{\r\n\t\t\tvar outputType = output.Type;\r\n\t\t\tif ( outputType == typeof( ColorTextureGenerator ) )\r\n\t\t\t{\r\n\t\t\t\toutputType = typeof( Color );\r\n\t\t\t}\r\n\t\t\tif ( outputType is null ) continue;\r\n\t\t\tvar info = new PlugInfo()\r\n\t\t\t{\r\n\t\t\t\tName = output.Name,\r\n\t\t\t\tType = outputType,\r\n\t\t\t\tDisplayInfo = new DisplayInfo()\r\n\t\t\t\t{\r\n\t\t\t\t\tName = output.Name,\r\n\t\t\t\t\tFullname = outputType.FullName\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t\tvar plug = new BasePlugOut( this, info, outputType );\r\n\t\t\tvar oldPlug = InternalOutputs.FirstOrDefault( x =\u003E x is BasePlugOut plugOut \u0026\u0026 plugOut.Info.Name == info.Name \u0026\u0026 plugOut.Info.Type == info.Type ) as BasePlugOut;\r\n\t\t\tif ( oldPlug is not null )\r\n\t\t\t{\r\n\t\t\t\toldPlug.Info.Name = info.Name;\r\n\t\t\t\toldPlug.Info.Type = info.Type;\r\n\t\t\t\toldPlug.Info.DisplayInfo = info.DisplayInfo;\r\n\t\t\t\tplugs.Add( oldPlug );\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tplugs.Add( plug );\r\n\t\t\t}\r\n\t\t}\r\n\t\tInternalOutputs = plugs;\r\n\t}\r\n\r\n\tpublic List\u003Cstring\u003E GetErrors()\r\n\t{\r\n\t\tOnNodeCreated();\r\n\t\tif ( Subgraph is null )\r\n\t\t{\r\n\t\t\treturn new List\u003Cstring\u003E { $\u0022Cannot find subgraph at \\\u0022{SubgraphPath}\\\u0022\u0022 };\r\n\t\t}\r\n\r\n\t\tvar errors = new List\u003Cstring\u003E();\r\n\r\n\t\tforeach ( var node in Subgraph.Nodes )\r\n\t\t{\r\n\t\t\tif ( node is IErroringNode erroringNode )\r\n\t\t\t{\r\n\t\t\t\terrors.AddRange( erroringNode.GetErrors().Select( x =\u003E $\u0022[{DisplayInfo.Name}] {x}\u0022 ) );\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tforeach ( var input in InputReferences )\r\n\t\t{\r\n\t\t\tvar plug = input.Key;\r\n\t\t\tvar parameterNode = input.Value.Item1;\r\n\t\t\tvar inputName = parameterNode.InputName;\r\n\t\t\tif ( string.IsNullOrWhiteSpace( inputName ) ) inputName = input.Key.DisplayInfo.Name;\r\n\t\t\tif ( parameterNode.IsRequired \u0026\u0026 plug.ConnectedOutput is null )\r\n\t\t\t{\r\n\t\t\t\terrors.Add( $\u0022Required Input \\\u0022{inputName}\\\u0022 is missing on Node \\\u0022{Subgraph.Title}\\\u0022\u0022 );\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn errors;\r\n\t}\r\n\r\n\tpublic override void OnDoubleClick( MouseEvent e )\r\n\t{\r\n\t\tbase.OnDoubleClick( e );\r\n\r\n\t\tif ( string.IsNullOrEmpty( SubgraphPath ) ) return;\r\n\r\n\t\tvar shader = AssetSystem.FindByPath( SubgraphPath );\r\n\t\tif ( shader is null ) return;\r\n\r\n\t\tvar window = new MainWindowFunc();\r\n\t\twindow.AssetOpen( shader );\r\n\t}\r\n}\r\n\r\n[CustomEditor( typeof( Dictionary\u003Cstring, object\u003E ), NamedEditor = \u0022subgraphnode\u0022, WithAllAttributes = [typeof( WideModeAttribute )] )]\r\ninternal class SubgraphNodeControlWidget : ControlWidget\r\n{\r\n\tpublic override bool SupportsMultiEdit =\u003E false;\r\n\r\n\tSubgraphNode Node;\r\n\tControlSheet Sheet;\r\n\r\n\tpublic SubgraphNodeControlWidget( SerializedProperty property ) : base( property )\r\n\t{\r\n\t\tNode = property.Parent.Targets.First() as SubgraphNode;\r\n\r\n\t\tLayout = Layout.Column();\r\n\t\tLayout.Spacing = 2;\r\n\t\tSheet = new ControlSheet();\r\n\t\tLayout.Add( Sheet );\r\n\r\n\t\tRebuild();\r\n\t}\r\n\r\n\tprotected override void OnPaint()\r\n\t{\r\n\r\n\t}\r\n\r\n\tprivate void Rebuild()\r\n\t{\r\n\t\tSheet.Clear( true );\r\n\r\n\t\tforeach ( var inputRef in Node.InputReferences )\r\n\t\t{\r\n\t\t\tvar name = inputRef.Key.Identifier;\r\n\t\t\tvar type = inputRef.Value.Item2;\r\n\t\t\tvar getter = () =\u003E\r\n\t\t\t{\r\n\t\t\t\tif ( Node.DefaultValues.ContainsKey( name ) )\r\n\t\t\t\t{\r\n\t\t\t\t\treturn Node.DefaultValues[name];\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tvar val = inputRef.Value.Item1.GetValue();\r\n\t\t\t\t\tif ( val is JsonElement el ) return el.GetDouble();\r\n\t\t\t\t\treturn val;\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tvar displayName = $\u0022Default {name}\u0022;\r\n\t\t\tif ( type == typeof( float ) )\r\n\t\t\t{\r\n\t\t\t\tSheet.AddRow( TypeLibrary.CreateProperty\u003Cfloat\u003E(\r\n\t\t\t\t\tdisplayName, () =\u003E\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar val = getter();\r\n\t\t\t\t\t\tif ( val is JsonElement el ) return float.Parse( el.GetRawText() );\r\n\t\t\t\t\t\treturn (float)val;\r\n\t\t\t\t\t}, x =\u003E SetDefaultValue( name, x )\r\n\t\t\t\t) );\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( Vector2 ) )\r\n\t\t\t{\r\n\t\t\t\tSheet.AddRow( TypeLibrary.CreateProperty\u003CVector2\u003E(\r\n\t\t\t\t\tdisplayName, () =\u003E\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar val = getter();\r\n\t\t\t\t\t\tif ( val is JsonElement el ) return Vector2.Parse( el.GetString() );\r\n\t\t\t\t\t\treturn (Vector2)val;\r\n\t\t\t\t\t}, x =\u003E SetDefaultValue( name, x )\r\n\t\t\t\t) );\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( Vector3 ) )\r\n\t\t\t{\r\n\t\t\t\tSheet.AddRow( TypeLibrary.CreateProperty\u003CVector3\u003E(\r\n\t\t\t\t\tdisplayName, () =\u003E\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar val = getter();\r\n\t\t\t\t\t\tif ( val is JsonElement el ) return Vector3.Parse( el.GetString() );\r\n\t\t\t\t\t\treturn (Vector3)val;\r\n\t\t\t\t\t}, x =\u003E SetDefaultValue( name, x )\r\n\t\t\t\t) );\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( Color ) )\r\n\t\t\t{\r\n\t\t\t\tSheet.AddRow( TypeLibrary.CreateProperty\u003CColor\u003E(\r\n\t\t\t\t\tdisplayName, () =\u003E\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar val = getter();\r\n\t\t\t\t\t\tif ( val is JsonElement el )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn Color.Parse( el.GetString() ) ?? Color.White;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn (Color)val;\r\n\t\t\t\t\t}, x =\u003E SetDefaultValue( name, x )\r\n\t\t\t\t) );\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( Sampler ) )\r\n\t\t\t{\r\n\t\t\t\t// Sampler is not editable in the UI - will use default value from SubgraphInput\r\n\t\t\t\t// Skip adding a control widget for this type\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( Texture2DObject ) )\r\n\t\t\t{\r\n\t\t\t\t// Texture2DObject is not editable in the UI - must be connected via node\r\n\t\t\t\t// Skip adding a control widget for this type\r\n\t\t\t}\r\n\t\t\telse if ( type == typeof( TextureCubemapObject ) )\r\n\t\t\t{\r\n\t\t\t\t// TextureCubemapObject is not editable in the UI - must be connected via node\r\n\t\t\t\t// Skip adding a control widget for this type\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tint textureInt = 0;\r\n\t\tint defaultInt = 0;\r\n\t\tforeach ( var node in Node.Subgraph.Nodes )\r\n\t\t{\r\n\t\t\tif ( node is ITextureParameterNode texNode )\r\n\t\t\t{\r\n\t\t\t\tvar name = texNode.UI.Name;\r\n\t\t\t\tvar type = typeof( Texture );\r\n\t\t\t\tif ( string.IsNullOrEmpty( name ) )\r\n\t\t\t\t{\r\n\t\t\t\t\tname = $\u0022{type.Name}_{defaultInt}\u0022;\r\n\t\t\t\t\tdefaultInt\u002B\u002B;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tvar prop = TypeLibrary.CreateProperty\u003Cstring\u003E(\r\n\t\t\t\t\t$\u0022Default {name}\u0022,\r\n\t\t\t\t\t() =\u003E texNode.Image,\r\n\t\t\t\t\tx =\u003E\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttexNode.Image = x;\r\n\t\t\t\t\t\tSetDefaultValue( $\u0022__tex_{name}\u0022, x );\r\n\t\t\t\t\t},\r\n\t\t\t\t\t[new ImageAssetPathAttribute()]\r\n\t\t\t\t\t);\r\n\t\t\t\tSheet.AddRow( prop );\r\n\r\n\t\t\t\ttextureInt\u002B\u002B;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void SetDefaultValue( string name, object value )\r\n\t{\r\n\t\tNode.DefaultValues[name] = value;\r\n\t\tNode.Update();\r\n\t\tNode.IsDirty = true;\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/BaseNodes/Camera.cs","FileName":"Camera.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"\r\nnamespace Editor.ShaderGraphExtras.Nodes;\r\n/// \u003Csummary\u003E\r\n/// Camera position and shit\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Camera\u0022 ), Category( \u0022Variables\u0022 ), Icon( \u0022photo_camera\u0022 )]\r\npublic sealed class Camera : ShaderNode\r\n{\r\n\t[Output( typeof( Vector3 ) ), Title( \u0022Position\u0022 )]\r\n\t[Hide]\r\n\tpublic static NodeResult.Func WorldPosition =\u003E ( GraphCompiler compiler ) =\u003E new( 3, \u0022g_vCameraPositionWs\u0022 );\r\n\r\n\t[Output( typeof( Vector3 ) )]\r\n\t[Hide]\r\n\tpublic static NodeResult.Func Direction =\u003E ( GraphCompiler compiler ) =\u003E new( 3, \u0022g_vCameraDirWs\u0022 );\r\n\r\n\t[Output( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic static NodeResult.Func NearPlane =\u003E ( GraphCompiler compiler ) =\u003E new( 1, \u0022g_flNearPlane\u0022 );\r\n\r\n\t[Output( typeof( float ) )]\r\n\t[Hide]\r\n\tpublic static NodeResult.Func FarPlane =\u003E ( GraphCompiler compiler ) =\u003E new( 1, \u0022g_flFarPlane\u0022 );\r\n}\r\n\r\n/// \u003Csummary\u003E\r\n/// Sample depth texture\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Depth\u0022 ), Category( \u0022Camera\u0022 )]\r\npublic sealed class Depth : ShaderNode\r\n{\r\n\t[Input( typeof( Vector2 ) ), Hide]\r\n\tpublic NodeInput UV { get; set; }\r\n\r\n\t[Output( typeof( float ) ), Hide]\r\n\tpublic NodeResult.Func Out =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar result = UV.IsValid() ? compiler.Result( UV ).Cast( 2 ) :\r\n\t\t\tcompiler.IsVs ? \u0022i.vPositionPs.xy\u0022 : \u0022i.vPositionSs.xy\u0022;\r\n\r\n\t\treturn new NodeResult( 1, $\u0022Depth::Get( {result} )\u0022 );\r\n\t};\r\n}\r\n\r\n/// \u003Csummary\u003E\r\n/// Sample linear depth, which is absolute coordinates away from the camera\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Linear Depth\u0022 ), Category( \u0022Camera\u0022 )]\r\npublic sealed class LinearDepth : ShaderNode\r\n{\r\n\t[Input( typeof( Vector2 ) ), Hide]\r\n\tpublic NodeInput UV { get; set; }\r\n\r\n\t[Output( typeof( float ) ), Hide]\r\n\tpublic NodeResult.Func Out =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar result = UV.IsValid() ? compiler.Result( UV ).Cast( 2 ) :\r\n\t\t\tcompiler.IsVs ? \u0022i.vPositionPs.xy\u0022 : \u0022i.vPositionSs.xy\u0022;\r\n\r\n\t\treturn new NodeResult( 1, $\u0022Depth::GetLinear( {result} )\u0022 );\r\n\t};\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/BaseNodes/Parameter.cs","FileName":"Parameter.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"\r\nnamespace Editor.ShaderGraphExtras.Nodes;\r\n/// \u003Csummary\u003E\r\n/// Single float value\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Float\u0022 ), Category( \u0022Constants\u0022 ), Icon( \u0022looks_one\u0022 )]\r\npublic sealed class Float : ParameterNode\u003Cfloat\u003E\r\n{\r\n\t[Hide] public float Step =\u003E UI.Step;\r\n\r\n\t[Output( typeof( float ) ), Title( \u0022Value\u0022 )]\r\n\t[Hide, Editor( nameof( Value ) ), Range( nameof( Min ), nameof( Max ), nameof( Step ) )]\r\n\tpublic NodeResult.Func Result =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\treturn compiler.ResultParameter( Name, Value, Min, Max, Min != Max, IsAttribute, UI );\r\n\t};\r\n\r\n\t[Group( \u0022Range\u0022 )] public float Min { get; set; }\r\n\t[Group( \u0022Range\u0022 )] public float Max { get; set; }\r\n\r\n\tpublic Float()\r\n\t{\r\n\t\tMin = 0;\r\n\t\tMax = 1;\r\n\t}\r\n\r\n\tpublic override Vector4 GetRangeMin()\r\n\t{\r\n\t\treturn new( Min );\r\n\t}\r\n\r\n\tpublic override Vector4 GetRangeMax()\r\n\t{\r\n\t\treturn new( Max );\r\n\t}\r\n}\r\n\r\n/// \u003Csummary\u003E\r\n/// 2 float values\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Float2\u0022 ), Category( \u0022Constants\u0022 ), Icon( \u0022looks_two\u0022 )]\r\npublic sealed class Float2 : ParameterNode\u003CVector2\u003E\r\n{\r\n\t[Output( typeof( Vector2 ) ), Title( \u0022XY\u0022 ), Hide]\r\n\tpublic NodeResult.Func Result =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\treturn compiler.ResultParameter( Name, Value, Min, Max, Min != Max, IsAttribute, UI );\r\n\t};\r\n\r\n\t[Group( \u0022Range\u0022 )] public Vector2 Min { get; set; }\r\n\t[Group( \u0022Range\u0022 )] public Vector2 Max { get; set; }\r\n\r\n\tpublic Float2()\r\n\t{\r\n\t\tMin = 0;\r\n\t\tMax = 1;\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueX\r\n\t{\r\n\t\tget =\u003E Value.x;\r\n\t\tset =\u003E Value = Value.WithX( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueY\r\n\t{\r\n\t\tget =\u003E Value.y;\r\n\t\tset =\u003E Value = Value.WithY( value );\r\n\t}\r\n\r\n\t[Hide] public float MinX =\u003E Min.x;\r\n\t[Hide] public float MinY =\u003E Min.y;\r\n\t[Hide] public float MaxX =\u003E Max.x;\r\n\t[Hide] public float MaxY =\u003E Max.y;\r\n\r\n\t[Hide] public float Step =\u003E UI.Step;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// X component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueX ) ), Title( \u0022X\u0022 )]\r\n\t[Range( nameof( MinX ), nameof( MaxX ), nameof( Step ) )]\r\n\tpublic NodeResult.Func X =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022x\u0022, ValueX, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Y component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueY ) ), Title( \u0022Y\u0022 )]\r\n\t[Range( nameof( MinY ), nameof( MaxY ), nameof( Step ) )]\r\n\tpublic NodeResult.Func Y =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022y\u0022, ValueY, compiler );\r\n\r\n\tpublic override Vector4 GetRangeMin()\r\n\t{\r\n\t\treturn new( Min.x, Min.y, 0, 0 );\r\n\t}\r\n\r\n\tpublic override Vector4 GetRangeMax()\r\n\t{\r\n\t\treturn new( Max.x, Max.y, 0, 0 );\r\n\t}\r\n}\r\n\r\n/// \u003Csummary\u003E\r\n/// 3 float values\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Float3\u0022 ), Category( \u0022Constants\u0022 ), Icon( \u0022looks_3\u0022 )]\r\npublic sealed class Float3 : ParameterNode\u003CVector3\u003E\r\n{\r\n\t[Output( typeof( Vector3 ) ), Title( \u0022XYZ\u0022 ), Hide]\r\n\tpublic NodeResult.Func Result =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\treturn compiler.ResultParameter( Name, Value, Min, Max, Min != Max, IsAttribute, UI );\r\n\t};\r\n\r\n\t[Group( \u0022Range\u0022 )] public Vector3 Min { get; set; }\r\n\t[Group( \u0022Range\u0022 )] public Vector3 Max { get; set; }\r\n\r\n\tpublic Float3()\r\n\t{\r\n\t\tMin = 0;\r\n\t\tMax = 1;\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueX\r\n\t{\r\n\t\tget =\u003E Value.x;\r\n\t\tset =\u003E Value = Value.WithX( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueY\r\n\t{\r\n\t\tget =\u003E Value.y;\r\n\t\tset =\u003E Value = Value.WithY( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueZ\r\n\t{\r\n\t\tget =\u003E Value.z;\r\n\t\tset =\u003E Value = Value.WithZ( value );\r\n\t}\r\n\r\n\t[Hide] public float MinX =\u003E Min.x;\r\n\t[Hide] public float MinY =\u003E Min.y;\r\n\t[Hide] public float MinZ =\u003E Min.z;\r\n\t[Hide] public float MaxX =\u003E Max.x;\r\n\t[Hide] public float MaxY =\u003E Max.y;\r\n\t[Hide] public float MaxZ =\u003E Max.z;\r\n\r\n\t[Hide] public float Step =\u003E UI.Step;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// X component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueX ) ), Title( \u0022X\u0022 )]\r\n\t[Range( nameof( MinX ), nameof( MaxX ), nameof( Step ) )]\r\n\tpublic NodeResult.Func X =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022x\u0022, ValueX, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Y component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueY ) ), Title( \u0022Y\u0022 )]\r\n\t[Range( nameof( MinY ), nameof( MaxY ), nameof( Step ) )]\r\n\tpublic NodeResult.Func Y =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022y\u0022, ValueY, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Z component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueZ ) ), Title( \u0022Z\u0022 )]\r\n\t[Range( nameof( MinZ ), nameof( MaxZ ), nameof( Step ) )]\r\n\tpublic NodeResult.Func Z =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022z\u0022, ValueZ, compiler );\r\n\r\n\tpublic override Vector4 GetRangeMin()\r\n\t{\r\n\t\treturn new( Min.x, Min.y, Min.z, 0 );\r\n\t}\r\n\r\n\tpublic override Vector4 GetRangeMax()\r\n\t{\r\n\t\treturn new( Max.x, Max.y, Max.z, 0 );\r\n\t}\r\n}\r\n\r\n/// \u003Csummary\u003E\r\n/// 4 float values, normally used as a color\r\n/// \u003C/summary\u003E\r\n[Title( \u0022Color\u0022 ), Category( \u0022Constants\u0022 ), Icon( \u0022palette\u0022 )]\r\npublic sealed class Float4 : ParameterNode\u003CColor\u003E\r\n{\r\n\t[Output( typeof( Color ) ), Title( \u0022RGBA\u0022 )]\r\n\t[Hide, Editor( nameof( Value ) )]\r\n\tpublic NodeResult.Func Result =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\treturn compiler.ResultParameter( Name, Value, default, default, false, IsAttribute, UI );\r\n\t};\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueR\r\n\t{\r\n\t\tget =\u003E Value.r;\r\n\t\tset =\u003E Value = Value.WithRed( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueG\r\n\t{\r\n\t\tget =\u003E Value.g;\r\n\t\tset =\u003E Value = Value.WithGreen( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueB\r\n\t{\r\n\t\tget =\u003E Value.b;\r\n\t\tset =\u003E Value = Value.WithBlue( value );\r\n\t}\r\n\r\n\t[JsonIgnore, Hide]\r\n\tpublic float ValueA\r\n\t{\r\n\t\tget =\u003E Value.a;\r\n\t\tset =\u003E Value = Value.WithAlpha( value );\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Red component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueR ) ), Title( \u0022Red\u0022 )]\r\n\tpublic NodeResult.Func R =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022r\u0022, ValueR, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Green component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueG ) ), Title( \u0022Green\u0022 )]\r\n\tpublic NodeResult.Func G =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022g\u0022, ValueG, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Green component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueB ) ), Title( \u0022Blue\u0022 )]\r\n\tpublic NodeResult.Func B =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022b\u0022, ValueB, compiler );\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Alpha component of result\r\n\t/// \u003C/summary\u003E\r\n\t[Output( typeof( float ) ), Hide, Editor( nameof( ValueA ) ), Title( \u0022Alpha\u0022 )]\r\n\tpublic NodeResult.Func A =\u003E ( GraphCompiler compiler ) =\u003E Component( \u0022a\u0022, ValueA, compiler );\r\n\r\n\tpublic Float4()\r\n\t{\r\n\t\tValue = Color.White;\r\n\t\tUI = new ParameterUI { Type = UIType.Color };\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/UniversalNodes/ComponentMask.cs","FileName":"ComponentMask.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"/*\r\nCredits:\r\n- https://sbox.game/quack/shadergraphplus\r\n- https://github.com/QuackCola/ShaderGraphPlus\r\n*/\r\n\r\nnamespace Editor.ShaderGraphExtras.Nodes;\r\n\r\n[Title( \u0022SGE - Component Mask\u0022 ), Category( \u0022Shader Graph Extras - Universal\u0022 ), Icon( \u0022call_split\u0022 )]\r\npublic sealed class SGEComponentMaskNode : ShaderNode\r\n{\r\n\t[Hide]\r\n\tpublic override string Title\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tList\u003Cstring\u003E components = new List\u003Cstring\u003E();\r\n\r\n\t\t\tif ( R ) components.Add( \u0022R\u0022 );\r\n\t\t\tif ( G ) components.Add( \u0022G\u0022 );\r\n\t\t\tif ( B ) components.Add( \u0022B\u0022 );\r\n\t\t\tif ( A ) components.Add( \u0022A\u0022 );\r\n\r\n\t\t\tvar suffix = components.Count \u003E 0 ? $\u0022{string.Join( \u0022 \u0022, components )}\u0022 : \u0022\u0022;\r\n\r\n\t\t\treturn !string.IsNullOrWhiteSpace( suffix ) ? $\u0022{DisplayInfo.For( this ).Name} ( {suffix} )\u0022 : DisplayInfo.For( this ).Name;\r\n\t\t}\r\n\t}\r\n\r\n\t[Input, Hide]\r\n\tpublic NodeInput Input { get; set; }\r\n\r\n\tpublic bool R { get; set; } = true;\r\n\tpublic bool G { get; set; } = true;\r\n\tpublic bool B { get; set; } = true;\r\n\tpublic bool A { get; set; } = true;\r\n\r\n\t[Output, Hide]\r\n\tpublic NodeResult.Func Output =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar output = compiler.Result( Input );\r\n\r\n\t\tif ( !output.IsValid )\r\n\t\t{\r\n\t\t\treturn new NodeResult( 1, \u00220.0f\u0022 );\r\n\t\t}\r\n\r\n\t\tvar components = string.Empty;\r\n\r\n\t\tswitch ( output.Components )\r\n\t\t{\r\n\t\t\tcase 1:\r\n\t\t\t\tif ( R ) components \u002B= \u0022x\u0022;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 2:\r\n\t\t\t\tif ( R ) components \u002B= \u0022x\u0022;\r\n\t\t\t\tif ( G ) components \u002B= \u0022y\u0022;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 3:\r\n\t\t\t\tif ( R ) components \u002B= \u0022x\u0022;\r\n\t\t\t\tif ( G ) components \u002B= \u0022y\u0022;\r\n\t\t\t\tif ( B ) components \u002B= \u0022z\u0022;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 4:\r\n\t\t\t\tif ( R ) components \u002B= \u0022x\u0022;\r\n\t\t\t\tif ( G ) components \u002B= \u0022y\u0022;\r\n\t\t\t\tif ( B ) components \u002B= \u0022z\u0022;\r\n\t\t\t\tif ( A ) components \u002B= \u0022w\u0022;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tvar outputType = components.Length;\r\n\r\n\t\tif ( components == string.Empty )\r\n\t\t\treturn new NodeResult( 1, \u00220.0f\u0022 );\r\n\r\n\t\treturn new NodeResult( outputType, $\u0022{output}.{components}\u0022 );\r\n\t};\r\n}"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Nodes/UpgradedNodes/DecalProjection.cs","FileName":"DecalProjection.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras.Nodes;\r\n\r\n[Title( \u0022SGE - Decal Projection\u0022 ), Category( \u0022Shader Graph Extras - Upgraded\u0022 ), Icon( \u0022connected_tv\u0022 )]\r\npublic sealed class SGEDecalProjectionNode : ShaderNode\r\n{\r\n[Output( typeof( Vector3 ) )]\r\n[Hide]\r\npublic static NodeResult.Func Forward =\u003E ( GraphCompiler compiler ) =\u003E new( NodeResultType.Vector3, \u0022i.vDecalForward\u0022 );\r\n\r\n[Output( typeof( Vector3 ) )]\r\n[Hide]\r\npublic static NodeResult.Func Right =\u003E ( GraphCompiler compiler ) =\u003E new( NodeResultType.Vector3, \u0022i.vDecalRight\u0022 );\r\n\r\n[Output( typeof( Vector3 ) )]\r\n[Hide]\r\npublic static NodeResult.Func Up =\u003E ( GraphCompiler compiler ) =\u003E new( NodeResultType.Vector3, \u0022i.vDecalUp\u0022 );\r\n\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/UI/MainWindow.cs","FileName":"MainWindow.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\n\r\npublic class MainWindowFunc : MainWindow\r\n{\r\n\tpublic override bool IsSubgraph =\u003E true;\r\n\tpublic override string FileType =\u003E \u0022Shader Sub-Graph\u0022;\r\n\tpublic override string FileExtension =\u003E \u0022shdrfunc\u0022;\r\n}\r\n\r\n[EditorApp( \u0022Upgraded Shader Graph\u0022, \u0022gradient\u0022, \u0022edit shaders\u0022 )]\r\npublic class MainWindowShader : MainWindow\r\n{\r\n\tpublic override bool IsSubgraph =\u003E false;\r\n\tpublic override string FileType =\u003E \u0022Shader Graph\u0022;\r\n\tpublic override string FileExtension =\u003E \u0022shdrgrph\u0022;\r\n}\r\n\r\n\r\npublic class MainWindow : DockWindow\r\n{\r\n\tpublic virtual bool IsSubgraph =\u003E false;\r\n\tpublic virtual string FileType =\u003E \u0022Shader Graph\u0022;\r\n\tpublic virtual string FileExtension =\u003E \u0022shdrgrph\u0022;\r\n\r\n\tprotected ShaderGraph _graph;\r\n\tprotected ShaderGraphView _graphView;\r\n\tprivate Asset _asset;\r\n\r\n\tpublic string AssetPath =\u003E _asset?.Path;\r\n\r\n\tprivate Widget _graphCanvas;\r\n\tprivate Properties _properties;\r\n\tprotected PreviewPanel _preview;\r\n\tprotected Output _output;\r\n\tprivate UndoHistory _undoHistory;\r\n\tprivate PaletteWidget _palette;\r\n\r\n\tprivate readonly UndoStack _undoStack = new();\r\n\r\n\tprivate Option _undoOption;\r\n\tprivate Option _redoOption;\r\n\r\n\tprivate Option _undoMenuOption;\r\n\tprivate Option _redoMenuOption;\r\n\r\n\tpublic UndoStack UndoStack =\u003E _undoStack;\r\n\r\n\tprivate bool _dirty = false;\r\n\r\n\tprivate string _generatedCode;\r\n\tprivate readonly Dictionary\u003Cstring, Texture\u003E _textureAttributes = new();\r\n\tprivate readonly Dictionary\u003Cstring, Color\u003E _float4Attributes = new();\r\n\tprivate readonly Dictionary\u003Cstring, Vector3\u003E _float3Attributes = new();\r\n\tprivate readonly Dictionary\u003Cstring, Vector2\u003E _float2Attributes = new();\r\n\tprivate readonly Dictionary\u003Cstring, float\u003E _floatAttributes = new();\r\n\tprivate readonly Dictionary\u003Cstring, bool\u003E _boolAttributes = new();\r\n\r\n\tprivate readonly List\u003CBaseNode\u003E _compiledNodes = new();\r\n\r\n\tprivate bool _isCompiling = false;\r\n\tprivate bool _isPendingCompile = false;\r\n\tprivate RealTimeSince _timeSinceCompile;\r\n\r\n\tprivate Menu _recentFilesMenu;\r\n\tprivate readonly List\u003Cstring\u003E _recentFiles = new();\r\n\tprivate Option _fileHistoryBack;\r\n\tprivate Option _fileHistoryForward;\r\n\tprivate Option _fileHistoryHome;\r\n\r\n\tprivate List\u003Cstring\u003E _fileHistory = new();\r\n\tprivate int _fileHistoryPosition = 0;\r\n\r\n\tpublic bool CanOpenMultipleAssets =\u003E true;\r\n\r\n\tpublic MainWindow()\r\n\t{\r\n\t\tDeleteOnClose = true;\r\n\r\n\t\tTitle = FileType;\r\n\t\tSize = new Vector2( 1700, 1050 );\r\n\r\n\t\t_graph = new();\r\n\t\t_graph.IsSubgraph = IsSubgraph;\r\n\r\n\t\tCreateToolBar();\r\n\r\n\t\t_recentFiles = FileSystem.Temporary.ReadJsonOrDefault( \u0022shadergraph_recentfiles.json\u0022, _recentFiles )\r\n\t\t\t.Where( System.IO.File.Exists ).ToList();\r\n\r\n\t\tCreateUI();\r\n\t\tShow();\r\n\t\tStateCookie = \u0022ShaderGraph\u0022;\r\n\r\n\t\tCreateNew();\r\n\t}\r\n\r\n\tpublic void AssetOpen( Asset asset )\r\n\t{\r\n\t\tif ( asset == null || string.IsNullOrWhiteSpace( asset.AbsolutePath ) )\r\n\t\t\treturn;\r\n\r\n\t\tPromptSave( () =\u003E Open( asset.AbsolutePath ) );\r\n\t}\r\n\r\n\tprivate void RestoreShader()\r\n\t{\r\n\t\tif ( !_preview.IsValid() )\r\n\t\t\treturn;\r\n\r\n\t\t_preview.Material = Material.Load( \u0022materials/core/shader_editor.vmat\u0022 );\r\n\t}\r\n\r\n\tpublic void OnNodeSelected( BaseNode node )\r\n\t{\r\n\t\t_properties.Target = node != null ? node : _graph;\r\n\r\n\t\t_preview.SetStage( _compiledNodes.IndexOf( node ) \u002B 1 );\r\n\t}\r\n\r\n\tpublic void OnMultipleNodesSelected( List\u003CBaseNode\u003E nodes )\r\n\t{\r\n\t\t_properties.SetMultiEditTargets( nodes );\r\n\t\t_preview.SetStage( 0 );\r\n\t}\r\n\r\n\tprivate void OpenGeneratedShader()\r\n\t{\r\n\t\tif ( _asset is null )\r\n\t\t{\r\n\t\t\tSave();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tvar path = System.IO.Path.ChangeExtension( _asset.AbsolutePath, \u0022.shader\u0022 );\r\n\t\t\tvar asset = AssetSystem.FindByPath( path );\r\n\t\t\tasset?.OpenInEditor();\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void Screenshot()\r\n\t{\r\n\t\tif ( _asset is null )\r\n\t\t\treturn;\r\n\r\n\t\tvar path = FileSystem.Root.GetFullPath( $\u0022/screenshots/shadergraphs/{_asset.Name}.png\u0022 );\r\n\t\tSystem.IO.Directory.CreateDirectory( System.IO.Path.GetDirectoryName( path ) );\r\n\r\n\t\t_graphView.Capture( $\u0022screenshots/shadergraphs/{_asset.Name}.png\u0022 );\r\n\r\n\t\tEditorUtility.OpenFileFolder( path );\r\n\t}\r\n\r\n\tprivate void ForceCompile()\r\n\t{\r\n\t\tif ( _asset == null )\r\n\t\t\treturn;\r\n\r\n\t\tvar compiler = new GraphCompiler( _graph, false );\r\n\t\tvar code = compiler.Generate();\r\n\t\tif ( string.IsNullOrWhiteSpace( code ) )\r\n\t\t\treturn;\r\n\r\n\t\tvar shaderPath = System.IO.Path.ChangeExtension( _asset.AbsolutePath, \u0022.shader\u0022 );\r\n\t\tSystem.IO.File.WriteAllText( shaderPath, code );\r\n\t}\r\n\r\n\tprotected virtual void Compile()\r\n\t{\r\n\t\t_shaderCompileErrors.Clear();\r\n\r\n\t\tvar compileErrors = new List\u003CGraphCompiler.Error\u003E();\r\n\t\tforeach ( var node in _graph.Nodes )\r\n\t\t{\r\n\t\t\tif ( node is IErroringNode erroring )\r\n\t\t\t{\r\n\t\t\t\tvar errors = erroring.GetErrors();\r\n\t\t\t\tif ( errors.Count \u003E 0 )\r\n\t\t\t\t{\r\n\t\t\t\t\t_shaderCompileErrors.AddRange( errors );\r\n\r\n\t\t\t\t\tif ( IsSubgraph )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tforeach ( var error in errors )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tcompileErrors.Add( new() { Message = error, Node = node } );\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t_output.Errors = compileErrors;\r\n\r\n\t\tif ( string.IsNullOrWhiteSpace( _generatedCode ) )\r\n\t\t{\r\n\t\t\tRestoreShader();\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif ( _isCompiling )\r\n\t\t{\r\n\t\t\t_isPendingCompile = true;\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar assetPath = $\u0022shadergraph/{_asset?.Name ?? \u0022untitled\u0022}_shadergraph.generated.shader\u0022;\r\n\t\tvar resourcePath = System.IO.Path.Combine( \u0022.source2/temp\u0022, assetPath );\r\n\r\n\t\tFileSystem.Root.CreateDirectory( \u0022.source2/temp/shadergraph\u0022 );\r\n\t\tFileSystem.Root.WriteAllText( resourcePath, _generatedCode );\r\n\r\n\t\t_isCompiling = true;\r\n\t\t_preview.IsCompiling = _isCompiling;\r\n\r\n\t\tRestoreShader();\r\n\r\n\t\t_timeSinceCompile = 0;\r\n\r\n\t\tCompileAsync( resourcePath );\r\n\t}\r\n\r\n\tprivate async void CompileAsync( string path )\r\n\t{\r\n\t\tvar options = new Sandbox.Engine.Shaders.ShaderCompileOptions\r\n\t\t{\r\n\t\t\tConsoleOutput = true\r\n\t\t};\r\n\r\n\t\tvar result = await EditorUtility.CompileShader( FileSystem.Root, path, options );\r\n\r\n\t\tif ( result.Success )\r\n\t\t{\r\n\t\t\tvar asset = AssetSystem.RegisterFile( FileSystem.Root.GetFullPath( path ) );\r\n\r\n\t\t\twhile ( !asset.IsCompiledAndUpToDate )\r\n\t\t\t{\r\n\t\t\t\tawait Task.Yield();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tMainThread.Queue( () =\u003E OnCompileFinished( result.Success ? 0 : 1 ) );\r\n\t}\r\n\r\n\tprotected readonly List\u003Cstring\u003E _shaderCompileErrors = new();\r\n\r\n\tprivate struct StatusMessage\r\n\t{\r\n\t\tpublic string Status { get; set; }\r\n\t\tpublic string Message { get; set; }\r\n\t}\r\n\r\n\tinternal void OnOutputData( object sender, DataReceivedEventArgs e )\r\n\t{\r\n\t\tvar str = e.Data;\r\n\t\tif ( str == null )\r\n\t\t\treturn;\r\n\r\n\t\tMainThread.Queue( () =\u003E\r\n\t\t{\r\n\t\t\tvar trimmed = str.Trim();\r\n\t\t\tif ( trimmed.StartsWith( \u0027{\u0027 ) \u0026\u0026 trimmed.EndsWith( \u0027}\u0027 ) )\r\n\t\t\t{\r\n\t\t\t\tvar status = Json.Deserialize\u003CStatusMessage\u003E( trimmed );\r\n\t\t\t\tif ( status.Status == \u0022Error\u0022 )\r\n\t\t\t\t{\r\n\t\t\t\t\tif ( !string.IsNullOrWhiteSpace( status.Message ) )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar lines = status.Message.Split( \u0027\\n\u0027 );\r\n\t\t\t\t\t\tforeach ( var line in lines.Where( x =\u003E !string.IsNullOrWhiteSpace( x ) ) )\r\n\t\t\t\t\t\t\t_shaderCompileErrors.Add( line );\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} );\r\n\t}\r\n\r\n\tinternal void OnErrorData( object sender, DataReceivedEventArgs e )\r\n\t{\r\n\t\tif ( e == null || e.Data == null )\r\n\t\t\treturn;\r\n\r\n\t\tMainThread.Queue( () =\u003E\r\n\t\t{\r\n\t\t\tvar error = $\u0022{e.Data}\u0022;\r\n\t\t\tif ( !string.IsNullOrWhiteSpace( error ) )\r\n\t\t\t\t_shaderCompileErrors.Add( error );\r\n\t\t} );\r\n\t}\r\n\r\n\tprivate void OnCompileFinished( int exitCode )\r\n\t{\r\n\t\t_isCompiling = false;\r\n\r\n\t\tif ( _isPendingCompile )\r\n\t\t{\r\n\t\t\t_isPendingCompile = false;\r\n\r\n\t\t\tCompile();\r\n\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tif ( exitCode == 0 \u0026\u0026 _shaderCompileErrors.Count == 0 )\r\n\t\t{\r\n\t\t\tLog.Info( $\u0022Compile finished in {_timeSinceCompile}\u0022 );\r\n\r\n\t\t\tvar shaderPath = $\u0022shadergraph/{_asset?.Name ?? \u0022untitled\u0022}_shadergraph.generated.shader\u0022;\r\n\r\n\t\t\t// Reload the shader otherwise it\u0027s gonna be the old wank\r\n\t\t\t// Alternatively Material.Create could be made to force reload the shader\r\n\t\t\tConsoleSystem.Run( $\u0022mat_reloadshaders {shaderPath}\u0022 );\r\n\r\n\t\t\tif ( _preview?.AutoCompile ?? true )\r\n\t\t\t\t_preview.Material = Material.Create( $\u0022{_asset?.Name ?? \u0022untitled\u0022}_shadergraph_generated\u0022, shaderPath );\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tLog.Error( $\u0022Compile failed in {_timeSinceCompile}\u0022 );\r\n\r\n\t\t\t_output.Errors = _shaderCompileErrors.Select( x =\u003E new GraphCompiler.Error { Message = x } );\r\n\t\t\tDockManager.RaiseDock( \u0022Output\u0022 );\r\n\r\n\t\t\tRestoreShader();\r\n\t\t\tClearAttributes();\r\n\t\t}\r\n\r\n\t\t_preview.IsCompiling = _isCompiling;\r\n\t\t_preview.PostProcessing = _graph.Domain == ShaderDomain.PostProcess;\r\n\r\n\t\t_shaderCompileErrors.Clear();\r\n\t}\r\n\r\n\tprivate void OnAttribute( string name, object value )\r\n\t{\r\n\t\tif ( value == null )\r\n\t\t\treturn;\r\n\r\n\t\tswitch ( value )\r\n\t\t{\r\n\t\t\tcase Color v:\r\n\t\t\t\t_float4Attributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase Vector4 v:\r\n\t\t\t\t_float4Attributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, (Color)v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase Vector3 v:\r\n\t\t\t\t_float3Attributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase Vector2 v:\r\n\t\t\t\t_float2Attributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase float v:\r\n\t\t\t\t_floatAttributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase bool v:\r\n\t\t\t\t_boolAttributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tcase Texture v:\r\n\t\t\t\t_textureAttributes[name] = v;\r\n\t\t\t\t_preview?.SetAttribute( name, v );\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tthrow new InvalidOperationException( $\u0022Unsupported attribute type: {value.GetType()}\u0022 );\r\n\t\t}\r\n\t}\r\n\r\n\tprivate string GeneratePreviewCode( bool force = false )\r\n\t{\r\n\t\tClearAttributes();\r\n\r\n\t\tvar resultNode = _graph.Nodes.OfType\u003CBaseResult\u003E().FirstOrDefault();\r\n\t\tvar compiler = new GraphCompiler( _graph, true );\r\n\t\tcompiler.OnAttribute = OnAttribute;\r\n\r\n\t\t// Evaluate all nodes\r\n\t\tforeach ( var node in _graph.Nodes.OfType\u003CBaseNode\u003E() )\r\n\t\t{\r\n\t\t\tvar property = node.GetType().GetProperties( BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static )\r\n\t\t\t\t.FirstOrDefault( x =\u003E x.GetGetMethod() != null \u0026\u0026 x.PropertyType == typeof( NodeResult.Func ) );\r\n\r\n\t\t\tif ( property == null )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tvar output = property.GetCustomAttribute\u003CBaseNode.OutputAttribute\u003E();\r\n\t\t\tif ( output == null )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tvar result = compiler.Result( new NodeInput { Identifier = node.Identifier, Output = property.Name } );\r\n\t\t\tif ( !result.IsValid() )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tvar componentType = result.ComponentType;\r\n\t\t\tif ( componentType == null )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\t// While we\u0027re here, let\u0027s check the output plugs and update their handle configs to the result type\r\n\r\n\t\t\tvar nodeUI = _graphView.FindNode( node );\r\n\t\t\tif ( !nodeUI.IsValid() )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tvar plugOut = nodeUI.Outputs.FirstOrDefault( x =\u003E ((BasePlug)x.Inner).Info.Property == property );\r\n\t\t\tif ( !plugOut.IsValid() )\r\n\t\t\t\tcontinue;\r\n\r\n\t\t\tplugOut.PropertyType = componentType;\r\n\r\n\t\t\t// We also have to update everything so they get repainted\r\n\r\n\t\t\tnodeUI.Update();\r\n\r\n\t\t\tforeach ( var input in nodeUI.Inputs )\r\n\t\t\t{\r\n\t\t\t\tif ( !input.IsValid() || !input.Connection.IsValid() )\r\n\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\tinput.Connection.Update();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_compiledNodes.Clear();\r\n\t\t_compiledNodes.AddRange( compiler.Nodes );\r\n\r\n\t\tif ( _properties.IsValid() \u0026\u0026 _properties.Target is BaseNode targetNode )\r\n\t\t{\r\n\t\t\t_preview.SetStage( _compiledNodes.IndexOf( targetNode ) \u002B 1 );\r\n\t\t}\r\n\r\n\t\tif ( resultNode != null )\r\n\t\t{\r\n\t\t\tvar nodeUI = _graphView.FindNode( resultNode );\r\n\t\t\tif ( nodeUI.IsValid() )\r\n\t\t\t{\r\n\t\t\t\tnodeUI.Update();\r\n\r\n\t\t\t\tforeach ( var input in nodeUI.Inputs )\r\n\t\t\t\t{\r\n\t\t\t\t\tif ( !input.IsValid() || !input.Connection.IsValid() )\r\n\t\t\t\t\t\tcontinue;\r\n\r\n\t\t\t\t\tinput.Connection.Update();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tvar code = compiler.Generate();\r\n\r\n\t\tif ( compiler.Errors.Any() || (!force \u0026\u0026 !(_preview?.AutoCompile ?? true)) )\r\n\t\t{\r\n\t\t\t_output.Errors = compiler.Errors;\r\n\t\t\tDockManager.RaiseDock( \u0022Output\u0022 );\r\n\r\n\t\t\t_generatedCode = null;\r\n\r\n\t\t\tRestoreShader();\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\t_output.Clear();\r\n\r\n\t\tif ( _generatedCode != code )\r\n\t\t{\r\n\t\t\t_generatedCode = code;\r\n\r\n\t\t\tCompile();\r\n\t\t}\r\n\r\n\t\treturn code;\r\n\t}\r\n\r\n\tpublic void OnUndoPushed()\r\n\t{\r\n\t\t_undoHistory.History = _undoStack.Names;\r\n\t}\r\n\r\n\tpublic void SetDirty( bool evaluate = true )\r\n\t{\r\n\t\tUpdate();\r\n\r\n\t\t_dirty = true;\r\n\t\t_graphCanvas.WindowTitle = $\u0022{_asset?.Name ?? \u0022untitled\u0022}*\u0022;\r\n\r\n\t\tif ( evaluate )\r\n\t\t\tGeneratePreviewCode();\r\n\t}\r\n\r\n\t[EditorEvent.Frame]\r\n\tprotected void Frame()\r\n\t{\r\n\t\t_undoOption.Enabled = _undoStack.CanUndo;\r\n\t\t_redoOption.Enabled = _undoStack.CanRedo;\r\n\t\t_undoMenuOption.Enabled = _undoStack.CanUndo;\r\n\t\t_redoMenuOption.Enabled = _undoStack.CanRedo;\r\n\r\n\t\t_undoOption.Text = _undoStack.UndoName;\r\n\t\t_redoOption.Text = _undoStack.RedoName;\r\n\t\t_undoMenuOption.Text = _undoStack.UndoName ?? \u0022Undo\u0022;\r\n\t\t_redoMenuOption.Text = _undoStack.RedoName ?? \u0022Redo\u0022;\r\n\r\n\t\t_undoOption.StatusTip = _undoStack.UndoName;\r\n\t\t_redoOption.StatusTip = _undoStack.RedoName;\r\n\t\t_undoMenuOption.StatusTip = _undoStack.UndoName;\r\n\t\t_redoMenuOption.StatusTip = _undoStack.RedoName;\r\n\r\n\t\tif ( _undoHistory is not null )\r\n\t\t{\r\n\t\t\t_undoHistory.UndoLevel = _undoStack.UndoLevel;\r\n\t\t}\r\n\r\n\t\tCheckForChanges();\r\n\t}\r\n\r\n\tprivate void CheckForChanges()\r\n\t{\r\n\t\tbool wasDirty = false;\r\n\t\tforeach ( var node in _graph.Nodes )\r\n\t\t{\r\n\t\t\tif ( node is ShaderNode shaderNode \u0026\u0026 shaderNode.IsDirty )\r\n\t\t\t{\r\n\t\t\t\tshaderNode.IsDirty = false;\r\n\t\t\t\twasDirty = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif ( wasDirty )\r\n\t\t{\r\n\t\t\t_graphView.ChildValuesChanged( null );\r\n\t\t}\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.undo\u0022, \u0022CTRL\u002BZ\u0022, ShortcutType.Window )]\r\n\tprivate void Undo()\r\n\t{\r\n\t\tif ( _undoStack.Undo() is UndoOp op )\r\n\t\t{\r\n\t\t\tLog.Info( $\u0022Undo ({op.name})\u0022 );\r\n\r\n\t\t\t_redoOption.Enabled = _undoStack.CanUndo;\r\n\r\n\t\t\t_graph.ClearNodes();\r\n\t\t\t_graph.DeserializeNodes( op.undoBuffer );\r\n\t\t\t_graphView.RebuildFromGraph();\r\n\r\n\t\t\tSetDirty();\r\n\t\t}\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.redo\u0022, \u0022CTRL\u002BY\u0022, ShortcutType.Window )]\r\n\tprivate void Redo()\r\n\t{\r\n\t\tif ( _undoStack.Redo() is UndoOp op )\r\n\t\t{\r\n\t\t\tLog.Info( $\u0022Redo ({op.name})\u0022 );\r\n\r\n\t\t\t_redoOption.Enabled = _undoStack.CanRedo;\r\n\r\n\t\t\t_graph.ClearNodes();\r\n\t\t\t_graph.DeserializeNodes( op.redoBuffer );\r\n\t\t\t_graphView.RebuildFromGraph();\r\n\r\n\t\t\tSetDirty();\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void SetUndoLevel( int level )\r\n\t{\r\n\t\tif ( _undoStack.SetUndoLevel( level ) is UndoOp op )\r\n\t\t{\r\n\t\t\tLog.Info( $\u0022SetUndoLevel ({op.name})\u0022 );\r\n\r\n\t\t\t_graph.ClearNodes();\r\n\t\t\t_graph.DeserializeNodes( op.redoBuffer );\r\n\t\t\t_graphView.RebuildFromGraph();\r\n\r\n\t\t\tSetDirty();\r\n\t\t}\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.cut\u0022, \u0022CTRL\u002BX\u0022, ShortcutType.Window )]\r\n\tprivate void CutSelection()\r\n\t{\r\n\t\t_graphView.CutSelection();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.copy\u0022, \u0022CTRL\u002BC\u0022, ShortcutType.Window )]\r\n\tprivate void CopySelection()\r\n\t{\r\n\t\t_graphView.CopySelection();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.paste\u0022, \u0022CTRL\u002BV\u0022, ShortcutType.Window )]\r\n\tprivate void PasteSelection()\r\n\t{\r\n\t\t_graphView.PasteSelection();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.duplicate\u0022, \u0022CTRL\u002BD\u0022, ShortcutType.Window )]\r\n\tprivate void DuplicateSelection()\r\n\t{\r\n\t\t_graphView.DuplicateSelection();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.select-all\u0022, \u0022CTRL\u002BA\u0022, ShortcutType.Window )]\r\n\tprivate void SelectAll()\r\n\t{\r\n\t\t_graphView.SelectAll();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.clear-selection\u0022, \u0022ESC\u0022, ShortcutType.Window )]\r\n\tprivate void ClearSelection()\r\n\t{\r\n\t\t_graphView.ClearSelection();\r\n\t}\r\n\r\n\tprivate void CreateToolBar()\r\n\t{\r\n\t\tvar toolBar = new ToolBar( this, \u0022ShaderGraphToolbar\u0022 );\r\n\t\tAddToolBar( toolBar, ToolbarPosition.Top );\r\n\r\n\t\ttoolBar.AddOption( \u0022New\u0022, \u0022common/new.png\u0022, New ).StatusTip = \u0022New Shader Graph\u0022;\r\n\t\ttoolBar.AddOption( \u0022Open\u0022, \u0022common/open.png\u0022, Open ).StatusTip = \u0022Open Shader Graph\u0022;\r\n\r\n\t\ttoolBar.AddSeparator();\r\n\r\n\t\ttoolBar.AddOption( \u0022Save\u0022, \u0022common/save.png\u0022, () =\u003E Save() ).StatusTip = \u0022Save Shader Graph\u0022;\r\n\t\ttoolBar.AddOption( \u0022Compile\u0022, \u0022refresh\u0022, ForceCompile ).StatusTip = \u0022Compile Generated Shader\u0022;\r\n\r\n\t\ttoolBar.AddSeparator();\r\n\r\n\t\t_undoOption = toolBar.AddOption( \u0022Undo\u0022, \u0022undo\u0022, Undo );\r\n\t\t_redoOption = toolBar.AddOption( \u0022Redo\u0022, \u0022redo\u0022, Redo );\r\n\r\n\t\ttoolBar.AddSeparator();\r\n\r\n\t\ttoolBar.AddOption( \u0022Cut\u0022, \u0022common/cut.png\u0022, CutSelection );\r\n\t\ttoolBar.AddOption( \u0022Copy\u0022, \u0022common/copy.png\u0022, CopySelection );\r\n\t\ttoolBar.AddOption( \u0022Paste\u0022, \u0022common/paste.png\u0022, PasteSelection );\r\n\t\ttoolBar.AddOption( \u0022Select All\u0022, \u0022select_all\u0022, SelectAll );\r\n\r\n\t\ttoolBar.AddSeparator();\r\n\r\n\t\ttoolBar.AddOption( \u0022Open Generated Shader\u0022, \u0022common/edit.png\u0022, OpenGeneratedShader ).StatusTip = \u0022Open Generated Shader\u0022;\r\n\t\ttoolBar.AddOption( \u0022Take Screenshot\u0022, \u0022photo_camera\u0022, Screenshot ).StatusTip = \u0022Take Screenshot\u0022;\r\n\r\n\t\t_undoOption.Enabled = false;\r\n\t\t_redoOption.Enabled = false;\r\n\t}\r\n\r\n\tpublic void BuildMenuBar()\r\n\t{\r\n\t\tvar file = MenuBar.AddMenu( \u0022File\u0022 );\r\n\t\tfile.AddOption( \u0022New\u0022, \u0022common/new.png\u0022, New, \u0022editor.new\u0022 ).StatusTip = \u0022New Graph\u0022;\r\n\t\tfile.AddOption( \u0022Open\u0022, \u0022common/open.png\u0022, Open, \u0022editor.open\u0022 ).StatusTip = \u0022Open Graph\u0022;\r\n\t\tfile.AddOption( \u0022Save\u0022, \u0022common/save.png\u0022, Save, \u0022editor.save\u0022 ).StatusTip = \u0022Save Graph\u0022;\r\n\t\tfile.AddOption( \u0022Save As...\u0022, \u0022common/save.png\u0022, SaveAs, \u0022editor.save-as\u0022 ).StatusTip = \u0022Save Graph As...\u0022;\r\n\r\n\t\tfile.AddSeparator();\r\n\r\n\t\t_recentFilesMenu = file.AddMenu( \u0022Recent Files\u0022 );\r\n\r\n\t\tfile.AddSeparator();\r\n\r\n\t\tfile.AddOption( \u0022Quit\u0022, null, Quit, \u0022editor.quit\u0022 ).StatusTip = \u0022Quit\u0022;\r\n\r\n\t\tvar edit = MenuBar.AddMenu( \u0022Edit\u0022 );\r\n\t\t_undoMenuOption = edit.AddOption( \u0022Undo\u0022, \u0022undo\u0022, Undo, \u0022editor.undo\u0022 );\r\n\t\t_redoMenuOption = edit.AddOption( \u0022Redo\u0022, \u0022redo\u0022, Redo, \u0022editor.redo\u0022 );\r\n\t\t_undoMenuOption.Enabled = _undoStack.CanUndo;\r\n\t\t_redoMenuOption.Enabled = _undoStack.CanRedo;\r\n\r\n\t\tedit.AddSeparator();\r\n\t\tedit.AddOption( \u0022Cut\u0022, \u0022common/cut.png\u0022, CutSelection, \u0022editor.cut\u0022 );\r\n\t\tedit.AddOption( \u0022Copy\u0022, \u0022common/copy.png\u0022, CopySelection, \u0022editor.copy\u0022 );\r\n\t\tedit.AddOption( \u0022Paste\u0022, \u0022common/paste.png\u0022, PasteSelection, \u0022editor.paste\u0022 );\r\n\t\tedit.AddOption( \u0022Select All\u0022, \u0022select_all\u0022, SelectAll, \u0022editor.select-all\u0022 );\r\n\r\n\t\tRefreshRecentFiles();\r\n\r\n\t\tvar view = MenuBar.AddMenu( \u0022View\u0022 );\r\n\t\tview.AboutToShow \u002B= () =\u003E OnViewMenu( view );\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.quit\u0022, \u0022CTRL\u002BQ\u0022, ShortcutType.Window )]\r\n\tvoid Quit()\r\n\t{\r\n\t\tClose();\r\n\t}\r\n\tvoid RefreshRecentFiles()\r\n\t{\r\n\t\t_recentFilesMenu.Enabled = _recentFiles.Count \u003E 0;\r\n\r\n\t\t_recentFilesMenu.Clear();\r\n\r\n\t\t_recentFilesMenu.AddOption( \u0022Clear recent files\u0022, null, ClearRecentFiles )\r\n\t\t\t.StatusTip = \u0022Clear recent files\u0022;\r\n\r\n\t\t_recentFilesMenu.AddSeparator();\r\n\r\n\t\tconst int maxFilesToDisplay = 10;\r\n\t\tint fileCount = 0;\r\n\r\n\t\tfor ( int i = _recentFiles.Count - 1; i \u003E= 0; i-- )\r\n\t\t{\r\n\t\t\tif ( fileCount \u003E= maxFilesToDisplay )\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tvar filePath = _recentFiles[i];\r\n\r\n\t\t\t_recentFilesMenu.AddOption( $\u0022{\u002B\u002BfileCount} - {filePath}\u0022, null, () =\u003E PromptSave( () =\u003E Open( filePath ) ) )\r\n\t\t\t\t.StatusTip = $\u0022Open {filePath}\u0022;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void OnViewMenu( Menu view )\r\n\t{\r\n\t\tview.Clear();\r\n\t\tview.AddOption( \u0022Restore To Default\u0022, \u0022settings_backup_restore\u0022, ResetLayout );\r\n\t\tview.AddSeparator();\r\n\r\n\t\tforeach ( var dock in DockManager.DockTypes )\r\n\t\t{\r\n\t\t\tvar o = view.AddOption( dock.Title, dock.Icon );\r\n\t\t\to.Checkable = true;\r\n\t\t\to.Checked = DockManager.IsDockOpen( dock.Title );\r\n\t\t\to.Toggled \u002B= ( b ) =\u003E DockManager.SetDockState( dock.Title, b );\r\n\t\t}\r\n\r\n\t\tview.AddSeparator();\r\n\r\n\t\tvar style = view.AddOption( \u0022Grid-Aligned Wires\u0022, \u0022turn_sharp_right\u0022 );\r\n\t\tstyle.Checkable = true;\r\n\t\tstyle.Checked = ShaderGraphView.EnableGridAlignedWires;\r\n\t\tstyle.Toggled \u002B= b =\u003E ShaderGraphView.EnableGridAlignedWires = b;\r\n\t}\r\n\r\n\tprivate void ClearRecentFiles()\r\n\t{\r\n\t\tif ( _recentFiles.Count == 0 )\r\n\t\t\treturn;\r\n\r\n\t\t_recentFiles.Clear();\r\n\r\n\t\tRefreshRecentFiles();\r\n\r\n\t\tSaveRecentFiles();\r\n\t}\r\n\r\n\tprivate void AddToRecentFiles( string filePath )\r\n\t{\r\n\t\tfilePath = filePath.ToLower();\r\n\r\n\t\t// If file is already recent, remove it so it\u0027ll become the most recent\r\n\t\tif ( _recentFiles.Contains( filePath ) )\r\n\t\t{\r\n\t\t\t_recentFiles.RemoveAll( x =\u003E x == filePath );\r\n\t\t}\r\n\r\n\t\t_recentFiles.Add( filePath );\r\n\r\n\t\tRefreshRecentFiles();\r\n\t\tSaveRecentFiles();\r\n\t}\r\n\r\n\tprivate void SaveRecentFiles()\r\n\t{\r\n\t\tFileSystem.Temporary.WriteJson( \u0022shadergraph_recentfiles.json\u0022, _recentFiles );\r\n\t}\r\n\r\n\tprivate void PromptSave( Action action )\r\n\t{\r\n\t\tif ( !_dirty )\r\n\t\t{\r\n\t\t\taction?.Invoke();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar confirm = new PopupWindow(\r\n\t\t\t\u0022Save Current Graph\u0022, \u0022The open graph has unsaved changes. Would you like to save now?\u0022, \u0022Cancel\u0022,\r\n\t\t\tnew Dictionary\u003Cstring, Action\u003E()\r\n\t\t\t{\r\n\t\t\t\t{ \u0022No\u0022, () =\u003E action?.Invoke() },\r\n\t\t\t\t{ \u0022Yes\u0022, () =\u003E { if ( SaveInternal( false ) ) action?.Invoke(); } }\r\n\t\t\t}\r\n\t\t);\r\n\r\n\t\tconfirm.Show();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.new\u0022, \u0022CTRL\u002BN\u0022, ShortcutType.Window )]\r\n\tpublic void New()\r\n\t{\r\n\t\tPromptSave( CreateNew );\r\n\t}\r\n\r\n\tpublic void CreateNew()\r\n\t{\r\n\t\t_asset = null;\r\n\t\t_graph = new();\r\n\t\t_dirty = false;\r\n\t\t_graphView.Graph = _graph;\r\n\t\t_graphCanvas.WindowTitle = \u0022untitled\u0022;\r\n\t\t_preview.Model = null;\r\n\t\t_preview.Tint = Color.White;\r\n\t\t_undoStack.Clear();\r\n\t\t_undoHistory.History = _undoStack.Names;\r\n\t\t_generatedCode = \u0022\u0022;\r\n\t\t_properties.Target = _graph;\r\n\r\n\t\t_output.Clear();\r\n\r\n\t\tif ( !IsSubgraph )\r\n\t\t{\r\n\t\t\tvar result = _graphView.CreateNewNode( _graphView.FindNodeType( typeof( Result ) ), 0 );\r\n\t\t\t_graphView.Scale = 1;\r\n\t\t\t_graphView.CenterOn( result.Size * 0.5f );\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tvar result = _graphView.CreateNewNode( _graphView.FindNodeType( typeof( FunctionResult ) ), 0 );\r\n\t\t\t_graphView.Scale = 1;\r\n\t\t\t_graphView.CenterOn( result.Size * 0.5f );\r\n\t\t}\r\n\r\n\t\tClearAttributes();\r\n\r\n\t\tRestoreShader();\r\n\t}\r\n\r\n\tprivate void ClearAttributes()\r\n\t{\r\n\t\t_textureAttributes.Clear();\r\n\t\t_float4Attributes.Clear();\r\n\t\t_float3Attributes.Clear();\r\n\t\t_float2Attributes.Clear();\r\n\t\t_floatAttributes.Clear();\r\n\t\t_boolAttributes.Clear();\r\n\t\t_compiledNodes.Clear();\r\n\r\n\t\t_preview?.ClearAttributes();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.open\u0022, \u0022CTRL\u002BO\u0022, ShortcutType.Window )]\r\n\tpublic void Open()\r\n\t{\r\n\t\tvar fd = new FileDialog( null )\r\n\t\t{\r\n\t\t\tTitle = $\u0022Open {FileType}\u0022,\r\n\t\t\tDefaultSuffix = $\u0022.{FileExtension}\u0022\r\n\t\t};\r\n\r\n\t\tfd.SetNameFilter( $\u0022{FileType} ( *.{FileExtension})\u0022 );\r\n\r\n\t\tif ( !fd.Execute() )\r\n\t\t\treturn;\r\n\r\n\t\tPromptSave( () =\u003E Open( fd.SelectedFile ) );\r\n\t}\r\n\r\n\tpublic void Open( string path, bool addToPath = true )\r\n\t{\r\n\t\tvar asset = AssetSystem.FindByPath( path );\r\n\t\tif ( asset == null )\r\n\t\t\treturn;\r\n\r\n\t\tif ( asset == _asset )\r\n\t\t{\r\n\t\t\tFocus();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tvar graph = new ShaderGraph();\r\n\t\tgraph.Deserialize( System.IO.File.ReadAllText( path ) );\r\n\t\tgraph.Path = asset.RelativePath;\r\n\t\tgraph.IsSubgraph = IsSubgraph;\r\n\r\n\t\t_preview.Model = string.IsNullOrWhiteSpace( graph.Model ) ? null : Model.Load( graph.Model );\r\n\t\t_preview.LoadSettings( graph.PreviewSettings );\r\n\r\n\t\t_asset = asset;\r\n\t\t_graph = graph;\r\n\t\t_dirty = false;\r\n\t\t_graphView.Graph = _graph;\r\n\t\t_graphCanvas.WindowTitle = _asset.Name;\r\n\t\t_undoStack.Clear();\r\n\t\t_undoHistory.History = _undoStack.Names;\r\n\t\t_generatedCode = \u0022\u0022;\r\n\t\t_properties.Target = _graph;\r\n\r\n\t\tif ( addToPath )\r\n\t\t\tAddFileHistory( path );\r\n\r\n\t\t_output.Clear();\r\n\r\n\t\tvar center = Vector2.Zero;\r\n\t\tvar resultNode = graph.Nodes.OfType\u003CBaseResult\u003E().FirstOrDefault();\r\n\t\tif ( resultNode != null )\r\n\t\t{\r\n\t\t\tvar nodeUI = _graphView.FindNode( resultNode );\r\n\t\t\tif ( nodeUI.IsValid() )\r\n\t\t\t{\r\n\t\t\t\tcenter = nodeUI.Position \u002B nodeUI.Size * 0.5f;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t_graphView.Scale = 1;\r\n\t\t_graphView.CenterOn( center );\r\n\t\t_graphView.RestoreViewFromCookie();\r\n\r\n\t\tClearAttributes();\r\n\r\n\t\tAddToRecentFiles( path );\r\n\r\n\t\tGeneratePreviewCode();\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.save-as\u0022, \u0022CTRL\u002BSHIFT\u002BS\u0022, ShortcutType.Window )]\r\n\tpublic void SaveAs()\r\n\t{\r\n\t\tSaveInternal( true );\r\n\t}\r\n\r\n\t[Shortcut( \u0022editor.save\u0022, \u0022CTRL\u002BS\u0022, ShortcutType.Window )]\r\n\tpublic void Save()\r\n\t{\r\n\t\tSaveInternal( false );\r\n\t}\r\n\r\n\tprivate void AddFileHistory( string path )\r\n\t{\r\n\t\tvar lastFileHistory = _fileHistory.LastOrDefault();\r\n\t\tif ( _fileHistoryPosition \u003C _fileHistory.Count - 1 )\r\n\t\t{\r\n\t\t\t_fileHistory.RemoveRange( _fileHistoryPosition \u002B 1, _fileHistory.Count - _fileHistoryPosition - 1 );\r\n\t\t}\r\n\t\tif ( path != lastFileHistory )\r\n\t\t\t_fileHistory.Add( path );\r\n\t\t_fileHistoryPosition = _fileHistory.Count - 1;\r\n\r\n\t\tUpdateFileHistoryButtons();\r\n\t}\r\n\r\n\tprivate void FileHistoryForward()\r\n\t{\r\n\t\tif ( _fileHistoryPosition \u003C _fileHistory.Count - 1 )\r\n\t\t{\r\n\t\t\t_fileHistoryPosition\u002B\u002B;\r\n\t\t\tPromptSave( () =\u003E\r\n\t\t\t{\r\n\t\t\t\tOpen( _fileHistory[_fileHistoryPosition], false );\r\n\t\t\t\tUpdateFileHistoryButtons();\r\n\t\t\t} );\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void FileHistoryBack()\r\n\t{\r\n\t\tif ( _fileHistoryPosition \u003E 0 )\r\n\t\t{\r\n\t\t\t_fileHistoryPosition--;\r\n\t\t\tPromptSave( () =\u003E\r\n\t\t\t{\r\n\t\t\t\tOpen( _fileHistory[_fileHistoryPosition], false );\r\n\t\t\t\tUpdateFileHistoryButtons();\r\n\t\t\t} );\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void FileHistoryHome()\r\n\t{\r\n\t\tif ( _fileHistory.Count == 0 ) return;\r\n\t\tPromptSave( () =\u003E\r\n\t\t{\r\n\t\t\tOpen( _fileHistory.First() );\r\n\t\t\tUpdateFileHistoryButtons();\r\n\t\t} );\r\n\t}\r\n\r\n\tprivate void UpdateFileHistoryButtons()\r\n\t{\r\n\t\t_fileHistoryForward.Enabled = _fileHistoryPosition \u003C _fileHistory.Count - 1;\r\n\t\t_fileHistoryBack.Enabled = _fileHistoryPosition \u003E 0;\r\n\t\t_fileHistoryHome.Enabled = _asset.Path != _fileHistory.FirstOrDefault();\r\n\t}\r\n\r\n\tprivate bool SaveInternal( bool saveAs )\r\n\t{\r\n\t\tvar savePath = _asset == null || saveAs ? GetSavePath() : _asset.AbsolutePath;\r\n\t\tif ( string.IsNullOrWhiteSpace( savePath ) )\r\n\t\t\treturn false;\r\n\r\n\t\t_preview.SaveSettings( _graph.PreviewSettings );\r\n\r\n\t\t// Write serialized graph to asset file\r\n\t\tSystem.IO.File.WriteAllText( savePath, _graph.Serialize() );\r\n\r\n\t\tif ( saveAs )\r\n\t\t{\r\n\t\t\t// If we\u0027re saving as, we want to register the new asset\r\n\t\t\t_asset = null;\r\n\t\t}\r\n\r\n\t\t// Register asset if we haven\u0027t already\r\n\t\t_asset ??= AssetSystem.RegisterFile( savePath );\r\n\r\n\t\tif ( _asset == null )\r\n\t\t{\r\n\t\t\tLog.Warning( $\u0022Unable to register asset {savePath}\u0022 );\r\n\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tMainAssetBrowser.Instance?.Local.UpdateAssetList();\r\n\r\n\t\t_dirty = false;\r\n\t\t_graphCanvas.WindowTitle = _asset.Name;\r\n\r\n\t\tif ( IsSubgraph )\r\n\t\t{\r\n\t\t\tCompile();\r\n\t\t}\r\n\r\n\t\tAddToRecentFiles( savePath );\r\n\r\n\t\tEditorEvent.Run( \u0022shadergraph.update.subgraph\u0022, _asset.RelativePath );\r\n\r\n\t\treturn true;\r\n\t}\r\n\r\n\tprivate string GetSavePath()\r\n\t{\r\n\t\tvar fd = new FileDialog( null )\r\n\t\t{\r\n\t\t\tTitle = $\u0022Save {FileType}\u0022,\r\n\t\t\tDefaultSuffix = $\u0022.{FileExtension}\u0022\r\n\t\t};\r\n\r\n\t\tfd.SelectFile( $\u0022untitled.{FileExtension}\u0022 );\r\n\t\tfd.SetFindFile();\r\n\t\tfd.SetModeSave();\r\n\t\tfd.SetNameFilter( $\u0022{FileType} (*.{FileExtension})\u0022 );\r\n\t\tif ( !fd.Execute() )\r\n\t\t\treturn null;\r\n\r\n\t\treturn fd.SelectedFile;\r\n\t}\r\n\r\n\tpublic void CreateUI()\r\n\t{\r\n\t\tBuildMenuBar();\r\n\r\n\t\t_graphCanvas = new Widget( this ) { WindowTitle = $\u0022{(_asset != null ? _asset.Name : \u0022untitled\u0022)}{(_dirty ? \u0022*\u0022 : \u0022\u0022)}\u0022 };\r\n\t\t_graphCanvas.Name = \u0022Graph\u0022;\r\n\t\t_graphCanvas.SetWindowIcon( \u0022account_tree\u0022 );\r\n\t\t_graphCanvas.Layout = Layout.Column();\r\n\r\n\t\tvar graphToolBar = new ToolBar( _graphCanvas, \u0022GraphToolBar\u0022 );\r\n\t\tgraphToolBar.SetIconSize( 16 );\r\n\t\t_fileHistoryBack = graphToolBar.AddOption( null, \u0022arrow_back\u0022 );\r\n\t\t_fileHistoryForward = graphToolBar.AddOption( null, \u0022arrow_forward\u0022 );\r\n\t\tgraphToolBar.AddSeparator();\r\n\t\t_fileHistoryHome = graphToolBar.AddOption( null, \u0022common/home.png\u0022 );\r\n\t\t_fileHistoryBack.Triggered \u002B= FileHistoryBack;\r\n\t\t_fileHistoryForward.Triggered \u002B= FileHistoryForward;\r\n\t\t_fileHistoryHome.Triggered \u002B= FileHistoryHome;\r\n\t\t_fileHistoryBack.Enabled = false;\r\n\t\t_fileHistoryForward.Enabled = false;\r\n\t\t_fileHistoryHome.Enabled = false;\r\n\r\n\t\tvar stretcher = new Widget( graphToolBar );\r\n\t\tstretcher.Layout = Layout.Row();\r\n\t\tstretcher.Layout.AddStretchCell( 1 );\r\n\t\tgraphToolBar.AddWidget( stretcher );\r\n\r\n\t\t_graphCanvas.Layout.Add( graphToolBar );\r\n\r\n\t\t_graphView = new ShaderGraphView( _graphCanvas, this );\r\n\t\t_graphView.BilinearFiltering = false;\r\n\r\n\t\tvar types = EditorTypeLibrary.GetTypes\u003CShaderNode\u003E()\r\n\t\t\t.Where( x =\u003E !x.IsAbstract ).OrderBy( x =\u003E x.Name );\r\n\r\n\t\tforeach ( var type in types )\r\n\t\t{\r\n\t\t\t_graphView.AddNodeType( type );\r\n\t\t}\r\n\r\n\t\tvar subgraphs = AssetSystem.All.Where( x =\u003E x.Path.EndsWith( \u0022.shdrfunc\u0022, StringComparison.OrdinalIgnoreCase ) );\r\n\t\tforeach ( var subgraph in subgraphs )\r\n\t\t{\r\n\t\t\t_graphView.AddNodeType( subgraph.Path );\r\n\t\t}\r\n\r\n\t\t_graphView.Graph = _graph;\r\n\t\t_graphView.OnChildValuesChanged \u002B= ( w ) =\u003E SetDirty();\r\n\t\t_graphCanvas.Layout.Add( _graphView, 1 );\r\n\r\n\t\t_output = new Output( this );\r\n\t\t_output.OnNodeSelected \u002B= ( node ) =\u003E\r\n\t\t{\r\n\t\t\tvar nodeUI = _graphView.SelectNode( node );\r\n\r\n\t\t\t_graphView.Scale = 1;\r\n\t\t\t_graphView.CenterOn( nodeUI.Center );\r\n\t\t};\r\n\r\n\t\t_preview = new PreviewPanel( this, _graph.Model )\r\n\t\t{\r\n\t\t\tOnModelChanged = ( model ) =\u003E _graph.Model = model?.Name,\r\n\t\t\tOnAutoCompileEnabled = () =\u003E GeneratePreviewCode()\r\n\t\t};\r\n\r\n\t\tforeach ( var value in _textureAttributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\tforeach ( var value in _float4Attributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\tforeach ( var value in _float3Attributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\tforeach ( var value in _float2Attributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\tforeach ( var value in _floatAttributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\tforeach ( var value in _boolAttributes )\r\n\t\t{\r\n\t\t\t_preview.SetAttribute( value.Key, value.Value );\r\n\t\t}\r\n\r\n\t\t_properties = new Properties( this );\r\n\t\t_properties.Target = _graph;\r\n\t\t_properties.PropertyUpdated \u002B= OnPropertyUpdated;\r\n\r\n\t\t_undoHistory = new UndoHistory( this, _undoStack );\r\n\t\t_undoHistory.OnUndo = Undo;\r\n\t\t_undoHistory.OnRedo = Redo;\r\n\t\t_undoHistory.OnHistorySelected = SetUndoLevel;\r\n\r\n\t\t_palette = new PaletteWidget( this, IsSubgraph );\r\n\r\n\t\tDockManager.AddDock( \u0022Graph\u0022, \u0022account_tree\u0022, _graphCanvas, DockArea.Center );\r\n\t\tDockManager.AddDock( \u0022Preview\u0022, \u0022photo\u0022, _preview, DockArea.Left );\r\n\t\tDockManager.AddDock( \u0022Properties\u0022, \u0022edit\u0022, _properties, DockArea.Bottom );\r\n\t\tvar output = DockManager.AddDock( \u0022Output\u0022, \u0022notes\u0022, _output, DockArea.Bottom );\r\n\r\n\t\tif ( EditorTypeLibrary.Create( \u0022ConsoleWidget\u0022, typeof( Widget ), new[] { this } ) is Widget console )\r\n\t\t\tDockManager.AddDock( \u0022Console\u0022, \u0022text_snippet\u0022, console, DockArea.Center, relativeTo: output );\r\n\r\n\t\tDockManager.AddDock( \u0022Undo History\u0022, \u0022history\u0022, _undoHistory, DockArea.Center, relativeTo: output );\r\n\t\tDockManager.AddDock( \u0022Palette\u0022, \u0022palette\u0022, _palette, DockArea.Center, relativeTo: output );\r\n\r\n\t\tDockManager.RaiseDock( \u0022Output\u0022 );\r\n\r\n\t\tCompile();\r\n\t}\r\n\r\n\tprotected override void BuildDefaultLayout()\r\n\t{\r\n\t\tvar graph = DockManager.OpenDock( \u0022Graph\u0022, DockArea.Center );\r\n\t\tvar preview = DockManager.OpenDock( \u0022Preview\u0022, DockArea.Left );\r\n\t\tDockManager.SetSplitterProportions( preview, 0.3f, 0.7f );\r\n\r\n\t\tvar properties = DockManager.OpenDock( \u0022Properties\u0022, DockArea.Bottom, preview );\r\n\t\tvar output = DockManager.OpenDock( \u0022Output\u0022, DockArea.Bottom, graph );\r\n\t\tDockManager.OpenDock( \u0022Console\u0022, DockArea.Center, output );\r\n\t\tDockManager.OpenDock( \u0022Undo History\u0022, DockArea.Center, output );\r\n\t\tDockManager.OpenDock( \u0022Palette\u0022, DockArea.Center, output );\r\n\r\n\t\tDockManager.SetSplitterProportions( properties, 0.5f, 0.5f );\r\n\t\tDockManager.SetSplitterProportions( output, 0.75f, 0.25f );\r\n\t\tDockManager.RaiseDock( \u0022Output\u0022 );\r\n\t}\r\n\r\n\tprivate void OnPropertyUpdated()\r\n\t{\r\n\t\t_preview.PostProcessing = _graphView.Graph.Domain == ShaderDomain.PostProcess;\r\n\t\tif ( _properties.Target is BaseNode node )\r\n\t\t{\r\n\t\t\t_graphView.UpdateNode( node );\r\n\t\t}\r\n\t\telse if ( _properties.MultiEditTargets is { Count: \u003E 0 } multiNodes )\r\n\t\t{\r\n\t\t\tforeach ( var multiNode in multiNodes )\r\n\t\t\t\t_graphView.UpdateNode( multiNode );\r\n\t\t}\r\n\r\n\t\tvar shouldEvaluate = _properties.Target is not CommentNode;\r\n\t\tSetDirty( shouldEvaluate );\r\n\t}\r\n\r\n\tprotected override bool OnClose()\r\n\t{\r\n\t\tif ( !_dirty )\r\n\t\t{\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tvar confirm = new PopupWindow(\r\n\t\t\t\u0022Save Current Graph\u0022, \u0022The open graph has unsaved changes. Would you like to save now?\u0022, \u0022Cancel\u0022,\r\n\t\t\tnew Dictionary\u003Cstring, Action\u003E()\r\n\t\t\t{\r\n\t\t\t\t{ \u0022No\u0022, () =\u003E { _dirty = false; Close(); } },\r\n\t\t\t\t{ \u0022Yes\u0022, () =\u003E { if ( SaveInternal( false ) ) Close(); } }\r\n\t\t\t}\r\n\t\t);\r\n\r\n\t\tconfirm.Show();\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\t[Event( \u0022shadergraph.update.subgraph\u0022 )]\r\n\tpublic void OnSubgraphUpdate( string updatedPath )\r\n\t{\r\n\t\tforeach ( var node in _graph.Nodes )\r\n\t\t{\r\n\t\t\tif ( node is SubgraphNode subgraphNode )\r\n\t\t\t{\r\n\t\t\t\tsubgraphNode.Subgraph = null;\r\n\t\t\t\tsubgraphNode.OnNodeCreated();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tGeneratePreviewCode();\r\n\t}\r\n}\r\n"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UniversalNodes/Refraction.cs","FileName":"Refraction.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraph.Nodes;\r\n\r\n[Title( \u0022SGE - Refraction\u0022 ), Category( \u0022Shader Graph Extras - Universal\u0022 ), Icon( \u0022lens\u0022 )]\r\npublic sealed class SGERefractionNode : ShaderNode\r\n{\r\n\t[Hide]\r\n\tpublic static string SGERefraction =\u003E @\u0022\r\n\t\tfloat3 SGERefraction(float3 viewDirection, float3 worldNormal, float indexOfRefraction)\r\n\t\t{\r\n\t\t\treturn refract(viewDirection, worldNormal, indexOfRefraction);\r\n\t\t}\r\n\t\t\u0022;\r\n\r\n\t[Input( typeof( Vector3 ) )]\r\n\t[Title(\u0022View Direction\u0022)]\r\n\t[Hide]\r\n\tpublic NodeInput ViewDirection { get; set; }\r\n\r\n\t[Input( typeof( Vector3 ) )]\r\n\t[Title(\u0022World Normal\u0022)]\r\n\t[Hide]\r\n\tpublic NodeInput WorldNormal { get; set; }\r\n\r\n\t[Input (typeof(float))]\r\n\t[Title(\u0022Index Of Refraction\u0022)]\r\n\t[Hide]\r\n\tpublic NodeInput IndexOfRefraction {get;set;}\r\n\r\n\t[InputDefault( nameof( IndexOfRefraction ) )]\r\n\tpublic float DefaultIndexOfRefraction {get; set;} = 0.5f;\r\n\r\n\t[Output( typeof( Vector3 ) )] \r\n\t[Hide]\r\n\tpublic NodeResult.Func Output =\u003E ( GraphCompiler compiler ) =\u003E\r\n\t{\r\n\t\tvar viewDirection = compiler.Result(ViewDirection);\r\n\t\tvar worldNormal = compiler.Result(WorldNormal);\r\n\t\tvar indexOfRefraction = compiler.ResultOrDefault(IndexOfRefraction,DefaultIndexOfRefraction);\r\n\r\n\t\treturn new NodeResult(NodeResultType.Vector3, compiler.ResultFunction( compiler.RegisterFunction( SGERefraction ), $\u0022{viewDirection}, {worldNormal}, {indexOfRefraction}\u0022));\r\n\t};\r\n}"},{"Ident":"ali3nsystems.lib-shader_graph_extras","Path":"Editor/UpgradedShaderGraph/Core/Compiler/ShadingModels/Unlit.cs","FileName":"Unlit.cs","PackageType":"library","CodeKind":"Editor","AssetVersionId":336415,"IsPrivate":false,"Code":"namespace Editor.ShaderGraphExtras;\r\npublic static class UnlitShadingModel\r\n{\r\n\tpublic static Dictionary\u003Cstring, bool\u003E Features =\u003E new()\r\n\t{\r\n        { \u0022SupportsAlbedo\u0022, true},\r\n\t\t{ \u0022SupportsEmission\u0022, false },\r\n        { \u0022SupportsOpacity\u0022, true},\r\n\t\t{ \u0022SupportsNormal\u0022, false },\r\n\t\t{ \u0022SupportsRoughness\u0022, false },\r\n\t\t{ \u0022SupportsMetalness\u0022, false },\r\n\t\t{ \u0022SupportsAmbientOcclusion\u0022, false },\r\n\t\t{ \u0022SupportsPositionOffset\u0022, true },\r\n        { \u0022SupportsPixelDepthOffset\u0022, false},\r\n\r\n\t\t{ \u0022SupportsOpaqueBlendMode\u0022, true},\r\n\t\t{ \u0022SupportsMaskedBlendMode\u0022, true},\r\n\t\t{ \u0022SupportsTranslucentBlendMode\u0022, true},\r\n\t\t{ \u0022SupportsDynamicBlendMode\u0022, true},\r\n\t\t{ \u0022SupportsCustomBlendMode\u0022, true}\r\n\t};\r\n\tpublic static string Code =\u003E @\u0022\r\nreturn float4( m.Albedo, m.Opacity );\u0022;\r\n}\r\n"}]}