godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add support for editing Godot shaders in an external editor #1466

Open vitorbalbio opened 4 years ago

vitorbalbio commented 4 years ago

Describe the project you are working on: Space Tactical RPG https://twitter.com/ZeroPointGame

Describe the problem or limitation you are having in your project: You can't nicely edit Godot Shaders in external text editors like VSCode.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: Described above.

If this enhancement will not be used often, can it be worked around with a few lines of script?: Will be used all the time for everyone that use external editors.

Is there a reason why this should be core and not an add-on in the asset library?: It's a core feature for the ecosystem not to Godot editor only itself.

Calinou commented 4 years ago

Shaders are often embedded in scenes/resources, so there would have to be a way to communicate the saved file back to the Godot editor (perhaps by saving to a temporary location).

clayjohn commented 4 years ago

I think a necessary first step would be for 3rd party text editors to support Godot syntax. It goes without saying, but we don't control the tooling for 3rd party projects.

For example, a Godot shader typically has two "processor functions" vertex(), and fragment() while a typical glsl shader only has one main function main(). Accordingly, writing a shader in any other editor will produce needless errors right now. Additionally, they won't catch the Godot built in variables.

I guess it is a chicken and egg problem. Why would anyone support our syntax when it is so hard to open Godot shaders in external editors, but then again, why would we add support for external editors if no one supports our syntax?

vitorbalbio commented 4 years ago

I think a necessary first step would be for 3rd party text editors to support Godot syntax. It goes without saying, but we don't control the tooling for 3rd party projects.

For example, a Godot shader typically has two "processor functions" vertex(), and fragment() while a typical glsl shader only has one main function main(). Accordingly, writing a shader in any other editor will produce needless errors right now. Additionally, they won't catch the Godot built in variables.

I guess it is a chicken and egg problem. Why would anyone support our syntax when it is so hard to open Godot shaders in external editors, but then again, why would we add support for external editors if no one supports our syntax?

Maybe you're thinking about support Godot language in shader editors like shadertoy. But that's not what I'm proposing. This proposal is about add Godot shader language to text editors like VSCode the same way it already have support to GDScript language.

clayjohn commented 4 years ago

Maybe you're thinking about support Godot language in shader editors like shadertoy. But that's not what I'm proposing. This proposal is about add Godot shader language to text editors like VSCode the same way it already have support to GDScript language.

I understand! As I said above, it would be great if someone added support for Godot syntax to 3rd party text editors.

Calinou commented 4 years ago

I feel like there are multiple feature requests intertwined together here.

One is about allowing Godot to use an external shader editor:

-Allow to set External Editors as default shader editor

  • Clicking on shader icons/files in editor all over the place open it externally instead of use the internal shader editor.

One is about developing extensions:

  • Add support to Godot Shader syntax and functions in external editors like VSCode and MSVC

We do have an officially-maintained VS Code extension to which we can add Godot shader language support, but other editors should be left to the community.

PS: MSVC is a compiler, the IDE is called Visual Studio :slightly_smiling_face:

vitorbalbio commented 4 years ago

I feel like there are multiple feature requests intertwined together here.

One is about allowing Godot to use an external shader editor:

-Allow to set External Editors as default shader editor

  • Clicking on shader icons/files in editor all over the place open it externally instead of use the internal shader editor.

One is about developing extenstsions:

  • Add support to Godot Shader syntax and functions in external editors like VSCode and MSVC

We do have an officially-maintained VS Code extension to which we can add Godot shader language support, but other editors should be left to the community.

PS: MSVC is a compiler, the IDE is called Visual Studio 🙂

My proposal was only about support external text editors like VSCode. Use external shader editors like shadertoy to godot shaders is quite useless. Edited the proposal to make it more specific.

Calinou commented 4 years ago

@vitorbalbio By "external shader editor", I mean opening an external text editor of any kind when choosing a shader in the Godot editor.

WhalesState commented 2 years ago

Shaders are often embedded in scenes/resources, so there would have to be a way to communicate the saved file back to the Godot editor (perhaps by saving to a temporary location).

Maybe we can make shaders as script files and we link to the shader file path in the scenes/resources, or we allow the use of GLSL and it will be supported in many IDEs. This will require so much work to be done yes but there are some hacks for it.

Calinou commented 2 years ago

to support GLSL ! since many people finds it hard to learn godot shaders language so why don't we support GLSL directly and they will find so many tutorials/shaders for it easily, it's similar to godot shaders languages and can be converted easily to godot shaders language or vice versa.

Using GLSL directly is already supported in Godot 4.0, but it's intended for advanced users only and will remain so. The Godot shader has a lot of usability niceties for a reason :slightly_smiling_face:

WhalesState commented 2 years ago

Using GLSL directly is already supported in Godot 4.0, but it's intended for advanced users only and will remain so. The Godot shader has a lot of usability niceties for a reason slightly_smiling_face

Will it be back-ported to 3.x ? Can we have external minimal support for .shader files auto-completion? and with the help of the community we can later create extensions for each IDE to support preview.

Calinou commented 2 years ago

Will it be back-ported to 3.x ?

No, as it relies on compatibility-breaking changes.

Can we have external minimal support for .shader files auto-completion? and with the help of the community we can later create extensions for each IDE to support preview.

I would suggest forking an existing GLSL grammar file for your editor/IDE and modifying it to support the Godot shader language's built-in functions and variables.

saminton commented 11 months ago

I guess it is a chicken and egg problem. Why would anyone support our syntax when it is so hard to open Godot shaders in external editors, but then again, why would we add support for external editors if no one supports our syntax?

I think the first step is to simply allow Godot shaders to be opened in and external code editor. When setting up an external editor I was confused as to why the shaders were still opening with Godot and thought maybe it was a bug.

I understand the concern with auto completion but tbh the autocompletion feature in Godot's own shader editor is already rather limited so I feel that this isn't a major loss over the benefits an external editor can provide (not to mention that VSCode already has several GLSL extensions with syntax highlighting and some basic snippets).

If I chose to use an external editor it's mainly because I can customise the experience to my liking with shortcuts, snippets etc. and to keep the coding side separate for the game editor. Currently having to juggle between 2 editors and remembering two sets of shortcuts and behaviours is a pain.

Could we get at least get a "use external editor for shaders" checkbox so that those you want to use an external editor can do so ?

vitorbalbio commented 11 months ago

Only making it open in an external editor would already be awesome. The community can improve it over time with external plugins for each IDE

pgrwe commented 5 months ago

Any updates on this? Would love to see this implemented (I am addicted to my vim binds). Any thoughts on how this could be implemented? What are the current setbacks/issues?