Showing preview only (945K chars total). Download the full file or copy to clipboard to get everything.
Repository: KdotJPG/OpenSimplex2
Branch: master
Commit: 4cd120d35bfc
Files: 35
Total size: 916.5 KB
Directory structure:
gitextract_r8vzkgd4/
├── .gitignore
├── Cargo.toml
├── LICENSE
├── README.md
├── _old/
│ ├── c/
│ │ ├── Makefile
│ │ ├── OpenSimplex2F.c
│ │ ├── OpenSimplex2F.h
│ │ ├── UNLICENSE
│ │ └── test_OpenSimplex2F.c
│ ├── cpp/
│ │ ├── OpenSimplex2S.cpp
│ │ ├── OpenSimplex2S.hpp
│ │ └── UNLICENSE
│ ├── csharp/
│ │ ├── OpenSimplex2F.cs
│ │ ├── OpenSimplex2S.cs
│ │ └── legacy/
│ │ ├── OpenSimplex.cs
│ │ └── UNLICENSE
│ └── java/
│ ├── OpenSimplex2F.java
│ ├── OpenSimplex2S.java
│ ├── legacy/
│ │ ├── OpenSimplex.java
│ │ └── UNLICENSE
│ └── legacy_unoptimized/
│ └── OpenSimplexUnoptimized.java
├── csharp/
│ ├── OpenSimplex2.cs
│ └── OpenSimplex2S.cs
├── glsl/
│ ├── OpenSimplex2.glsl
│ └── OpenSimplex2S.glsl
├── hlsl/
│ ├── OpenSimplex2.hlsl
│ ├── OpenSimplex2S.hlsl
│ └── UNLICENSE
├── java/
│ ├── OpenSimplex2.java
│ └── OpenSimplex2S.java
└── rust/
├── OpenSimplex2.h
├── fast.rs
├── ffi.rs
├── lib.rs
└── smooth.rs
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
target
================================================
FILE: Cargo.toml
================================================
[package]
name = "opensimplex2"
version = "1.1.0"
edition = "2021"
description = "Port of OpenSimplex2"
authors = ["KdotJPG"]
license = "CC0-1.0"
repository = "https://github.com/KdotJPG/OpenSimplex2"
categories = ["algorithms", "graphics", "game-development"]
keywords = ["OpenSimplex", "Simplex", "noise", "random", "Perlin"]
# omit java, etc. from .crate file
include = [
"Cargo.toml",
"rust/*.rs",
]
[lib]
path = "rust/lib.rs"
crate-type = ["rlib", "staticlib", "cdylib"]
================================================
FILE: LICENSE
================================================
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
================================================
FILE: README.md
================================================
# OpenSimplex 2
Successors to OpenSimplex Noise, plus updated OpenSimplex. Includes 2D, 3D, and 4D noise.
## Motivation
Legacy OpenSimplex used a different grid layout scheme to Simplex. It worked fine for common applications, but didn't produce as consistent contrast as the original Simplex point layout in 3D/4D. It also broke down completely when extended to 5D+, producing diagonal bands of visibly-varying value ranges.
Instead of vertex rearrangement, OpenSimplex2 focuses on congruent layouts constructed and traversed using disparate methods where need was concluded.
Gradient vector tables were also revisited to improve probability symmetry in both the old and new noise.
## Included
### OpenSimplex2(F)
* Looks the most like Simplex.
* Is about as fast as common Simplex implementations.
* 3D is implemented by constructing a rotated body-centered-cubic grid as the offset union of two rotated cubic grids, and finding the closest two points on each.
* 4D is implemented using 5 offset copies of the dual (reverse-skewed) grid to produce the target grid. This technique generalizes to any number of dimensions.
* Bundled 2D function is just 2D Simplex with a nice gradient table. The 4D technique does extend to 2D, but this was found to be faster and I couldn't find evidence of limitations on its use. 3D and 4D are novel contributions to the field.
### OpenSimplex2S
* Looks the most like 2014 OpenSimplex.
* Uses large vertex contribution ranges like 2014 OpenSimplex, but has better uniformity in 3D and 4D.
* 3D is implemented analogously to OpenSimplex2(F), but finds the closest four points on each to match the larger radius.
* 4D is implemented using the ordinary skew and a pre-generated 4x4x4x4 lookup table. I have a work-in-progress more-procedural implementation in my project backlog, which I will swap in if I find it to be competitive in performance.
* 2D is based on Simplex, but uses a different process to find which points are in range.
* Recommended choice for ridged noise (if passing individual layers into `abs(x)`).
### Legacy OpenSimplex with updated gradients
* In some code bases using original OpenSimplex, it may take fewer dev cycles to swap in the same noise that just has the new gradient tables. This brings moderate improvements without changing consistency characteristics or internal frequency.
* Included in `_old/{language}/legacy`.
### Older OpenSimplex2 implementations
* OpenSimplex2 noise implementations from before performance and portability re-engineering.
* Can also be found in the `_old` directory.
Note: area-generators have been moved to [their original repository](https://github.com/KdotJPG/Noise-VertexQueue-AreaGen).
## C FFI usage
Install a [Rust toolchain](https://www.rust-lang.org/tools/install) if needed.
Build debug or release artifacts with:
```
cargo build
# or
cargo build --release
```
Library files will be in `./target/{debug,release}/`. Copy header from [`./rust/OpenSimplex2.h`](./rust/OpenSimplex2.h).
## Changelog
* Tuned up this `README.md`. (Mar 26, 2022)
* Re-wrote functions to be instancelessly seedable and less dependent on lookup tables. Re-organized repository. Renamed `OpenSimplex2F` to just `OpenSimplex2` in file/class names. (Jan 16, 2022)
* Shortened lookup table for Simplex/OpenSimplex2(F) 4D (July 5, 2020)
* Added 4D to OpenSimplex2(F) Java/C#, port OpenSimplex2S 4D to C#. (July 5, 2020)
* Added 4D to OpenSimplex2S Java. (Apr 30, 2020)
* Replaced individual renders in `README.md` with consolidated renders. (Feb 10, 2020)
* Replaced 12-direction 2D gradient set with a 24-direction set, to reduce visible feature repetition in thresholded single-octave 2D noise. (Feb 10, 2020)
* Renamed filenames FastSimplexStyleNoise to OpenSimplex2F, and SuperSimplexNoise to OpenSimplex2S. (Feb 10, 2020)
* Moved legacy OpenSimplex into legacy directories. (Feb 10, 2020)
* Slightly reorganized description above, and added TODO/changelog. (Jan 23, 2020)
* Renamed / additionally named the noise "OpenSimplex (2.0)", separated into two versions/variants. (Jan 23, 2020)
* SuperSimplex and FastSimplexStyleNoise are very similar to each other algorithmically, and are in the same spirit as the original OpenSimplex.
* OpenSimplex is used in a lot of projects, and the naming might help facilitate adoption of the new noise in its place.
* Add C# ports of evaluators. (Jan 13, 2020)
* Create separate files which include area generators. (Jan 13, 2020)
* Renamed PlaneFirst evaluators to XYBeforeZ, and added XZBeforeY. (Jan 13, 2020)
* Fixed equals() method in AreaGenLatticePoint3D for area generators. (Dec 24, 2019)
## Renders
### 2D Noise

* OpenSimplex2S is a smoother copy of OpenSimplex2(F).
* OpenSimplex2S and Updated OpenSimplex are effectively identical.
* Original OpenSimplex produced more straight parts and was not as probabilistically symmetric.
### 3D Noise (ImproveXY Orientation)

* OpenSimplex2(F) and OpenSimplex2S, 2D slices of 3D ImproveXY, keep mostly the same properties as you move along the third axis.
* Updated OpenSimplex looks good in both slices, but the slices look different from each other. In an animation, this is particularly noticeable.
* Original OpenSimplex was less uniform and not as probabilistically symmetric.
### 3D Noise (Fallback Orientation)

* OpenSimplex2(F) and OpenSimplex2S, 2D slices of 3D in the classic lattice orientation, look decent but are less ideal for X/Y planes being the primary focus.
* This Updated OpenSimplex render appears to show less directional bias than original OpenSimplex.
### 4D Noise (ImproveXY_ImproveZW Orientation)

* OpenSimplex2S 4D has higher apparent contrast than original OpenSimplex.
* OpenSimplex2(F) 4D has a very dotty appearance. Fine for fBm, but may pair best with extra steps if used for ridged noise.
### 4D Noise (ImproveXYZ Orientation)

* 2D slices look fine, but this rotation is most intended for texturing 3D objects with an additional time variable.
### 4D Noise (Fallback Orientation)

* OpenSimplex2(F) has the most noticeable diagonal artifacts, followed by Old OpenSimplex.
### 4D Noise (Torus Mapping)

* Seamless tileable 2D noise from 4D, mapped using noise4(r sin x, r cos x, r sin y, r cos y)
## Public Domain Dedication
This is free and unencumbered software. The majority of files are released under CC0. Where marked, files in certain directories fall under UNLICENSE instead, as they were based off of UNLICENSE code other than mine (e.g. Pull Requests, legacy OpenSimplex with DigitalShadow's lookup tables). To the best of my non-lawyer knowledge, no patent claims cover anything implemented here (though also nothing here is legal advice). Please use this software to make cool things, rather than to make patents! Enjoy.
================================================
FILE: _old/c/Makefile
================================================
CFLAGS=-Wall -Wextra --pedantic -O3
# CFLAGS=-Wall -Wextra --pedantic -g -fsanitize=undefined
# CFLAGS=-Wall -Wextra --pedantic -g -fsanitize=address
all: OpenSimplex2F.o test_OpenSimplex2F
OpenSimplex2F.o: OpenSimplex2F.c OpenSimplex2F.h Makefile
$(CC) ${CFLAGS} -c OpenSimplex2F.c -lm
test_OpenSimplex2F: test_OpenSimplex2F.c OpenSimplex2F.o Makefile
$(CC) ${CFLAGS} -o test_OpenSimplex2F test_OpenSimplex2F.c OpenSimplex2F.o -lm -lpng
clean:
rm -f *.o test_OpenSimplex2F test2d.png test3d.png test4d.png
================================================
FILE: _old/c/OpenSimplex2F.c
================================================
/**
* K.jpg's OpenSimplex 2, faster variant
*
* - 2D is standard simplex implemented using a lookup table.
* - 3D is "Re-oriented 4-point BCC noise" which constructs a
* congruent BCC lattice in a much different way than usual.
* - 4D constructs the lattice as a union of five copies of its
* reciprocal. It successively finds the closest point on each.
*
* Multiple versions of each function are provided. See the
* documentation above each, for more info.
*/
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include "OpenSimplex2F.h"
#define PSIZE (2048)
#define PMASK (2047)
static const double N2 = 0.01001634121365712;
static const double N3 = 0.030485933181293584;
static const double N4 = 0.009202377986303158;
#define B0000 0x00
#define B0001 0x01
#define B0010 0x02
#define B0011 0x03
#define B0100 0x04
#define B0101 0x05
#define B0110 0x06
#define B0111 0x07
#define B1000 0x08
#define B1001 0x09
#define B1010 0x0a
#define B1011 0x0b
#define B1100 0x0c
#define B1101 0x0d
#define B1110 0x0e
#define B1111 0x0f
struct Grad2 {
double dx, dy;
};
struct Grad3 {
double dx, dy, dz;
};
struct Grad4 {
double dx, dy, dz, dw;
};
struct LatticePoint2D {
int xsv, ysv;
double dx, dy;
};
static struct LatticePoint2D *new_LatticePoint2D(int xsv, int ysv)
{
struct LatticePoint2D *this = calloc(1, sizeof(*this));
this->xsv = xsv; this->ysv = ysv;
double ssv = (xsv + ysv) * -0.211324865405187;
this->dx = -xsv - ssv;
this->dy = -ysv - ssv;
return this;
}
struct LatticePoint3D {
double dxr, dyr, dzr;
int xrv, yrv, zrv;
struct LatticePoint3D *nextOnFailure, *nextOnSuccess;
};
static struct LatticePoint3D *new_LatticePoint3D(int xrv, int yrv, int zrv, int lattice)
{
struct LatticePoint3D *this = calloc(1, sizeof(*this));
this->dxr = -xrv + lattice * 0.5; this->dyr = -yrv + lattice * 0.5; this->dzr = -zrv + lattice * 0.5;
this->xrv = xrv + lattice * 1024; this->yrv = yrv + lattice * 1024; this->zrv = zrv + lattice * 1024;
return this;
}
static void find_unique_pointers(struct LatticePoint3D *tree, struct LatticePoint3D *list[], int *n)
{
if (!tree)
return;
int i, found;
found = 0;
for (i = 0; i < *n; i++) {
if (list[i] == tree) {
found = 1;
break;
}
}
if (!found) {
list[*n] = tree;
(*n)++;
}
find_unique_pointers(tree->nextOnFailure, list, n);
find_unique_pointers(tree->nextOnSuccess, list, n);
}
static void free_LatticePoint3D(struct LatticePoint3D *list[], int n)
{
int i;
for (i = 0; i < n; i++)
free(list[i]);
}
struct LatticePoint4D {
int xsv, ysv, zsv, wsv;
double dx, dy, dz, dw;
double xsi, ysi, zsi, wsi;
double ssiDelta;
};
static struct LatticePoint4D *new_LatticePoint4D(int xsv, int ysv, int zsv, int wsv)
{
struct LatticePoint4D *this = calloc(1, sizeof(*this));
this->xsv = xsv + 409; this->ysv = ysv + 409; this->zsv = zsv + 409; this->wsv = wsv + 409;
double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
this->dx = -xsv - ssv;
this->dy = -ysv - ssv;
this->dz = -zsv - ssv;
this->dw = -wsv - ssv;
this->xsi = 0.2 - xsv;
this->ysi = 0.2 - ysv;
this->zsi = 0.2 - zsv;
this->wsi = 0.2 - wsv;
this->ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
return this;
}
struct OpenSimplex2F_context {
int16_t *perm;
struct Grad2 *permGrad2;
struct Grad3 *permGrad3;
struct Grad4 *permGrad4;
};
#define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
static struct Grad2 GRADIENTS_2D[PSIZE];
static struct Grad3 GRADIENTS_3D[PSIZE];
static struct Grad4 GRADIENTS_4D[PSIZE];
static struct LatticePoint2D *LOOKUP_2D[4];
static struct LatticePoint3D *LOOKUP_3D[8];
static struct LatticePoint4D *VERTICES_4D[16];
static struct Grad2 grad2[] = {
{ 0.130526192220052, 0.99144486137381},
{ 0.38268343236509, 0.923879532511287},
{ 0.608761429008721, 0.793353340291235},
{ 0.793353340291235, 0.608761429008721},
{ 0.923879532511287, 0.38268343236509},
{ 0.99144486137381, 0.130526192220051},
{ 0.99144486137381, -0.130526192220051},
{ 0.923879532511287, -0.38268343236509},
{ 0.793353340291235, -0.60876142900872},
{ 0.608761429008721, -0.793353340291235},
{ 0.38268343236509, -0.923879532511287},
{ 0.130526192220052, -0.99144486137381},
{-0.130526192220052, -0.99144486137381},
{-0.38268343236509, -0.923879532511287},
{-0.608761429008721, -0.793353340291235},
{-0.793353340291235, -0.608761429008721},
{-0.923879532511287, -0.38268343236509},
{-0.99144486137381, -0.130526192220052},
{-0.99144486137381, 0.130526192220051},
{-0.923879532511287, 0.38268343236509},
{-0.793353340291235, 0.608761429008721},
{-0.608761429008721, 0.793353340291235},
{-0.38268343236509, 0.923879532511287},
{-0.130526192220052, 0.99144486137381}
};
static struct Grad3 grad3[] = {
{-2.22474487139, -2.22474487139, -1.0},
{-2.22474487139, -2.22474487139, 1.0},
{-3.0862664687972017, -1.1721513422464978, 0.0},
{-1.1721513422464978, -3.0862664687972017, 0.0},
{-2.22474487139, -1.0, -2.22474487139},
{-2.22474487139, 1.0, -2.22474487139},
{-1.1721513422464978, 0.0, -3.0862664687972017},
{-3.0862664687972017, 0.0, -1.1721513422464978},
{-2.22474487139, -1.0, 2.22474487139},
{-2.22474487139, 1.0, 2.22474487139},
{-3.0862664687972017, 0.0, 1.1721513422464978},
{-1.1721513422464978, 0.0, 3.0862664687972017},
{-2.22474487139, 2.22474487139, -1.0},
{-2.22474487139, 2.22474487139, 1.0},
{-1.1721513422464978, 3.0862664687972017, 0.0},
{-3.0862664687972017, 1.1721513422464978, 0.0},
{-1.0, -2.22474487139, -2.22474487139},
{ 1.0, -2.22474487139, -2.22474487139},
{ 0.0, -3.0862664687972017, -1.1721513422464978},
{ 0.0, -1.1721513422464978, -3.0862664687972017},
{-1.0, -2.22474487139, 2.22474487139},
{ 1.0, -2.22474487139, 2.22474487139},
{ 0.0, -1.1721513422464978, 3.0862664687972017},
{ 0.0, -3.0862664687972017, 1.1721513422464978},
{-1.0, 2.22474487139, -2.22474487139},
{ 1.0, 2.22474487139, -2.22474487139},
{ 0.0, 1.1721513422464978, -3.0862664687972017},
{ 0.0, 3.0862664687972017, -1.1721513422464978},
{-1.0, 2.22474487139, 2.22474487139},
{ 1.0, 2.22474487139, 2.22474487139},
{ 0.0, 3.0862664687972017, 1.1721513422464978},
{ 0.0, 1.1721513422464978, 3.0862664687972017},
{ 2.22474487139, -2.22474487139, -1.0},
{ 2.22474487139, -2.22474487139, 1.0},
{ 1.1721513422464978, -3.0862664687972017, 0.0},
{ 3.0862664687972017, -1.1721513422464978, 0.0},
{ 2.22474487139, -1.0, -2.22474487139},
{ 2.22474487139, 1.0, -2.22474487139},
{ 3.0862664687972017, 0.0, -1.1721513422464978},
{ 1.1721513422464978, 0.0, -3.0862664687972017},
{ 2.22474487139, -1.0, 2.22474487139},
{ 2.22474487139, 1.0, 2.22474487139},
{ 1.1721513422464978, 0.0, 3.0862664687972017},
{ 3.0862664687972017, 0.0, 1.1721513422464978},
{ 2.22474487139, 2.22474487139, -1.0},
{ 2.22474487139, 2.22474487139, 1.0},
{ 3.0862664687972017, 1.1721513422464978, 0.0},
{ 1.1721513422464978, 3.0862664687972017, 0.0}
};
static struct Grad4 grad4[] = {
{-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624},
{-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098},
{-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301},
{-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301},
{-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174},
{-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174},
{-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796},
{-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842},
{-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624},
{-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098},
{-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301},
{ 0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301},
{-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174},
{ 0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174},
{ 0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796},
{-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842},
{-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624},
{-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098},
{-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301},
{ 0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301},
{-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174},
{ 0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174},
{ 0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796},
{-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842},
{-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078},
{-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708},
{-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708},
{ 0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708},
{-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365},
{ 0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365},
{ 0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365},
{-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062},
{-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381},
{-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724},
{-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724},
{-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712},
{-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585},
{-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602},
{-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602},
{-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944},
{-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381},
{-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724},
{ 0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724},
{ 0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712},
{-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585},
{-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602},
{ 0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602},
{ 0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944},
{-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381},
{-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724},
{ 0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724},
{ 0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712},
{-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585},
{-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602},
{ 0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602},
{ 0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944},
{-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537},
{-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164},
{-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195},
{-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945},
{-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945},
{-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195},
{-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164},
{-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537},
{-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537},
{-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164},
{ 0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195},
{ 0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945},
{-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945},
{-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195},
{ 0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164},
{ 0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537},
{-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944},
{-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602},
{ 0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602},
{ 0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585},
{-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712},
{-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724},
{ 0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724},
{ 0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381},
{-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537},
{-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164},
{-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195},
{-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945},
{-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945},
{-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195},
{-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164},
{-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537},
{-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537},
{-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164},
{ 0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195},
{ 0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945},
{-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945},
{-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195},
{ 0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164},
{ 0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537},
{-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944},
{-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602},
{ 0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602},
{ 0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585},
{-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712},
{-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724},
{ 0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724},
{ 0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381},
{ 0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537},
{ 0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164},
{ 0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195},
{ 0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945},
{ 0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945},
{ 0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195},
{ 0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164},
{ 0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537},
{ 0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537},
{ 0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164},
{ 0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195},
{ 0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945},
{ 0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945},
{ 0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195},
{ 0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164},
{ 0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537},
{ 0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944},
{ 0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602},
{ 0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602},
{ 0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585},
{ 0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712},
{ 0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724},
{ 0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724},
{ 0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381},
{ 0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062},
{-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365},
{-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365},
{-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708},
{ 0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365},
{ 0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708},
{ 0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708},
{ 0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078},
{ 0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842},
{-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796},
{-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174},
{-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301},
{ 0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174},
{ 0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301},
{ 0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098},
{ 0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624},
{ 0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842},
{-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796},
{-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174},
{-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301},
{ 0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174},
{ 0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301},
{ 0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098},
{ 0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624},
{ 0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842},
{ 0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796},
{ 0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174},
{ 0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301},
{ 0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174},
{ 0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301},
{ 0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098},
{ 0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624}
};
static void setup_gradients(void)
{
static int already_did = 0;
int i;
if (already_did)
return;
already_did = 1;
for (i = 0; (size_t) i < ARRAYSIZE(grad2); i++) {
grad2[i].dx /= N2; grad2[i].dy /= N2;
}
for (int i = 0; i < PSIZE; i++) {
GRADIENTS_2D[i] = grad2[i % ARRAYSIZE(grad2)];
}
for (i = 0; (size_t) i < ARRAYSIZE(grad3); i++) {
grad3[i].dx /= N3; grad3[i].dy /= N3; grad3[i].dz /= N3;
}
for (i = 0; i < PSIZE; i++) {
GRADIENTS_3D[i] = grad3[i % ARRAYSIZE(grad3)];
}
for (i = 0; (size_t) i < ARRAYSIZE(grad4); i++) {
grad4[i].dx /= N4; grad4[i].dy /= N4; grad4[i].dz /= N4; grad4[i].dw /= N4;
}
for (i = 0; i < PSIZE; i++) {
GRADIENTS_4D[i] = grad4[i % ARRAYSIZE(grad4)];
}
}
static void setup_lattice_points(void)
{
static int already_did = 0;
int i;
if (already_did)
return;
already_did = 1;
LOOKUP_2D[0] = new_LatticePoint2D(1, 0);
LOOKUP_2D[1] = new_LatticePoint2D(0, 0);
LOOKUP_2D[2] = new_LatticePoint2D(1, 1);
LOOKUP_2D[3] = new_LatticePoint2D(0, 1);
for (i = 0; i < 8; i++) {
int i1, j1, k1, i2, j2, k2;
i1 = (i >> 0) & 1; j1 = (i >> 1) & 1; k1 = (i >> 2) & 1;
i2 = i1 ^ 1; j2 = j1 ^ 1; k2 = k1 ^ 1;
// The two points within this octant, one from each of the two cubic half-lattices.
struct LatticePoint3D *c0 = new_LatticePoint3D(i1, j1, k1, 0);
struct LatticePoint3D *c1 = new_LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
// Each single step away on the first half-lattice.
struct LatticePoint3D *c2 = new_LatticePoint3D(i1 ^ 1, j1, k1, 0);
struct LatticePoint3D *c3 = new_LatticePoint3D(i1, j1 ^ 1, k1, 0);
struct LatticePoint3D *c4 = new_LatticePoint3D(i1, j1, k1 ^ 1, 0);
// Each single step away on the second half-lattice.
struct LatticePoint3D *c5 = new_LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
struct LatticePoint3D *c6 = new_LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
struct LatticePoint3D *c7 = new_LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
// First two are guaranteed.
c0->nextOnFailure = c0->nextOnSuccess = c1;
c1->nextOnFailure = c1->nextOnSuccess = c2;
// Once we find one on the first half-lattice, the rest are out.
// In addition, knowing c2 rules out c5.
c2->nextOnFailure = c3; c2->nextOnSuccess = c6;
c3->nextOnFailure = c4; c3->nextOnSuccess = c5;
c4->nextOnFailure = c4->nextOnSuccess = c5;
// Once we find one on the second half-lattice, the rest are out.
c5->nextOnFailure = c6; c5->nextOnSuccess = NULL;
c6->nextOnFailure = c7; c6->nextOnSuccess = NULL;
c7->nextOnFailure = c7->nextOnSuccess = NULL;
LOOKUP_3D[i] = c0;
}
for (i = 0; i < 16; i++) {
VERTICES_4D[i] = new_LatticePoint4D((i >> 0) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
}
}
/* Free up all the LatticePoint stuff allocated in setup_lattice_points() */
void OpenSimplex2F_shutdown(void)
{
int i;
struct LatticePoint3D *list[8];
int count = 0;
for (i = 0; (size_t) i < ARRAYSIZE(LOOKUP_2D); i++) {
if (LOOKUP_2D[i]) {
free(LOOKUP_2D[i]);
LOOKUP_2D[i] = NULL;
}
}
for (i = 0; (size_t) i < ARRAYSIZE(LOOKUP_3D); i++) {
if (LOOKUP_3D[i]) {
/* There are cycles in the tree LOOKUP_3D[i], so we have to
* make a list of unique pointers within the tree to free them.
* We know there are only 8 unique pointers in the tree.
*/
count = 0;
memset(list, 0, sizeof(list));
find_unique_pointers(LOOKUP_3D[i], list, &count);
free_LatticePoint3D(list, count);
LOOKUP_3D[i] = NULL;
}
}
for (i = 0; (size_t) i < ARRAYSIZE(VERTICES_4D); i++) {
if (VERTICES_4D[i]) {
free(VERTICES_4D[i]);
VERTICES_4D[i] = NULL;
}
}
}
void OpenSimplex2F_free(struct OpenSimplex2F_context *ctx)
{
if (ctx->perm)
free(ctx->perm);
if (ctx->permGrad2)
free(ctx->permGrad2);
if (ctx->permGrad3)
free(ctx->permGrad3);
if (ctx->permGrad4)
free(ctx->permGrad4);
free(ctx);
}
int OpenSimplex2F(int64_t seed, struct OpenSimplex2F_context **ctx)
{
struct OpenSimplex2F_context *c;
int i, *source;
setup_gradients();
setup_lattice_points();
source = calloc(1, sizeof(*source) * PSIZE);
if (!source)
return -1;
c = calloc(1, sizeof(**ctx));
if (!c) {
free(source);
return -1;
}
*ctx = c;
c->perm = calloc(1, sizeof(*c->perm) * PSIZE);
c->permGrad2 = calloc(1, sizeof(*c->permGrad2) * PSIZE);
c->permGrad3 = calloc(1, sizeof(*c->permGrad3) * PSIZE);
c->permGrad4 = calloc(1, sizeof(*c->permGrad4) * PSIZE);
if (!c->perm || !c->permGrad2 || !c->permGrad3 || !c->permGrad4) {
OpenSimplex2F_free(*ctx);
*ctx = NULL;
free(source);
return -1;
}
for (i = 0; i < PSIZE; i++)
source[i] = (int16_t) i;
for (int i = PSIZE - 1; i >= 0; i--) {
seed = (uint64_t) seed * (uint64_t) 6364136223846793005LL + (uint64_t) 1442695040888963407LL;
int r = (int)((seed + 31) % (i + 1));
if (r < 0)
r += (i + 1);
c->perm[i] = source[r];
c->permGrad2[i] = GRADIENTS_2D[c->perm[i]];
c->permGrad3[i] = GRADIENTS_3D[c->perm[i]];
c->permGrad4[i] = GRADIENTS_4D[c->perm[i]];
source[r] = source[i];
}
free(source);
return 0;
}
static int fastFloor(double x)
{
int xi = (int)x;
return x < xi ? xi - 1 : xi;
}
/*
* 2D Simplex noise base.
* Lookup table implementation inspired by DigitalShadow.
*/
static double noise2_Base(struct OpenSimplex2F_context *ctx, double xs, double ys)
{
double value = 0;
int i;
// Get base points and offsets
int xsb = fastFloor(xs), ysb = fastFloor(ys);
double xsi = xs - xsb, ysi = ys - ysb;
// Index to point list
int index = (int)((ysi - xsi) / 2 + 1);
double ssi = (xsi + ysi) * -0.211324865405187;
double xi = xsi + ssi, yi = ysi + ssi;
// Point contributions
for (i = 0; i < 3; i++) {
struct LatticePoint2D c = *(LOOKUP_2D[index + i]);
double dx = xi + c.dx, dy = yi + c.dy;
double attn = 0.5 - dx * dx - dy * dy;
if (attn <= 0) continue;
int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
struct Grad2 grad = ctx->permGrad2[ctx->perm[pxm] ^ pym];
double extrapolation = grad.dx * dx + grad.dy * dy;
attn *= attn;
value += attn * attn * extrapolation;
}
return value;
}
/**
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
* Lookup table implementation inspired by DigitalShadow.
* It was actually faster to narrow down the points in the loop itself,
* than to build up the index with enough info to isolate 4 points.
*/
static double noise3_BCC(struct OpenSimplex2F_context *ctx, double xr, double yr, double zr)
{
// Get base and offsets inside cube of first lattice.
int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
// Identify which octant of the cube we're in. This determines which cell
// in the other cubic lattice we're in, and also narrows down one point on each.
int xht = (int)(xri + 0.5), yht = (int)(yri + 0.5), zht = (int)(zri + 0.5);
int index = (xht << 0) | (yht << 1) | (zht << 2);
// Point contributions
double value = 0;
struct LatticePoint3D *c = LOOKUP_3D[index];
while (c != NULL) {
double dxr = xri + c->dxr, dyr = yri + c->dyr, dzr = zri + c->dzr;
double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
if (attn < 0) {
c = c->nextOnFailure;
} else {
int pxm = (xrb + c->xrv) & PMASK, pym = (yrb + c->yrv) & PMASK, pzm = (zrb + c->zrv) & PMASK;
struct Grad3 grad = ctx->permGrad3[ctx->perm[ctx->perm[pxm] ^ pym] ^ pzm];
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
attn *= attn;
value += attn * attn * extrapolation;
c = c->nextOnSuccess;
}
}
return value;
}
/**
* 2D Simplex noise, standard lattice orientation.
*/
double OpenSimplex2F_noise2(struct OpenSimplex2F_context *ctx, double x, double y)
{
// Get points for A2* lattice
double s = 0.366025403784439 * (x + y);
double xs = x + s, ys = y + s;
return noise2_Base(ctx, xs, ys);
}
/**
* 2D Simplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
double OpenSimplex2F_noise2_XBeforeY(struct OpenSimplex2F_context *ctx, double x, double y)
{
// Skew transform and rotation baked into one.
double xx = x * 0.7071067811865476;
double yy = y * 1.224744871380249;
return noise2_Base(ctx, yy + xx, yy - xx);
}
/**
* 3D Re-oriented 4-point BCC noise, classic orientation.
* Proper substitute for 3D Simplex in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
double OpenSimplex2F_noise3_Classic(struct OpenSimplex2F_context *ctx, double x, double y, double z)
{
// Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
// If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
// Orthonormal rotation. Not a skew transform.
double r = (2.0 / 3.0) * (x + y + z);
double xr = r - x, yr = r - y, zr = r - z;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(ctx, xr, yr, zr);
}
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
double OpenSimplex2F_noise3_XYBeforeZ(struct OpenSimplex2F_context *ctx, double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xy = x + y;
double s2 = xy * -0.211324865405187;
double zz = z * 0.577350269189626;
double xr = x + s2 - zz, yr = y + s2 - zz;
double zr = xy * 0.577350269189626 + zz;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(ctx, xr, yr, zr);
}
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
double OpenSimplex2F_noise3_XZBeforeY(struct OpenSimplex2F_context *ctx, double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xz = x + z;
double s2 = xz * -0.211324865405187;
double yy = y * 0.577350269189626;
double xr = x + s2 - yy; double zr = z + s2 - yy;
double yr = xz * 0.577350269189626 + yy;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(ctx, xr, yr, zr);
}
/**
* 4D OpenSimplex2F noise base.
* Current implementation not fully optimized by lookup tables.
* But still comes out slightly ahead of Gustavson's Simplex in tests.
*/
static double noise4_Base(struct OpenSimplex2F_context *ctx, double xs, double ys, double zs, double ws)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
// If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
double siSum = xsi + ysi + zsi + wsi;
double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
bool inLowerHalf = (siSum < 2);
if (inLowerHalf) {
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
siSum = 4 - siSum;
}
// Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
double aabbScore = fabs(aabb), ababScore = fabs(abab), abbaScore = fabs(abba);
// Find the closest point on the stretched tesseract as if it were the upper half
int vertexIndex, via, vib;
double asi, bsi;
if (aabbScore > ababScore && aabbScore > abbaScore) {
if (aabb > 0) {
asi = zsi; bsi = wsi; vertexIndex = B0011; via = B0111; vib = B1011;
} else {
asi = xsi; bsi = ysi; vertexIndex = B1100; via = B1101; vib = B1110;
}
} else if (ababScore > abbaScore) {
if (abab > 0) {
asi = ysi; bsi = wsi; vertexIndex = B0101; via = B0111; vib = B1101;
} else {
asi = xsi; bsi = zsi; vertexIndex = B1010; via = B1011; vib = B1110;
}
} else {
if (abba > 0) {
asi = ysi; bsi = zsi; vertexIndex = B1001; via = B1011; vib = B1101;
} else {
asi = xsi; bsi = wsi; vertexIndex = B0110; via = B0111; vib = B1110;
}
}
if (bsi > asi) {
via = vib;
double temp = bsi;
bsi = asi;
asi = temp;
}
if (siSum + asi > 3) {
vertexIndex = via;
if (siSum + bsi > 4) {
vertexIndex = B1111;
}
}
// Now flip back if we're actually in the lower half.
if (inLowerHalf) {
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
vertexIndex ^= B1111;
}
// Five points to add, total, from five copies of the A4 lattice.
for (int i = 0; i < 5; i++) {
// Update xsb/etc. and add the lattice point's contribution.
struct LatticePoint4D c = *(VERTICES_4D[vertexIndex]);
xsb += c.xsv; ysb += c.ysv; zsb += c.zsv; wsb += c.wsv;
double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
if (attn > 0) {
int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
struct Grad4 grad = ctx->permGrad4[ctx->perm[ctx->perm[ctx->perm[pxm] ^ pym] ^ pzm] ^ pwm];
double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
attn *= attn;
value += attn * attn * ramped;
}
// Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
if (i == 4) break;
// Update the relative skewed coordinates to reference the vertex we just added.
// Rather, reference its counterpart on the lattice copy that is shifted down by
// the vector <-0.2, -0.2, -0.2, -0.2>
xsi += c.xsi; ysi += c.ysi; zsi += c.zsi; wsi += c.wsi;
ssi += c.ssiDelta;
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
vertexIndex = B0000;
if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0) {
vertexIndex = B0001;
}
else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0) {
vertexIndex = B0010;
}
else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0) {
vertexIndex = B0100;
}
else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0) {
vertexIndex = B1000;
}
}
return value;
}
/**
* 4D OpenSimplex2F noise, classic lattice orientation.
*/
double OpenSimplex2F_noise4_Classic(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w)
{
// Get points for A4 lattice
double s = -0.138196601125011 * (x + y + z + w);
double xs = x + s, ys = y + s, zs = z + s, ws = w + s;
return noise4_Base(ctx, xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XY and ZW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.
* Recommended for noise(x, y, sin(time), cos(time)) trick.
*/
double OpenSimplex2F_noise4_XYBeforeZW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w)
{
double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
return noise4_Base(ctx, xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XZ and YW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
*/
double OpenSimplex2F_noise4_XZBeforeYW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w)
{
double s2 = (x + z) * -0.178275657951399372 + (y + w) * 0.215623393288842828;
double t2 = (y + w) * -0.403949762580207112 + (x + z) * -0.375199083010075342;
double xs = x + s2, ys = y + t2, zs = z + s2, ws = w + t2;
return noise4_Base(ctx, xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic,
* and W for an extra degree of freedom. W repeats eventually.
* Recommended for time-varied animations which texture a 3D object (W=time)
*/
double OpenSimplex2F_noise4_XYZBeforeW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w)
{
double xyz = x + y + z;
double ww = w * 0.2236067977499788;
double s2 = xyz * -0.16666666666666666 + ww;
double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
return noise4_Base(ctx, xs, ys, zs, ws);
}
================================================
FILE: _old/c/OpenSimplex2F.h
================================================
#ifndef OpenSimplex2F_h__
#define OpenSimplex2F_h__
/**
* K.jpg's OpenSimplex 2, faster variant
*
* - 2D is standard simplex implemented using a lookup table.
* - 3D is "Re-oriented 4-point BCC noise" which constructs a
* congruent BCC lattice in a much different way than usual.
* - 4D constructs the lattice as a union of five copies of its
* reciprocal. It successively finds the closest point on each.
*
* Multiple versions of each function are provided. See the
* documentation above each, for more info.
*
* Ported from Java to C by Stephen M. Cameron
*
*/
#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
struct OpenSimplex2F_context;
/* Allocate and initialize OpenSimplex2F context */
int OpenSimplex2F(int64_t seed, struct OpenSimplex2F_context **ctx);
/* Free OpenSimplex2F context */
void OpenSimplex2F_free(struct OpenSimplex2F_context * ctx);
/* Free singleton lattice point data */
void OpenSimplex2F_shutdown(void);
/**
* 2D Simplex noise, standard lattice orientation.
*/
double OpenSimplex2F_noise2(struct OpenSimplex2F_context *ctx, double x, double y);
/**
* 2D Simplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
double OpenSimplex2F_noise2_XBeforeY(struct OpenSimplex2F_context *ctx, double x, double y);
/**
* 3D Re-oriented 4-point BCC noise, classic orientation.
* Proper substitute for 3D Simplex in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
double OpenSimplex2F_noise3_Classic(struct OpenSimplex2F_context *ctx, double x, double y, double z);
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
double OpenSimplex2F_noise3_XYBeforeZ(struct OpenSimplex2F_context *ctx, double x, double y, double z);
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
double OpenSimplex2F_noise3_XZBeforeY(struct OpenSimplex2F_context *ctx, double x, double y, double z);
/**
* 4D OpenSimplex2F noise, classic lattice orientation.
*/
double OpenSimplex2F_noise4_Classic(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w);
/**
* 4D OpenSimplex2F noise, with XY and ZW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.
* Recommended for noise(x, y, sin(time), cos(time)) trick.
*/
double OpenSimplex2F_noise4_XYBeforeZW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w);
/**
* 4D OpenSimplex2F noise, with XZ and YW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
*/
double OpenSimplex2F_noise4_XZBeforeYW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w);
/**
* 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic,
* and W for an extra degree of freedom. W repeats eventually.
* Recommended for time-varied animations which texture a 3D object (W=time)
*/
double OpenSimplex2F_noise4_XYZBeforeW(struct OpenSimplex2F_context *ctx, double x, double y, double z, double w);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: _old/c/UNLICENSE
================================================
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 <https://unlicense.org>
================================================
FILE: _old/c/test_OpenSimplex2F.c
================================================
#include <stdio.h>
#if ((__STDC_VERSION__ >= 199901L) || (_MSC_VER))
#include <stdint.h>
#endif
#include <string.h>
#include <errno.h>
#include <png.h>
#include "OpenSimplex2F.h"
#define WIDTH 512
#define HEIGHT 512
#define FEATURE_SIZE 24
static int write_png_image(const char *filename, unsigned char *pixels, int w, int h, int has_alpha)
{
png_structp png_ptr;
png_infop info_ptr;
png_byte **row;
int x, y, rc, colordepth = 8;
int bytes_per_pixel = has_alpha ? 4 : 3;
FILE *f;
f = fopen(filename, "w");
if (!f) {
fprintf(stderr, "fopen: %s:%s\n", filename, strerror(errno));
return -1;
}
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr)
goto cleanup1;
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
goto cleanup2;
if (setjmp(png_jmpbuf(png_ptr))) /* oh libpng, you're old as dirt, aren't you. */
goto cleanup2;
png_set_IHDR(png_ptr, info_ptr, (size_t) w, (size_t) h, colordepth,
has_alpha ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
row = png_malloc(png_ptr, h * sizeof(*row));
for (y = 0; y < h; y++) {
row[y] = png_malloc(png_ptr, w * bytes_per_pixel);
for (x = 0; x < w; x++) {
unsigned char *r = (unsigned char *) row[y];
unsigned char *src = (unsigned char *)
&pixels[y * w * bytes_per_pixel + x * bytes_per_pixel];
unsigned char *dest = &r[x * bytes_per_pixel];
memcpy(dest, src, bytes_per_pixel);
}
}
png_init_io(png_ptr, f);
png_set_rows(png_ptr, info_ptr, row);
png_write_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING, NULL);
for (y = 0; y < h; y++)
png_free(png_ptr, row[y]);
png_free(png_ptr, row);
rc = 0;
cleanup2:
png_destroy_write_struct(&png_ptr, &info_ptr);
cleanup1:
fclose(f);
return rc;
}
int main(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[])
{
int x, y;
double value;
double v0, v1, v2; /* values from different octaves. */
uint32_t rgb;
uint32_t image2d[HEIGHT][WIDTH];
uint32_t image3d[HEIGHT][WIDTH];
uint32_t image4d[HEIGHT][WIDTH];
struct OpenSimplex2F_context *ctx;
OpenSimplex2F(77374, &ctx);
for (y = 0; y < HEIGHT; y++) {
for (x = 0; x < WIDTH; x++) {
#if defined(SINGLE_OCTAVE)
value = open_simplex_noise4(ctx, (double) x / FEATURE_SIZE, (double) y / FEATURE_SIZE, 0.0, 0.0);
#else
/* Use three octaves: frequency N, N/2 and N/4 with relative amplitudes 4:2:1. */
v0 = OpenSimplex2F_noise4_Classic(ctx, (double) x / FEATURE_SIZE / 4,
(double) y / FEATURE_SIZE / 4, 0.0, 0.0);
v1 = OpenSimplex2F_noise4_Classic(ctx, (double) x / FEATURE_SIZE / 2,
(double) y / FEATURE_SIZE / 2, 0.0, 0.0);
v2 = OpenSimplex2F_noise4_Classic(ctx, (double) x / FEATURE_SIZE / 1,
(double) y / FEATURE_SIZE / 1, 0.0, 0.0);
value = v0 * 4 / 7.0 + v1 * 2 / 7.0 + v2 * 1 / 7.0;
#endif
rgb = 0x010101 * (uint32_t) ((value + 1) * 127.5);
image2d[y][x] = ((uint32_t) 0x0ff << 24) | (rgb);
value = OpenSimplex2F_noise2(ctx, (double) x / FEATURE_SIZE, (double) y / FEATURE_SIZE);
rgb = 0x010101 * (uint32_t) ((value + 1) * 127.5);
image3d[y][x] = ((uint32_t) 0x0ff << 24) | (rgb);
value = OpenSimplex2F_noise3_Classic(ctx, (double) x / FEATURE_SIZE, (double) y / FEATURE_SIZE, 0.0);
rgb = 0x010101 * (uint32_t) ((value + 1) * 127.5);
image4d[y][x] = ((uint32_t) 0x0ff << 24) | (rgb);
}
}
write_png_image("test2d.png", (unsigned char *) image2d, WIDTH, HEIGHT, 1);
write_png_image("test3d.png", (unsigned char *) image3d, WIDTH, HEIGHT, 1);
write_png_image("test4d.png", (unsigned char *) image4d, WIDTH, HEIGHT, 1);
OpenSimplex2F_free(ctx);
OpenSimplex2F_shutdown();
return 0;
}
================================================
FILE: _old/cpp/OpenSimplex2S.cpp
================================================
#include "OpenSimplex2S.hpp"
OpenSimplex2S::Grad2 OpenSimplex2S::GRADIENTS_2D[OpenSimplex2S::PSIZE] {};
OpenSimplex2S::Grad3 OpenSimplex2S::GRADIENTS_3D[OpenSimplex2S::PSIZE] {};
OpenSimplex2S::Grad4 OpenSimplex2S::GRADIENTS_4D[OpenSimplex2S::PSIZE] {};
OpenSimplex2S::LatticePoint2D OpenSimplex2S::LOOKUP_2D[8 * 4] {};
OpenSimplex2S::LatticePoint3D OpenSimplex2S::LOOKUP_3D[8] {};
OpenSimplex2S::LatticePoint4D OpenSimplex2S::LOOKUP_4D[256][20] {};
unsigned char OpenSimplex2S::LOOKUP_4D_SIZE[256] {};
OpenSimplex2S::Initializer::Initializer()
{
OpenSimplex2S::initLatticePoints();
OpenSimplex2S::initGradients();
}
OpenSimplex2S::Initializer OpenSimplex2S::initializer {};
OpenSimplex2S::OpenSimplex2S(long seed)
{
short source[PSIZE] {};
for (short i = 0; i < PSIZE; i++) {
source[i] = i;
}
for (int i = PSIZE - 1; i >= 0; i--) {
seed = seed * 6364136223846793005L + 1442695040888963407L;
int r = static_cast<int>((seed + 31) % (i + 1));
if (r < 0) {
r += (i + 1);
}
perm[i] = source[r];
permGrad2[i] = GRADIENTS_2D[perm[i]];
permGrad3[i] = GRADIENTS_3D[perm[i]];
permGrad4[i] = GRADIENTS_4D[perm[i]];
source[r] = source[i];
}
}
/**
* 2D SuperSimplex noise, standard lattice orientation.
*/
double OpenSimplex2S::noise2(double x, double y)
{
// Get points for A2* lattice
double s = 0.366025403784439 * (x + y);
double xs = x + s;
double ys = y + s;
return noise2_Base(xs, ys);
}
/**
* 2D SuperSimplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
double OpenSimplex2S::noise2_XBeforeY(double x, double y)
{
// Skew transform and rotation baked into one.
double xx = x * 0.7071067811865476;
double yy = y * 1.224744871380249;
return noise2_Base(yy + xx, yy - xx);
}
/**
* 2D SuperSimplex noise base.
* Lookup table implementation inspired by DigitalShadow.
*/
double OpenSimplex2S::noise2_Base(double xs, double ys)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs);
int ysb = fastFloor(ys);
double xsi = xs - xsb;
double ysi = ys - ysb;
// Index to point list
int a = static_cast<int>(xsi + ysi);
int index = (a << 2) | static_cast<int>(xsi - ysi / 2 + 1 - a / 2.0) << 3
| static_cast<int>(ysi - xsi / 2 + 1 - a / 2.0) << 4;
double ssi = (xsi + ysi) * -0.211324865405187;
double xi = xsi + ssi;
double yi = ysi + ssi;
// Point contributions
for (int i = 0; i < 4; i++) {
LatticePoint2D c = LOOKUP_2D[index + i];
double dx = xi + c.dx;
double dy = yi + c.dy;
double attn = 2.0 / 3.0 - dx * dx - dy * dy;
if (attn <= 0) {
continue;
}
int pxm = (xsb + c.xsv) & PMASK;
int pym = (ysb + c.ysv) & PMASK;
Grad2 grad = permGrad2[perm[pxm] ^ pym];
double extrapolation = grad.dx * dx + grad.dy * dy;
attn *= attn;
value += attn * attn * extrapolation;
}
return value;
}
/**
* 3D Re-oriented 8-point BCC noise, classic orientation
* Proper substitute for what 3D SuperSimplex would be,
* in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
double OpenSimplex2S::noise3_Classic(double x, double y, double z)
{
// Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar
// slices. If texturing objects that don't tend to have cardinal plane faces, you could even
// remove this. Orthonormal rotation. Not a skew transform.
double r = (2.0 / 3.0) * (x + y + z);
double xr = r - x;
double yr = r - y;
double zr = r - z;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
double OpenSimplex2S::noise3_XYBeforeZ(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xy = x + y;
double s2 = xy * -0.211324865405187;
double zz = z * 0.577350269189626;
double xr = x + s2 - zz;
double yr = y + s2 - zz;
double zr = xy * 0.577350269189626 + zz;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
double OpenSimplex2S::noise3_XZBeforeY(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xz = x + z;
double s2 = xz * -0.211324865405187;
double yy = y * 0.577350269189626;
double xr = x + s2 - yy;
double zr = z + s2 - yy;
double yr = xz * 0.577350269189626 + yy;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
* Lookup table implementation inspired by DigitalShadow.
* It was actually faster to narrow down the points in the loop itself,
* than to build up the index with enough info to isolate 8 points.
*/
double OpenSimplex2S::noise3_BCC(double xr, double yr, double zr)
{
// Get base and offsets inside cube of first lattice.
int xrb = fastFloor(xr);
int yrb = fastFloor(yr);
int zrb = fastFloor(zr);
double xri = xr - xrb;
double yri = yr - yrb;
double zri = zr - zrb;
// Identify which octant of the cube we're in. This determines which cell
// in the other cubic lattice we're in, and also narrows down one point on each.
int xht = static_cast<int>(xri + 0.5);
int yht = static_cast<int>(yri + 0.5);
int zht = static_cast<int>(zri + 0.5);
int index = (xht << 0) | (yht << 1) | (zht << 2);
// Point contributions
double value = 0;
LatticePoint3D* c = &LOOKUP_3D[index];
while (c != nullptr) {
double dxr = xri + c->dxr;
double dyr = yri + c->dyr;
double dzr = zri + c->dzr;
double attn = 0.75 - dxr * dxr - dyr * dyr - dzr * dzr;
if (attn < 0) {
c = c->nextOnFailure;
} else {
int pxm = (xrb + c->xrv) & PMASK;
int pym = (yrb + c->yrv) & PMASK;
int pzm = (zrb + c->zrv) & PMASK;
Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
attn *= attn;
value += attn * attn * extrapolation;
c = c->nextOnSuccess;
}
}
return value;
}
/**
* 4D SuperSimplex noise, classic lattice orientation.
*/
double OpenSimplex2S::noise4_Classic(double x, double y, double z, double w)
{
// Get points for A4 lattice
double s = 0.309016994374947 * (x + y + z + w);
double xs = x + s;
double ys = y + s;
double zs = z + s;
double ws = w + s;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D SuperSimplex noise, with XY and ZW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.
* Recommended for noise(x, y, sin(time), cos(time)) trick.
*/
double OpenSimplex2S::noise4_XYBeforeZW(double x, double y, double z, double w)
{
double s2 = (x + y) * -0.28522513987434876941 + (z + w) * 0.83897065470611435718;
double t2 = (z + w) * 0.21939749883706435719 + (x + y) * -0.48214856493302476942;
double xs = x + s2;
double ys = y + s2;
double zs = z + t2;
double ws = w + t2;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D SuperSimplex noise, with XZ and YW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
*/
double OpenSimplex2S::noise4_XZBeforeYW(double x, double y, double z, double w)
{
double s2 = (x + z) * -0.28522513987434876941 + (y + w) * 0.83897065470611435718;
double t2 = (y + w) * 0.21939749883706435719 + (x + z) * -0.48214856493302476942;
double xs = x + s2;
double ys = y + t2;
double zs = z + s2;
double ws = w + t2;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D SuperSimplex noise, with XYZ oriented like noise3_Classic,
* and W for an extra degree of freedom.
* Recommended for time-varied animations which texture a 3D object (W=time)
*/
double OpenSimplex2S::noise4_XYZBeforeW(double x, double y, double z, double w)
{
double xyz = x + y + z;
double ww = w * 1.118033988749894;
double s2 = xyz * -0.16666666666666666 + ww;
double xs = x + s2;
double ys = y + s2;
double zs = z + s2;
double ws = -0.5 * xyz + ww;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D SuperSimplex noise base.
* Using ultra-simple 4x4x4x4 lookup partitioning.
* This isn't as elegant or SIMD/GPU/etc. portable as other approaches,
* but it does compete performance-wise with optimized OpenSimplex1.
*/
double OpenSimplex2S::noise4_Base(double xs, double ys, double zs, double ws)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs);
int ysb = fastFloor(ys);
int zsb = fastFloor(zs);
int wsb = fastFloor(ws);
double xsi = xs - xsb;
double ysi = ys - ysb;
double zsi = zs - zsb;
double wsi = ws - wsb;
// Unskewed offsets
double ssi = (xsi + ysi + zsi + wsi) * -0.138196601125011;
double xi = xsi + ssi;
double yi = ysi + ssi;
double zi = zsi + ssi;
double wi = wsi + ssi;
int index = ((fastFloor(xs * 4) & 3) << 0) | ((fastFloor(ys * 4) & 3) << 2)
| ((fastFloor(zs * 4) & 3) << 4) | ((fastFloor(ws * 4) & 3) << 6);
// Point contributions
for (int i = 0; i < LOOKUP_4D_SIZE[index]; ++i) {
auto& c = LOOKUP_4D[index][i];
double dx = xi + c.dx;
double dy = yi + c.dy;
double dz = zi + c.dz;
double dw = wi + c.dw;
double attn = 0.8 - dx * dx - dy * dy - dz * dz - dw * dw;
if (attn > 0) {
attn *= attn;
int pxm = (xsb + c.xsv) & PMASK;
int pym = (ysb + c.ysv) & PMASK;
int pzm = (zsb + c.zsv) & PMASK;
int pwm = (wsb + c.wsv) & PMASK;
Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
double extrapolation = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
value += attn * attn * extrapolation;
}
}
return value;
}
int OpenSimplex2S::fastFloor(double x)
{
int xi = static_cast<int>(x);
return x < xi ? xi - 1 : xi;
}
OpenSimplex2S::LatticePoint2D::LatticePoint2D(int a_xsv, int a_ysv)
{
xsv = a_xsv;
ysv = a_ysv;
double ssv = (a_xsv + a_ysv) * -0.211324865405187;
dx = -a_xsv - ssv;
dy = -a_ysv - ssv;
}
OpenSimplex2S::LatticePoint2D::LatticePoint2D() = default;
OpenSimplex2S::LatticePoint3D::LatticePoint3D(int a_xrv, int a_yrv, int a_zrv, int lattice)
{
dxr = -a_xrv + lattice * 0.5;
dyr = -a_yrv + lattice * 0.5;
dzr = -a_zrv + lattice * 0.5;
xrv = a_xrv + lattice * 1024;
yrv = a_yrv + lattice * 1024;
zrv = a_zrv + lattice * 1024;
}
OpenSimplex2S::LatticePoint3D::LatticePoint3D() = default;
OpenSimplex2S::LatticePoint4D::LatticePoint4D(int a_xsv, int a_ysv, int a_zsv, int a_wsv)
{
xsv = a_xsv;
ysv = a_ysv;
zsv = a_zsv;
wsv = a_wsv;
double ssv = (a_xsv + a_ysv + a_zsv + a_wsv) * -0.138196601125011;
dx = -a_xsv - ssv;
dy = -a_ysv - ssv;
dz = -a_zsv - ssv;
dw = -a_wsv - ssv;
}
OpenSimplex2S::LatticePoint4D::LatticePoint4D() = default;
void OpenSimplex2S::initLatticePoints()
{
for (int i = 0; i < 8; i++) {
int i1, j1, i2, j2;
if ((i & 1) == 0) {
if ((i & 2) == 0) {
i1 = -1;
j1 = 0;
} else {
i1 = 1;
j1 = 0;
}
if ((i & 4) == 0) {
i2 = 0;
j2 = -1;
} else {
i2 = 0;
j2 = 1;
}
} else {
if ((i & 2) != 0) {
i1 = 2;
j1 = 1;
} else {
i1 = 0;
j1 = 1;
}
if ((i & 4) != 0) {
i2 = 1;
j2 = 2;
} else {
i2 = 1;
j2 = 0;
}
}
LOOKUP_2D[i * 4 + 0] = { 0, 0 };
LOOKUP_2D[i * 4 + 1] = { 1, 1 };
LOOKUP_2D[i * 4 + 2] = { i1, j1 };
LOOKUP_2D[i * 4 + 3] = { i2, j2 };
}
for (int i = 0; i < 8; i++) {
int i1, j1, k1, i2, j2, k2;
i1 = (i >> 0) & 1;
j1 = (i >> 1) & 1;
k1 = (i >> 2) & 1;
i2 = i1 ^ 1;
j2 = j1 ^ 1;
k2 = k1 ^ 1;
// The two points within this octant, one from each of the two cubic half-lattices.
auto* c0 = new LatticePoint3D(i1, j1, k1, 0);
auto* c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
// (1, 0, 0) vs (0, 1, 1) away from octant.
auto* c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
auto* c3 = new LatticePoint3D(i1, j1 ^ 1, k1 ^ 1, 0);
// (1, 0, 0) vs (0, 1, 1) away from octant, on second half-lattice.
auto* c4 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
auto* c5 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + (k2 ^ 1), 1);
// (0, 1, 0) vs (1, 0, 1) away from octant.
auto* c6 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
auto* c7 = new LatticePoint3D(i1 ^ 1, j1, k1 ^ 1, 0);
// (0, 1, 0) vs (1, 0, 1) away from octant, on second half-lattice.
auto* c8 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
auto* c9 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + (k2 ^ 1), 1);
// (0, 0, 1) vs (1, 1, 0) away from octant.
auto* cA = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
auto* cB = new LatticePoint3D(i1 ^ 1, j1 ^ 1, k1, 0);
// (0, 0, 1) vs (1, 1, 0) away from octant, on second half-lattice.
auto* cC = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
auto* cD = new LatticePoint3D(i1 + (i2 ^ 1), j1 + (j2 ^ 1), k1 + k2, 1);
// First two points are guaranteed.
c0->nextOnFailure = c0->nextOnSuccess = c1;
c1->nextOnFailure = c1->nextOnSuccess = c2;
// If c2 is in range, then we know c3 and c4 are not.
c2->nextOnFailure = c3;
c2->nextOnSuccess = c5;
c3->nextOnFailure = c4;
c3->nextOnSuccess = c4;
// If c4 is in range, then we know c5 is not.
c4->nextOnFailure = c5;
c4->nextOnSuccess = c6;
c5->nextOnFailure = c5->nextOnSuccess = c6;
// If c6 is in range, then we know c7 and c8 are not.
c6->nextOnFailure = c7;
c6->nextOnSuccess = c9;
c7->nextOnFailure = c8;
c7->nextOnSuccess = c8;
// If c8 is in range, then we know c9 is not.
c8->nextOnFailure = c9;
c8->nextOnSuccess = cA;
c9->nextOnFailure = c9->nextOnSuccess = cA;
// If cA is in range, then we know cB and cC are not.
cA->nextOnFailure = cB;
cA->nextOnSuccess = cD;
cB->nextOnFailure = cC;
cB->nextOnSuccess = cC;
// If cC is in range, then we know cD is not.
cC->nextOnFailure = cD;
cC->nextOnSuccess = nullptr;
cD->nextOnFailure = cD->nextOnSuccess = nullptr;
LOOKUP_3D[i] = *c0;
}
unsigned char lookup4DPregenSize[256] {
// clang-format off
20, 15, 16, 17, 15, 16, 12, 15, 16, 12, 10, 14, 17, 15, 14, 17,
15, 16, 12, 15, 16, 14, 14, 13, 12, 14, 11, 12, 15, 13, 12, 14,
16, 12, 10, 14, 12, 14, 11, 12, 10, 11, 10, 13, 14, 12, 13, 15,
17, 15, 14, 17, 15, 13, 12, 14, 14, 12, 13, 15, 17, 14, 15, 17,
15, 16, 12, 15, 16, 14, 14, 13, 12, 14, 11, 12, 15, 13, 12, 14,
16, 14, 14, 13, 14, 16, 16, 10, 14, 16, 19, 11, 13, 10, 11, 10,
12, 14, 11, 12, 14, 16, 19, 11, 11, 19, 13, 14, 12, 11, 14, 13,
15, 13, 12, 14, 13, 10, 11, 10, 12, 11, 14, 13, 14, 10, 13, 13,
16, 12, 10, 14, 12, 14, 11, 12, 10, 11, 10, 13, 14, 12, 13, 15,
12, 14, 11, 12, 14, 16, 19, 11, 11, 19, 13, 14, 12, 11, 14, 13,
10, 11, 10, 13, 11, 19, 13, 14, 10, 13, 16, 14, 13, 14, 14, 16,
14, 12, 13, 15, 12, 11, 14, 13, 13, 14, 14, 16, 15, 13, 16, 15,
17, 15, 14, 17, 15, 13, 12, 14, 14, 12, 13, 15, 17, 14, 15, 17,
15, 13, 12, 14, 13, 10, 11, 10, 12, 11, 14, 13, 14, 10, 13, 13,
14, 12, 13, 15, 12, 11, 14, 13, 13, 14, 14, 16, 15, 13, 16, 15,
17, 14, 15, 17, 14, 10, 13, 13, 15, 13, 16, 15, 17, 13, 15, 20,
// clang-format on
};
unsigned char lookup4DPregen[256][20] {
// clang-format off
{ 0x15, 0x45, 0x51, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA },
{ 0x15, 0x45, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x01, 0x05, 0x11, 0x15, 0x41, 0x45, 0x51, 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x01, 0x15, 0x16, 0x45, 0x46, 0x51, 0x52, 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00 },
{ 0x15, 0x45, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x45, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x45, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x16, 0x45, 0x46, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x04, 0x05, 0x14, 0x15, 0x44, 0x45, 0x54, 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x45, 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x45, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x16, 0x45, 0x46, 0x55, 0x56, 0x59, 0x5A, 0x5B, 0x6A, 0x9A, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x04, 0x15, 0x19, 0x45, 0x49, 0x54, 0x55, 0x58, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x19, 0x45, 0x49, 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x19, 0x45, 0x49, 0x55, 0x56, 0x59, 0x5A, 0x5E, 0x6A, 0x9A, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x05, 0x15, 0x1A, 0x45, 0x4A, 0x55, 0x56, 0x59, 0x5A, 0x5B, 0x5E, 0x6A, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00 },
{ 0x15, 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x51, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x96, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x16, 0x51, 0x52, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x96, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x9A, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x16, 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x6B, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x54, 0x55, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x99, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x16, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x6B, 0x9A, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x19, 0x54, 0x55, 0x58, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x99, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x19, 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x6E, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x19, 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x6E, 0x9A, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x1A, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x6B, 0x6E, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x10, 0x11, 0x14, 0x15, 0x50, 0x51, 0x54, 0x55, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x51, 0x55, 0x56, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x51, 0x55, 0x56, 0x65, 0x66, 0x6A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x16, 0x51, 0x52, 0x55, 0x56, 0x65, 0x66, 0x67, 0x6A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x54, 0x55, 0x59, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x16, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x6B, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x54, 0x55, 0x59, 0x65, 0x69, 0x6A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x16, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x6B, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x19, 0x54, 0x55, 0x58, 0x59, 0x65, 0x69, 0x6A, 0x6D, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x19, 0x55, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x6E, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x19, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x6E, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x69, 0x6A, 0x6B, 0x6E, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x10, 0x15, 0x25, 0x51, 0x54, 0x55, 0x61, 0x64, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x25, 0x51, 0x55, 0x56, 0x61, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x25, 0x51, 0x55, 0x56, 0x61, 0x65, 0x66, 0x6A, 0x76, 0xA6, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x11, 0x15, 0x26, 0x51, 0x55, 0x56, 0x62, 0x65, 0x66, 0x67, 0x6A, 0x76, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x25, 0x54, 0x55, 0x59, 0x64, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x25, 0x55, 0x65, 0x66, 0x69, 0x6A, 0x7A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x25, 0x55, 0x56, 0x65, 0x66, 0x69, 0x6A, 0x7A, 0xA6, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x26, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x6B, 0x7A, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x25, 0x54, 0x55, 0x59, 0x64, 0x65, 0x69, 0x6A, 0x79, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x25, 0x55, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x7A, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x25, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x7A, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x6B, 0x7A, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x14, 0x15, 0x29, 0x54, 0x55, 0x59, 0x65, 0x68, 0x69, 0x6A, 0x6D, 0x79, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00 },
{ 0x15, 0x29, 0x55, 0x59, 0x65, 0x69, 0x6A, 0x6E, 0x7A, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x6E, 0x7A, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x6B, 0x6E, 0x7A, 0xAA, 0xAB, 0xAE, 0xBA, 0xBF, 0x00, 0x00, 0x00 },
{ 0x45, 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x5A, 0x66, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x46, 0x51, 0x52, 0x55, 0x56, 0x5A, 0x66, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x69, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x46, 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0x9B, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x5A, 0x69, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x46, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x96, 0x9A, 0x9B, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x49, 0x54, 0x55, 0x58, 0x59, 0x5A, 0x69, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x49, 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0x9E, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x49, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x99, 0x9A, 0x9E, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x4A, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x9A, 0x9B, 0x9E, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x66, 0x69, 0x95, 0x96, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x59, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x52, 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xA7, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x56, 0x59, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x45, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x45, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x45, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0xAB, 0xAE, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x58, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAD, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x66, 0x69, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x52, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x96, 0xA6, 0xA7, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xBA, 0x00 },
{ 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x6A, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAE, 0xBA, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x9A, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x58, 0x59, 0x65, 0x69, 0x6A, 0x99, 0xA9, 0xAA, 0xAD, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x69, 0x6A, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x61, 0x64, 0x65, 0x66, 0x69, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x61, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xB6, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x61, 0x65, 0x66, 0x6A, 0xA5, 0xA6, 0xAA, 0xB6, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x62, 0x65, 0x66, 0x6A, 0xA6, 0xA7, 0xAA, 0xAB, 0xB6, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x64, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xB9, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x65, 0x66, 0x6A, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x64, 0x65, 0x69, 0x6A, 0xA5, 0xA9, 0xAA, 0xB9, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x68, 0x69, 0x6A, 0xA9, 0xAA, 0xAD, 0xAE, 0xB9, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x65, 0x69, 0x6A, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x15, 0x55, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0xAA, 0xAB, 0xAE, 0xBA, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x40, 0x41, 0x44, 0x45, 0x50, 0x51, 0x54, 0x55, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x46, 0x51, 0x52, 0x55, 0x56, 0x95, 0x96, 0x97, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x46, 0x55, 0x56, 0x5A, 0x95, 0x96, 0x9A, 0x9B, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x46, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0x9B, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x49, 0x54, 0x55, 0x58, 0x59, 0x95, 0x99, 0x9A, 0x9D, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x49, 0x55, 0x59, 0x5A, 0x95, 0x99, 0x9A, 0x9E, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x49, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0x9E, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x96, 0x99, 0x9A, 0x9B, 0x9E, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x95, 0x96, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x52, 0x55, 0x56, 0x66, 0x95, 0x96, 0x9A, 0xA6, 0xA7, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x51, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xEA, 0x00 },
{ 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x54, 0x55, 0x56, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAE, 0xEA, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x66, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x58, 0x59, 0x69, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xAD, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x96, 0x99, 0x9A, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x52, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xA7, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x54, 0x55, 0x56, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0xEA, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA6, 0xA9, 0xAA, 0xAB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x58, 0x59, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0xAD, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0xAE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x66, 0x69, 0x6A, 0x96, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0xAB, 0xAE, 0xAF, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x61, 0x64, 0x65, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xB5, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x61, 0x65, 0x66, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xB6, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x61, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0xB6, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x96, 0xA5, 0xA6, 0xA7, 0xAA, 0xAB, 0xB6, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x64, 0x65, 0x69, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xB9, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x65, 0x66, 0x69, 0x6A, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x6A, 0x96, 0xA5, 0xA6, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x64, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0xB9, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x96, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xBA, 0xBB, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x6A, 0x99, 0xA5, 0xA9, 0xAA, 0xAD, 0xAE, 0xB9, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x6A, 0x99, 0xA5, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAE, 0xBA, 0xBE, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x9A, 0xA6, 0xA9, 0xAA, 0xAB, 0xAE, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x40, 0x45, 0x51, 0x54, 0x55, 0x85, 0x91, 0x94, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x85, 0x91, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x85, 0x91, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0xD6, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x41, 0x45, 0x51, 0x55, 0x56, 0x86, 0x92, 0x95, 0x96, 0x97, 0x9A, 0xA6, 0xAA, 0xAB, 0xD6, 0xEA, 0xEB, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x85, 0x94, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x85, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xDA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x85, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xAA, 0xDA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x86, 0x95, 0x96, 0x9A, 0x9B, 0xA6, 0xAA, 0xAB, 0xDA, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x85, 0x94, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xD9, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x59, 0x85, 0x95, 0x96, 0x99, 0x9A, 0xA9, 0xAA, 0xDA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x85, 0x95, 0x96, 0x99, 0x9A, 0xAA, 0xDA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0x9B, 0xA6, 0xAA, 0xAB, 0xDA, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x44, 0x45, 0x54, 0x55, 0x59, 0x89, 0x95, 0x98, 0x99, 0x9A, 0x9D, 0xA9, 0xAA, 0xAE, 0xD9, 0xEA, 0xEE, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x59, 0x89, 0x95, 0x99, 0x9A, 0x9E, 0xA9, 0xAA, 0xAE, 0xDA, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0x9E, 0xA9, 0xAA, 0xAE, 0xDA, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0x9B, 0x9E, 0xAA, 0xAB, 0xAE, 0xDA, 0xEA, 0xEF, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x91, 0x94, 0x95, 0x96, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x91, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xE6, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x91, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xAA, 0xE6, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x92, 0x95, 0x96, 0x9A, 0xA6, 0xA7, 0xAA, 0xAB, 0xE6, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x94, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xE9, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x95, 0x96, 0x9A, 0xA6, 0xAA, 0xAB, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x94, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xE9, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x56, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xAA, 0xAB, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x95, 0x98, 0x99, 0x9A, 0xA9, 0xAA, 0xAD, 0xAE, 0xE9, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x95, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x45, 0x55, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xA9, 0xAA, 0xAE, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x95, 0x96, 0x99, 0x9A, 0xAA, 0xAB, 0xAE, 0xEA, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x91, 0x94, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xE5, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x65, 0x91, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0xE6, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x91, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0xE6, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x66, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xA7, 0xAA, 0xAB, 0xE6, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x65, 0x94, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xE9, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x65, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x66, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xAA, 0xAB, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x94, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0xE9, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x65, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x5A, 0x66, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xEA, 0xEB, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x69, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xAD, 0xAE, 0xE9, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x69, 0x95, 0x99, 0x9A, 0xA5, 0xA9, 0xAA, 0xAE, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x5A, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAE, 0xEA, 0xEE, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA6, 0xA9, 0xAA, 0xAB, 0xAE, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x50, 0x51, 0x54, 0x55, 0x65, 0x95, 0xA1, 0xA4, 0xA5, 0xA6, 0xA9, 0xAA, 0xB5, 0xBA, 0xE5, 0xEA, 0xFA, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x65, 0x95, 0xA1, 0xA5, 0xA6, 0xA9, 0xAA, 0xB6, 0xBA, 0xE6, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0xB6, 0xBA, 0xE6, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xA7, 0xAA, 0xAB, 0xB6, 0xBA, 0xE6, 0xEA, 0xFB, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x65, 0x95, 0xA4, 0xA5, 0xA6, 0xA9, 0xAA, 0xB9, 0xBA, 0xE9, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x65, 0x95, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x51, 0x55, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x65, 0x66, 0x95, 0x96, 0xA5, 0xA6, 0xAA, 0xAB, 0xBA, 0xEA, 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xB9, 0xBA, 0xE9, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xBA, 0xEA, 0xFA, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x65, 0x66, 0x6A, 0x95, 0x96, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xBA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x54, 0x55, 0x59, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0xAD, 0xAE, 0xB9, 0xBA, 0xE9, 0xEA, 0xFE, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x65, 0x69, 0x95, 0x99, 0xA5, 0xA9, 0xAA, 0xAE, 0xBA, 0xEA, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x59, 0x65, 0x69, 0x6A, 0x95, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAE, 0xBA, 0xEA, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x55, 0x56, 0x59, 0x5A, 0x65, 0x66, 0x69, 0x6A, 0x95, 0x96, 0x99, 0x9A, 0xA5, 0xA6, 0xA9, 0xAA, 0xAB, 0xAE, 0xBA, 0xEA },
// clang-format on
};
LatticePoint4D latticePoints[256];
for (int i = 0; i < 256; i++) {
int cx = ((i >> 0) & 3) - 1;
int cy = ((i >> 2) & 3) - 1;
int cz = ((i >> 4) & 3) - 1;
int cw = ((i >> 6) & 3) - 1;
latticePoints[i] = { cx, cy, cz, cw };
}
for (unsigned int i = 0; i < 256; i++) {
LOOKUP_4D_SIZE[i] = lookup4DPregenSize[i];
for (unsigned char j = 0; j < lookup4DPregenSize[i]; j++) {
LOOKUP_4D[i][j] = latticePoints[lookup4DPregen[i][j]];
}
}
}
void OpenSimplex2S::initGradients()
{
static const int grad2_size = 24;
Grad2 grad2[grad2_size] {
{ 0.130526192220052, 0.99144486137381 }, { 0.38268343236509, 0.923879532511287 },
{ 0.608761429008721, 0.793353340291235 }, { 0.793353340291235, 0.608761429008721 },
{ 0.923879532511287, 0.38268343236509 }, { 0.99144486137381, 0.130526192220051 },
{ 0.99144486137381, -0.130526192220051 }, { 0.923879532511287, -0.38268343236509 },
{ 0.793353340291235, -0.60876142900872 }, { 0.608761429008721, -0.793353340291235 },
{ 0.38268343236509, -0.923879532511287 }, { 0.130526192220052, -0.99144486137381 },
{ -0.130526192220052, -0.99144486137381 }, { -0.38268343236509, -0.923879532511287 },
{ -0.608761429008721, -0.793353340291235 }, { -0.793353340291235, -0.608761429008721 },
{ -0.923879532511287, -0.38268343236509 }, { -0.99144486137381, -0.130526192220052 },
{ -0.99144486137381, 0.130526192220051 }, { -0.923879532511287, 0.38268343236509 },
{ -0.793353340291235, 0.608761429008721 }, { -0.608761429008721, 0.793353340291235 },
{ -0.38268343236509, 0.923879532511287 }, { -0.130526192220052, 0.99144486137381 },
};
for (int i = 0; i < grad2_size; i++) {
grad2[i].dx /= N2;
grad2[i].dy /= N2;
}
for (int i = 0; i < PSIZE; i++) {
GRADIENTS_2D[i] = grad2[i % grad2_size];
}
static const int grad3_size = 48;
Grad3 grad3[grad3_size] {
{ -2.22474487139, -2.22474487139, -1.0 },
{ -2.22474487139, -2.22474487139, 1.0 },
{ -3.0862664687972017, -1.1721513422464978, 0.0 },
{ -1.1721513422464978, -3.0862664687972017, 0.0 },
{ -2.22474487139, -1.0, -2.22474487139 },
{ -2.22474487139, 1.0, -2.22474487139 },
{ -1.1721513422464978, 0.0, -3.0862664687972017 },
{ -3.0862664687972017, 0.0, -1.1721513422464978 },
{ -2.22474487139, -1.0, 2.22474487139 },
{ -2.22474487139, 1.0, 2.22474487139 },
{ -3.0862664687972017, 0.0, 1.1721513422464978 },
{ -1.1721513422464978, 0.0, 3.0862664687972017 },
{ -2.22474487139, 2.22474487139, -1.0 },
{ -2.22474487139, 2.22474487139, 1.0 },
{ -1.1721513422464978, 3.0862664687972017, 0.0 },
{ -3.0862664687972017, 1.1721513422464978, 0.0 },
{ -1.0, -2.22474487139, -2.22474487139 },
{ 1.0, -2.22474487139, -2.22474487139 },
{ 0.0, -3.0862664687972017, -1.1721513422464978 },
{ 0.0, -1.1721513422464978, -3.0862664687972017 },
{ -1.0, -2.22474487139, 2.22474487139 },
{ 1.0, -2.22474487139, 2.22474487139 },
{ 0.0, -1.1721513422464978, 3.0862664687972017 },
{ 0.0, -3.0862664687972017, 1.1721513422464978 },
{ -1.0, 2.22474487139, -2.22474487139 },
{ 1.0, 2.22474487139, -2.22474487139 },
{ 0.0, 1.1721513422464978, -3.0862664687972017 },
{ 0.0, 3.0862664687972017, -1.1721513422464978 },
{ -1.0, 2.22474487139, 2.22474487139 },
{ 1.0, 2.22474487139, 2.22474487139 },
{ 0.0, 3.0862664687972017, 1.1721513422464978 },
{ 0.0, 1.1721513422464978, 3.0862664687972017 },
{ 2.22474487139, -2.22474487139, -1.0 },
{ 2.22474487139, -2.22474487139, 1.0 },
{ 1.1721513422464978, -3.0862664687972017, 0.0 },
{ 3.0862664687972017, -1.1721513422464978, 0.0 },
{ 2.22474487139, -1.0, -2.22474487139 },
{ 2.22474487139, 1.0, -2.22474487139 },
{ 3.0862664687972017, 0.0, -1.1721513422464978 },
{ 1.1721513422464978, 0.0, -3.0862664687972017 },
{ 2.22474487139, -1.0, 2.22474487139 },
{ 2.22474487139, 1.0, 2.22474487139 },
{ 1.1721513422464978, 0.0, 3.0862664687972017 },
{ 3.0862664687972017, 0.0, 1.1721513422464978 },
{ 2.22474487139, 2.22474487139, -1.0 },
{ 2.22474487139, 2.22474487139, 1.0 },
{ 3.0862664687972017, 1.1721513422464978, 0.0 },
{ 1.1721513422464978, 3.0862664687972017, 0.0 },
};
for (int i = 0; i < grad3_size; i++) {
grad3[i].dx /= N3;
grad3[i].dy /= N3;
grad3[i].dz /= N3;
}
for (int i = 0; i < PSIZE; i++) {
GRADIENTS_3D[i] = grad3[i % grad3_size];
}
static const int grad4_size = 160;
Grad4 grad4[grad4_size] {
{ -0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624 },
{ -0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098 },
{ -0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301 },
{ -0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301 },
{ -0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174 },
{ -0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174 },
{ -0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796 },
{ -0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842 },
{ -0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624 },
{ -0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098 },
{ -0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301 },
{ 0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301 },
{ -0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174 },
{ 0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174 },
{ 0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796 },
{ -0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842 },
{ -0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624 },
{ -0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098 },
{ -0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301 },
{ 0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301 },
{ -0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174 },
{ 0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174 },
{ 0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796 },
{ -0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842 },
{ -0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078 },
{ -0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708 },
{ -0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708 },
{ 0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708 },
{ -0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365 },
{ 0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365 },
{ 0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365 },
{ -0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062 },
{ -0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381 },
{ -0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724 },
{ -0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724 },
{ -0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712 },
{ -0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585 },
{ -0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602 },
{ -0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602 },
{ -0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944 },
{ -0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381 },
{ -0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724 },
{ 0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724 },
{ 0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712 },
{ -0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585 },
{ -0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602 },
{ 0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602 },
{ 0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944 },
{ -0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381 },
{ -0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724 },
{ 0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724 },
{ 0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712 },
{ -0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585 },
{ -0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602 },
{ 0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602 },
{ 0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944 },
{ -0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537 },
{ -0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164 },
{ -0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195 },
{ -0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945 },
{ -0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945 },
{ -0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195 },
{ -0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164 },
{ -0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537 },
{ -0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537 },
{ -0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164 },
{ 0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195 },
{ 0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945 },
{ -0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945 },
{ -0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195 },
{ 0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164 },
{ 0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537 },
{ -0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944 },
{ -0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602 },
{ 0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602 },
{ 0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585 },
{ -0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712 },
{ -0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724 },
{ 0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724 },
{ 0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381 },
{ -0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537 },
{ -0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164 },
{ -0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195 },
{ -0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945 },
{ -0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945 },
{ -0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195 },
{ -0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164 },
{ -0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537 },
{ -0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537 },
{ -0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164 },
{ 0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195 },
{ 0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945 },
{ -0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945 },
{ -0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195 },
{ 0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164 },
{ 0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537 },
{ -0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944 },
{ -0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602 },
{ 0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602 },
{ 0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585 },
{ -0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712 },
{ -0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724 },
{ 0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724 },
{ 0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381 },
{ 0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537 },
{ 0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164 },
{ 0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195 },
{ 0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945 },
{ 0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945 },
{ 0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195 },
{ 0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164 },
{ 0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537 },
{ 0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537 },
{ 0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164 },
{ 0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195 },
{ 0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945 },
{ 0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945 },
{ 0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195 },
{ 0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164 },
{ 0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537 },
{ 0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944 },
{ 0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602 },
{ 0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602 },
{ 0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585 },
{ 0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712 },
{ 0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724 },
{ 0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724 },
{ 0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381 },
{ 0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062 },
{ -0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365 },
{ -0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365 },
{ -0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708 },
{ 0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365 },
{ 0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708 },
{ 0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708 },
{ 0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078 },
{ 0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842 },
{ -0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796 },
{ -0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174 },
{ -0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301 },
{ 0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174 },
{ 0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301 },
{ 0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098 },
{ 0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624 },
{ 0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842 },
{ -0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796 },
{ -0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174 },
{ -0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301 },
{ 0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174 },
{ 0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301 },
{ 0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098 },
{ 0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624 },
{ 0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842 },
{ 0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796 },
{ 0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174 },
{ 0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301 },
{ 0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174 },
{ 0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301 },
{ 0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098 },
{ 0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624 },
};
for (int i = 0; i < grad4_size; i++) {
grad4[i].dx /= N4;
grad4[i].dy /= N4;
grad4[i].dz /= N4;
grad4[i].dw /= N4;
}
for (int i = 0; i < PSIZE; i++) {
GRADIENTS_4D[i] = grad4[i % grad4_size];
}
}
================================================
FILE: _old/cpp/OpenSimplex2S.hpp
================================================
/**
* Ported from https://github.com/KdotJPG/OpenSimplex2/blob/master/java/OpenSimplex2S.java
* Probably not best implementation of static initialization.
* Also changed some code to use fixed c-style arrays, to avoid using of std library.
*/
/**
* K.jpg's OpenSimplex 2, smooth variant ("SuperSimplex")
*
* - 2D is standard simplex, modified to support larger kernels.
* Implemented using a lookup table.
* - 3D is "Re-oriented 8-point BCC noise" which constructs a
* congruent BCC lattice in a much different way than usual.
* - 4D uses a naïve pregenerated lookup table, and averages out
* to the expected performance.
*
* Multiple versions of each function are provided. See the
* documentation above each, for more info.
*/
class OpenSimplex2S
{
struct Grad2
{
double dx {};
double dy {};
};
struct Grad3
{
double dx {};
double dy {};
double dz {};
};
struct Grad4
{
double dx {};
double dy {};
double dz {};
double dw {};
};
struct LatticePoint2D
{
int xsv {};
int ysv {};
double dx {};
double dy {};
LatticePoint2D();
LatticePoint2D(int xsv, int ysv);
};
struct LatticePoint3D
{
double dxr {};
double dyr {};
double dzr {};
int xrv {};
int yrv {};
int zrv {};
LatticePoint3D* nextOnFailure {};
LatticePoint3D* nextOnSuccess {};
LatticePoint3D();
LatticePoint3D(int xrv, int yrv, int zrv, int lattice);
};
struct LatticePoint4D
{
int xsv {};
int ysv {};
int zsv {};
int wsv {};
double dx {};
double dy {};
double dz {};
double dw {};
LatticePoint4D();
LatticePoint4D(int xsv, int ysv, int zsv, int wsv);
};
static const int PSIZE = 2048;
static const int PMASK = 2047;
constexpr static const double N2 = 0.05481866495625118;
constexpr static const double N3 = 0.2781926117527186;
constexpr static const double N4 = 0.11127401889945551;
static Grad2 GRADIENTS_2D[PSIZE];
static Grad3 GRADIENTS_3D[PSIZE];
static Grad4 GRADIENTS_4D[PSIZE];
static LatticePoint2D LOOKUP_2D[8 * 4];
static LatticePoint3D LOOKUP_3D[8];
static LatticePoint4D LOOKUP_4D[256][20];
static unsigned char LOOKUP_4D_SIZE[256];
short perm[PSIZE];
Grad2 permGrad2[PSIZE];
Grad3 permGrad3[PSIZE];
Grad4 permGrad4[PSIZE];
/**
* 2D SuperSimplex noise base.
* Lookup table implementation inspired by DigitalShadow.
*/
double noise2_Base(double xs, double ys);
/**
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
* Lookup table implementation inspired by DigitalShadow.
* It was actually faster to narrow down the points in the loop itself,
* than to build up the index with enough info to isolate 8 points.
*/
double noise3_BCC(double xr, double yr, double zr);
/**
* 4D SuperSimplex noise base.
* Using ultra-simple 4x4x4x4 lookup partitioning.
* This isn't as elegant or SIMD/GPU/etc. portable as other approaches,
* but it does compete performance-wise with optimized OpenSimplex1.
*/
double noise4_Base(double xs, double ys, double zs, double ws);
static int fastFloor(double x);
static void initLatticePoints();
static void initGradients();
struct Initializer
{
Initializer();
};
static Initializer initializer;
public:
explicit OpenSimplex2S(long seed = 0);
/**
* 2D SuperSimplex noise, standard lattice orientation.
*/
double noise2(double x, double y);
/**
* 2D SuperSimplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
double noise2_XBeforeY(double x, double y);
/**
* 3D Re-oriented 8-point BCC noise, classic orientation
* Proper substitute for what 3D SuperSimplex would be,
* in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
double noise3_Classic(double x, double y, double z);
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
double noise3_XYBeforeZ(double x, double y, double z);
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
double noise3_XZBeforeY(double x, double y, double z);
/**
* 4D SuperSimplex noise, classic lattice orientation.
*/
double noise4_Classic(double x, double y, double z, double w);
/**
* 4D SuperSimplex noise, with XY and ZW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.
* Recommended for noise(x, y, sin(time), cos(time)) trick.
*/
double noise4_XYBeforeZW(double x, double y, double z, double w);
/**
* 4D SuperSimplex noise, with XZ and YW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
*/
double noise4_XZBeforeYW(double x, double y, double z, double w);
/**
* 4D SuperSimplex noise, with XYZ oriented like noise3_Classic,
* and W for an extra degree of freedom.
* Recommended for time-varied animations which texture a 3D object (W=time)
*/
double noise4_XYZBeforeW(double x, double y, double z, double w);
};
================================================
FILE: _old/cpp/UNLICENSE
================================================
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 <https://unlicense.org>
================================================
FILE: _old/csharp/OpenSimplex2F.cs
================================================
/**
* K.jpg's OpenSimplex 2, faster variant
*
* - 2D is standard simplex implemented using a lookup table.
* - 3D is "Re-oriented 4-point BCC noise" which constructs a
* congruent BCC lattice in a much different way than usual.
* - 4D constructs the lattice as a union of five copies of its
* reciprocal. It successively finds the closest point on each.
*
* Multiple versions of each function are provided. See the
* documentation above each, for more info.
*/
using System;
using System.Runtime.CompilerServices;
namespace Noise
{
public class OpenSimplex2F
{
private const int PSIZE = 2048;
private const int PMASK = 2047;
private short[] perm;
private Grad2[] permGrad2;
private Grad3[] permGrad3;
private Grad4[] permGrad4;
public OpenSimplex2F(long seed)
{
perm = new short[PSIZE];
permGrad2 = new Grad2[PSIZE];
permGrad3 = new Grad3[PSIZE];
permGrad4 = new Grad4[PSIZE];
short[] source = new short[PSIZE];
for (short i = 0; i < PSIZE; i++)
source[i] = i;
for (int i = PSIZE - 1; i >= 0; i--)
{
seed = seed * 6364136223846793005L + 1442695040888963407L;
int r = (int)((seed + 31) % (i + 1));
if (r < 0)
r += (i + 1);
perm[i] = source[r];
permGrad2[i] = GRADIENTS_2D[perm[i]];
permGrad3[i] = GRADIENTS_3D[perm[i]];
permGrad4[i] = GRADIENTS_4D[perm[i]];
source[r] = source[i];
}
}
/*
* Noise Evaluators
*/
/**
* 2D Simplex noise, standard lattice orientation.
*/
public double Noise2(double x, double y)
{
// Get points for A2* lattice
double s = 0.366025403784439 * (x + y);
double xs = x + s, ys = y + s;
return noise2_Base(xs, ys);
}
/**
* 2D Simplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
public double Noise2_XBeforeY(double x, double y)
{
// Skew transform and rotation baked into one.
double xx = x * 0.7071067811865476;
double yy = y * 1.224744871380249;
return noise2_Base(yy + xx, yy - xx);
}
/**
* 2D Simplex noise base.
* Lookup table implementation inspired by DigitalShadow.
*/
private double noise2_Base(double xs, double ys)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs), ysb = fastFloor(ys);
double xsi = xs - xsb, ysi = ys - ysb;
// Index to point list
int index = (int)((ysi - xsi) / 2 + 1);
double ssi = (xsi + ysi) * -0.211324865405187;
double xi = xsi + ssi, yi = ysi + ssi;
// Point contributions
for (int i = 0; i < 3; i++)
{
LatticePoint2D c = LOOKUP_2D[index + i];
double dx = xi + c.dx, dy = yi + c.dy;
double attn = 0.5 - dx * dx - dy * dy;
if (attn <= 0) continue;
int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
Grad2 grad = permGrad2[perm[pxm] ^ pym];
double extrapolation = grad.dx * dx + grad.dy * dy;
attn *= attn;
value += attn * attn * extrapolation;
}
return value;
}
/**
* 3D Re-oriented 4-point BCC noise, classic orientation.
* Proper substitute for 3D Simplex in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
public double Noise3_Classic(double x, double y, double z)
{
// Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
// If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
// Orthonormal rotation. Not a skew transform.
double r = (2.0 / 3.0) * (x + y + z);
double xr = r - x, yr = r - y, zr = r - z;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
public double Noise3_XYBeforeZ(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xy = x + y;
double s2 = xy * -0.211324865405187;
double zz = z * 0.577350269189626;
double xr = x + s2 - zz, yr = y + s2 - zz;
double zr = xy * 0.577350269189626 + zz;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 4-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
public double Noise3_XZBeforeY(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xz = x + z;
double s2 = xz * -0.211324865405187;
double yy = y * 0.577350269189626;
double xr = x + s2 - yy; double zr = z + s2 - yy;
double yr = xz * 0.577350269189626 + yy;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
* Lookup table implementation inspired by DigitalShadow.
* It was actually faster to narrow down the points in the loop itself,
* than to build up the index with enough info to isolate 4 points.
*/
private double noise3_BCC(double xr, double yr, double zr)
{
// Get base and offsets inside cube of first lattice.
int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
// Identify which octant of the cube we're in. This determines which cell
// in the other cubic lattice we're in, and also narrows down one point on each.
int xht = (int)(xri + 0.5), yht = (int)(yri + 0.5), zht = (int)(zri + 0.5);
int index = (xht << 0) | (yht << 1) | (zht << 2);
// Point contributions
double value = 0;
LatticePoint3D c = LOOKUP_3D[index];
while (c != null)
{
double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
double attn = 0.5 - dxr * dxr - dyr * dyr - dzr * dzr;
if (attn < 0)
{
c = c.NextOnFailure;
}
else
{
int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
attn *= attn;
value += attn * attn * extrapolation;
c = c.NextOnSuccess;
}
}
return value;
}
/**
* 4D OpenSimplex2F noise, classic lattice orientation.
*/
public double Noise4_Classic(double x, double y, double z, double w)
{
// Get points for A4 lattice
double s = -0.138196601125011 * (x + y + z + w);
double xs = x + s, ys = y + s, zs = z + s, ws = w + s;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XY and ZW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Y (or Z and W) are horizontal.
* Recommended for noise(x, y, sin(time), cos(time)) trick.
*/
public double Noise4_XYBeforeZW(double x, double y, double z, double w)
{
double s2 = (x + y) * -0.178275657951399372 + (z + w) * 0.215623393288842828;
double t2 = (z + w) * -0.403949762580207112 + (x + y) * -0.375199083010075342;
double xs = x + s2, ys = y + s2, zs = z + t2, ws = w + t2;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XZ and YW forming orthogonal triangular-based planes.
* Recommended for 3D terrain, where X and Z (or Y and W) are horizontal.
*/
public double Noise4_XZBeforeYW(double x, double y, double z, double w)
{
double s2 = (x + z) * -0.178275657951399372 + (y + w) * 0.215623393288842828;
double t2 = (y + w) * -0.403949762580207112 + (x + z) * -0.375199083010075342;
double xs = x + s2, ys = y + t2, zs = z + s2, ws = w + t2;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise, with XYZ oriented like noise3_Classic,
* and W for an extra degree of freedom. W repeats eventually.
* Recommended for time-varied animations which texture a 3D object (W=time)
*/
public double Noise4_XYZBeforeW(double x, double y, double z, double w)
{
double xyz = x + y + z;
double ww = w * 0.2236067977499788;
double s2 = xyz * -0.16666666666666666 + ww;
double xs = x + s2, ys = y + s2, zs = z + s2, ws = -0.5 * xyz + ww;
return noise4_Base(xs, ys, zs, ws);
}
/**
* 4D OpenSimplex2F noise base.
* Current implementation not fully optimized by lookup tables.
* But still comes out slightly ahead of Gustavson's Simplex in tests.
*/
private double noise4_Base(double xs, double ys, double zs, double ws)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs), ysb = fastFloor(ys), zsb = fastFloor(zs), wsb = fastFloor(ws);
double xsi = xs - xsb, ysi = ys - ysb, zsi = zs - zsb, wsi = ws - wsb;
// If we're in the lower half, flip so we can repeat the code for the upper half. We'll flip back later.
double siSum = xsi + ysi + zsi + wsi;
double ssi = siSum * 0.309016994374947; // Prep for vertex contributions.
bool inLowerHalf = (siSum < 2);
if (inLowerHalf)
{
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
siSum = 4 - siSum;
}
// Consider opposing vertex pairs of the octahedron formed by the central cross-section of the stretched tesseract
double aabb = xsi + ysi - zsi - wsi, abab = xsi - ysi + zsi - wsi, abba = xsi - ysi - zsi + wsi;
double aabbScore = Math.Abs(aabb), ababScore = Math.Abs(abab), abbaScore = Math.Abs(abba);
// Find the closest point on the stretched tesseract as if it were the upper half
int vertexIndex, via, vib;
double asi, bsi;
if (aabbScore > ababScore && aabbScore > abbaScore)
{
if (aabb > 0)
{
asi = zsi; bsi = wsi; vertexIndex = 0b0011; via = 0b0111; vib = 0b1011;
}
else
{
asi = xsi; bsi = ysi; vertexIndex = 0b1100; via = 0b1101; vib = 0b1110;
}
}
else if (ababScore > abbaScore)
{
if (abab > 0)
{
asi = ysi; bsi = wsi; vertexIndex = 0b0101; via = 0b0111; vib = 0b1101;
}
else
{
asi = xsi; bsi = zsi; vertexIndex = 0b1010; via = 0b1011; vib = 0b1110;
}
}
else
{
if (abba > 0)
{
asi = ysi; bsi = zsi; vertexIndex = 0b1001; via = 0b1011; vib = 0b1101;
}
else
{
asi = xsi; bsi = wsi; vertexIndex = 0b0110; via = 0b0111; vib = 0b1110;
}
}
if (bsi > asi)
{
via = vib;
double temp = bsi;
bsi = asi;
asi = temp;
}
if (siSum + asi > 3)
{
vertexIndex = via;
if (siSum + bsi > 4)
{
vertexIndex = 0b1111;
}
}
// Now flip back if we're actually in the lower half.
if (inLowerHalf)
{
xsi = 1 - xsi; ysi = 1 - ysi; zsi = 1 - zsi; wsi = 1 - wsi;
vertexIndex ^= 0b1111;
}
// Five points to add, total, from five copies of the A4 lattice.
for (int i = 0; i < 5; i++)
{
// Update xsb/etc. and add the lattice point's contribution.
LatticePoint4D c = VERTICES_4D[vertexIndex];
xsb += c.xsv; ysb += c.ysv; zsb += c.zsv; wsb += c.wsv;
double xi = xsi + ssi, yi = ysi + ssi, zi = zsi + ssi, wi = wsi + ssi;
double dx = xi + c.dx, dy = yi + c.dy, dz = zi + c.dz, dw = wi + c.dw;
double attn = 0.5 - dx * dx - dy * dy - dz * dz - dw * dw;
if (attn > 0)
{
int pxm = xsb & PMASK, pym = ysb & PMASK, pzm = zsb & PMASK, pwm = wsb & PMASK;
Grad4 grad = permGrad4[perm[perm[perm[pxm] ^ pym] ^ pzm] ^ pwm];
double ramped = grad.dx * dx + grad.dy * dy + grad.dz * dz + grad.dw * dw;
attn *= attn;
value += attn * attn * ramped;
}
// Maybe this helps the compiler/JVM/LLVM/etc. know we can end the loop here. Maybe not.
if (i == 4) break;
// Update the relative skewed coordinates to reference the vertex we just added.
// Rather, reference its counterpart on the lattice copy that is shifted down by
// the vector <-0.2, -0.2, -0.2, -0.2>
xsi += c.xsi; ysi += c.ysi; zsi += c.zsi; wsi += c.wsi;
ssi += c.ssiDelta;
// Next point is the closest vertex on the 4-simplex whose base vertex is the aforementioned vertex.
double score0 = 1.0 + ssi * (-1.0 / 0.309016994374947); // Seems slightly faster than 1.0-xsi-ysi-zsi-wsi
vertexIndex = 0b0000;
if (xsi >= ysi && xsi >= zsi && xsi >= wsi && xsi >= score0)
{
vertexIndex = 0b0001;
}
else if (ysi > xsi && ysi >= zsi && ysi >= wsi && ysi >= score0)
{
vertexIndex = 0b0010;
}
else if (zsi > xsi && zsi > ysi && zsi >= wsi && zsi >= score0)
{
vertexIndex = 0b0100;
}
else if (wsi > xsi && wsi > ysi && wsi > zsi && wsi >= score0)
{
vertexIndex = 0b1000;
}
}
return value;
}
/*
* Utility
*/
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int fastFloor(double x)
{
int xi = (int)x;
return x < xi ? xi - 1 : xi;
}
/*
* Lookup Tables & Gradients
*/
private static LatticePoint2D[] LOOKUP_2D;
private static LatticePoint3D[] LOOKUP_3D;
private static LatticePoint4D[] VERTICES_4D;
private const double N2 = 0.01001634121365712;
private const double N3 = 0.030485933181293584;
private const double N4 = 0.009202377986303158;
private static Grad2[] GRADIENTS_2D;
private static Grad3[] GRADIENTS_3D;
private static Grad4[] GRADIENTS_4D;
static OpenSimplex2F()
{
LOOKUP_2D = new LatticePoint2D[4];
LOOKUP_3D = new LatticePoint3D[8];
VERTICES_4D = new LatticePoint4D[16];
LOOKUP_2D[0] = new LatticePoint2D(1, 0);
LOOKUP_2D[1] = new LatticePoint2D(0, 0);
LOOKUP_2D[2] = new LatticePoint2D(1, 1);
LOOKUP_2D[3] = new LatticePoint2D(0, 1);
for (int i = 0; i < 8; i++)
{
int i1, j1, k1, i2, j2, k2;
i1 = (i >> 0) & 1; j1 = (i >> 1) & 1; k1 = (i >> 2) & 1;
i2 = i1 ^ 1; j2 = j1 ^ 1; k2 = k1 ^ 1;
// The two points within this octant, one from each of the two cubic half-lattices.
LatticePoint3D c0 = new LatticePoint3D(i1, j1, k1, 0);
LatticePoint3D c1 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + k2, 1);
// Each single step away on the first half-lattice.
LatticePoint3D c2 = new LatticePoint3D(i1 ^ 1, j1, k1, 0);
LatticePoint3D c3 = new LatticePoint3D(i1, j1 ^ 1, k1, 0);
LatticePoint3D c4 = new LatticePoint3D(i1, j1, k1 ^ 1, 0);
// Each single step away on the second half-lattice.
LatticePoint3D c5 = new LatticePoint3D(i1 + (i2 ^ 1), j1 + j2, k1 + k2, 1);
LatticePoint3D c6 = new LatticePoint3D(i1 + i2, j1 + (j2 ^ 1), k1 + k2, 1);
LatticePoint3D c7 = new LatticePoint3D(i1 + i2, j1 + j2, k1 + (k2 ^ 1), 1);
// First two are guaranteed.
c0.NextOnFailure = c0.NextOnSuccess = c1;
c1.NextOnFailure = c1.NextOnSuccess = c2;
// Once we find one on the first half-lattice, the rest are out.
// In addition, knowing c2 rules out c5.
c2.NextOnFailure = c3; c2.NextOnSuccess = c6;
c3.NextOnFailure = c4; c3.NextOnSuccess = c5;
c4.NextOnFailure = c4.NextOnSuccess = c5;
// Once we find one on the second half-lattice, the rest are out.
c5.NextOnFailure = c6; c5.NextOnSuccess = null;
c6.NextOnFailure = c7; c6.NextOnSuccess = null;
c7.NextOnFailure = c7.NextOnSuccess = null;
LOOKUP_3D[i] = c0;
}
for (int i = 0; i < 16; i++)
{
VERTICES_4D[i] = new LatticePoint4D((i >> 0) & 1, (i >> 1) & 1, (i >> 2) & 1, (i >> 3) & 1);
}
GRADIENTS_2D = new Grad2[PSIZE];
Grad2[] grad2 = {
new Grad2( 0.130526192220052, 0.99144486137381),
new Grad2( 0.38268343236509, 0.923879532511287),
new Grad2( 0.608761429008721, 0.793353340291235),
new Grad2( 0.793353340291235, 0.608761429008721),
new Grad2( 0.923879532511287, 0.38268343236509),
new Grad2( 0.99144486137381, 0.130526192220051),
new Grad2( 0.99144486137381, -0.130526192220051),
new Grad2( 0.923879532511287, -0.38268343236509),
new Grad2( 0.793353340291235, -0.60876142900872),
new Grad2( 0.608761429008721, -0.793353340291235),
new Grad2( 0.38268343236509, -0.923879532511287),
new Grad2( 0.130526192220052, -0.99144486137381),
new Grad2(-0.130526192220052, -0.99144486137381),
new Grad2(-0.38268343236509, -0.923879532511287),
new Grad2(-0.608761429008721, -0.793353340291235),
new Grad2(-0.793353340291235, -0.608761429008721),
new Grad2(-0.923879532511287, -0.38268343236509),
new Grad2(-0.99144486137381, -0.130526192220052),
new Grad2(-0.99144486137381, 0.130526192220051),
new Grad2(-0.923879532511287, 0.38268343236509),
new Grad2(-0.793353340291235, 0.608761429008721),
new Grad2(-0.608761429008721, 0.793353340291235),
new Grad2(-0.38268343236509, 0.923879532511287),
new Grad2(-0.130526192220052, 0.99144486137381)
};
for (int i = 0; i < grad2.Length; i++)
{
grad2[i].dx /= N2; grad2[i].dy /= N2;
}
for (int i = 0; i < PSIZE; i++)
{
GRADIENTS_2D[i] = grad2[i % grad2.Length];
}
GRADIENTS_3D = new Grad3[PSIZE];
Grad3[] grad3 = {
new Grad3(-2.22474487139, -2.22474487139, -1.0),
new Grad3(-2.22474487139, -2.22474487139, 1.0),
new Grad3(-3.0862664687972017, -1.1721513422464978, 0.0),
new Grad3(-1.1721513422464978, -3.0862664687972017, 0.0),
new Grad3(-2.22474487139, -1.0, -2.22474487139),
new Grad3(-2.22474487139, 1.0, -2.22474487139),
new Grad3(-1.1721513422464978, 0.0, -3.0862664687972017),
new Grad3(-3.0862664687972017, 0.0, -1.1721513422464978),
new Grad3(-2.22474487139, -1.0, 2.22474487139),
new Grad3(-2.22474487139, 1.0, 2.22474487139),
new Grad3(-3.0862664687972017, 0.0, 1.1721513422464978),
new Grad3(-1.1721513422464978, 0.0, 3.0862664687972017),
new Grad3(-2.22474487139, 2.22474487139, -1.0),
new Grad3(-2.22474487139, 2.22474487139, 1.0),
new Grad3(-1.1721513422464978, 3.0862664687972017, 0.0),
new Grad3(-3.0862664687972017, 1.1721513422464978, 0.0),
new Grad3(-1.0, -2.22474487139, -2.22474487139),
new Grad3( 1.0, -2.22474487139, -2.22474487139),
new Grad3( 0.0, -3.0862664687972017, -1.1721513422464978),
new Grad3( 0.0, -1.1721513422464978, -3.0862664687972017),
new Grad3(-1.0, -2.22474487139, 2.22474487139),
new Grad3( 1.0, -2.22474487139, 2.22474487139),
new Grad3( 0.0, -1.1721513422464978, 3.0862664687972017),
new Grad3( 0.0, -3.0862664687972017, 1.1721513422464978),
new Grad3(-1.0, 2.22474487139, -2.22474487139),
new Grad3( 1.0, 2.22474487139, -2.22474487139),
new Grad3( 0.0, 1.1721513422464978, -3.0862664687972017),
new Grad3( 0.0, 3.0862664687972017, -1.1721513422464978),
new Grad3(-1.0, 2.22474487139, 2.22474487139),
new Grad3( 1.0, 2.22474487139, 2.22474487139),
new Grad3( 0.0, 3.0862664687972017, 1.1721513422464978),
new Grad3( 0.0, 1.1721513422464978, 3.0862664687972017),
new Grad3( 2.22474487139, -2.22474487139, -1.0),
new Grad3( 2.22474487139, -2.22474487139, 1.0),
new Grad3( 1.1721513422464978, -3.0862664687972017, 0.0),
new Grad3( 3.0862664687972017, -1.1721513422464978, 0.0),
new Grad3( 2.22474487139, -1.0, -2.22474487139),
new Grad3( 2.22474487139, 1.0, -2.22474487139),
new Grad3( 3.0862664687972017, 0.0, -1.1721513422464978),
new Grad3( 1.1721513422464978, 0.0, -3.0862664687972017),
new Grad3( 2.22474487139, -1.0, 2.22474487139),
new Grad3( 2.22474487139, 1.0, 2.22474487139),
new Grad3( 1.1721513422464978, 0.0, 3.0862664687972017),
new Grad3( 3.0862664687972017, 0.0, 1.1721513422464978),
new Grad3( 2.22474487139, 2.22474487139, -1.0),
new Grad3( 2.22474487139, 2.22474487139, 1.0),
new Grad3( 3.0862664687972017, 1.1721513422464978, 0.0),
new Grad3( 1.1721513422464978, 3.0862664687972017, 0.0)
};
for (int i = 0; i < grad3.Length; i++)
{
grad3[i].dx /= N3; grad3[i].dy /= N3; grad3[i].dz /= N3;
}
for (int i = 0; i < PSIZE; i++)
{
GRADIENTS_3D[i] = grad3[i % grad3.Length];
}
GRADIENTS_4D = new Grad4[PSIZE];
Grad4[] grad4 = {
new Grad4(-0.753341017856078, -0.37968289875261624, -0.37968289875261624, -0.37968289875261624),
new Grad4(-0.7821684431180708, -0.4321472685365301, -0.4321472685365301, 0.12128480194602098),
new Grad4(-0.7821684431180708, -0.4321472685365301, 0.12128480194602098, -0.4321472685365301),
new Grad4(-0.7821684431180708, 0.12128480194602098, -0.4321472685365301, -0.4321472685365301),
new Grad4(-0.8586508742123365, -0.508629699630796, 0.044802370851755174, 0.044802370851755174),
new Grad4(-0.8586508742123365, 0.044802370851755174, -0.508629699630796, 0.044802370851755174),
new Grad4(-0.8586508742123365, 0.044802370851755174, 0.044802370851755174, -0.508629699630796),
new Grad4(-0.9982828964265062, -0.03381941603233842, -0.03381941603233842, -0.03381941603233842),
new Grad4(-0.37968289875261624, -0.753341017856078, -0.37968289875261624, -0.37968289875261624),
new Grad4(-0.4321472685365301, -0.7821684431180708, -0.4321472685365301, 0.12128480194602098),
new Grad4(-0.4321472685365301, -0.7821684431180708, 0.12128480194602098, -0.4321472685365301),
new Grad4( 0.12128480194602098, -0.7821684431180708, -0.4321472685365301, -0.4321472685365301),
new Grad4(-0.508629699630796, -0.8586508742123365, 0.044802370851755174, 0.044802370851755174),
new Grad4( 0.044802370851755174, -0.8586508742123365, -0.508629699630796, 0.044802370851755174),
new Grad4( 0.044802370851755174, -0.8586508742123365, 0.044802370851755174, -0.508629699630796),
new Grad4(-0.03381941603233842, -0.9982828964265062, -0.03381941603233842, -0.03381941603233842),
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.753341017856078, -0.37968289875261624),
new Grad4(-0.4321472685365301, -0.4321472685365301, -0.7821684431180708, 0.12128480194602098),
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.7821684431180708, -0.4321472685365301),
new Grad4( 0.12128480194602098, -0.4321472685365301, -0.7821684431180708, -0.4321472685365301),
new Grad4(-0.508629699630796, 0.044802370851755174, -0.8586508742123365, 0.044802370851755174),
new Grad4( 0.044802370851755174, -0.508629699630796, -0.8586508742123365, 0.044802370851755174),
new Grad4( 0.044802370851755174, 0.044802370851755174, -0.8586508742123365, -0.508629699630796),
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.9982828964265062, -0.03381941603233842),
new Grad4(-0.37968289875261624, -0.37968289875261624, -0.37968289875261624, -0.753341017856078),
new Grad4(-0.4321472685365301, -0.4321472685365301, 0.12128480194602098, -0.7821684431180708),
new Grad4(-0.4321472685365301, 0.12128480194602098, -0.4321472685365301, -0.7821684431180708),
new Grad4( 0.12128480194602098, -0.4321472685365301, -0.4321472685365301, -0.7821684431180708),
new Grad4(-0.508629699630796, 0.044802370851755174, 0.044802370851755174, -0.8586508742123365),
new Grad4( 0.044802370851755174, -0.508629699630796, 0.044802370851755174, -0.8586508742123365),
new Grad4( 0.044802370851755174, 0.044802370851755174, -0.508629699630796, -0.8586508742123365),
new Grad4(-0.03381941603233842, -0.03381941603233842, -0.03381941603233842, -0.9982828964265062),
new Grad4(-0.6740059517812944, -0.3239847771997537, -0.3239847771997537, 0.5794684678643381),
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.15296486218853164, 0.5029860367700724),
new Grad4(-0.7504883828755602, 0.15296486218853164, -0.4004672082940195, 0.5029860367700724),
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.08164729285680945, 0.4553054119602712),
new Grad4(-0.4553054119602712, -0.08164729285680945, -0.08164729285680945, 0.8828161875373585),
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.4004672082940195, 0.7504883828755602),
new Grad4(-0.5029860367700724, 0.4004672082940195, -0.15296486218853164, 0.7504883828755602),
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.3239847771997537, 0.6740059517812944),
new Grad4(-0.3239847771997537, -0.6740059517812944, -0.3239847771997537, 0.5794684678643381),
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.15296486218853164, 0.5029860367700724),
new Grad4( 0.15296486218853164, -0.7504883828755602, -0.4004672082940195, 0.5029860367700724),
new Grad4( 0.08164729285680945, -0.8828161875373585, 0.08164729285680945, 0.4553054119602712),
new Grad4(-0.08164729285680945, -0.4553054119602712, -0.08164729285680945, 0.8828161875373585),
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.4004672082940195, 0.7504883828755602),
new Grad4( 0.4004672082940195, -0.5029860367700724, -0.15296486218853164, 0.7504883828755602),
new Grad4( 0.3239847771997537, -0.5794684678643381, 0.3239847771997537, 0.6740059517812944),
new Grad4(-0.3239847771997537, -0.3239847771997537, -0.6740059517812944, 0.5794684678643381),
new Grad4(-0.4004672082940195, 0.15296486218853164, -0.7504883828755602, 0.5029860367700724),
new Grad4( 0.15296486218853164, -0.4004672082940195, -0.7504883828755602, 0.5029860367700724),
new Grad4( 0.08164729285680945, 0.08164729285680945, -0.8828161875373585, 0.4553054119602712),
new Grad4(-0.08164729285680945, -0.08164729285680945, -0.4553054119602712, 0.8828161875373585),
new Grad4(-0.15296486218853164, 0.4004672082940195, -0.5029860367700724, 0.7504883828755602),
new Grad4( 0.4004672082940195, -0.15296486218853164, -0.5029860367700724, 0.7504883828755602),
new Grad4( 0.3239847771997537, 0.3239847771997537, -0.5794684678643381, 0.6740059517812944),
new Grad4(-0.6740059517812944, -0.3239847771997537, 0.5794684678643381, -0.3239847771997537),
new Grad4(-0.7504883828755602, -0.4004672082940195, 0.5029860367700724, 0.15296486218853164),
new Grad4(-0.7504883828755602, 0.15296486218853164, 0.5029860367700724, -0.4004672082940195),
new Grad4(-0.8828161875373585, 0.08164729285680945, 0.4553054119602712, 0.08164729285680945),
new Grad4(-0.4553054119602712, -0.08164729285680945, 0.8828161875373585, -0.08164729285680945),
new Grad4(-0.5029860367700724, -0.15296486218853164, 0.7504883828755602, 0.4004672082940195),
new Grad4(-0.5029860367700724, 0.4004672082940195, 0.7504883828755602, -0.15296486218853164),
new Grad4(-0.5794684678643381, 0.3239847771997537, 0.6740059517812944, 0.3239847771997537),
new Grad4(-0.3239847771997537, -0.6740059517812944, 0.5794684678643381, -0.3239847771997537),
new Grad4(-0.4004672082940195, -0.7504883828755602, 0.5029860367700724, 0.15296486218853164),
new Grad4( 0.15296486218853164, -0.7504883828755602, 0.5029860367700724, -0.4004672082940195),
new Grad4( 0.08164729285680945, -0.8828161875373585, 0.4553054119602712, 0.08164729285680945),
new Grad4(-0.08164729285680945, -0.4553054119602712, 0.8828161875373585, -0.08164729285680945),
new Grad4(-0.15296486218853164, -0.5029860367700724, 0.7504883828755602, 0.4004672082940195),
new Grad4( 0.4004672082940195, -0.5029860367700724, 0.7504883828755602, -0.15296486218853164),
new Grad4( 0.3239847771997537, -0.5794684678643381, 0.6740059517812944, 0.3239847771997537),
new Grad4(-0.3239847771997537, -0.3239847771997537, 0.5794684678643381, -0.6740059517812944),
new Grad4(-0.4004672082940195, 0.15296486218853164, 0.5029860367700724, -0.7504883828755602),
new Grad4( 0.15296486218853164, -0.4004672082940195, 0.5029860367700724, -0.7504883828755602),
new Grad4( 0.08164729285680945, 0.08164729285680945, 0.4553054119602712, -0.8828161875373585),
new Grad4(-0.08164729285680945, -0.08164729285680945, 0.8828161875373585, -0.4553054119602712),
new Grad4(-0.15296486218853164, 0.4004672082940195, 0.7504883828755602, -0.5029860367700724),
new Grad4( 0.4004672082940195, -0.15296486218853164, 0.7504883828755602, -0.5029860367700724),
new Grad4( 0.3239847771997537, 0.3239847771997537, 0.6740059517812944, -0.5794684678643381),
new Grad4(-0.6740059517812944, 0.5794684678643381, -0.3239847771997537, -0.3239847771997537),
new Grad4(-0.7504883828755602, 0.5029860367700724, -0.4004672082940195, 0.15296486218853164),
new Grad4(-0.7504883828755602, 0.5029860367700724, 0.15296486218853164, -0.4004672082940195),
new Grad4(-0.8828161875373585, 0.4553054119602712, 0.08164729285680945, 0.08164729285680945),
new Grad4(-0.4553054119602712, 0.8828161875373585, -0.08164729285680945, -0.08164729285680945),
new Grad4(-0.5029860367700724, 0.7504883828755602, -0.15296486218853164, 0.4004672082940195),
new Grad4(-0.5029860367700724, 0.7504883828755602, 0.4004672082940195, -0.15296486218853164),
new Grad4(-0.5794684678643381, 0.6740059517812944, 0.3239847771997537, 0.3239847771997537),
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.6740059517812944, -0.3239847771997537),
new Grad4(-0.4004672082940195, 0.5029860367700724, -0.7504883828755602, 0.15296486218853164),
new Grad4( 0.15296486218853164, 0.5029860367700724, -0.7504883828755602, -0.4004672082940195),
new Grad4( 0.08164729285680945, 0.4553054119602712, -0.8828161875373585, 0.08164729285680945),
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.4553054119602712, -0.08164729285680945),
new Grad4(-0.15296486218853164, 0.7504883828755602, -0.5029860367700724, 0.4004672082940195),
new Grad4( 0.4004672082940195, 0.7504883828755602, -0.5029860367700724, -0.15296486218853164),
new Grad4( 0.3239847771997537, 0.6740059517812944, -0.5794684678643381, 0.3239847771997537),
new Grad4(-0.3239847771997537, 0.5794684678643381, -0.3239847771997537, -0.6740059517812944),
new Grad4(-0.4004672082940195, 0.5029860367700724, 0.15296486218853164, -0.7504883828755602),
new Grad4( 0.15296486218853164, 0.5029860367700724, -0.4004672082940195, -0.7504883828755602),
new Grad4( 0.08164729285680945, 0.4553054119602712, 0.08164729285680945, -0.8828161875373585),
new Grad4(-0.08164729285680945, 0.8828161875373585, -0.08164729285680945, -0.4553054119602712),
new Grad4(-0.15296486218853164, 0.7504883828755602, 0.4004672082940195, -0.5029860367700724),
new Grad4( 0.4004672082940195, 0.7504883828755602, -0.15296486218853164, -0.5029860367700724),
new Grad4( 0.3239847771997537, 0.6740059517812944, 0.3239847771997537, -0.5794684678643381),
new Grad4( 0.5794684678643381, -0.6740059517812944, -0.3239847771997537, -0.3239847771997537),
new Grad4( 0.5029860367700724, -0.7504883828755602, -0.4004672082940195, 0.15296486218853164),
new Grad4( 0.5029860367700724, -0.7504883828755602, 0.15296486218853164, -0.4004672082940195),
new Grad4( 0.4553054119602712, -0.8828161875373585, 0.08164729285680945, 0.08164729285680945),
new Grad4( 0.8828161875373585, -0.4553054119602712, -0.08164729285680945, -0.08164729285680945),
new Grad4( 0.7504883828755602, -0.5029860367700724, -0.15296486218853164, 0.4004672082940195),
new Grad4( 0.7504883828755602, -0.5029860367700724, 0.4004672082940195, -0.15296486218853164),
new Grad4( 0.6740059517812944, -0.5794684678643381, 0.3239847771997537, 0.3239847771997537),
new Grad4( 0.5794684678643381, -0.3239847771997537, -0.6740059517812944, -0.3239847771997537),
new Grad4( 0.5029860367700724, -0.4004672082940195, -0.7504883828755602, 0.15296486218853164),
new Grad4( 0.5029860367700724, 0.15296486218853164, -0.7504883828755602, -0.4004672082940195),
new Grad4( 0.4553054119602712, 0.08164729285680945, -0.8828161875373585, 0.08164729285680945),
new Grad4( 0.8828161875373585, -0.08164729285680945, -0.4553054119602712, -0.08164729285680945),
new Grad4( 0.7504883828755602, -0.15296486218853164, -0.5029860367700724, 0.4004672082940195),
new Grad4( 0.7504883828755602, 0.4004672082940195, -0.5029860367700724, -0.15296486218853164),
new Grad4( 0.6740059517812944, 0.3239847771997537, -0.5794684678643381, 0.3239847771997537),
new Grad4( 0.5794684678643381, -0.3239847771997537, -0.3239847771997537, -0.6740059517812944),
new Grad4( 0.5029860367700724, -0.4004672082940195, 0.15296486218853164, -0.7504883828755602),
new Grad4( 0.5029860367700724, 0.15296486218853164, -0.4004672082940195, -0.7504883828755602),
new Grad4( 0.4553054119602712, 0.08164729285680945, 0.08164729285680945, -0.8828161875373585),
new Grad4( 0.8828161875373585, -0.08164729285680945, -0.08164729285680945, -0.4553054119602712),
new Grad4( 0.7504883828755602, -0.15296486218853164, 0.4004672082940195, -0.5029860367700724),
new Grad4( 0.7504883828755602, 0.4004672082940195, -0.15296486218853164, -0.5029860367700724),
new Grad4( 0.6740059517812944, 0.3239847771997537, 0.3239847771997537, -0.5794684678643381),
new Grad4( 0.03381941603233842, 0.03381941603233842, 0.03381941603233842, 0.9982828964265062),
new Grad4(-0.044802370851755174, -0.044802370851755174, 0.508629699630796, 0.8586508742123365),
new Grad4(-0.044802370851755174, 0.508629699630796, -0.044802370851755174, 0.8586508742123365),
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.4321472685365301, 0.7821684431180708),
new Grad4( 0.508629699630796, -0.044802370851755174, -0.044802370851755174, 0.8586508742123365),
new Grad4( 0.4321472685365301, -0.12128480194602098, 0.4321472685365301, 0.7821684431180708),
new Grad4( 0.4321472685365301, 0.4321472685365301, -0.12128480194602098, 0.7821684431180708),
new Grad4( 0.37968289875261624, 0.37968289875261624, 0.37968289875261624, 0.753341017856078),
new Grad4( 0.03381941603233842, 0.03381941603233842, 0.9982828964265062, 0.03381941603233842),
new Grad4(-0.044802370851755174, 0.044802370851755174, 0.8586508742123365, 0.508629699630796),
new Grad4(-0.044802370851755174, 0.508629699630796, 0.8586508742123365, -0.044802370851755174),
new Grad4(-0.12128480194602098, 0.4321472685365301, 0.7821684431180708, 0.4321472685365301),
new Grad4( 0.508629699630796, -0.044802370851755174, 0.8586508742123365, -0.044802370851755174),
new Grad4( 0.4321472685365301, -0.12128480194602098, 0.7821684431180708, 0.4321472685365301),
new Grad4( 0.4321472685365301, 0.4321472685365301, 0.7821684431180708, -0.12128480194602098),
new Grad4( 0.37968289875261624, 0.37968289875261624, 0.753341017856078, 0.37968289875261624),
new Grad4( 0.03381941603233842, 0.9982828964265062, 0.03381941603233842, 0.03381941603233842),
new Grad4(-0.044802370851755174, 0.8586508742123365, -0.044802370851755174, 0.508629699630796),
new Grad4(-0.044802370851755174, 0.8586508742123365, 0.508629699630796, -0.044802370851755174),
new Grad4(-0.12128480194602098, 0.7821684431180708, 0.4321472685365301, 0.4321472685365301),
new Grad4( 0.508629699630796, 0.8586508742123365, -0.044802370851755174, -0.044802370851755174),
new Grad4( 0.4321472685365301, 0.7821684431180708, -0.12128480194602098, 0.4321472685365301),
new Grad4( 0.4321472685365301, 0.7821684431180708, 0.4321472685365301, -0.12128480194602098),
new Grad4( 0.37968289875261624, 0.753341017856078, 0.37968289875261624, 0.37968289875261624),
new Grad4( 0.9982828964265062, 0.03381941603233842, 0.03381941603233842, 0.03381941603233842),
new Grad4( 0.8586508742123365, -0.044802370851755174, -0.044802370851755174, 0.508629699630796),
new Grad4( 0.8586508742123365, -0.044802370851755174, 0.508629699630796, -0.044802370851755174),
new Grad4( 0.7821684431180708, -0.12128480194602098, 0.4321472685365301, 0.4321472685365301),
new Grad4( 0.8586508742123365, 0.508629699630796, -0.044802370851755174, -0.044802370851755174),
new Grad4( 0.7821684431180708, 0.4321472685365301, -0.12128480194602098, 0.4321472685365301),
new Grad4( 0.7821684431180708, 0.4321472685365301, 0.4321472685365301, -0.12128480194602098),
new Grad4( 0.753341017856078, 0.37968289875261624, 0.37968289875261624, 0.37968289875261624)
};
for (int i = 0; i < grad4.Length; i++)
{
grad4[i].dx /= N4; grad4[i].dy /= N4; grad4[i].dz /= N4; grad4[i].dw /= N4;
}
for (int i = 0; i < PSIZE; i++)
{
GRADIENTS_4D[i] = grad4[i % grad4.Length];
}
}
private struct LatticePoint2D
{
public int xsv, ysv;
public double dx, dy;
public LatticePoint2D(int xsv, int ysv)
{
this.xsv = xsv; this.ysv = ysv;
double ssv = (xsv + ysv) * -0.211324865405187;
this.dx = -xsv - ssv;
this.dy = -ysv - ssv;
}
}
private class LatticePoint3D
{
public double dxr, dyr, dzr;
public int xrv, yrv, zrv;
public LatticePoint3D NextOnFailure, NextOnSuccess;
public LatticePoint3D(int xrv, int yrv, int zrv, int lattice)
{
this.dxr = -xrv + lattice * 0.5; this.dyr = -yrv + lattice * 0.5; this.dzr = -zrv + lattice * 0.5;
this.xrv = xrv + lattice * 1024; this.yrv = yrv + lattice * 1024; this.zrv = zrv + lattice * 1024;
}
}
private struct LatticePoint4D
{
public int xsv, ysv, zsv, wsv;
public double dx, dy, dz, dw;
public double xsi, ysi, zsi, wsi;
public double ssiDelta;
public LatticePoint4D(int xsv, int ysv, int zsv, int wsv)
{
this.xsv = xsv + 409; this.ysv = ysv + 409; this.zsv = zsv + 409; this.wsv = wsv + 409;
double ssv = (xsv + ysv + zsv + wsv) * 0.309016994374947;
this.dx = -xsv - ssv;
this.dy = -ysv - ssv;
this.dz = -zsv - ssv;
this.dw = -wsv - ssv;
this.xsi = xsi = 0.2 - xsv;
this.ysi = ysi = 0.2 - ysv;
this.zsi = zsi = 0.2 - zsv;
this.wsi = wsi = 0.2 - wsv;
this.ssiDelta = (0.8 - xsv - ysv - zsv - wsv) * 0.309016994374947;
}
}
private struct Grad2
{
public double dx, dy;
public Grad2(double dx, double dy)
{
this.dx = dx; this.dy = dy;
}
}
private struct Grad3
{
public double dx, dy, dz;
public Grad3(double dx, double dy, double dz)
{
this.dx = dx; this.dy = dy; this.dz = dz;
}
}
private struct Grad4
{
public double dx, dy, dz, dw;
public Grad4(double dx, double dy, double dz, double dw)
{
this.dx = dx; this.dy = dy; this.dz = dz; this.dw = dw;
}
}
}
}
================================================
FILE: _old/csharp/OpenSimplex2S.cs
================================================
/**
* K.jpg's OpenSimplex 2, smooth variant ("SuperSimplex")
*
* - 2D is standard simplex, modified to support larger kernels.
* Implemented using a lookup table.
* - 3D is "Re-oriented 8-point BCC noise" which constructs a
* congruent BCC lattice in a much different way than usual.
* - 4D uses a naïve pregenerated lookup table, and averages out
* to the expected performance.
*
* Multiple versions of each function are provided. See the
* documentation above each, for more info.
*/
using System.Runtime.CompilerServices;
namespace Noise
{
public class OpenSimplex2S
{
private const int PSIZE = 2048;
private const int PMASK = 2047;
private short[] perm;
private Grad2[] permGrad2;
private Grad3[] permGrad3;
private Grad4[] permGrad4;
public OpenSimplex2S(long seed)
{
perm = new short[PSIZE];
permGrad2 = new Grad2[PSIZE];
permGrad3 = new Grad3[PSIZE];
permGrad4 = new Grad4[PSIZE];
short[] source = new short[PSIZE];
for (short i = 0; i < PSIZE; i++)
source[i] = i;
for (int i = PSIZE - 1; i >= 0; i--)
{
seed = seed * 6364136223846793005L + 1442695040888963407L;
int r = (int)((seed + 31) % (i + 1));
if (r < 0)
r += (i + 1);
perm[i] = source[r];
permGrad2[i] = GRADIENTS_2D[perm[i]];
permGrad3[i] = GRADIENTS_3D[perm[i]];
permGrad4[i] = GRADIENTS_4D[perm[i]];
source[r] = source[i];
}
}
/*
* Noise Evaluators
*/
/**
* 2D SuperSimplex noise, standard lattice orientation.
*/
public double Noise2(double x, double y)
{
// Get points for A2* lattice
double s = 0.366025403784439 * (x + y);
double xs = x + s, ys = y + s;
return noise2_Base(xs, ys);
}
/**
* 2D SuperSimplex noise, with Y pointing down the main diagonal.
* Might be better for a 2D sandbox style game, where Y is vertical.
* Probably slightly less optimal for heightmaps or continent maps.
*/
public double Noise2_XBeforeY(double x, double y)
{
// Skew transform and rotation baked into one.
double xx = x * 0.7071067811865476;
double yy = y * 1.224744871380249;
return noise2_Base(yy + xx, yy - xx);
}
/**
* 2D SuperSimplex noise base.
* Lookup table implementation inspired by DigitalShadow.
*/
private double noise2_Base(double xs, double ys)
{
double value = 0;
// Get base points and offsets
int xsb = fastFloor(xs), ysb = fastFloor(ys);
double xsi = xs - xsb, ysi = ys - ysb;
// Index to point list
int a = (int)(xsi + ysi);
int index =
(a << 2) |
(int)(xsi - ysi / 2 + 1 - a / 2.0) << 3 |
(int)(ysi - xsi / 2 + 1 - a / 2.0) << 4;
double ssi = (xsi + ysi) * -0.211324865405187;
double xi = xsi + ssi, yi = ysi + ssi;
// Point contributions
for (int i = 0; i < 4; i++)
{
LatticePoint2D c = LOOKUP_2D[index + i];
double dx = xi + c.dx, dy = yi + c.dy;
double attn = 2.0 / 3.0 - dx * dx - dy * dy;
if (attn <= 0) continue;
int pxm = (xsb + c.xsv) & PMASK, pym = (ysb + c.ysv) & PMASK;
Grad2 grad = permGrad2[perm[pxm] ^ pym];
double extrapolation = grad.dx * dx + grad.dy * dy;
attn *= attn;
value += attn * attn * extrapolation;
}
return value;
}
/**
* 3D Re-oriented 8-point BCC noise, classic orientation
* Proper substitute for what 3D SuperSimplex "should" be,
* in light of Forbidden Formulae.
* Use noise3_XYBeforeZ or noise3_XZBeforeY instead, wherever appropriate.
*/
public double Noise3_Classic(double x, double y, double z)
{
// Re-orient the cubic lattices via rotation, to produce the expected look on cardinal planar slices.
// If texturing objects that don't tend to have cardinal plane faces, you could even remove this.
// Orthonormal rotation. Not a skew transform.
double r = (2.0 / 3.0) * (x + y + z);
double xr = r - x, yr = r - y, zr = r - z;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Y).
* Recommended for 3D terrain and time-varied animations.
* The Z coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XYBeforeZ(x, z, Y) or use noise3_XZBeforeY.
* If Z is vertical in world coordinates, call noise3_XYBeforeZ(x, y, Z).
* For a time varied animation, call noise3_XYBeforeZ(x, y, T).
*/
public double Noise3_XYBeforeZ(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Y triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xy = x + y;
double s2 = xy * -0.211324865405187;
double zz = z * 0.577350269189626;
double xr = x + s2 - zz, yr = y + s2 - zz;
double zr = xy * 0.577350269189626 + zz;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* 3D Re-oriented 8-point BCC noise, with better visual isotropy in (X, Z).
* Recommended for 3D terrain and time-varied animations.
* The Y coordinate should always be the "different" coordinate in your use case.
* If Y is vertical in world coordinates, call noise3_XZBeforeY(x, Y, z).
* If Z is vertical in world coordinates, call noise3_XZBeforeY(x, Z, y) or use noise3_XYBeforeZ.
* For a time varied animation, call noise3_XZBeforeY(x, T, y) or use noise3_XYBeforeZ.
*/
public double Noise3_XZBeforeY(double x, double y, double z)
{
// Re-orient the cubic lattices without skewing, to make X and Z triangular like 2D.
// Orthonormal rotation. Not a skew transform.
double xz = x + z;
double s2 = xz * -0.211324865405187;
double yy = y * 0.577350269189626;
double xr = x + s2 - yy; double zr = z + s2 - yy;
double yr = xz * 0.577350269189626 + yy;
// Evaluate both lattices to form a BCC lattice.
return noise3_BCC(xr, yr, zr);
}
/**
* Generate overlapping cubic lattices for 3D Re-oriented BCC noise.
* Lookup table implementation inspired by DigitalShadow.
* It was actually faster to narrow down the points in the loop itself,
* than to build up the index with enough info to isolate 8 points.
*/
private double noise3_BCC(double xr, double yr, double zr)
{
// Get base and offsets inside cube of first lattice.
int xrb = fastFloor(xr), yrb = fastFloor(yr), zrb = fastFloor(zr);
double xri = xr - xrb, yri = yr - yrb, zri = zr - zrb;
// Identify which octant of the cube we're in. This determines which cell
// in the other cubic lattice we're in, and also narrows down one point on each.
int xht = (int)(xri + 0.5), yht = (int)(yri + 0.5), zht = (int)(zri + 0.5);
int index = (xht << 0) | (yht << 1) | (zht << 2);
// Point contributions
double value = 0;
LatticePoint3D c = LOOKUP_3D[index];
while (c != null)
{
double dxr = xri + c.dxr, dyr = yri + c.dyr, dzr = zri + c.dzr;
double attn = 0.75 - dxr * dxr - dyr * dyr - dzr * dzr;
if (attn < 0)
{
c = c.NextOnFailure;
}
else
{
int pxm = (xrb + c.xrv) & PMASK, pym = (yrb + c.yrv) & PMASK, pzm = (zrb + c.zrv) & PMASK;
Grad3 grad = permGrad3[perm[perm[pxm] ^ pym] ^ pzm];
double extrapolation = grad.dx * dxr + grad.dy * dyr + grad.dz * dzr;
attn *= attn;
value += attn * attn * extrapolation;
c = c.NextOnSuccess;
}
}
return value;
}
/**
* 4D SuperSimplex noise, classic lattice orientation.
*/
public double Noise4_Classic(double x, double y, dou
gitextract_r8vzkgd4/
├── .gitignore
├── Cargo.toml
├── LICENSE
├── README.md
├── _old/
│ ├── c/
│ │ ├── Makefile
│ │ ├── OpenSimplex2F.c
│ │ ├── OpenSimplex2F.h
│ │ ├── UNLICENSE
│ │ └── test_OpenSimplex2F.c
│ ├── cpp/
│ │ ├── OpenSimplex2S.cpp
│ │ ├── OpenSimplex2S.hpp
│ │ └── UNLICENSE
│ ├── csharp/
│ │ ├── OpenSimplex2F.cs
│ │ ├── OpenSimplex2S.cs
│ │ └── legacy/
│ │ ├── OpenSimplex.cs
│ │ └── UNLICENSE
│ └── java/
│ ├── OpenSimplex2F.java
│ ├── OpenSimplex2S.java
│ ├── legacy/
│ │ ├── OpenSimplex.java
│ │ └── UNLICENSE
│ └── legacy_unoptimized/
│ └── OpenSimplexUnoptimized.java
├── csharp/
│ ├── OpenSimplex2.cs
│ └── OpenSimplex2S.cs
├── glsl/
│ ├── OpenSimplex2.glsl
│ └── OpenSimplex2S.glsl
├── hlsl/
│ ├── OpenSimplex2.hlsl
│ ├── OpenSimplex2S.hlsl
│ └── UNLICENSE
├── java/
│ ├── OpenSimplex2.java
│ └── OpenSimplex2S.java
└── rust/
├── OpenSimplex2.h
├── fast.rs
├── ffi.rs
├── lib.rs
└── smooth.rs
SYMBOL INDEX (448 symbols across 18 files)
FILE: _old/c/OpenSimplex2F.c
type Grad2 (line 43) | struct Grad2 {
type Grad3 (line 47) | struct Grad3 {
type Grad4 (line 51) | struct Grad4 {
type LatticePoint2D (line 55) | struct LatticePoint2D {
type LatticePoint2D (line 60) | struct LatticePoint2D
type LatticePoint2D (line 62) | struct LatticePoint2D
type LatticePoint3D (line 71) | struct LatticePoint3D {
type LatticePoint3D (line 77) | struct LatticePoint3D
type LatticePoint3D (line 79) | struct LatticePoint3D
function find_unique_pointers (line 86) | static void find_unique_pointers(struct LatticePoint3D *tree, struct Lat...
function free_LatticePoint3D (line 107) | static void free_LatticePoint3D(struct LatticePoint3D *list[], int n)
type LatticePoint4D (line 115) | struct LatticePoint4D {
type LatticePoint4D (line 122) | struct LatticePoint4D
type LatticePoint4D (line 124) | struct LatticePoint4D
type OpenSimplex2F_context (line 140) | struct OpenSimplex2F_context {
type Grad2 (line 149) | struct Grad2
type Grad3 (line 150) | struct Grad3
type Grad4 (line 151) | struct Grad4
type LatticePoint2D (line 152) | struct LatticePoint2D
type LatticePoint3D (line 153) | struct LatticePoint3D
type LatticePoint4D (line 154) | struct LatticePoint4D
type Grad2 (line 156) | struct Grad2
type Grad3 (line 183) | struct Grad3
type Grad4 (line 234) | struct Grad4
function setup_gradients (line 398) | static void setup_gradients(void)
function setup_lattice_points (line 429) | static void setup_lattice_points(void)
function OpenSimplex2F_shutdown (line 486) | void OpenSimplex2F_shutdown(void)
function OpenSimplex2F_free (line 521) | void OpenSimplex2F_free(struct OpenSimplex2F_context *ctx)
function OpenSimplex2F (line 534) | int OpenSimplex2F(int64_t seed, struct OpenSimplex2F_context **ctx)
function fastFloor (line 583) | static int fastFloor(double x)
function noise2_Base (line 593) | static double noise2_Base(struct OpenSimplex2F_context *ctx, double xs, ...
function noise3_BCC (line 633) | static double noise3_BCC(struct OpenSimplex2F_context *ctx, double xr, d...
function OpenSimplex2F_noise2 (line 668) | double OpenSimplex2F_noise2(struct OpenSimplex2F_context *ctx, double x,...
function OpenSimplex2F_noise2_XBeforeY (line 682) | double OpenSimplex2F_noise2_XBeforeY(struct OpenSimplex2F_context *ctx, ...
function OpenSimplex2F_noise3_Classic (line 696) | double OpenSimplex2F_noise3_Classic(struct OpenSimplex2F_context *ctx, d...
function OpenSimplex2F_noise3_XYBeforeZ (line 716) | double OpenSimplex2F_noise3_XYBeforeZ(struct OpenSimplex2F_context *ctx,...
function OpenSimplex2F_noise3_XZBeforeY (line 738) | double OpenSimplex2F_noise3_XZBeforeY(struct OpenSimplex2F_context *ctx,...
function noise4_Base (line 757) | static double noise4_Base(struct OpenSimplex2F_context *ctx, double xs, ...
function OpenSimplex2F_noise4_Classic (line 869) | double OpenSimplex2F_noise4_Classic(struct OpenSimplex2F_context *ctx, d...
function OpenSimplex2F_noise4_XYBeforeZW (line 883) | double OpenSimplex2F_noise4_XYBeforeZW(struct OpenSimplex2F_context *ctx...
function OpenSimplex2F_noise4_XZBeforeYW (line 897) | double OpenSimplex2F_noise4_XZBeforeYW(struct OpenSimplex2F_context *ctx...
function OpenSimplex2F_noise4_XYZBeforeW (line 911) | double OpenSimplex2F_noise4_XYZBeforeW(struct OpenSimplex2F_context *ctx...
FILE: _old/c/OpenSimplex2F.h
type OpenSimplex2F_context (line 35) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 38) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 41) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 49) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 56) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 63) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 73) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 83) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 88) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 95) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 101) | struct OpenSimplex2F_context
type OpenSimplex2F_context (line 108) | struct OpenSimplex2F_context
FILE: _old/c/test_OpenSimplex2F.c
function write_png_image (line 16) | static int write_png_image(const char *filename, unsigned char *pixels, ...
function main (line 71) | int main(__attribute__((unused)) int argc, __attribute__((unused)) char ...
FILE: _old/cpp/OpenSimplex2S.hpp
class OpenSimplex2S (line 20) | class OpenSimplex2S
type Grad2 (line 22) | struct Grad2
type Grad3 (line 28) | struct Grad3
type Grad4 (line 35) | struct Grad4
type LatticePoint2D (line 43) | struct LatticePoint2D
type LatticePoint3D (line 54) | struct LatticePoint3D
type LatticePoint4D (line 68) | struct LatticePoint4D
type Initializer (line 131) | struct Initializer
FILE: _old/csharp/OpenSimplex2F.cs
class OpenSimplex2F (line 19) | public class OpenSimplex2F
method OpenSimplex2F (line 29) | public OpenSimplex2F(long seed)
method Noise2 (line 59) | public double Noise2(double x, double y)
method Noise2_XBeforeY (line 74) | public double Noise2_XBeforeY(double x, double y)
method noise2_Base (line 88) | private double noise2_Base(double xs, double ys)
method Noise3_Classic (line 127) | public double Noise3_Classic(double x, double y, double z)
method Noise3_XYBeforeZ (line 148) | public double Noise3_XYBeforeZ(double x, double y, double z)
method Noise3_XZBeforeY (line 171) | public double Noise3_XZBeforeY(double x, double y, double z)
method noise3_BCC (line 192) | private double noise3_BCC(double xr, double yr, double zr)
method Noise4_Classic (line 232) | public double Noise4_Classic(double x, double y, double z, double w)
method Noise4_XYBeforeZW (line 247) | public double Noise4_XYBeforeZW(double x, double y, double z, double w)
method Noise4_XZBeforeYW (line 261) | public double Noise4_XZBeforeYW(double x, double y, double z, double w)
method Noise4_XYZBeforeW (line 276) | public double Noise4_XYZBeforeW(double x, double y, double z, double w)
method noise4_Base (line 292) | private double noise4_Base(double xs, double ys, double zs, double ws)
method fastFloor (line 430) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method OpenSimplex2F (line 452) | static OpenSimplex2F()
type LatticePoint2D (line 775) | private struct LatticePoint2D
method LatticePoint2D (line 779) | public LatticePoint2D(int xsv, int ysv)
class LatticePoint3D (line 788) | private class LatticePoint3D
method LatticePoint3D (line 793) | public LatticePoint3D(int xrv, int yrv, int zrv, int lattice)
type LatticePoint4D (line 800) | private struct LatticePoint4D
method LatticePoint4D (line 806) | public LatticePoint4D(int xsv, int ysv, int zsv, int wsv)
type Grad2 (line 822) | private struct Grad2
method Grad2 (line 825) | public Grad2(double dx, double dy)
type Grad3 (line 831) | private struct Grad3
method Grad3 (line 834) | public Grad3(double dx, double dy, double dz)
type Grad4 (line 840) | private struct Grad4
method Grad4 (line 843) | public Grad4(double dx, double dy, double dz, double dw)
FILE: _old/csharp/OpenSimplex2S.cs
class OpenSimplex2S (line 19) | public class OpenSimplex2S
method OpenSimplex2S (line 29) | public OpenSimplex2S(long seed)
method Noise2 (line 59) | public double Noise2(double x, double y)
method Noise2_XBeforeY (line 74) | public double Noise2_XBeforeY(double x, double y)
method noise2_Base (line 88) | private double noise2_Base(double xs, double ys)
method Noise3_Classic (line 132) | public double Noise3_Classic(double x, double y, double z)
method Noise3_XYBeforeZ (line 153) | public double Noise3_XYBeforeZ(double x, double y, double z)
method Noise3_XZBeforeY (line 176) | public double Noise3_XZBeforeY(double x, double y, double z)
method noise3_BCC (line 197) | private double noise3_BCC(double xr, double yr, double zr)
method Noise4_Classic (line 237) | public double Noise4_Classic(double x, double y, double z, double w)
method Noise4_XYBeforeZW (line 252) | public double Noise4_XYBeforeZW(double x, double y, double z, double w)
method Noise4_XZBeforeYW (line 266) | public double Noise4_XZBeforeYW(double x, double y, double z, double w)
method Noise4_XYZBeforeW (line 281) | public double Noise4_XYZBeforeW(double x, double y, double z, double w)
method noise4_Base (line 298) | private double noise4_Base(double xs, double ys, double zs, double ws)
method fastFloor (line 339) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method OpenSimplex2S (line 361) | static OpenSimplex2S()
type LatticePoint2D (line 996) | private struct LatticePoint2D
method LatticePoint2D (line 1000) | public LatticePoint2D(int xsv, int ysv)
class LatticePoint3D (line 1009) | private class LatticePoint3D
method LatticePoint3D (line 1014) | public LatticePoint3D(int xrv, int yrv, int zrv, int lattice)
class LatticePoint4D (line 1021) | private class LatticePoint4D
method LatticePoint4D (line 1025) | public LatticePoint4D(int xsv, int ysv, int zsv, int wsv)
type Grad2 (line 1036) | private struct Grad2
method Grad2 (line 1039) | public Grad2(double dx, double dy)
type Grad3 (line 1045) | private struct Grad3
method Grad3 (line 1048) | public Grad3(double dx, double dy, double dz)
type Grad4 (line 1054) | private struct Grad4
method Grad4 (line 1057) | public Grad4(double dx, double dy, double dz, double dw)
FILE: _old/csharp/legacy/OpenSimplex.cs
class OpenSimplex (line 18) | public class OpenSimplex
method OpenSimplex (line 45) | static OpenSimplex()
method FastFloor (line 426) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method OpenSimplex (line 433) | public OpenSimplex()
method OpenSimplex (line 438) | public OpenSimplex(long seed)
method Evaluate (line 465) | public double Evaluate(double x, double y)
method Evaluate (line 513) | public double Evaluate(double x, double y, double z)
method Evaluate3_XYBeforeZ (line 525) | public double Evaluate3_XYBeforeZ(double x, double y, double z)
method Evaluate3_XZBeforeY (line 538) | public double Evaluate3_XZBeforeY(double x, double y, double z)
method evaluate3_Base (line 550) | private double evaluate3_Base(double xs, double ys, double zs)
method Evaluate (line 603) | public double Evaluate(double x, double y, double z, double w)
class Contribution2 (line 671) | private class Contribution2
method Contribution2 (line 677) | public Contribution2(double multiplier, int xsb, int ysb)
class Contribution3 (line 686) | private class Contribution3
method Contribution3 (line 692) | public Contribution3(double multiplier, int xsb, int ysb, int zsb)
class Contribution4 (line 703) | private class Contribution4
method Contribution4 (line 709) | public Contribution4(double multiplier, int xsb, int ysb, int zsb, i...
class Grad2 (line 722) | public class Grad2
method Grad2 (line 725) | public Grad2(double dx, double dy)
class Grad3 (line 732) | public class Grad3
method Grad3 (line 735) | public Grad3(double dx, double dy, double dz)
class Grad4 (line 743) | public class Grad4
method Grad4 (line 746) | public Grad4(double dx, double dy, double dz, double dw)
FILE: _old/java/OpenSimplex2F.java
class OpenSimplex2F (line 13) | public class OpenSimplex2F {
method OpenSimplex2F (line 23) | public OpenSimplex2F(long seed) {
method noise2 (line 51) | public double noise2(double x, double y) {
method noise2_XBeforeY (line 65) | public double noise2_XBeforeY(double x, double y) {
method noise2_Base (line 78) | private double noise2_Base(double xs, double ys) {
method noise3_Classic (line 115) | public double noise3_Classic(double x, double y, double z) {
method noise3_XYBeforeZ (line 135) | public double noise3_XYBeforeZ(double x, double y, double z) {
method noise3_XZBeforeY (line 157) | public double noise3_XZBeforeY(double x, double y, double z) {
method noise3_BCC (line 177) | private double noise3_BCC(double xr, double yr, double zr) {
method noise4_Classic (line 212) | public double noise4_Classic(double x, double y, double z, double w) {
method noise4_XYBeforeZW (line 226) | public double noise4_XYBeforeZW(double x, double y, double z, double w) {
method noise4_XZBeforeYW (line 239) | public double noise4_XZBeforeYW(double x, double y, double z, double w) {
method noise4_XYZBeforeW (line 253) | public double noise4_XYZBeforeW(double x, double y, double z, double w) {
method noise4_Base (line 268) | private double noise4_Base(double xs, double ys, double zs, double ws) {
method fastFloor (line 380) | private static int fastFloor(double x) {
class LatticePoint2D (line 444) | private static class LatticePoint2D {
method LatticePoint2D (line 447) | public LatticePoint2D(int xsv, int ysv) {
class LatticePoint3D (line 455) | private static class LatticePoint3D {
method LatticePoint3D (line 459) | public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
class LatticePoint4D (line 465) | private static class LatticePoint4D {
method LatticePoint4D (line 470) | public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
class Grad2 (line 489) | private static class Grad2 {
method Grad2 (line 491) | public Grad2(double dx, double dy) {
class Grad3 (line 496) | private static class Grad3 {
method Grad3 (line 498) | public Grad3(double dx, double dy, double dz) {
class Grad4 (line 503) | private static class Grad4 {
method Grad4 (line 505) | public Grad4(double dx, double dy, double dz, double dw) {
FILE: _old/java/OpenSimplex2S.java
class OpenSimplex2S (line 14) | public class OpenSimplex2S {
method OpenSimplex2S (line 24) | public OpenSimplex2S(long seed) {
method noise2 (line 52) | public double noise2(double x, double y) {
method noise2_XBeforeY (line 66) | public double noise2_XBeforeY(double x, double y) {
method noise2_Base (line 79) | private double noise2_Base(double xs, double ys) {
method noise3_Classic (line 121) | public double noise3_Classic(double x, double y, double z) {
method noise3_XYBeforeZ (line 141) | public double noise3_XYBeforeZ(double x, double y, double z) {
method noise3_XZBeforeY (line 163) | public double noise3_XZBeforeY(double x, double y, double z) {
method noise3_BCC (line 183) | private double noise3_BCC(double xr, double yr, double zr) {
method noise4_Classic (line 218) | public double noise4_Classic(double x, double y, double z, double w) {
method noise4_XYBeforeZW (line 232) | public double noise4_XYBeforeZW(double x, double y, double z, double w) {
method noise4_XZBeforeYW (line 245) | public double noise4_XZBeforeYW(double x, double y, double z, double w) {
method noise4_XYZBeforeW (line 259) | public double noise4_XYZBeforeW(double x, double y, double z, double w) {
method noise4_Base (line 275) | private double noise4_Base(double xs, double ys, double zs, double ws) {
method fastFloor (line 313) | private static int fastFloor(double x) {
class LatticePoint2D (line 683) | private static class LatticePoint2D {
method LatticePoint2D (line 686) | public LatticePoint2D(int xsv, int ysv) {
class LatticePoint3D (line 694) | private static class LatticePoint3D {
method LatticePoint3D (line 698) | public LatticePoint3D(int xrv, int yrv, int zrv, int lattice) {
class LatticePoint4D (line 704) | private static class LatticePoint4D {
method LatticePoint4D (line 707) | public LatticePoint4D(int xsv, int ysv, int zsv, int wsv) {
class Grad2 (line 721) | private static class Grad2 {
method Grad2 (line 723) | public Grad2(double dx, double dy) {
class Grad3 (line 728) | private static class Grad3 {
method Grad3 (line 730) | public Grad3(double dx, double dy, double dz) {
class Grad4 (line 735) | private static class Grad4 {
method Grad4 (line 737) | public Grad4(double dx, double dy, double dz, double dw) {
FILE: _old/java/legacy/OpenSimplex.java
class OpenSimplex (line 13) | public class OpenSimplex
method OpenSimplex (line 29) | public OpenSimplex(long seed) {
method eval (line 52) | public double eval(double x, double y) {
method eval (line 97) | public double eval(double x, double y, double z) {
method eval3_XYBeforeZ (line 108) | public double eval3_XYBeforeZ(double x, double y, double z)
method eval3_XZBeforeY (line 121) | public double eval3_XZBeforeY(double x, double y, double z)
method eval3_Base (line 133) | private double eval3_Base(double xs, double ys, double zs) {
method eval (line 183) | public double eval(double x, double y, double z, double w) {
method eval4_XYBeforeZW (line 192) | public double eval4_XYBeforeZW(double x, double y, double z, double w) {
method eval4_XZBeforeYW (line 201) | public double eval4_XZBeforeYW(double x, double y, double z, double w) {
method eval4_XYZBeforeW (line 210) | public double eval4_XYZBeforeW(double x, double y, double z, double w) {
method eval4_Base (line 220) | private double eval4_Base(double xs, double ys, double zs, double ws) {
class Contribution2 (line 279) | private static class Contribution2 {
method Contribution2 (line 284) | public Contribution2(double multiplier, int xsb, int ysb) {
class Contribution3 (line 292) | private static class Contribution3 {
method Contribution3 (line 297) | public Contribution3(double multiplier, int xsb, int ysb, int zsb) {
class Contribution4 (line 307) | private static class Contribution4 {
method Contribution4 (line 312) | public Contribution4(double multiplier, int xsb, int ysb, int zsb, i...
class Grad2 (line 324) | public static class Grad2 {
method Grad2 (line 326) | public Grad2(double dx, double dy) {
class Grad3 (line 332) | public static class Grad3 {
method Grad3 (line 334) | public Grad3(double dx, double dy, double dz) {
class Grad4 (line 341) | public static class Grad4 {
method Grad4 (line 343) | public Grad4(double dx, double dy, double dz, double dw) {
method fastFloor (line 355) | private static int fastFloor(double x) {
FILE: _old/java/legacy_unoptimized/OpenSimplexUnoptimized.java
class OpenSimplexUnoptimized (line 14) | public class OpenSimplexUnoptimized {
method OpenSimplexUnoptimized (line 33) | public OpenSimplexUnoptimized() {
method OpenSimplexUnoptimized (line 37) | public OpenSimplexUnoptimized(short[] perm) {
method OpenSimplexUnoptimized (line 50) | public OpenSimplexUnoptimized(long seed) {
method eval (line 72) | public double eval(double x, double y) {
method eval (line 183) | public double eval(double x, double y, double z) {
method eval3_XYBeforeZ (line 196) | public double eval3_XYBeforeZ(double x, double y, double z)
method eval3_XZBeforeY (line 209) | public double eval3_XZBeforeY(double x, double y, double z)
method eval3_Base (line 222) | private double eval3_Base(double xs, double ys, double zs) {
method eval (line 771) | public double eval(double x, double y, double z, double w) {
method eval4_XYBeforeZW (line 780) | public double eval4_XYBeforeZW(double x, double y, double z, double w) {
method eval4_XZBeforeYW (line 789) | public double eval4_XZBeforeYW(double x, double y, double z, double w) {
method eval4_XYZBeforeW (line 798) | public double eval4_XYZBeforeW(double x, double y, double z, double w) {
method eval4_Base (line 809) | private double eval4_Base(double xs, double ys, double zs, double ws) {
method extrapolate (line 2109) | private double extrapolate(int xsb, int ysb, double dx, double dy)
method extrapolate (line 2115) | private double extrapolate(int xsb, int ysb, int zsb, double dx, doubl...
method extrapolate (line 2121) | private double extrapolate(int xsb, int ysb, int zsb, int wsb, double ...
method fastFloor (line 2127) | private static int fastFloor(double x) {
class Grad2 (line 2132) | public static class Grad2 {
method Grad2 (line 2134) | public Grad2(double dx, double dy) {
class Grad3 (line 2139) | public static class Grad3 {
method Grad3 (line 2141) | public Grad3(double dx, double dy, double dz) {
class Grad4 (line 2146) | public static class Grad4 {
method Grad4 (line 2148) | public Grad4(double dx, double dy, double dz, double dw) {
FILE: csharp/OpenSimplex2.cs
class OpenSimplex2 (line 7) | public static class OpenSimplex2
method Noise2 (line 52) | public static float Noise2(long seed, double x, double y)
method Noise2_ImproveX (line 68) | public static float Noise2_ImproveX(long seed, double x, double y)
method Noise2_UnskewedBase (line 80) | private static float Noise2_UnskewedBase(long seed, double xs, double ys)
method Noise3_ImproveXY (line 143) | public static float Noise3_ImproveXY(long seed, double x, double y, do...
method Noise3_ImproveXZ (line 167) | public static float Noise3_ImproveXZ(long seed, double x, double y, do...
method Noise3_Fallback (line 188) | public static float Noise3_Fallback(long seed, double x, double y, dou...
method Noise3_UnrotatedBase (line 202) | private static float Noise3_UnrotatedBase(long seed, double xr, double...
method Noise4_ImproveXYZ_ImproveXY (line 297) | public static float Noise4_ImproveXYZ_ImproveXY(long seed, double x, d...
method Noise4_ImproveXYZ_ImproveXZ (line 316) | public static float Noise4_ImproveXYZ_ImproveXZ(long seed, double x, d...
method Noise4_ImproveXYZ (line 335) | public static float Noise4_ImproveXYZ(long seed, double x, double y, d...
method Noise4_Fallback (line 348) | public static float Noise4_Fallback(long seed, double x, double y, dou...
method Noise4_UnskewedBase (line 360) | private static float Noise4_UnskewedBase(long seed, double xs, double ...
method Grad (line 452) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method Grad (line 462) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method Grad (line 472) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method FastFloor (line 482) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method FastRound (line 489) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method OpenSimplex2 (line 502) | static OpenSimplex2()
FILE: csharp/OpenSimplex2S.cs
class OpenSimplex2S (line 9) | public static class OpenSimplex2S
method Noise2 (line 51) | public static float Noise2(long seed, double x, double y)
method Noise2_ImproveX (line 67) | public static float Noise2_ImproveX(long seed, double x, double y)
method Noise2_UnskewedBase (line 79) | private static float Noise2_UnskewedBase(long seed, double xs, double ys)
method Noise3_ImproveXY (line 205) | public static float Noise3_ImproveXY(long seed, double x, double y, do...
method Noise3_ImproveXZ (line 229) | public static float Noise3_ImproveXZ(long seed, double x, double y, do...
method Noise3_Fallback (line 250) | public static float Noise3_Fallback(long seed, double x, double y, dou...
method Noise3_UnrotatedBase (line 267) | private static float Noise3_UnrotatedBase(long seed, double xr, double...
method Noise4_ImproveXYZ_ImproveXY (line 455) | public static float Noise4_ImproveXYZ_ImproveXY(long seed, double x, d...
method Noise4_ImproveXYZ_ImproveXZ (line 474) | public static float Noise4_ImproveXYZ_ImproveXZ(long seed, double x, d...
method Noise4_ImproveXYZ (line 493) | public static float Noise4_ImproveXYZ(long seed, double x, double y, d...
method Noise4_Fallback (line 506) | public static float Noise4_Fallback(long seed, double x, double y, dou...
method Noise4_UnskewedBase (line 521) | private static float Noise4_UnskewedBase(long seed, double xs, double ...
method Grad (line 562) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method Grad (line 572) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method Grad (line 582) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method FastFloor (line 592) | [MethodImpl(MethodImplOptions.AggressiveInlining)]
method OpenSimplex2S (line 609) | static OpenSimplex2S()
class LatticeVertex4D (line 1170) | private class LatticeVertex4D
method LatticeVertex4D (line 1174) | public LatticeVertex4D(int xsv, int ysv, int zsv, int wsv)
FILE: java/OpenSimplex2.java
class OpenSimplex2 (line 5) | public class OpenSimplex2 {
method noise2 (line 50) | public static float noise2(long seed, double x, double y) {
method noise2_ImproveX (line 66) | public static float noise2_ImproveX(long seed, double x, double y) {
method noise2_UnskewedBase (line 78) | private static float noise2_UnskewedBase(long seed, double xs, double ...
method noise3_ImproveXY (line 136) | public static float noise3_ImproveXY(long seed, double x, double y, do...
method noise3_ImproveXZ (line 160) | public static float noise3_ImproveXZ(long seed, double x, double y, do...
method noise3_Fallback (line 181) | public static float noise3_Fallback(long seed, double x, double y, dou...
method noise3_UnrotatedBase (line 195) | private static float noise3_UnrotatedBase(long seed, double xr, double...
method noise4_ImproveXYZ_ImproveXY (line 283) | public static float noise4_ImproveXYZ_ImproveXY(long seed, double x, d...
method noise4_ImproveXYZ_ImproveXZ (line 302) | public static float noise4_ImproveXYZ_ImproveXZ(long seed, double x, d...
method noise4_ImproveXYZ (line 321) | public static float noise4_ImproveXYZ(long seed, double x, double y, d...
method noise4_ImproveXY_ImproveZW (line 336) | public static float noise4_ImproveXY_ImproveZW(long seed, double x, do...
method noise4_Fallback (line 348) | public static float noise4_Fallback(long seed, double x, double y, dou...
method noise4_UnskewedBase (line 360) | private static float noise4_UnskewedBase(long seed, double xs, double ...
method grad (line 445) | private static float grad(long seed, long xsvp, long ysvp, float dx, f...
method grad (line 453) | private static float grad(long seed, long xrvp, long yrvp, long zrvp, ...
method grad (line 461) | private static float grad(long seed, long xsvp, long ysvp, long zsvp, ...
method fastFloor (line 469) | private static int fastFloor(double x) {
method fastRound (line 474) | private static int fastRound(double x) {
FILE: java/OpenSimplex2S.java
class OpenSimplex2S (line 5) | public class OpenSimplex2S {
method noise2 (line 47) | public static float noise2(long seed, double x, double y) {
method noise2_ImproveX (line 63) | public static float noise2_ImproveX(long seed, double x, double y) {
method noise2_UnskewedBase (line 75) | private static float noise2_UnskewedBase(long seed, double xs, double ...
method noise3_ImproveXY (line 188) | public static float noise3_ImproveXY(long seed, double x, double y, do...
method noise3_ImproveXZ (line 212) | public static float noise3_ImproveXZ(long seed, double x, double y, do...
method noise3_Fallback (line 233) | public static float noise3_Fallback(long seed, double x, double y, dou...
method noise3_UnrotatedBase (line 250) | private static float noise3_UnrotatedBase(long seed, double xr, double...
method noise4_ImproveXYZ_ImproveXY (line 423) | public static float noise4_ImproveXYZ_ImproveXY(long seed, double x, d...
method noise4_ImproveXYZ_ImproveXZ (line 441) | public static float noise4_ImproveXYZ_ImproveXZ(long seed, double x, d...
method noise4_ImproveXYZ (line 459) | public static float noise4_ImproveXYZ(long seed, double x, double y, d...
method noise4_ImproveXY_ImproveZW (line 473) | public static float noise4_ImproveXY_ImproveZW(long seed, double x, do...
method noise4_Fallback (line 485) | public static float noise4_Fallback(long seed, double x, double y, dou...
method noise4_UnskewedBase (line 500) | private static float noise4_UnskewedBase(long seed, double xs, double ...
method grad (line 541) | private static float grad(long seed, long xsvp, long ysvp, float dx, f...
method grad (line 549) | private static float grad(long seed, long xrvp, long yrvp, long zrvp, ...
method grad (line 557) | private static float grad(long seed, long xsvp, long ysvp, long zsvp, ...
method fastFloor (line 565) | private static int fastFloor(double x) {
class LatticeVertex4D (line 1129) | private static class LatticeVertex4D {
method LatticeVertex4D (line 1132) | public LatticeVertex4D(int xsv, int ysv, int zsv, int wsv) {
FILE: rust/fast.rs
constant PRIME_X (line 7) | const PRIME_X: i64 = 0x5205402B9270C86F;
constant PRIME_Y (line 8) | const PRIME_Y: i64 = 0x598CD327003817B5;
constant PRIME_Z (line 9) | const PRIME_Z: i64 = 0x5BCC226E9FA0BACB;
constant PRIME_W (line 10) | const PRIME_W: i64 = 0x56CC5227E58F554B;
constant HASH_MULTIPLIER (line 11) | const HASH_MULTIPLIER: i64 = 0x53A3F72DEEC546F5;
constant SEED_FLIP_3D (line 12) | const SEED_FLIP_3D: i64 = -0x52D547B2E96ED629;
constant SEED_OFFSET_4D (line 13) | const SEED_OFFSET_4D: i64 = 0xE83DC3E0DA7164D;
constant ROOT2OVER2 (line 15) | const ROOT2OVER2: f64 = 0.7071067811865476;
constant SKEW_2D (line 16) | const SKEW_2D: f64 = 0.366025403784439;
constant UNSKEW_2D (line 17) | const UNSKEW_2D: f64 = -0.21132486540518713;
constant ROOT3OVER3 (line 19) | const ROOT3OVER3: f64 = 0.577350269189626;
constant FALLBACK_ROTATE_3D (line 20) | const FALLBACK_ROTATE_3D: f64 = 2.0 / 3.0;
constant ROTATE_3D_ORTHOGONALIZER (line 21) | const ROTATE_3D_ORTHOGONALIZER: f64 = UNSKEW_2D;
constant SKEW_4D (line 23) | const SKEW_4D: f32 = -0.138196601125011;
constant UNSKEW_4D (line 24) | const UNSKEW_4D: f32 = 0.309016994374947;
constant LATTICE_STEP_4D (line 25) | const LATTICE_STEP_4D: f32 = 0.2;
constant N_GRADS_2D_EXPONENT (line 27) | const N_GRADS_2D_EXPONENT: i32 = 7;
constant N_GRADS_3D_EXPONENT (line 28) | const N_GRADS_3D_EXPONENT: i32 = 8;
constant N_GRADS_4D_EXPONENT (line 29) | const N_GRADS_4D_EXPONENT: i32 = 9;
constant N_GRADS_2D (line 30) | const N_GRADS_2D: i32 = 1 << N_GRADS_2D_EXPONENT;
constant N_GRADS_3D (line 31) | const N_GRADS_3D: i32 = 1 << N_GRADS_3D_EXPONENT;
constant N_GRADS_4D (line 32) | const N_GRADS_4D: i32 = 1 << N_GRADS_4D_EXPONENT;
constant NORMALIZER_2D (line 34) | const NORMALIZER_2D: f64 = 0.01001634121365712;
constant NORMALIZER_3D (line 35) | const NORMALIZER_3D: f64 = 0.07969837668935331;
constant NORMALIZER_4D (line 36) | const NORMALIZER_4D: f64 = 0.0220065933241897;
constant RSQUARED_2D (line 38) | const RSQUARED_2D: f32 = 0.5;
constant RSQUARED_3D (line 39) | const RSQUARED_3D: f32 = 0.6;
constant RSQUARED_4D (line 40) | const RSQUARED_4D: f32 = 0.6;
function noise2 (line 49) | pub fn noise2(seed: i64, x: f64, y: f64) -> f32 {
function noise2_ImproveX (line 65) | pub fn noise2_ImproveX(seed: i64, x: f64, y: f64) -> f32 {
function noise2_UnskewedBase (line 76) | fn noise2_UnskewedBase(seed: i64, xs: f64, ys: f64) -> f32 {
function noise3_ImproveXY (line 146) | pub fn noise3_ImproveXY(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_ImproveXZ (line 169) | pub fn noise3_ImproveXZ(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_Fallback (line 189) | pub fn noise3_Fallback(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_UnrotatedBase (line 204) | fn noise3_UnrotatedBase(seed: i64, xr: f64, yr: f64, zr: f64) -> f32 {
function noise4_ImproveXYZ_ImproveXY (line 331) | pub fn noise4_ImproveXYZ_ImproveXY(seed: i64, x: f64, y: f64, z: f64, w:...
function noise4_ImproveXYZ_ImproveXZ (line 350) | pub fn noise4_ImproveXYZ_ImproveXZ(seed: i64, x: f64, y: f64, z: f64, w:...
function noise4_ImproveXYZ (line 369) | pub fn noise4_ImproveXYZ(seed: i64, x: f64, y: f64, z: f64, w: f64) -> f...
function noise4_ImproveXY_ImproveZW (line 386) | pub fn noise4_ImproveXY_ImproveZW(seed: i64, x: f64, y: f64, z: f64, w: ...
function noise4_Fallback (line 400) | pub fn noise4_Fallback(seed: i64, x: f64, y: f64, z: f64, w: f64) -> f32 {
function noise4_UnskewedBase (line 414) | fn noise4_UnskewedBase(seed: i64, xs: f64, ys: f64, zs: f64, ws: f64) ->...
function grad2 (line 516) | fn grad2(seed: Wrapping<i64>, xsvp: Wrapping<i64>, ysvp: Wrapping<i64>, ...
function grad3 (line 525) | fn grad3(
function grad4 (line 542) | fn grad4(
function fastFloor (line 561) | fn fastFloor(x: f64) -> i32 {
function fastRound (line 570) | fn fastRound(x: f64) -> i32 {
type Gradients (line 582) | struct Gradients {
function getGradients (line 590) | fn getGradients() -> &'static Gradients {
function initGradients (line 599) | fn initGradients() -> Gradients {
constant GRAD2_SRC (line 635) | const GRAD2_SRC: &[f64] = &[
constant GRAD3_SRC (line 664) | const GRAD3_SRC: &[f64] = &[
constant GRAD4_SRC (line 717) | const GRAD4_SRC: &[f64] = &[
FILE: rust/ffi.rs
function opensimplex2_fast_noise2 (line 6) | pub extern "C" fn opensimplex2_fast_noise2(seed: c_longlong, x: c_double...
function opensimplex2_fast_noise2_ImproveX (line 11) | pub extern "C" fn opensimplex2_fast_noise2_ImproveX(
function opensimplex2_fast_noise3_ImproveXY (line 20) | pub extern "C" fn opensimplex2_fast_noise3_ImproveXY(
function opensimplex2_fast_noise3_ImproveXZ (line 30) | pub extern "C" fn opensimplex2_fast_noise3_ImproveXZ(
function opensimplex2_fast_noise3_Fallback (line 40) | pub extern "C" fn opensimplex2_fast_noise3_Fallback(
function opensimplex2_fast_noise4_ImproveXYZ_ImproveXY (line 50) | pub extern "C" fn opensimplex2_fast_noise4_ImproveXYZ_ImproveXY(
function opensimplex2_fast_noise4_ImproveXYZ_ImproveXZ (line 61) | pub extern "C" fn opensimplex2_fast_noise4_ImproveXYZ_ImproveXZ(
function opensimplex2_fast_noise4_ImproveXYZ (line 72) | pub extern "C" fn opensimplex2_fast_noise4_ImproveXYZ(
function opensimplex2_fast_noise4_ImproveXY_ImproveZW (line 83) | pub extern "C" fn opensimplex2_fast_noise4_ImproveXY_ImproveZW(
function opensimplex2_fast_noise4_Fallback (line 94) | pub extern "C" fn opensimplex2_fast_noise4_Fallback(
function opensimplex2_smooth_noise2 (line 105) | pub extern "C" fn opensimplex2_smooth_noise2(
function opensimplex2_smooth_noise2_ImproveX (line 114) | pub extern "C" fn opensimplex2_smooth_noise2_ImproveX(
function opensimplex2_smooth_noise3_ImproveXY (line 123) | pub extern "C" fn opensimplex2_smooth_noise3_ImproveXY(
function opensimplex2_smooth_noise3_ImproveXZ (line 133) | pub extern "C" fn opensimplex2_smooth_noise3_ImproveXZ(
function opensimplex2_smooth_noise3_Fallback (line 143) | pub extern "C" fn opensimplex2_smooth_noise3_Fallback(
function opensimplex2_smooth_noise4_ImproveXYZ_ImproveXY (line 153) | pub extern "C" fn opensimplex2_smooth_noise4_ImproveXYZ_ImproveXY(
function opensimplex2_smooth_noise4_ImproveXYZ_ImproveXZ (line 164) | pub extern "C" fn opensimplex2_smooth_noise4_ImproveXYZ_ImproveXZ(
function opensimplex2_smooth_noise4_ImproveXYZ (line 175) | pub extern "C" fn opensimplex2_smooth_noise4_ImproveXYZ(
function opensimplex2_smooth_noise4_ImproveXY_ImproveZW (line 186) | pub extern "C" fn opensimplex2_smooth_noise4_ImproveXY_ImproveZW(
function opensimplex2_smooth_noise4_Fallback (line 197) | pub extern "C" fn opensimplex2_smooth_noise4_Fallback(
FILE: rust/smooth.rs
constant PRIME_X (line 7) | const PRIME_X: i64 = 0x5205402B9270C86F;
constant PRIME_Y (line 8) | const PRIME_Y: i64 = 0x598CD327003817B5;
constant PRIME_Z (line 9) | const PRIME_Z: i64 = 0x5BCC226E9FA0BACB;
constant PRIME_W (line 10) | const PRIME_W: i64 = 0x56CC5227E58F554B;
constant HASH_MULTIPLIER (line 11) | const HASH_MULTIPLIER: i64 = 0x53A3F72DEEC546F5;
constant SEED_FLIP_3D (line 12) | const SEED_FLIP_3D: i64 = -0x52D547B2E96ED629;
constant ROOT2OVER2 (line 14) | const ROOT2OVER2: f64 = 0.7071067811865476;
constant SKEW_2D (line 15) | const SKEW_2D: f64 = 0.366025403784439;
constant UNSKEW_2D (line 16) | const UNSKEW_2D: f64 = -0.21132486540518713;
constant ROOT3OVER3 (line 18) | const ROOT3OVER3: f64 = 0.577350269189626;
constant FALLBACK_ROTATE3 (line 19) | const FALLBACK_ROTATE3: f64 = 2.0 / 3.0;
constant ROTATE3_ORTHOGONALIZER (line 20) | const ROTATE3_ORTHOGONALIZER: f64 = UNSKEW_2D;
constant SKEW_4D (line 22) | const SKEW_4D: f32 = 0.309016994374947;
constant UNSKEW_4D (line 23) | const UNSKEW_4D: f32 = -0.138196601125011;
constant N_GRADS_2D_EXPONENT (line 25) | const N_GRADS_2D_EXPONENT: i32 = 7;
constant N_GRADS_3D_EXPONENT (line 26) | const N_GRADS_3D_EXPONENT: i32 = 8;
constant N_GRADS_4D_EXPONENT (line 27) | const N_GRADS_4D_EXPONENT: i32 = 9;
constant N_GRADS_2D (line 28) | const N_GRADS_2D: i32 = 1 << N_GRADS_2D_EXPONENT;
constant N_GRADS_3D (line 29) | const N_GRADS_3D: i32 = 1 << N_GRADS_3D_EXPONENT;
constant N_GRADS_4D (line 30) | const N_GRADS_4D: i32 = 1 << N_GRADS_4D_EXPONENT;
constant NORMALIZER_2D (line 32) | const NORMALIZER_2D: f64 = 0.05481866495625118;
constant NORMALIZER_3D (line 33) | const NORMALIZER_3D: f64 = 0.2781926117527186;
constant NORMALIZER_4D (line 34) | const NORMALIZER_4D: f64 = 0.11127401889945551;
constant RSQUARED_2D (line 36) | const RSQUARED_2D: f32 = 2.0 / 3.0;
constant RSQUARED_3D (line 37) | const RSQUARED_3D: f32 = 3.0 / 4.0;
constant RSQUARED_4D (line 38) | const RSQUARED_4D: f32 = 4.0 / 5.0;
function noise2 (line 47) | pub fn noise2(seed: i64, x: f64, y: f64) -> f32 {
function noise2_ImproveX (line 63) | pub fn noise2_ImproveX(seed: i64, x: f64, y: f64) -> f32 {
function noise2_UnskewedBase (line 74) | fn noise2_UnskewedBase(seed: i64, xs: f64, ys: f64) -> f32 {
function noise3_ImproveXY (line 213) | pub fn noise3_ImproveXY(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_ImproveXZ (line 236) | pub fn noise3_ImproveXZ(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_Fallback (line 256) | pub fn noise3_Fallback(seed: i64, x: f64, y: f64, z: f64) -> f32 {
function noise3_UnrotatedBase (line 274) | fn noise3_UnrotatedBase(seed: i64, xr: f64, yr: f64, zr: f64) -> f32 {
function noise4_ImproveXYZ_ImproveXY (line 576) | pub fn noise4_ImproveXYZ_ImproveXY(seed: i64, x: f64, y: f64, z: f64, w:...
function noise4_ImproveXYZ_ImproveXZ (line 595) | pub fn noise4_ImproveXYZ_ImproveXZ(seed: i64, x: f64, y: f64, z: f64, w:...
function noise4_ImproveXYZ (line 614) | pub fn noise4_ImproveXYZ(seed: i64, x: f64, y: f64, z: f64, w: f64) -> f...
function noise4_ImproveXY_ImproveZW (line 631) | pub fn noise4_ImproveXY_ImproveZW(seed: i64, x: f64, y: f64, z: f64, w: ...
function noise4_Fallback (line 645) | pub fn noise4_Fallback(seed: i64, x: f64, y: f64, z: f64, w: f64) -> f32 {
function noise4_UnskewedBase (line 662) | fn noise4_UnskewedBase(seed: i64, xs: f64, ys: f64, zs: f64, ws: f64) ->...
function grad2 (line 732) | fn grad2(seed: Wrapping<i64>, xsvp: Wrapping<i64>, ysvp: Wrapping<i64>, ...
function grad3 (line 741) | fn grad3(
function grad4 (line 758) | fn grad4(
function fastFloor (line 777) | fn fastFloor(x: f64) -> i32 {
type LatticeVertex4D (line 791) | struct LatticeVertex4D {
method new (line 803) | pub fn new(xsv: i32, ysv: i32, zsv: i32, wsv: i32) -> Self {
type StaticData (line 818) | struct StaticData {
function getStaticData (line 829) | fn getStaticData() -> &'static StaticData {
function initStaticData (line 838) | fn initStaticData() -> StaticData {
constant GRAD2_SRC (line 897) | const GRAD2_SRC: &[f64] = &[
constant GRAD3_SRC (line 926) | const GRAD3_SRC: &[f64] = &[
constant GRAD4_SRC (line 979) | const GRAD4_SRC: &[f64] = &[
constant LOOKUP_4D_VERTEX_CODES (line 1144) | const LOOKUP_4D_VERTEX_CODES: &[&[u8]] = &[
Condensed preview — 35 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (974K chars).
[
{
"path": ".gitignore",
"chars": 7,
"preview": "target\n"
},
{
"path": "Cargo.toml",
"chars": 481,
"preview": "[package]\nname = \"opensimplex2\"\nversion = \"1.1.0\"\nedition = \"2021\"\n\ndescription = \"Port of OpenSimplex2\"\nauthors = [\"Kdo"
},
{
"path": "LICENSE",
"chars": 7048,
"preview": "Creative Commons Legal Code\n\nCC0 1.0 Universal\n\n CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE\n"
},
{
"path": "README.md",
"chars": 7668,
"preview": "# OpenSimplex 2\n\nSuccessors to OpenSimplex Noise, plus updated OpenSimplex. Includes 2D, 3D, and 4D noise.\n\n## Motivatio"
},
{
"path": "_old/c/Makefile",
"chars": 517,
"preview": "\nCFLAGS=-Wall -Wextra --pedantic -O3\n# CFLAGS=-Wall -Wextra --pedantic -g -fsanitize=undefined\n# CFLAGS=-Wall -Wextra --"
},
{
"path": "_old/c/OpenSimplex2F.c",
"chars": 39811,
"preview": "/**\n * K.jpg's OpenSimplex 2, faster variant\n *\n * - 2D is standard simplex implemented using a lookup table.\n * - 3D is"
},
{
"path": "_old/c/OpenSimplex2F.h",
"chars": 4320,
"preview": "#ifndef OpenSimplex2F_h__\n#define OpenSimplex2F_h__\n\n/**\n * K.jpg's OpenSimplex 2, faster variant\n *\n * - 2D is standard"
},
{
"path": "_old/c/UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "_old/c/test_OpenSimplex2F.c",
"chars": 3704,
"preview": "#include <stdio.h>\n#if ((__STDC_VERSION__ >= 199901L) || (_MSC_VER))\n\t#include <stdint.h>\n#endif\n#include <string.h>\n#in"
},
{
"path": "_old/cpp/OpenSimplex2S.cpp",
"chars": 68919,
"preview": "#include \"OpenSimplex2S.hpp\"\n\nOpenSimplex2S::Grad2 OpenSimplex2S::GRADIENTS_2D[OpenSimplex2S::PSIZE] {};\nOpenSimplex2S::"
},
{
"path": "_old/cpp/OpenSimplex2S.hpp",
"chars": 6101,
"preview": "/**\n * Ported from https://github.com/KdotJPG/OpenSimplex2/blob/master/java/OpenSimplex2S.java\n * Probably not best impl"
},
{
"path": "_old/cpp/UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "_old/csharp/OpenSimplex2F.cs",
"chars": 48141,
"preview": "/**\n * K.jpg's OpenSimplex 2, faster variant\n *\n * - 2D is standard simplex implemented using a lookup table.\n * - 3D i"
},
{
"path": "_old/csharp/OpenSimplex2S.cs",
"chars": 75078,
"preview": "/**\n * K.jpg's OpenSimplex 2, smooth variant (\"SuperSimplex\")\n *\n * - 2D is standard simplex, modified to support large"
},
{
"path": "_old/csharp/legacy/OpenSimplex.cs",
"chars": 55179,
"preview": "/**\n * K.jpg's original OpenSimplex Noise\n * DigitalShadow's optimized implementation, https://gist.github.com/digitalsh"
},
{
"path": "_old/csharp/legacy/UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "_old/java/OpenSimplex2F.java",
"chars": 39764,
"preview": "/**\n * K.jpg's OpenSimplex 2, faster variant\n *\n * - 2D is standard simplex implemented using a lookup table.\n * - 3D is"
},
{
"path": "_old/java/OpenSimplex2S.java",
"chars": 61554,
"preview": "/**\n * K.jpg's OpenSimplex 2, smooth variant (\"SuperSimplex\")\n *\n * - 2D is standard simplex, modified to support larger"
},
{
"path": "_old/java/legacy/OpenSimplex.java",
"chars": 48462,
"preview": "/**\n * K.jpg's original OpenSimplex Noise\n * DigitalShadow's optimized implementation, https://gist.github.com/digitalsh"
},
{
"path": "_old/java/legacy/UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "_old/java/legacy_unoptimized/OpenSimplexUnoptimized.java",
"chars": 89584,
"preview": "/**\n * K.jpg's original OpenSimplex Noise, unoptimized version\n * With updated gradient sets (Dec 2019, Feb 2020)\n * Thi"
},
{
"path": "csharp/OpenSimplex2.cs",
"chars": 42857,
"preview": "/**\n * K.jpg's OpenSimplex 2, faster variant\n */\n\nusing System.Runtime.CompilerServices;\n\npublic static class OpenSimple"
},
{
"path": "csharp/OpenSimplex2S.cs",
"chars": 76823,
"preview": "/**\n * K.jpg's OpenSimplex 2, smooth variant (\"SuperSimplex\")\n * \n * Note: Not yet compatible with Unity Burst.\n */\n\nusi"
},
{
"path": "glsl/OpenSimplex2.glsl",
"chars": 3836,
"preview": "//////////////// K.jpg's Re-oriented 4-Point BCC Noise (OpenSimplex2) ////////////////\n////////////////////// Output: ve"
},
{
"path": "glsl/OpenSimplex2S.glsl",
"chars": 3940,
"preview": "/////////////// K.jpg's Re-oriented 8-Point BCC Noise (OpenSimplex2S) ////////////////\n////////////////////// Output: ve"
},
{
"path": "hlsl/OpenSimplex2.hlsl",
"chars": 4319,
"preview": "#ifndef __bcc_noise_4_hlsl_\n#define __bcc_noise_4_hlsl_\n\n/////////////// K.jpg's Simplex-like Re-oriented 4-Point BCC No"
},
{
"path": "hlsl/OpenSimplex2S.hlsl",
"chars": 4398,
"preview": "#ifndef __bcc_noise_8_hlsl_\n#define __bcc_noise_8_hlsl_\n\n////////////////// K.jpg's Smooth Re-oriented 8-Point BCC Noise"
},
{
"path": "hlsl/UNLICENSE",
"chars": 1211,
"preview": "This is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, c"
},
{
"path": "java/OpenSimplex2.java",
"chars": 43034,
"preview": "/**\n * K.jpg's OpenSimplex 2, faster variant\n */\n\npublic class OpenSimplex2 {\n\n private static final long PRIME_X = 0"
},
{
"path": "java/OpenSimplex2S.java",
"chars": 78605,
"preview": "/**\n * K.jpg's OpenSimplex 2, smooth variant (\"SuperSimplex\")\n */\n\npublic class OpenSimplex2S {\n\n private static fina"
},
{
"path": "rust/OpenSimplex2.h",
"chars": 2065,
"preview": "#pragma once\n#ifndef OPENSIMPLEX2_H\n\nextern float opensimplex2_fast_noise2(long long seed, double x, double y);\nextern f"
},
{
"path": "rust/fast.rs",
"chars": 40249,
"preview": "/*!\n K.jpg's OpenSimplex 2, faster variant\n*/\n\nuse std::{num::Wrapping, sync::Once};\n\nconst PRIME_X: i64 = 0x5205402B"
},
{
"path": "rust/ffi.rs",
"chars": 4300,
"preview": "use std::ffi::{c_double, c_float, c_longlong};\n\nuse crate::{fast, smooth};\n\n#[no_mangle]\npub extern \"C\" fn opensimplex2_"
},
{
"path": "rust/lib.rs",
"chars": 66,
"preview": "#![allow(non_snake_case)]\n\npub mod fast;\nmod ffi;\npub mod smooth;\n"
},
{
"path": "rust/smooth.rs",
"chars": 71648,
"preview": "/*!\n K.jpg's OpenSimplex 2, smooth variant (\"SuperSimplex\")\n*/\n\nuse std::{num::Wrapping, sync::Once};\n\nconst PRIME_X:"
}
]
About this extraction
This page contains the full source code of the KdotJPG/OpenSimplex2 GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 35 files (916.5 KB), approximately 429.8k tokens, and a symbol index with 448 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.