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

Correctly identify fragment closing brace to allow custom light functions #594

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

Xtarsia
Copy link
Contributor

@Xtarsia Xtarsia commented Jan 15, 2025

Shader inserts (Editor functions & debug views) currently find the last " } " in the shader, however this prevents use of a custom light() function.

Identifying the correct " } " fixes this issue.

@Xtarsia Xtarsia force-pushed the fix-custom-light-shader branch from e63d115 to a3b0a1f Compare January 15, 2025 14:51
@TokisanGames TokisanGames added the shaders Shader development label Jan 15, 2025
@TokisanGames
Copy link
Owner

TokisanGames commented Jan 20, 2025

Looks good. Minor point: This will break if there is no space after a statement's semicolon and the last }:

void fragment() {vec2 uv = UV;}

or

void fragment() {vec2 uv = UV

;}

or

void fragment() {vec2 uv = UV;

int a;}
  333 | void fragment() {vec2 uv = UV;
  334 |
  335 | int a
E 336->  ALBEDO = get_decal(ALBEDO, uv);
  337 |
  338 | ;}
SHADER ERROR: Expected a ',' or ';'.
          at: (null) (:335)

@Xtarsia
Copy link
Contributor Author

Xtarsia commented Jan 20, 2025

Fixed the idx value adjustment, and it seems to work just fine when that space is missing now as well!

tested with this monstrosity:
image

also no space at the end, along with every debug view enabled at the same time.

@TokisanGames TokisanGames force-pushed the fix-custom-light-shader branch from 47d1503 to f8b4fe4 Compare January 21, 2025 11:18
@TokisanGames TokisanGames merged commit 517bce0 into TokisanGames:main Jan 21, 2025
15 checks passed
@TokisanGames
Copy link
Owner

Great work. Thanks!

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

Successfully merging this pull request may close these issues.

2 participants