Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes for OpenSimplex2S Noise 2D (GLSL) and Value Cubic Noise 3D (GLSL and HLSL) #127

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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