mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Add FastNoiseLite / general noise overhaul
- replace OpenSimplexNoise Co-authored-by: Cory Petkovsek <tinmanjuggernaut@users.noreply.github.com>
This commit is contained in:
parent
c251ea01db
commit
2a55f10e8b
26 changed files with 4084 additions and 2991 deletions
8
thirdparty/README.md
vendored
8
thirdparty/README.md
vendored
|
|
@ -412,10 +412,10 @@ Collection of single-file libraries used in Godot components.
|
|||
* Upstream: https://archive.blender.org/wiki/index.php/Dev:Shading/Tangent_Space_Normal_Maps/
|
||||
* Version: 1.0 (2011)
|
||||
* License: zlib
|
||||
- `open-simplex-noise.{c,h}`
|
||||
* Upstream: https://github.com/smcameron/open-simplex-noise-in-c
|
||||
* Version: git (826f1dd1724e6fb3ff45f58e48c0fbae864c3403, 2020) + custom changes
|
||||
* License: Public Domain or Unlicense
|
||||
- `FastNoiseLite.h}`
|
||||
* Upstream: https://github.com/Auburn/FastNoiseLite
|
||||
* Version: git (6be3d6bf7fb408de341285f9ee8a29b67fd953f1, 2022) + custom changes
|
||||
* License: MIT
|
||||
- `pcg.{cpp,h}`
|
||||
* Upstream: http://www.pcg-random.org
|
||||
* Version: minimal C implementation, http://www.pcg-random.org/download.html
|
||||
|
|
|
|||
25
thirdparty/misc/open-simplex-noise-LICENSE
vendored
25
thirdparty/misc/open-simplex-noise-LICENSE
vendored
|
|
@ -1,25 +0,0 @@
|
|||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
||||
|
||||
133
thirdparty/misc/open-simplex-noise-no-allocate.patch
vendored
133
thirdparty/misc/open-simplex-noise-no-allocate.patch
vendored
|
|
@ -1,133 +0,0 @@
|
|||
diff -u orig/open-simplex-noise.c misc/open-simplex-noise.c
|
||||
--- orig/open-simplex-noise.c 2018-09-14 11:11:40.049810000 +0200
|
||||
+++ misc/open-simplex-noise.c 2018-09-14 11:09:39.726457000 +0200
|
||||
@@ -13,6 +13,11 @@
|
||||
* of any particular randomization library, so results
|
||||
* will be the same when ported to other languages.
|
||||
*/
|
||||
+
|
||||
+// -- GODOT start --
|
||||
+// Modified to work without allocating memory, also removed some unused function.
|
||||
+// -- GODOT end --
|
||||
+
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
@@ -34,11 +39,12 @@
|
||||
|
||||
#define DEFAULT_SEED (0LL)
|
||||
|
||||
-struct osn_context {
|
||||
+// -- GODOT start --
|
||||
+/*struct osn_context {
|
||||
int16_t *perm;
|
||||
int16_t *permGradIndex3D;
|
||||
-};
|
||||
-
|
||||
+};*/
|
||||
+// -- GODOT end --
|
||||
#define ARRAYSIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
||||
/*
|
||||
@@ -126,7 +132,9 @@
|
||||
int xi = (int) x;
|
||||
return x < xi ? xi - 1 : xi;
|
||||
}
|
||||
-
|
||||
+
|
||||
+// -- GODOT start --
|
||||
+/*
|
||||
static int allocate_perm(struct osn_context *ctx, int nperm, int ngrad)
|
||||
{
|
||||
if (ctx->perm)
|
||||
@@ -154,18 +162,21 @@
|
||||
memcpy(ctx->perm, p, sizeof(*ctx->perm) * nelements);
|
||||
|
||||
for (i = 0; i < 256; i++) {
|
||||
- /* Since 3D has 24 gradients, simple bitmask won't work, so precompute modulo array. */
|
||||
+ // Since 3D has 24 gradients, simple bitmask won't work, so precompute modulo array.
|
||||
ctx->permGradIndex3D[i] = (int16_t)((ctx->perm[i] % (ARRAYSIZE(gradients3D) / 3)) * 3);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+*/
|
||||
+// -- GODOT end --
|
||||
|
||||
/*
|
||||
* Initializes using a permutation array generated from a 64-bit seed.
|
||||
* Generates a proper permutation (i.e. doesn't merely perform N successive pair
|
||||
* swaps on a base array). Uses a simple 64-bit LCG.
|
||||
*/
|
||||
-int open_simplex_noise(int64_t seed, struct osn_context **ctx)
|
||||
+// -- GODOT start --
|
||||
+int open_simplex_noise(int64_t seed, struct osn_context *ctx)
|
||||
{
|
||||
int rc;
|
||||
int16_t source[256];
|
||||
@@ -174,20 +185,9 @@
|
||||
int16_t *permGradIndex3D;
|
||||
int r;
|
||||
|
||||
- *ctx = (struct osn_context *) malloc(sizeof(**ctx));
|
||||
- if (!(*ctx))
|
||||
- return -ENOMEM;
|
||||
- (*ctx)->perm = NULL;
|
||||
- (*ctx)->permGradIndex3D = NULL;
|
||||
-
|
||||
- rc = allocate_perm(*ctx, 256, 256);
|
||||
- if (rc) {
|
||||
- free(*ctx);
|
||||
- return rc;
|
||||
- }
|
||||
-
|
||||
- perm = (*ctx)->perm;
|
||||
- permGradIndex3D = (*ctx)->permGradIndex3D;
|
||||
+ perm = ctx->perm;
|
||||
+ permGradIndex3D = ctx->permGradIndex3D;
|
||||
+// -- GODOT end --
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
source[i] = (int16_t) i;
|
||||
@@ -206,6 +206,8 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+// -- GODOT start --
|
||||
+/*
|
||||
void open_simplex_noise_free(struct osn_context *ctx)
|
||||
{
|
||||
if (!ctx)
|
||||
@@ -220,6 +222,8 @@
|
||||
}
|
||||
free(ctx);
|
||||
}
|
||||
+*/
|
||||
+// -- GODOT end --
|
||||
|
||||
/* 2D OpenSimplex (Simplectic) Noise. */
|
||||
double open_simplex_noise2(struct osn_context *ctx, double x, double y)
|
||||
diff -u orig/open-simplex-noise.h misc/open-simplex-noise.h
|
||||
--- orig/open-simplex-noise.h 2018-09-14 11:11:19.659807000 +0200
|
||||
+++ misc/open-simplex-noise.h 2018-09-14 11:10:05.006460000 +0200
|
||||
@@ -35,11 +35,18 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
-struct osn_context;
|
||||
+// -- GODOT start --
|
||||
+// Modified to work without allocating memory, also removed some unused function.
|
||||
|
||||
-int open_simplex_noise(int64_t seed, struct osn_context **ctx);
|
||||
+struct osn_context {
|
||||
+ int16_t perm[256];
|
||||
+ int16_t permGradIndex3D[256];
|
||||
+};
|
||||
+
|
||||
+int open_simplex_noise(int64_t seed, struct osn_context *ctx);
|
||||
+//int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements);
|
||||
+// -- GODOT end --
|
||||
void open_simplex_noise_free(struct osn_context *ctx);
|
||||
-int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements);
|
||||
double open_simplex_noise2(struct osn_context *ctx, double x, double y);
|
||||
double open_simplex_noise3(struct osn_context *ctx, double x, double y, double z);
|
||||
double open_simplex_noise4(struct osn_context *ctx, double x, double y, double z, double w);
|
||||
2255
thirdparty/misc/open-simplex-noise.c
vendored
2255
thirdparty/misc/open-simplex-noise.c
vendored
File diff suppressed because it is too large
Load diff
58
thirdparty/misc/open-simplex-noise.h
vendored
58
thirdparty/misc/open-simplex-noise.h
vendored
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef OPEN_SIMPLEX_NOISE_H__
|
||||
#define OPEN_SIMPLEX_NOISE_H__
|
||||
|
||||
/*
|
||||
* OpenSimplex (Simplectic) Noise in C.
|
||||
* Ported to C from Kurt Spencer's java implementation by Stephen M. Cameron
|
||||
*
|
||||
* v1.1 (October 6, 2014)
|
||||
* - Ported to C
|
||||
*
|
||||
* v1.1 (October 5, 2014)
|
||||
* - Added 2D and 4D implementations.
|
||||
* - Proper gradient sets for all dimensions, from a
|
||||
* dimensionally-generalizable scheme with an actual
|
||||
* rhyme and reason behind it.
|
||||
* - Removed default permutation array in favor of
|
||||
* default seed.
|
||||
* - Changed seed-based constructor to be independent
|
||||
* of any particular randomization library, so results
|
||||
* will be the same when ported to other languages.
|
||||
*/
|
||||
|
||||
#if ((__GNUC_STDC_INLINE__) || (__STDC_VERSION__ >= 199901L))
|
||||
#include <stdint.h>
|
||||
#define INLINE inline
|
||||
#elif (defined (_MSC_VER) || defined (__GNUC_GNU_INLINE__))
|
||||
#include <stdint.h>
|
||||
#define INLINE __inline
|
||||
#else
|
||||
/* ANSI C doesn't have inline or stdint.h. */
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// -- GODOT start --
|
||||
// Modified to work without allocating memory, also removed some unused function.
|
||||
|
||||
struct osn_context {
|
||||
int16_t perm[256];
|
||||
int16_t permGradIndex3D[256];
|
||||
};
|
||||
|
||||
int open_simplex_noise(int64_t seed, struct osn_context *ctx);
|
||||
//int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements);
|
||||
// -- GODOT end --
|
||||
void open_simplex_noise_free(struct osn_context *ctx);
|
||||
double open_simplex_noise2(const struct osn_context *ctx, double x, double y);
|
||||
double open_simplex_noise3(const struct osn_context *ctx, double x, double y, double z);
|
||||
double open_simplex_noise4(const struct osn_context *ctx, double x, double y, double z, double w);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
22
thirdparty/noise/FastNoise-LICENSE
vendored
Normal file
22
thirdparty/noise/FastNoise-LICENSE
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright(c) 2020 Jordan Peck (jordan.me2@gmail.com)
|
||||
Copyright(c) 2020 Contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
2589
thirdparty/noise/FastNoiseLite.h
vendored
Normal file
2589
thirdparty/noise/FastNoiseLite.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
18
thirdparty/noise/patches/FastNoiseLite.patch
vendored
Normal file
18
thirdparty/noise/patches/FastNoiseLite.patch
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
--- orig/FastNoiseLite.h 1900-01-00 00:00:00 +0000
|
||||
+++ noise/FastNoiseLite.h 1900-01-00 00:00:00 +0000
|
||||
@@ -52,6 +52,8 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
+namespace fastnoiselite{
|
||||
+
|
||||
class FastNoiseLite
|
||||
{
|
||||
public:
|
||||
@@ -2583,4 +2585,5 @@
|
||||
-0.7870349638f, 0.03447489231f, 0.6159443543f, 0, -0.2015596421f, 0.6859872284f, 0.6991389226f, 0, -0.08581082512f, -0.10920836f, -0.9903080513f, 0, 0.5532693395f, 0.7325250401f, -0.396610771f, 0, -0.1842489331f, -0.9777375055f, -0.1004076743f, 0, 0.0775473789f, -0.9111505856f, 0.4047110257f, 0, 0.1399838409f, 0.7601631212f, -0.6344734459f, 0, 0.4484419361f, -0.845289248f, 0.2904925424f, 0
|
||||
};
|
||||
|
||||
-#endif
|
||||
+}
|
||||
+#endif // namespace fastnoiselite
|
||||
Loading…
Add table
Add a link
Reference in a new issue