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

Simplex Rework + Domain Warp #135

Open
wants to merge 1 commit into
base: NewFastSIMD
Choose a base branch
from
Open
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
60 changes: 41 additions & 19 deletions include/FastNoise/Generators/DomainWarpSimplex.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
#pragma once
#include "Generator.h"
#include "DomainWarp.h"

namespace FastNoise
{
class DomainWarpOpenSimplex : public virtual DomainWarp
{
public: const Metadata& GetMetadata() const override;
};

#ifdef FASTNOISE_METADATA
template<>
struct MetadataT<DomainWarpOpenSimplex> : MetadataT<DomainWarp>
{
SmartNode<> CreateNode( FastSIMD::FeatureSet ) const override;
};
#endif
}
#pragma once
#include "Generator.h"
#include "DomainWarp.h"

namespace FastNoise
{
class DomainWarpSimplex : public virtual DomainWarp
{
public:
const Metadata& GetMetadata() const override;

void SetType( SimplexType value ) { mType = value; }
void SetVectorizationScheme( VectorizationScheme value ) { mVectorizationScheme = value; }

protected:
SimplexType mType = SimplexType::Standard;
VectorizationScheme mVectorizationScheme = VectorizationScheme::OrthogonalGradientMatrix;
};

#ifdef FASTNOISE_METADATA
template<>
struct MetadataT<DomainWarpSimplex> : MetadataT<DomainWarp>
{
SmartNode<> CreateNode( FastSIMD::FeatureSet ) const override;

MetadataT()
{
this->AddVariableEnum(
{ "Type", "Noise character style" },
SimplexType::Standard, &DomainWarpSimplex::SetType,
kSimplexType_Strings
);
this->AddVariableEnum(
{ "Vectorization Scheme", "Construction used by the noise to produce a vector output" },
VectorizationScheme::OrthogonalGradientMatrix, &DomainWarpSimplex::SetVectorizationScheme,
kVectorizationScheme_Strings
);
}
};
#endif
}
1,216 changes: 1,062 additions & 154 deletions include/FastNoise/Generators/DomainWarpSimplex.inl

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions include/FastNoise/Generators/Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@ namespace FastNoise
"Minkowski",
};

enum class SimplexType
{
Standard,
Smooth
};

constexpr static const char* kSimplexType_Strings[] =
{
"Standard",
"Smooth",
};

enum class VectorizationScheme
{
OrthogonalGradientMatrix,
GradientOuterProduct
};

constexpr static const char* kVectorizationScheme_Strings[] =
{
"Orthogonal Gradient Matrix",
"Gradient Outer Product",
};

struct OutputMinMax
{
float min = INFINITY;
Expand Down
28 changes: 14 additions & 14 deletions include/FastNoise/Generators/Perlin.inl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class FastSIMD::DispatchClass<FastNoise::Perlin, SIMD> final : public virtual Fa
constexpr float kBounding = 0.579106986522674560546875f;

return this->ScaleOutput( Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0 ), xf0, yf0 ), GetGradientDot( HashPrimes( seed, x1, y0 ), xf1, yf0 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1 ), xf0, yf1 ), GetGradientDot( HashPrimes( seed, x1, y1 ), xf1, yf1 ), xs ), ys ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y0 ), xf0, yf0 ), GetGradientDotPerlin( HashPrimes( seed, x1, y0 ), xf1, yf0 ), xs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y1 ), xf0, yf1 ), GetGradientDotPerlin( HashPrimes( seed, x1, y1 ), xf1, yf1 ), xs ), ys ),
-1 / kBounding, 1 / kBounding );
}

Expand Down Expand Up @@ -60,11 +60,11 @@ class FastSIMD::DispatchClass<FastNoise::Perlin, SIMD> final : public virtual Fa
constexpr float kBounding = 0.964921414852142333984375f;

return this->ScaleOutput( Lerp( Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z0 ), xf0, yf0, zf0 ), GetGradientDot( HashPrimes( seed, x1, y0, z0 ), xf1, yf0, zf0 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z0 ), xf0, yf1, zf0 ), GetGradientDot( HashPrimes( seed, x1, y1, z0 ), xf1, yf1, zf0 ), xs ), ys ),
Lerp( GetGradientDotCommon( HashPrimes( seed, x0, y0, z0 ), xf0, yf0, zf0 ), GetGradientDotCommon( HashPrimes( seed, x1, y0, z0 ), xf1, yf0, zf0 ), xs ),
Lerp( GetGradientDotCommon( HashPrimes( seed, x0, y1, z0 ), xf0, yf1, zf0 ), GetGradientDotCommon( HashPrimes( seed, x1, y1, z0 ), xf1, yf1, zf0 ), xs ), ys ),
Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z1 ), xf0, yf0, zf1 ), GetGradientDot( HashPrimes( seed, x1, y0, z1 ), xf1, yf0, zf1 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z1 ), xf0, yf1, zf1 ), GetGradientDot( HashPrimes( seed, x1, y1, z1 ), xf1, yf1, zf1 ), xs ), ys ), zs ),
Lerp( GetGradientDotCommon( HashPrimes( seed, x0, y0, z1 ), xf0, yf0, zf1 ), GetGradientDotCommon( HashPrimes( seed, x1, y0, z1 ), xf1, yf0, zf1 ), xs ),
Lerp( GetGradientDotCommon( HashPrimes( seed, x0, y1, z1 ), xf0, yf1, zf1 ), GetGradientDotCommon( HashPrimes( seed, x1, y1, z1 ), xf1, yf1, zf1 ), xs ), ys ), zs ),
-1 / kBounding, 1 / kBounding );
}

Expand Down Expand Up @@ -103,17 +103,17 @@ class FastSIMD::DispatchClass<FastNoise::Perlin, SIMD> final : public virtual Fa
constexpr float kBounding = 0.964921414852142333984375f;

return this->ScaleOutput( Lerp( Lerp( Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z0, w0 ), xf0, yf0, zf0, wf0 ), GetGradientDot( HashPrimes( seed, x1, y0, z0, w0 ), xf1, yf0, zf0, wf0 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z0, w0 ), xf0, yf1, zf0, wf0 ), GetGradientDot( HashPrimes( seed, x1, y1, z0, w0 ), xf1, yf1, zf0, wf0 ), xs ), ys ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y0, z0, w0 ), xf0, yf0, zf0, wf0 ), GetGradientDotPerlin( HashPrimes( seed, x1, y0, z0, w0 ), xf1, yf0, zf0, wf0 ), xs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y1, z0, w0 ), xf0, yf1, zf0, wf0 ), GetGradientDotPerlin( HashPrimes( seed, x1, y1, z0, w0 ), xf1, yf1, zf0, wf0 ), xs ), ys ),
Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z1, w0 ), xf0, yf0, zf1, wf0 ), GetGradientDot( HashPrimes( seed, x1, y0, z1, w0 ), xf1, yf0, zf1, wf0 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z1, w0 ), xf0, yf1, zf1, wf0 ), GetGradientDot( HashPrimes( seed, x1, y1, z1, w0 ), xf1, yf1, zf1, wf0 ), xs ), ys ), zs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y0, z1, w0 ), xf0, yf0, zf1, wf0 ), GetGradientDotPerlin( HashPrimes( seed, x1, y0, z1, w0 ), xf1, yf0, zf1, wf0 ), xs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y1, z1, w0 ), xf0, yf1, zf1, wf0 ), GetGradientDotPerlin( HashPrimes( seed, x1, y1, z1, w0 ), xf1, yf1, zf1, wf0 ), xs ), ys ), zs ),
Lerp( Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z0, w1 ), xf0, yf0, zf0, wf1 ), GetGradientDot( HashPrimes( seed, x1, y0, z0, w1 ), xf1, yf0, zf0, wf1 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z0, w1 ), xf0, yf1, zf0, wf1 ), GetGradientDot( HashPrimes( seed, x1, y1, z0, w1 ), xf1, yf1, zf0, wf1 ), xs ), ys ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y0, z0, w1 ), xf0, yf0, zf0, wf1 ), GetGradientDotPerlin( HashPrimes( seed, x1, y0, z0, w1 ), xf1, yf0, zf0, wf1 ), xs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y1, z0, w1 ), xf0, yf1, zf0, wf1 ), GetGradientDotPerlin( HashPrimes( seed, x1, y1, z0, w1 ), xf1, yf1, zf0, wf1 ), xs ), ys ),
Lerp(
Lerp( GetGradientDot( HashPrimes( seed, x0, y0, z1, w1 ), xf0, yf0, zf1, wf1 ), GetGradientDot( HashPrimes( seed, x1, y0, z1, w1 ), xf1, yf0, zf1, wf1 ), xs ),
Lerp( GetGradientDot( HashPrimes( seed, x0, y1, z1, w1 ), xf0, yf1, zf1, wf1 ), GetGradientDot( HashPrimes( seed, x1, y1, z1, w1 ), xf1, yf1, zf1, wf1 ), xs ), ys ), zs ), ws ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y0, z1, w1 ), xf0, yf0, zf1, wf1 ), GetGradientDotPerlin( HashPrimes( seed, x1, y0, z1, w1 ), xf1, yf0, zf1, wf1 ), xs ),
Lerp( GetGradientDotPerlin( HashPrimes( seed, x0, y1, z1, w1 ), xf0, yf1, zf1, wf1 ), GetGradientDotPerlin( HashPrimes( seed, x1, y1, z1, w1 ), xf1, yf1, zf1, wf1 ), xs ), ys ), zs ), ws ),
-1 / kBounding, 1 / kBounding );
}
};
Expand Down
54 changes: 9 additions & 45 deletions include/FastNoise/Generators/Simplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ namespace FastNoise
class Simplex : public virtual VariableRange<ScalableGenerator>
{
public:
void SetType( SimplexType value ) { mType = value; }
const Metadata& GetMetadata() const override;

protected:
SimplexType mType = SimplexType::Standard;
};

#ifdef FASTNOISE_METADATA
Expand All @@ -22,52 +26,12 @@ namespace FastNoise
description =
"Smooth gradient noise from an N dimensional simplex grid\n"
"Developed by Ken Perlin in 2001";
}
};
#endif

class OpenSimplex2 : public virtual VariableRange<ScalableGenerator>
{
public:
const Metadata& GetMetadata() const override;
};

#ifdef FASTNOISE_METADATA
template<>
struct MetadataT<OpenSimplex2> : MetadataT<VariableRange<ScalableGenerator>>
{
SmartNode<> CreateNode( FastSIMD::FeatureSet ) const override;

MetadataT()
{
groups.push_back( "Coherent Noise" );

description =
"Smooth gradient noise from an N dimensional simplex grid, alternate implementation\n"
"Developed by K.jpg in 2019";
}
};
#endif

class OpenSimplex2S : public virtual VariableRange<ScalableGenerator>
{
public:
const Metadata& GetMetadata() const override;
};

#ifdef FASTNOISE_METADATA
template<>
struct MetadataT<OpenSimplex2S> : MetadataT<VariableRange<ScalableGenerator>>
{
SmartNode<> CreateNode( FastSIMD::FeatureSet ) const override;

MetadataT()
{
groups.push_back( "Coherent Noise" );

description =
"Smoother gradient noise from an N dimensional simplex grid\n"
"Developed by K.jpg in 2017";
this->AddVariableEnum(
{ "Type", "Noise character style" },
SimplexType::Standard, &Simplex::SetType,
kSimplexType_Strings
);
}
};
#endif
Expand Down
Loading
Loading