pure-noise-0.2.1.0: High-performance composable noise generation (Perlin, Simplex, Cellular)
MaintainerJeremy Nuttall <jeremy@jeremy-nuttall.com>
Stabilityexperimental
Safe HaskellNone
LanguageGHC2021

Numeric.Noise.Fractal

Description

 
Synopsis

Configuration

data FractalConfig a Source #

Configuration for fractal noise generation.

Fractal noise combines multiple octaves (layers) of noise at different frequencies and amplitudes to create more complex, natural-looking patterns.

Constructors

FractalConfig 

Fields

  • octaves :: Int

    Number of noise layers to combine. More octaves create more detail but are more expensive to compute. Must be \( >= 1 \).

  • lacunarity :: a

    Frequency multiplier between octaves. Each octave's frequency is the previous octave's frequency multiplied by lacunarity.

  • gain :: a

    Amplitude multiplier between octaves. Each octave's amplitude is the previous octave's amplitude multiplied by gain. Values \( < 1 \) create smoother noise, values \( > 1 \) create rougher noise.

  • weightedStrength :: a

    Controls how much each octave's amplitude is influenced by the previous octave's value. At 0, octaves have independent amplitudes. At 1, lower-valued areas in previous octaves reduce the amplitude of subsequent octaves. Range: \( [0, 1] \).

Instances

Instances details
Generic (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Associated Types

type Rep (FractalConfig a) 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) = D1 ('MetaData "FractalConfig" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "FractalConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "octaves") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "lacunarity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "gain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "weightedStrength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))
Read a => Read (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Show a => Show (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Eq a => Eq (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (FractalConfig a) = D1 ('MetaData "FractalConfig" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'False) (C1 ('MetaCons "FractalConfig" 'PrefixI 'True) ((S1 ('MetaSel ('Just "octaves") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "lacunarity") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)) :*: (S1 ('MetaSel ('Just "gain") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a) :*: S1 ('MetaSel ('Just "weightedStrength") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a))))

defaultFractalConfig :: RealFrac a => FractalConfig a Source #

Default configuration for fractal noise generation.

newtype PingPongStrength a Source #

Strength parameter for ping-pong fractal noise.

Controls the intensity of the ping-pong folding effect. Higher values create more frequent oscillations.

Constructors

PingPongStrength a 

Instances

Instances details
Generic (PingPongStrength a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

Associated Types

type Rep (PingPongStrength a) 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (PingPongStrength a) = D1 ('MetaData "PingPongStrength" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'True) (C1 ('MetaCons "PingPongStrength" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))
type Rep (PingPongStrength a) Source # 
Instance details

Defined in Numeric.Noise.Fractal

type Rep (PingPongStrength a) = D1 ('MetaData "PingPongStrength" "Numeric.Noise.Fractal" "pure-noise-0.2.1.0-4Gerhi0am1zGiIYaJVZKZH" 'True) (C1 ('MetaCons "PingPongStrength" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

defaultPingPongStrength :: RealFrac a => PingPongStrength a Source #

Default ping-pong strength value.

2D Noise

fractal2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply Fractal Brownian Motion (FBM) to a 2D noise function.

FBM combines multiple octaves of noise at increasing frequencies and decreasing amplitudes to create natural-looking, multi-scale patterns. This is the standard fractal noise implementation.

fbm :: Noise2 Float
fbm = fractal2 defaultFractalConfig perlin2

billow2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply billow fractal to a 2D noise function.

Billow creates a cloud-like or billowy appearance by taking the absolute value of each octave. This produces sharp ridges in the negative regions of the noise, creating a distinct puffy or cloudy look.

clouds :: Noise2 Float
clouds = billow2 defaultFractalConfig perlin2

ridged2 :: RealFrac a => FractalConfig a -> Noise2 a -> Noise2 a Source #

Apply ridged fractal to a 2D noise function.

Ridged creates sharp ridges by inverting and taking the absolute value of each octave. This is particularly useful for terrain generation, creating mountain ridges and valleys.

mountains :: Noise2 Float
mountains = ridged2 defaultFractalConfig perlin2

pingPong2 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise2 a -> Noise2 a Source #

Apply ping-pong fractal to a 2D noise function.

Ping-pong creates a wave-like pattern by folding the noise values back and forth within a range, creating a distinctive undulating appearance. The strength parameter controls the intensity of the ping-pong effect.

waves :: Noise2 Float
waves = pingPong2 defaultFractalConfig defaultPingPongStrength perlin2

3D Noise

fractal3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply Fractal Brownian Motion (FBM) to a 3D noise function.

3D version of fractal2. See fractal2 for details.

billow3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply billow fractal to a 3D noise function.

3D version of billow2. See billow2 for details.

ridged3 :: RealFrac a => FractalConfig a -> Noise3 a -> Noise3 a Source #

Apply ridged fractal to a 3D noise function.

3D version of ridged2. See ridged2 for details.

pingPong3 :: RealFrac a => FractalConfig a -> PingPongStrength a -> Noise3 a -> Noise3 a Source #

Apply ping-pong fractal to a 3D noise function.

3D version of pingPong2. See pingPong2 for details.

Utility

fractalNoiseMod :: a -> a Source #

Identity noise modifier for standard FBM.

This is used internally by fractal2 and fractal3. Exposed for users creating custom fractal implementations.

fractalAmpMod :: Num a => FractalConfig a -> a -> a Source #

Amplitude modifier for standard FBM.

Uses the weightedStrength parameter to influence amplitude based on the previous octave's value. Exposed for custom fractal implementations.

billowNoiseMod :: Num a => a -> a Source #

Noise modifier for billow fractal.

Transforms noise value to abs(n) * 2 - 1, creating the billow effect. Exposed for custom fractal implementations.

billowAmpMod :: Num a => FractalConfig a -> a -> a Source #

Amplitude modifier for billow fractal.

Uses the weightedStrength parameter. Exposed for custom fractal implementations.

ridgedNoiseMod :: Num a => a -> a Source #

Noise modifier for ridged fractal.

Transforms noise value to abs(n) * (-2) + 1, creating the ridge effect. Exposed for custom fractal implementations.

ridgedAmpMod :: Num a => FractalConfig a -> a -> a Source #

Amplitude modifier for ridged fractal.

Uses the weightedStrength parameter with inverted noise value. Exposed for custom fractal implementations.

pingPongNoiseMod :: RealFrac a => PingPongStrength a -> a -> a Source #

Noise modifier for ping-pong fractal.

Folds noise values back and forth within a range, creating a wave-like pattern. The strength parameter controls the folding intensity. Exposed for custom fractal implementations.

pingPongAmpMod :: Num a => FractalConfig a -> a -> a Source #

Amplitude modifier for ping-pong fractal.

Uses the weightedStrength parameter. Exposed for custom fractal implementations.