Allow exporting some gdshader preprocessor values via new directives #12937
Xtarsia
started this conversation in
General Discussions
Replies: 1 comment
-
This is a crucial change for shaders developed for other users.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes when making heavy use of the preprocessor when writing shaders, it is desirable to to have configurable constants, that change the way the preproccessor statements are evaluated when the shader is compiled.
This is more beneficial than falling back to use of uniforms.
currently the only way to do this is to manually construct the shader code from strings, via code setting the desired #define values as needed.
instead, I propose something along the lines of this:
#export_define type NAME value
#export_define_enum(string1, string2)
which is then handled by the engine when setting via script/inspector, default values could be included as well.
type
being restricted to valid gdshader types, excluding structs, so that the editor can handle the input field nicely.and example use of this inside a gdshader script:
This could be settable by code on the shader, not the material, with its own section in the inspector "Defined Constants" before (or after) uniforms.
Obviously the goal isnt to cause an explosion of shader variants, but this would serve as good quality of life when writting complex shaders that might want to have different configurations depending on other factors like game settings etc.
Beta Was this translation helpful? Give feedback.
All reactions