Facepunch / sbox-issues

175 stars 12 forks source link

[ShaderGraph] Ability to create custom shadergraph nodes in your own Editor Project and or Libraries #5634

Closed QuackCola closed 4 months ago

QuackCola commented 4 months ago

For?

S&Box, Other

What can't you do?

Currently you are unable to create a custom shadergraph node that inherits the base node or something like Unary nodetype for example. outside of the shadergraph project. which kind of sucks atm.

How would you like it to work?

Make it so you are able to access Shadergraph stuff from an editor project and or library.

What have you tried?

Just putting the custom node code inside the shadergraph project.

Additional context

No response

aylaylay commented 4 months ago

You can create your own nodes in tool libraries now

using Sandbox;

namespace Editor.ShaderGraph.Nodes;

[Title( "My Shader Node" ), Category( "Doggy" )]
public class MyShaderNode : ShaderNode
{
    [Input( typeof( float ) ), Hide, Title( "" )]
    public NodeInput In { get; set; }

    [Output, Hide]
    public NodeResult.Func Out => ( GraphCompiler compiler ) =>
    {
        var result = compiler.ResultOrDefault( In, 0.0f );
        return new NodeResult( result.Components, $"1 - {result}" );
    };
}
QuackCola commented 4 months ago

Lovely stuff! , seems to work fine on my end :)