Exactly what the title says. I don't even know if it's possible, cause I looked all over the internet for an answer.
this is the image of the code I need to copy from fragment to vertex. Thanks in advance for answers, I don't want to rewrite it from scratch.
Before you mess with this, make sure you have saved a copy of your shader.
Option 1: A workaround completely inside Godot:
Option 2: A workaround outside Godot:
Save your visual shader as a ".tres" file. These are text resources (hence the extension). And you can open them with a text editor.
The .tres file looks like an INI file. Each category (defined with a title in brackets) is a resource. The first one defines the shader file, leave that alone.
After then first line you will find categories that say "sub_resource", each is a node. You don't need to touch those either.
Finally you find a category that says "resource". At the end you will find values that look like this:
nodes/frament/3/node = SubResource( 4 )
nodes/frament/3/position = Vector2( 356, 417.037 )
That is telling you that the fragment shader has a node with id 3
is at position ( 356, 417.037 )
in the graph (the information of the node is in the category with id 4
near the start of the file).
You want to replace "fragment" for "vertex". However, make sure to give them a different id to those already in vertex, or you will have an error when re-importing in Godot, and lost what you did. Remember that Godot re-imports automatically when you switch windows to it.
You will also find a line that looks something like this:
nodes/fragment/connections = PoolIntArray( 3, 0, 0, 1, 4, 1, 0, 0 )
Those are the links between nodes. Each 4 numbers are a link. So here we have two links. The numbers for a link are as follows:
For example, 4, 1, 0, 0
means I am connecting the second output (1
) of the node with id 4
, to the first output of the shader (being a fragment shader, that is Albedo).
You will have to carefully edit those links (because remember that you also had to modify the ids to avoid conflict with whatever you had in the vertex shader). Consider not bothering to write the new links, and instead connect the nodes in Godot after re-importing.
I won't be surprised if this result in being more work than actually creating the nodes again in the vertex shader.
Option 3: Change the circumstances of the problem
Convert the visual shader to a regular shader, then you can simply copy the code (the option is at the end of the drop down of the Shader property of the ShaderMaterial in the inspector panel - which is on the right by default). Although, be aware that there is no conversion going back to a visual shader.
Option 4: Wait for Godot
You may consider writing a proposal for Godot on Github. All going well, it will be picked by the developers to add to a new version of Godot. Then you wait.