Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vitorbalbio opened this issue Sep 6, 2020 · 14 comments
Open

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

vitorbalbio opened this issue Sep 6, 2020 · 14 comments

Comments

@vitorbalbio
Copy link

vitorbalbio commented Sep 6, 2020

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:

  • Allow to set External Text Editors as default shader editor
  • Add support to Godot Shader syntax and functions in external text editors like VSCode
  • Clicking on shader icons/files in editor all over the place open it externally instead of use the internal shader editor.

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 Calinou changed the title Edit Godot Shaders in External Editors Add support for editing Godot shaders in an external editor Sep 6, 2020
@Calinou
Copy link
Member

Calinou commented Sep 6, 2020

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
Copy link
Member

clayjohn commented Sep 8, 2020

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
Copy link
Author

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
Copy link
Member

clayjohn commented Sep 8, 2020

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
Copy link
Member

Calinou commented Sep 8, 2020

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 🙂

@vitorbalbio
Copy link
Author

vitorbalbio commented Sep 8, 2020

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
Copy link
Member

Calinou commented Sep 8, 2020

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

@WhalesState
Copy link

WhalesState commented Feb 16, 2022

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.

  • We need to look for all the shaders that are embedded in scenes files and we separate each to a file!

    • how we should rename the new files and where to save them? they should be in the file system some how for external editors.
    • A scene can include more than a shader so it's impossible to touch them with external editors since godot already is running and editing them all the time!
  • A solution is :

    • to support only .shader files in external editors and we keep the embedded shaders in their scenes if we don't want them to be edited externally or make files for them, ie. a basic shader or it will be encrypted within the scene.
  • OR

    • 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.
  • OR

    • we add support to .glsl shaders and we only let godot able to convert/import them without changing, like when we edit the .glsl file godot imports them on "window focused signal" and converts them to godot shaders and we pack them in their scenes/file. we may also be able to drag-drop them to materials and the convert happens.

@Calinou
Copy link
Member

Calinou commented Feb 16, 2022

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 🙂

@WhalesState
Copy link

WhalesState commented Feb 16, 2022

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
Copy link
Member

Calinou commented Feb 16, 2022

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
Copy link

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
Copy link
Author

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
Copy link

pgrwe commented Jun 18, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants