Sandbox Logo

About Shader Graph Plus

This is a shrimple fork of shadergraph that is serving as my testbed of sorts . This may become obsolete in the future.

Major Changes

• Graph asset extension was changed from .shdrgrph to .shrph. ( Don't want you opening vanilla shadergraph files ).

• You can switch between lit & unlit shading models now. Do note that the ports on the material node that are unused in unlit mode are not greyed out yet.

• Nodes can have there own bundled hlsl functions. See Editor\ShaderGraphPlus\Nodes\Effects\Gerstner.cs as an example of this functionality being used.
•  Post Processing Shader Support. (Might be a lil buggy with the preview window) 
• Matrix Constants . ( float2x2, float3x3 & float4x4 )
• Gradient Node & Sample Gradient Node.

Custom Node Example

Below is an example of a custom node. Of which contains a bundled hlsl function. ( Cant make your own nodes within your editor project yet  due to this : https://github.com/Facepunch/sbox-issues/issues/6284)
[Title( "Box Shape" ), Category( "Procedural" )]

public sealed class BoxShapeNode : ShaderNodePlus
{
[Hide]
public string BoxShape => @"
float BoxShape( float2 UV, float Width, float Height )
{
float2 d = abs(UV * 2 - 1) - float2(Width, Height);
d = 1 - d / fwidth(d);
return saturate(min(d.x, d.y));
}
";

[Title( "UV" )]
[Input( typeof( Vector2 ) )]
[Hide]
public NodeInput Coords { get; set; }

[Title( "Width" )]
[Input( typeof( float ) )]
[Hide]
public NodeInput Width { get; set; }

[Title( "Height" )]
[Input( typeof( float ) )]
[Hide]
public NodeInput Height { get; set; }

public float DefaultWidth { get; set; } = 0.5f;
public float DefaultHeight { get; set; } = 0.5f;

[Output( typeof( float ) )]
[Hide]
public NodeResult.Func Result => ( GraphCompiler compiler ) =>
{
var incoords = compiler.Result( Coords );

// use defaults if no input is connected to either Width or Height.
var width = compiler.ResultOrDefault( Width, DefaultWidth );
var height = compiler.ResultOrDefault( Height, DefaultHeight );

var coords = "";

// Handle PostProcessing Shaders texture coords.
if ( compiler.Graph.MaterialDomain is MaterialDomain.PostProcess )
{
coords = incoords.IsValid ? $"{incoords.Cast( 2 )}" : "CalculateViewportUv( i.vPositionSs.xy )";
}
else
{
coords = incoords.IsValid ? $"{incoords.Cast( 2 )}" : "i.vTextureCoords.xy";
}

// Avalible Result Types
/*
ResultType.Bool
ResultType.Float
ResultType.Vector2
ResultType.Vector3
ResultType.Color
ResultType.Float2x2
ResultType.Float3x3
ResultType.Float4x4
ResultType.Sampler
ResultType.TextureObject
*/
return new NodeResult( ResultType.Float , compiler.ResultFunction( BoxShape, args: $"{coords}, {width}, {height}" ) );
};

}

Source

https://github.com/QuackCola/ShaderGraphPlus