-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Shader preprocessor remake #62513
Shader preprocessor remake #62513
Conversation
servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp
Show resolved
Hide resolved
63a914e
to
af2e20a
Compare
@clayjohn Did you try using a shader_type in the include? that should work I think. |
bool ShaderPreprocessor::check_directive_before_type(Tokenizer *p_tokenizer, const String &p_directive) { | ||
if (p_tokenizer->get_index() < state->shader_type_pos) { | ||
set_error(vformat(RTR("`#%s` may not be defined before `shader_type`."), p_directive), p_tokenizer->get_line()); | ||
return false; | ||
} | ||
return true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function does not needed now, since you've removed the handling of shader_type_pos
(which prevent declaration of directives before shader type).
int include_depth = 0; | ||
String current_include; | ||
String current_shader_type; | ||
int shader_type_pos = -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove shader_type_pos
- if we don't need handling of it (to prevent preprocessor directive declaration before shader type.
@reduz Error handling messages seems broken: |
|
|
What exactly do you mean? - there are a lot of functions inside UE. Also, create a proposal for this please. |
I mean that a developer could make custom nodes by writing first a visual shader and then including that visual shader in a bigger visual shader as function node (with user defined inputs and outputs). The expression node kinda works the way I described but currently you can only write inside it in text and you can't seperately save it to the disk for use. I just wanted to clarify what I meant, if I still need to create a proposal then I'll do it but for sake of consistency it would be nice to see something similar to this pull request but for visual shaders. |
You can already use |
Feels a bit less intuitive to create that way in my opinion . |
Co-authored-by: TheOrangeDay <6472143+TheOrangeDay@users.noreply.github.com>
* Moved preprocessor to Shader and ShaderInclude * Clean up RenderingServer side * Preprocessor is separate from parser now, but it emits tokens with include location hints. * Improved ShaderEditor validation code * Added include file code completion * Added notification for all files affected by a broken include.
af2e20a
to
f649678
Compare
@akien-mga We discussed with @Chaosus that the purpose of this PR, which was redoing the preprocess design, to solve some of the fundamental problems in integrating the original PR, have been achieved and it majorly works. It may be better to just merge it as-is (its fully usable) and then @Chaosus can work on fixing the small issues in the shader compiler/preprocessor which is more his area than mine nowadays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, let's merge this and improve further in follow up PRs.
Testers who found bugs are welcome to open dedicated issues to track them further.
Oops I never noticed this update. I guess I have to update the vscode plugin's syntax for .gdshader and add .gdshaderinc (presumably the exact same syntax?). |
Based on #61462.
Images:
Error reporting on the text side:
Code completion for includes:
Bugsquad edit: Closes godotengine/godot-proposals#944