Visual preview of graphs in forums and web

I’d like to propose a forum feature that could be expanded to other web content (blogs, tutorial pages, Unity connect … ) that would allow a graphical representation of the shader graph ‘code’.
If you select and copy any part of the graph in shader graph you already get a formated piece of ‘code’
something like:

_DisplayName\\\": \\\"Occlusion\\\",\\n    \\\"m_SlotType\\\": 0,\\n    \\\"m_Priority\\\": 2147483647,\\n    \\\"m_Hidden\\\": false,\\n    \\\"m_ShaderOutputName\\\": \\\"Occlusion\\\",\\n    \\\"m_StageCapability\\\": 2,\\n    \\\"m_Value\\\": 1.0,\\n    \\\"m_DefaultValue\\\": 1.0,\\n    \\\"m_Labels\\\": [\\n        \\\"X\\\"\\n    ]\\n}\"\n        },\n        {\n            \"typeInfo\": {\n                \"fullName\": \"UnityEditor.ShaderGraph.Vector1MaterialSlot\"\n            },\n            \"JSONnodeData\": \"{\\n    \\\"m_Id\\\": 7,\\n    \\\"m_DisplayName\\\": \\\"Alpha\\\",\\n    \\\"m_SlotType\\\": 0,\\n    \\\"m_Priority\\\": 2147483647,\\n    \\\"m_Hidden\\\": false,\\n    \\\"m_ShaderOutputName\\\":

But this isn’t readable obviously, so posting this when asking for help, or sharing tips with others wouldn’t make sense. On the other hand a screen shot of your graph clear to read, but recreating it inside Unity takes a lot of time and is prone to errors. If we could have the option to paste a special snippet of the 'shader graph ’ code that would get ‘rendered’ into the visual representation of the shader graph, but at the same time retain the code and allow to copy it, that would make sharing of resources and knowledge much easier.

‘code’ → graph image → ‘code’

This could be expanded to other graphs, like visual effects graph and visual scripting which I understand is on the road map as well.

1 Like

This could be implemented by community as an opensource Javascript based parser.

1 Like

This is a cool idea, but I’m afraid we really don’t have resources available to work on something like this. Be aware also that the data model for the different graphs (Shader Graph/VFX/etc) have almost nothing in common (the core serialization model is different) so this would be almost impossible to implement in a way where it works for all graphs. :frowning:

When we implement it, we will further require support for preview nodes, carrying textures, and so on. In the end, our return will be significantly lower than our work. Maybe we just want ShaderGraph to support exporting images.

‘Community’ project is an option, but I would be worried about the long term support with a feature that is changing constantly.
@Kink3d
This is a naive question, but how complicated is the part of the editor that does the graph ‘rendering’. Is it something that could potentially be run on a server, or locally in a browser?
I do hope that sooner or later this happens one way or the other :slight_smile: