Skip to content

Commit

Permalink
Bug fixes for OpenSimplex2S Noise 2D (GLSL) and Value Cubic Noise 3D …
Browse files Browse the repository at this point in the history
…(GLSL and HLSL) (#127)

* Fixed fragmentation bug in _fnlSingleOpenSimplex2S2D (GLSL)

In GLSL version OpenSimplex2S2D was divided into rhombic fragments. This fix was based on HLSL version code, that has no fragmentation bug: see https://github.com/Auburn/FastNoiseLite/blob/df34389c6b3cbba88fd7caf9d376587ebcb31522/HLSL/FastNoiseLite.hlsl#L1059C22-L1059C22

* Fixed contrast bug in _fnlSingleValueCubic3D (GLSL)

In GLSL version ValueCubic3D produced values that was outside of default color ramp. This fix was based on C++ version code, that has no contrast bug: see https://github.com/Auburn/FastNoiseLite/blob/df34389c6b3cbba88fd7caf9d376587ebcb31522/Cpp/FastNoiseLite.h#L1914

* Fixed contrast bug in _fnlSingleValueCubic3D (HLSL)

In HLSL version ValueCubic3D produced values that was outside of default color ramp. This fix was based on C++ version code, that has no contrast bug: see https://github.com/Auburn/FastNoiseLite/blob/df34389c6b3cbba88fd7caf9d376587ebcb31522/Cpp/FastNoiseLite.h#L1914
  • Loading branch information
MAGGen-hub authored Jan 3, 2024
1 parent df34389 commit ba3d86b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions GLSL/FastNoiseLite.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ float _fnlSingleOpenSimplex2S2D(int seed, FNLfloat x, FNLfloat y)
float y0 = yi - t;

int aMask = int((xi + yi + 1.f) * -0.5f);
int bMask = int((xi - float(aMask) + 2.f) * 0.5f - yi);
int cMask = int((yi - float(aMask) + 2.f) * 0.5f - xi);
int bMask = int((xi - (float(aMask) + 2.f)) * 0.5f - yi);
int cMask = int((yi - (float(aMask) + 2.f)) * 0.5f - xi);

float a0 = (2.f / 3.f) - x0 * x0 - y0 * y0;
float value = (a0 * a0) * (a0 * a0) * _fnlGradCoord2D(seed, i, j, x0, y0);
Expand Down Expand Up @@ -1446,7 +1446,7 @@ float _fnlSingleValueCubic3D(int seed, FNLfloat x, FNLfloat y, FNLfloat z)
_fnlCubicLerp(_fnlValCoord3D(seed, x0, y2, z3), _fnlValCoord3D(seed, x1, y2, z3), _fnlValCoord3D(seed, x2, y2, z3), _fnlValCoord3D(seed, x3, y2, z3), xs),
_fnlCubicLerp(_fnlValCoord3D(seed, x0, y3, z3), _fnlValCoord3D(seed, x1, y3, z3), _fnlValCoord3D(seed, x2, y3, z3), _fnlValCoord3D(seed, x3, y3, z3), xs),
ys),
zs) * (1.f / 1.5f * 1.5f * 1.5f);
zs) * (1.f / (1.5f * 1.5f * 1.5f));
}


Expand Down
2 changes: 1 addition & 1 deletion HLSL/FastNoiseLite.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ static float _fnlSingleValueCubic3D(int seed, FNLfloat x, FNLfloat y, FNLfloat z
_fnlCubicLerp(_fnlValCoord3D(seed, x0, y2, z3), _fnlValCoord3D(seed, x1, y2, z3), _fnlValCoord3D(seed, x2, y2, z3), _fnlValCoord3D(seed, x3, y2, z3), xs),
_fnlCubicLerp(_fnlValCoord3D(seed, x0, y3, z3), _fnlValCoord3D(seed, x1, y3, z3), _fnlValCoord3D(seed, x2, y3, z3), _fnlValCoord3D(seed, x3, y3, z3), xs),
ys),
zs) * (1 / 1.5f * 1.5f * 1.5f);
zs) * (1 / (1.5f * 1.5f * 1.5f));
}

// Value noise
Expand Down

0 comments on commit ba3d86b

Please sign in to comment.