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

"Invalid include exit hint @@< without matching enter hint." error setting built-ins after shader #include #81215

Closed
jitspoe opened this issue Sep 1, 2023 · 3 comments · Fixed by #81381
Assignees
Milestone

Comments

@jitspoe
Copy link
Contributor

jitspoe commented Sep 1, 2023

Godot version

4.1.1.stable.official

System information

Windows 10, Vulkan forward +

Issue description

When trying to use shader includes inside the body of the fragment() function, an error occurs when setting EMISSION after the include: Invalid include exit hint @@< without matching enter hint.

image

Edit: Seems this also happens setting ALPHA, ROUGHNESS, etc. Likely any built-in that can be set.

Steps to reproduce

Create a material.
Convert it to a shader material.
Copy the contents in the fragment() function into a new shader include.
Include the shader include inside the fragment() function.
Set EMISSION to something after the include. Note error. Setting before the include works fine.

Minimal reproduction project

(upload failed, will post in reply).

@jitspoe
Copy link
Contributor Author

jitspoe commented Sep 1, 2023

I don't know why my uploads always fail in the original post, but here's the repro scene:

test_shader_include_exit.zip

@jitspoe jitspoe changed the title "Invalid include exit hint @@< without matching enter hint." error setting EMISSION after shader #include "Invalid include exit hint @@< without matching enter hint." error setting built-ins after shader #include Sep 1, 2023
@bitsawer
Copy link
Member

bitsawer commented Sep 1, 2023

Looks like the shader parser does some backtracking which breaks the include end marker as it is processed multiple times. Basically any assignment immediately after an #include inside a function body will cause this. Workaround is trivial, for example add a dummy variable declaration or re-order the statements as you noticed:

#include "test_include.gdshaderinc"
    float dummy;
    EMISSION = vec3(1.0, 0.0, 0.0);  // Works again.

Still, it's a bug and should be fixed.

@jitspoe
Copy link
Contributor Author

jitspoe commented Sep 1, 2023

Ah, I thought I tried that.

I ended up scrapping this method of including shaders mid function due to the errors and also I started running into a problem where every time I edited a shader, it would get stuck in a near-infinite loop of triggering shader recompiling causing the editor to freeze up for sometimes minutes at a time, making it basically impossible to edit shaders. I couldn't figure out how to repro it in a minimal case, though, and ended up just reverting everything in frustration. Should have saved the problematic shaders. Ah, well.

Decided to go with more of an uber shader with #define's instead.

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

Successfully merging a pull request may close this issue.

3 participants