-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Add support for generating noise images with an offset #48805
Conversation
Demo The default behavior is to generate a grid of sprites containing noise data using gdscript. This is the slow method which is compatible with Godot 3.3. Running
|
This change would also have the side effect of fixing #47040 |
This has been tagged "breaks compat" but I don't believe it does break compatibility. The default behavior remains the same as before. |
It wouldn't fix #47040 per se, as the (0, 0) noise space pixel would be generated as before, and because the default behavior is still to generate a noise image which spans (0, 0) - (width, height). But this enhancement would give users more flexibility in working around #47040. |
At the suggestion of @Xrayez I updated this PR to use |
Looks great! Can you please squash your commits into one. We like to keep our git history very clean. After that, it should be ready to merge! |
Done. Thank you for the link! |
FYI, your local Git author details (see header of https://github.com/godotengine/godot/commit/f33800a9c8023843de271280a7482a5b7911e8e6.patch) don't seem to match the email registered in your GitHub account, which is why the commit doesn't appear as authored by "@radishes", so your GitHub account would not be properly credited as contributor once merged. It's not a problem technically for Git or GitHub, but if you want to claim this commit to your account, you can add this email as secondary email in your GitHub settings. |
Thank you! I've added that email address as a secondary email to my Github account. |
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.
Looks good to me :)
Thanks! And congrats for your first merged Godot contribution 🎉 |
This was labeled as a candidate to cherry-pick for |
I think swapping the offset coordinates to match the bug is the least surprising outcome for users. The example below produces tile-able continuous noise. Maybe an explanatory comment would help?
|
In any case, #30424 is a clear bug to me, and the PR which could've been cherry-picked in 3.1 as well, but I guess too many people might already rely on the wrongly swapped coordinates by now in 3.3... |
If there's going to be a 3.4, maybe that's a good time to break compatibility and fix the bug? Is that option on the table? |
I personally think it would be worth it, as long as the change is documented of course. It feels wrong to propagate the bug with workarounds further. But it's up to Akien to decide. It's probably a change which is easy to recover in existing projects. It would mostly affect procedural generation, and most of the time you don't really care about this sort of thing for randomness, unless you rely on reproducibility of the procedurally generated levels, but that's a quite specific use case. In fact, you shouldn't rely on reproducible results across platforms with Godot, a lot of the times it's just implementation detail. 😛 We've had regressions in |
I agree, I cherry-picked #30424 for 3.4.
That's not a very good argument. Those regressions have been fixed before the stable release, so there's no compat breakage in that specific instance. On the other hand, the now cherry-picked #30424 will break compat in a stable release. That's apples and oranges. |
Cherry-picked for 3.4. |
Problem
OpenSimplexNoise.get_image()
andNoiseTexture
can only generate noise from coordinates in the range (0,0) to (image_width, image_height). The result is that these classes can't be used to generate texture data across a larger space. My use case is that I want to generate noise data at arbitrary coordinates so that I can use the data for creating a procedural world, and passing to shaders.Workaround
It is possible to achieve the desired outcome in gdscript. I can generate an image by calling
OpenSimplexNoise.get_noise_2d()
for each coordinate, and generate a texture from that image. However, doing this in gdscript is very slow.Solution
In this PR, I've updated
OpenSimplexNoise.get_image()
andNoiseTexture
to accept a coordinate offset, so that they can generate noise images from anywhere in the noise space. In my tests, using the updated method is about an order of magnitude faster than using the gdscript method mentioned above.Rationale