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

GDShader: Add hint_enum for uniform int #94198

Closed
wants to merge 5 commits into from

Conversation

SomeRanDev
Copy link
Contributor

@SomeRanDev SomeRanDev commented Jul 11, 2024

This adds a new shader uniform hint for int named hint_enum.

uniform int noise_type : hint_enum("OpenSimplex2", "Cellular", "Perlin", "Value") = 0;

Similar to @export_enum, this changes the int input into a dropdown in the editor.

This has been requested in #8738 and then later in godot-proposals #7847

Unresolved Issues

There are two unresolved aspects to this PR:

  • This PR adds strings to the .gdshader parser, and maybe the error handling could be better? At the moment, using strings outside of this hint results in something like: Expected expression, found 'STRING_CONSTANT'. Maybe it should be something more coherent, like: Strings are not supported in shaders.?
  • While the visual shader implementation of this technically works, there appears to be some editor UI issues with visual shader nodes using PackedStringArray and String inputs. I wasn't able to figure out how to fix this.

@SomeRanDev SomeRanDev requested review from a team as code owners July 11, 2024 07:02
@SomeRanDev SomeRanDev requested a review from a team as a code owner July 11, 2024 09:37
@Chaosus
Copy link
Member

Chaosus commented Jul 13, 2024

I think you should recreate it as a separate branch rather than pushing a master - this is a common way to contribute to the engine, to avoid problems. You need to squash the commits also (see https://docs.godotengine.org/en/latest/contributing/workflow/pr_workflow.html#modifying-a-pull-request).

@SomeRanDev
Copy link
Contributor Author

Ahh, sorry for my mistake! I didn't realize pushing from master would cause issues. I'll redo everything in a sec (+ squash commits from this point forward). 👌

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

Successfully merging this pull request may close these issues.

Add hint_enum to int shader uniforms
3 participants