-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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 SimplexNoise and NoiseTexture as new resources #21569
Conversation
c00ac00
to
3c01755
Compare
Should the class be named |
Yes, I think |
If the concern is the patent issue with simplex noise then based on my estimation it should expire on 2021 so we can be strategical about naming convention.. Besides, OpenSimplex implementation could be replaced with Simplex in the future. |
extern "C" { | ||
#endif | ||
|
||
// -- GODOT start -- |
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.
Why are those changes needed? It should be documented (or ideally avoided if we can do without).
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.
Ah I saw the comment in the README.md. It would be nice to have a patch file like ./thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch
so that it can be easily reapplied when syncing with upstream.
thirdparty/README.md
Outdated
##open-simplex-noise | ||
|
||
- Upstream: https://github.com/smcameron/open-simplex-noise-in-c | ||
- Version: git (0d555e7, 2018) |
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.
That's 2015 :)
thirdparty/README.md
Outdated
@@ -393,6 +393,23 @@ Files extracted from the upstream source: | |||
- All .h files in `src/` | |||
- LICENSE.txt | |||
|
|||
##open-simplex-noise |
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.
There should be a space after ##
, and two lines between sections.
That being said, since it's only two files, I think it would be better to just put them in thirdparty/misc
(and document them in the relevant section). You can likely drop the README and maybe name the license file open-simplex-noise-LICENSE
.
thirdparty/README.md
Outdated
|
||
- Upstream: https://github.com/smcameron/open-simplex-noise-in-c | ||
- Version: git (0d555e7, 2018) | ||
- License: The Unlicense |
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.
The short identifier is just "Unlicense": https://spdx.org/licenses/Unlicense.html
modules/opensimplex/noise.cpp
Outdated
@@ -0,0 +1,226 @@ | |||
#include "noise.h" |
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.
Please add Godot's copyright header.
I'd also suggest to rename noise.{cpp,h}
to simplex_noise.{cpp,h}
to match the class name.
modules/opensimplex/noise.cpp
Outdated
@@ -0,0 +1,226 @@ | |||
#include "noise.h" | |||
#include "core_string_names.h" |
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.
This should be core/core_string_names.h
, I removed core/
from the include path. Please also add a line between noise.h
(or simplex_noise.h
) and other includes.
modules/opensimplex/noise.h
Outdated
@@ -0,0 +1,62 @@ | |||
#ifndef OPENSIMPLEX_NOISE_H |
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.
Copyright header needed here too. The guard should likely be renamed to match the class and filename (so SIMPLEX_NOISE_H
once renamed to simplex_noise.h
).
modules/opensimplex/noise.h
Outdated
#include "image.h" | ||
#include "open-simplex-noise.h" | ||
#include "scene/resources/texture.h" | ||
#include <reference.h> |
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.
Godot headers are included with ""
, <>
is for system/thirdparty headers. And core/
includes should be absolute. So this should be:
#include "core/image.h"
#include "core/reference.h"
#include "scene/resources/texture.h"
#include <open-simplex-noise.h>
@@ -0,0 +1,213 @@ | |||
#include "noise_texture.h" | |||
#include "core_string_names.h" |
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.
Same here, add core/
and a newline.
modules/opensimplex/noise_texture.h
Outdated
#include "editor/property_editor.h" | ||
#include "image.h" | ||
#include "noise.h" | ||
#include <reference.h> |
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.
Same comment as in noise.h
.
f90d77a
to
8ed68f5
Compare
<argument index="1" name="height" type="int"> | ||
</argument> | ||
<description> | ||
Generate a noise image with the requested [code]width[\code] and [code]height[\code], based on the current noise parameters. |
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.
You got those slashes backwards :)
</argument> | ||
<description> | ||
Generate a tileable noise image, based on the current noise parameters. | ||
Generated seamless images are always square ([code]size[\code]x[code]size[\code]). |
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.
Here too.
modules/opensimplex/SCsub
Outdated
|
||
thirdparty_dir = '#thirdparty/misc/' | ||
thirdparty_source = thirdparty_dir + 'open-simplex-noise.c' | ||
env.Append(CPPPATH=thirdparty_dir) |
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.
Since it's only one file, and not likely to be packaged by Linux distros and thus unbundled for the time being, I'd suggest not to include thirdparty/misc
to the include path, and instead include thirdparty/misc/open-simplex-noise.h
directly in the relevant files.
This saves us an extra 18 characters on every single compilation command line, which is nice to avoid logs growing to crazy sizes and Windows aborting the build due to too long instructions.
modules/opensimplex/simplex_noise.h
Outdated
#include "core/reference.h" | ||
#include "scene/resources/texture.h" | ||
|
||
#include <open-simplex-noise.h> |
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.
If you do change it to thirdparty/misc/open-simplex-noise.h
as I now suggested, it should go back to using double quotes as it's no longer a "system" include.
8ed68f5
to
b5b1745
Compare
SimplexNoise can be used to generate parameterized fractal noise based on Open Simplex. NoiseTexture uses SimplexNoise to generate noise textures for using in shaders/visual effects.
b5b1745
to
f12a1b8
Compare
Thanks a ton! :) |
Fantastic! XD Going to try it out soon. |
Before it's finalized in a release build: the correct spelling would be "persistence", not "persistance". |
Hello.
An argument against changing the underlying noise function in the future would be that this would change the behavior of any programs relying on it for e.g. deterministic procedural generation, which for some programs (e.g. something along the lines of No Man's Sky) this would amount to a breaking change. |
I also think that it should be named Open Simplex Noise because:
|
I have no preference on the name other than SimplexNoise being shorter. Feel free to open a PR with the change or an appropriate issue to discuss this. |
Are noise textures supposed to work within the Visual Shader Editor? I added a noise texture, fed it UV´s and put it in the Color output of a CanvasItem shader but it just shows up black. I tried right clicking the noise texture and tried to "edit" it so I could choose "SimplexNoise" like you would if you just add this texture to a Sprite but no settings are exposed. Figured I´d mention it here if it´s a bug, or maybe this is a bug of the Visual Shader editor, rather than the noise texture? |
@Wircoark It's a quirk of the visual shader editor. If you use the constant texture node and you create a new texture from the visual node itself then you have no way to modify it's parameters (gradient or curve textures have the same issue). I might try to fix it, but for the moment you can workaround it by creating a new NoiseTexture resource in memory (green plus icon in the inspector), saving it to a resource file and then loading it in the visual shader node. This way you will be able to open the resource's inspector through the file system dock and edit all of it's parameters. |
I am on the Alpha 3.1, when using the reference code from the docs I come up with OpenSimplexNoise not being declared in the current scope errors. Running the simple code in the Docs fail. |
@SethRzeszutek It was added after 3.1 alpha1. Try 3.1 alpha2, it has simplex noise in it: https://downloads.tuxfamily.org/godotengine/3.1/alpha2/ |
I am on the alpha, I downloaded it yesterday. Even the about section says GODOT 3.1.alpha, is there an alpha2? |
@SethRzeszutek it seems the editor doesn't display which alpha it is, but you should try the official alpha2 link I provided above, this one definitely has OpenSimplexNoise. |
That link allowed for me to use openSimplex, I guess I somehow downloaded the wrong alpha? Thank you! |
SimplexNoise can be used to generate parameterized fractal noise based on Open Simplex, intended to be used in GDsrcipt.
NoiseTexture uses SimplexNoise to generate noise textures for using in
shaders/visual effects.
Documentation is missing, I will make a separate PR for that later on.
Edit: added option to use noise as a normalmap,