Please allow ref as inout in CodeFunctionNode

    public CustomGlobeUV()
    {
        name = "CustomGlobeUV";
    }

    protected override MethodInfo GetFunctionToConvert()
    {
        return GetType().GetMethod(nameof(GenUV),BindingFlags.Static | BindingFlags.NonPublic);
    }

    static string GenUV(
        [Slot(0,Binding.ObjectSpacePosition,ShaderStageCapability.Fragment)] DynamicDimensionVector position,
        [Slot(3,Binding.None,0,0,1,0,0)] Vector2 offset,
        [Slot(4,Binding.MeshUV0)] ref Vector2 UV)
    {

Will generated

    void GenUV_float(float3 position, float2 offset, float2 UV)

But I expect

    void GenUV_float(float3 position, float2 offset, inout float2 UV)
1 Like

Not to disappoint you, but if you look at 2019.1 (beta), they removed the entire custom node API (the whole API is now internal instead of public) (see 2019.1 ShaderGraph custom nodes (poll, please vote !) ).
So it’s extremely unlikely that they will update the old 2018-only API.
This being said, I guess more feedback never hurts !

1 Like

Hi, thanks for the suggestion.

As ph_ notes, we have removed this API as of 2019.1. I will bring up this suggestion with the team to discuss implementing it via the Custom Function node but, honestly, I doubt we would implement this.

How would you imagine this works on a one-way data flow graph system? If you do this you are writing to the value of the input port. In your case you want to specifically modify the base UVs but I dont think this is ever something we would want to allow as it results in complex, order-dependent graphs (if that value is used elsewhere, how we do decide which nodes are calculated first?).

What I see as a more valid way of doing the same thing is us implementing custom interpolators (which are already on our backlog), then you could calculate custom UVs and use them in fragment without complex two-way graph logic.

@Kink3d I don’t think it has any problem in graph. Just has a input point with the same name as output point

If there was a problem about order dependent, we could transpile the graph to just copy variable before put in ref if there is dependency of that value (and if that value have no dependency then it shouldn’t need to be copied)

I don’t have specific require for transforming the same variable. I just want to have compact code and reduce variable slot