godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

#include statement in shader language #2674

Closed mnkylord closed 3 years ago

mnkylord commented 3 years ago

Describe the project you are working on

I am building a JRPG style game in 3D.

Describe the problem or limitation you are having in your project

Shader languages lack noises. So I watched tutorials and read sites on noises and wrote a library of noise generator functions. But copying and pasting them makes managing shaders codes very dirty and difficult.

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

It will be great if the shader language has #include functionality like C/C++. With it, shaders can share common libraries. This makes shader codes much cleaner and also much easier to optimize.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Using #include statements in shaders will make codes much cleaner instead of copying-and-pasting shader functions.

If this enhancement will not be used often, can it be worked around with a few lines of script?

As far as I understand, no.

Is there a reason why this should be core and not an add-on in the asset library?

I suppose it is possible to have an add-on that performs macros in shader codes. But in my opinion, #include is just a cleaner and better solution.

clayjohn commented 3 years ago

Duplicate of https://github.com/godotengine/godot-proposals/issues/944

Please search existing proposals before creating one of your own.

If you have anything to add to https://github.com/godotengine/godot-proposals/issues/944 please post it as a comment instead of creating a new proposal.