Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Header-only Perlin noise library for modern C++ (C++17/C++20)

License

NotificationsYou must be signed in to change notification settings

Reputeless/PerlinNoise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

noise

siv::PerlinNoise is a header-only Perlin noise library for modern C++ (C++17/20).
The implementation is based on Ken Perlin'sImproved Noise.

Features

  • 1D / 2D / 3D noise
  • octave noise
  • initial seed
  • (✨ new in v3.0) produce the same output on any platform (except for floating point errors)

License

siv::PerlinNoise is distributed under theMIT license.

Usage

#include<iostream>#include"PerlinNoise.hpp"intmain(){const siv::PerlinNoise::seed_type seed =123456u;const siv::PerlinNoise perlin{ seed };for (int y =0; y <5; ++y){for (int x =0; x <5; ++x){constdouble noise = perlin.octave2D_01((x *0.01), (y *0.01),4);std::cout << noise <<'\t';}std::cout <<'\n';}}

API

template <class Float> class BasicPerlinNoise

  • Typedefs
    • using PerlinNoise = BasicPerlinNoise<double>;
    • using state_type = std::array<std::uint8_t, 256>;
    • using value_type = Float;
    • using default_random_engine = std::mt19937;
    • using seed_type = typename default_random_engine::result_type;
  • Constructors
    • constexpr BasicPerlinNoise();
    • BasicPerlinNoise(seed_type seed);
    • BasicPerlinNoise(URBG&& urbg);
  • Reseed
    • void reseed(seed_type seed);
    • void reseed(URBG&& urbg);
  • Serialization
    • constexpr const state_type& serialize() const noexcept;
    • constexpr void deserialize(const state_type& state) noexcept;
  • Noise (The result isin the range [-1, 1])
    • value_type noise1D(value_type x) const noexcept;
    • value_type noise2D(value_type x, value_type y) const noexcept;
    • value_type noise3D(value_type x, value_type y, value_type z) const noexcept;
  • Noise (The result isremapped to the range [0, 1])
    • value_type noise1D_01(value_type x) const noexcept;
    • value_type noise2D_01(value_type x, value_type y) const noexcept;
    • value_type noise3D_01(value_type x, value_type y, value_type z) const noexcept;
  • Octave noise (The resultcan be out of the range [-1, 1])
    • value_type octave1D(value_type x, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave2D(value_type x, value_type y, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave3D(value_type x, value_type y, value_type z, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
  • Octave noise (The result isclamped to the range [-1, 1])
    • value_type octave1D_11(value_type x, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave2D_11(value_type x, value_type y, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave3D_11(value_type x, value_type y, value_type z, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
  • Octave noise (The result isclamped and remapped to the range [0, 1])
    • value_type octave1D_01(value_type x, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave2D_01(value_type x, value_type y, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type octave3D_01(value_type x, value_type y, value_type z, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
  • Octave noise (The result isnormalized to the range [-1, 1])
    • value_type normalizedOctave1D(value_type x, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type normalizedOctave2D(value_type x, value_type y, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type normalizedOctave3D(value_type x, value_type y, value_type z, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
  • Octave noise (The result isnormalized and remapped to the range [0, 1])
    • value_type normalizedOctave1D_01(value_type x, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type normalizedOctave2D_01(value_type x, value_type y, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;
    • value_type normalizedOctave3D_01(value_type x, value_type y, value_type z, std::int32_t octaves, value_type persistence = value_type(0.5)) const noexcept;

Example

Run example.cpp with the following parameters.

frequency = 8.0octaves = 8seed = 12345

noise


frequency = 8.0octaves = 8seed = 23456

noise


frequency = 8.0octaves = 3seed = 23456

noise

About

Header-only Perlin noise library for modern C++ (C++17/C++20)

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp