Swiftpack.co - markusmoenig/SwiftNoise as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by markusmoenig.
markusmoenig/SwiftNoise 0.1.5
A library of tillable, procedural noise and pattern functions. Implemented in Swift and utilizes the Surge Library.
⭐️ 7
🕓 2 years ago
.package(url: "https://github.com/markusmoenig/SwiftNoise.git", from: "0.1.5")

SwiftNoise

A library of tileable, procedural noise and pattern functions. Implemented in Swift and utilizes the Surge library.

Normally you would implement noise and similar functionality on the GPU, however in my specific use case, a heavily multi-threaded, permutative and recursive node system, a CPU implementation made more sense. Hope this Swift library is useful to others.

Based on Procedural Tileable Shaders.

Installation

Simply add the url of this Git to your Swift Packages.

Usage

All the functions listed below are member functions of the SwiftNoise class which you have to instantiate first. As these noises / patterns are tileable, only use the scale parameter to subdivide the noise into more tiles. Scaling the uv / pos parameter will not provide correct results.

This library is work in progress, currently implemented functions are:

// 2D Value noise.
// @param scale Number of tiles, must be an integer for tileable results, range: [2, inf]
// @param seed Seed to randomize result, range: [0, inf]
// @return Value of the noise, range: [-1, 1]
func noise(pos: SIMD2<Float>, scale: SIMD2<Float>, seed: Float) -> Float

"Perlin2D"

// 2D Gradient noise.
// @param scale Number of tiles, must be  integer for tileable results, range: [2, inf]
// @param seed Seed to randomize result, range: [0, inf], default: 0.0
// @return Value of the noise, range: [-1, 1]
func gradientNoise(pos: SIMD2<Float>, scale: SIMD2<Float>, seed: Float) -> Float

"Perlin2D"

// 2D Perlin noise.
// @param scale Number of tiles, must be  integer for tileable results, range: [2, inf]
// @param seed Seed to randomize result, range: [0, inf], default: 0.0
// @return Value of the noise, range: [-1, 1]
func perlinNoise(pos: SIMD2<Float>, scale: SIMD2<Float>, seed: Float) -> Float

"Perlin2D"

GitHub

link
Stars: 7
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

0.1.5
2 years ago

SwiftNoise 0.1.5

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics