+2
Under review

Support for custom programmable nodes

LennardF1989 4 years ago • updated 4 years ago 4
I got in contact with ShaderForge through one of my employers. While it's a near-complete solution compared to the Unreal Material Editor, I'm missing a key-feature, which is making re-usable functions (basically splitting off 20+ nodes from my tree, eg. a Complex Fresnel calculation).

While the code-node works as a work-around, the lag of multiple outputs is annoying, as I'm currently trying to port an UDK shader which uses those.

I currently hacked in custom node support into Shader Forge, which means that at the end of "InitializeNodeTemplates" inside of SF_Editor, an event "OnNodesInitialized" is called, which I can hook into and call "AddTemplate" on my own nodes.

While this is all rather hacky, it works, even serializing/deserializing. However, it would be neat if SF would get a system for this out of the box. For example some sort of plugin-system which loads a DLL by reflection and retrieves the list of custom nodes in that DLL.
Under review
This has been discussed a lot back and forth, and there are many things to consider:

http://forum.unity3d.com/threads/222049-Shader-For...

Plus a lot of discussion on it on this page:

http://forum.unity3d.com/threads/222049-Shader-For...

So, as I mentioned, I may open it up at some point, but we'll see when/if it happens.
Personally, I don't see why it would be that big of a deal to open up, people should use it at their own risk (eg. serialization going nuts). Have been playing with my hacked version, and the code required to make a node is pretty straight forward. My current base "SF_CustomNode" even supports additional functions (which people mentioned would be an issue with the code-node). I'd be willing to provide some code to dynamically load nodes.

The only thing that doesn't work, for some odd reason, is multiple outputs (eg. return float2(0, 1);), I have to pipe them through a component mask. 
That's sort of the thing - plenty of things are a bit hacky, due to some pretty bad vestigial sections of code, such as the component count of the output, and so forth. But I may open it up, like you said, on a "at your own risk" basis.

I've already got custom node loading ready to go, since I had to implement it for the Skyshop nodes, thanks for the offer anyhow :)
I made a quick work-around which doesn't require any hacking: http://forum.unity3d.com/threads/242835-Shader-For...

Maybe something useful to officially include for the time being?