Skip to content

Add PSRDNoise implementations for 2D and 3D#9

Merged
paddy-exe merged 1 commit intopaddy-exe:mainfrom
hmans:psrd-noise
Mar 9, 2023
Merged

Add PSRDNoise implementations for 2D and 3D#9
paddy-exe merged 1 commit intopaddy-exe:mainfrom
hmans:psrd-noise

Conversation

@hmans
Copy link
Copy Markdown
Contributor

@hmans hmans commented Mar 9, 2023

This PR adds 2D and 3D versions of the excellent PSRDNoise algorithm.

Notes:

  • The code is an almost 1:1 copy of the original psrdnoise2-min.glsl and psrdnoise3-min.glsl files. Only the mat3 initialization in psrdnoise3 had to be changed to match Godot's preferred matrix instantiation signature.
  • I've tested both functions and can confirm that everything is working.
  • In the original files, the functions were always called psrdnoise. I've renamed them to psrdnoise2 and psrdnoise3 so both can be imported without conflict.
  • Both functions allow for a final out vec2/3 gradient parameter. This is a very useful, but purely optional feature, but the signature will always require the user to provide a variable here, even if they don't use it, which is a little bit annoying. I'm not sure if Godot's shading language allows for making parameters optional? If not, I could provide additional overloads that do away with the parameter. Please let me know what you think.
    • After finding out that Godot's shader language doesn't support function overloading, I've pushed another commit that provides psrdnoise3 and psrdnoise3_with_gradient (and same for 2) functions.
  • Similarly, psrdnoise3.gdshaderinc exports a permute function. The potential for namespace collisions (especially if you later want to add other noise implementations) is high. How should we proceed here? We should probably rename the function to something a little less generic — anything else?
    • I've renamed it to __psrdnoise3_permute. If there is anything else we should do with it, let me know.

Copy link
Copy Markdown
Owner

@paddy-exe paddy-exe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the comment lines inside the shader code are removed and one blank line at the end of each file I can merge this :D thank you!

Comment thread addons/ShaderFunction-Extras/Noise/noise.gdshaderinc
@paddy-exe paddy-exe merged commit 5b4a634 into paddy-exe:main Mar 9, 2023
@paddy-exe
Copy link
Copy Markdown
Owner

Awesome work! Thanks :D

@hmans hmans deleted the psrd-noise branch March 9, 2023 15:17
@paddy-exe paddy-exe added the ⭐ enhancement New feature or request label Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⭐ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants