Accidental Noise Library in Godot Engine enhanced with visual noise editor

Accidental Noise Library in Godot Engine

🐧 Linux 🍎 macOS 🎨 Windows πŸ€– Android 🍏 iOS 🌐 JavaScript

This is a wrapper for the Accidental Noise Library originally written by Joshua Tippetts, modified to be properly compiled for Godot Engine and be used freely in both GDScript and C#.

The master branch aims to be in sync with Godot's master branch. Checkout other branches and/or releases for compatible versions. You can decide which version you need based on the following compatibility table:

Compatibility table (ANL/Godot)

3.0 3.1 3.2 4.0
1.0 πŸ‘ πŸ‘Ž πŸ‘Ž πŸ‘Ž
2.0 πŸ‘Ž πŸ‘ πŸ‘Ž πŸ‘Ž
2.1 πŸ‘Ž πŸ‘ πŸ‘ 🀞
2.2 πŸ‘Ž ❓ ❓ 🀞

Note: the latests versions may not be released yet and are kept for reference, but expect them to be compatible.

Notable features:

  • generate height, normal and bump maps from noise directly;
  • ability to construct noise from visual nodes in editor and via code;
  • make custom modular noise as components from base nodes.

Visual Accidental Noise Workbench Visual Accidental Noise Normalmap

See wiki on how to get started creating noise with visual nodes.

Overview

The AccidentalNoise class encapsulates the two main classes required for noise generation: CKernel and CNoiseExecutor.

The kernel holds any amount of noise functions together creating compound noise function. The noise executor then evaluates the function chain at any point of the pipeline.

The library is full of features compared to other noise generation libraries with a drawback of poorer performance.

Compiling

If you'd like to try out or develop the module:

git clone https://github.com/Xrayez/godot-anl anl
scons

Note that scons will clone Godot Engine repository and compile the engine with the module for you. Make sure that the module's directory name is exactly anl. Once the compilation is done, the resulting binaries should be available under godot/bin directory.

If you'd like to compile the module the traditional way, please refer to Godot Engine: Compiling documentation.

Configuring the build

Extending the noise period

Noise functions will have a period of 256; with coordinates higher than that, the patterns will repeat. If a larger period is required, build with anl_use_expressions_camelcase command line option to use a long-period hash instead in exchange for a slight decrease in performance:

scons anl_use_long_period=yes

Expression naming convention

The original library uses camelCase to parse function tokens in an expression, yet the module uses snake_case to confirm to Godot's naming convention. If you still want to use camelCase style, build with anl_use_expressions_camelcase command line option:

scons anl_use_expressions_camelcase=yes

Usage examples

GDScript

Generating 2D landscape:

See landscape.gd.

Result

Simple 2D terrain

You can also map the noise to an image with dedicated method instead to simplify the above example:

image = noise.get_image(width, height)

... or even tiled texture!

noise.mode = AccidentalNoise.SEAMLESS_XY
texture = noise.get_texture(width, height)

Expression builder can be used to simplify the process of chaining functions together to one-liners:

var n = AccidentalNoise.new()

var expression = "translate(select(0, 1, (x + y), 0.5, 0), 10)"
var function = noise.evaluate(expression)
var value = noise.color_2d(x, y, function)

But please note that the expression builder feature is a work in progress as stated by original author. Some functions work, some don't and might crash the engine.

C#

See demo project: AnlTest.cs.

using Godot;
using System;

public class AnlTest : Godot.Node2D
{
	public override void _Ready()
	{
		AccidentalNoise an = new Godot.AccidentalNoise();
		AccidentalNoise.InterpolationTypes interp = AccidentalNoise.InterpolationTypes.Linear;
		int seed = 37;
		an.Function = an.GradientBasis(an.Constant((double)interp), an.Constant(seed));
		an.Function = an.Scale(an.Function, an.Constant(5.0));
		an.Mode = AccidentalNoise.MappingModes.Xy;
		ImageTexture noise = an.GetTexture(128, 128) as ImageTexture;
		GetNode<TextureRect>("Noise").Texture = noise;
	}
}

Programmable noise

It's possible to modify noise parameters via special noise variables which are like constant() but can be set and retrieved by name.

See random_noise.gd.

Result

Before After

Other examples

Texture synthesis

Water or Smoke? Stones with moss? Lapis lazuli?

Legal considerations

The original Accidental Noise Library uses Simplex noise for some of the noise generation methods, implementation of which might be patented for uses in 3D and higher for textured image synthesis. I'm not a lawyer, but I think using 2D implementation of Simplex noise should be safe. I need to find that out someday. I might look into integrating OpenSimplex noise instead, if this is the case.

Owner
Andrii Doroshenko
Freeborn game development enthusiast.
Andrii Doroshenko
Comments
  • Porting to 4.0

    Porting to 4.0

    Module version: 2.1+, Godot 3.2 and 4.0+.

    Issue description: As you may know, Godot is currently undergoing major rewrite for 4.0. Some changes has already introduced compatibility breakage which need to be resolved in the module.

    Currently, the module's master branch aims to be in sync with the latest development changes in Godot as noted in README. That worked well up until now, because rewriting the module means that:

    • new features are going to end up to be only 4.0-compatible;
    • new features need to be ported to 3.2 manually for each.

    Given that the engine won't be usable nor stable for quite a long time (and most people would be actually using the released version of the engine which is Godot 3.2), I think it would be reasonable to change the branching model. Cherry-picking features from 4.0 to 3.2 is just going to be double work, and it's expected that new features can be added against Godot 3.2 too.

    Instead, I propose that for each major engine version, there should be a separate branch. Namely:

    • rename master branch to <module_version>-<engine_major_version>;
    • create a new branch for the next major engine version in development.

    Some examples of how it would look like:

    • 2.1-gd3 (2.1 as of now)
    • 2.1-gd4
    • 3.0-gd3
    • dev-gd3 (master as of now)
    • dev-gd4

    For stable releases (by stability I define that no new features are added to that version), the version tags would look like:

    • v2.1-gd3-stable
    • v2.1-gd4-alpha

    It also means that each engine-specific version can diverge and have different set of features (ideally they shouldn't), and depending on community needs they can be cross-ported between versions (bumping the major component of the module itself for each branch, if necessary). Once Godot 4.0 is released to the public, any Godot 3.x-specific features can be finally moved to 4.0.

    I'm just announcing this publicly and perhaps people can suggest something better, especially the naming prefixes/suffixes to encode engine major version for branches. I think this kind of distinction will work better in the long run. I'm not that familiar with other branching models out there.

    Note that there will be no master branch anymore, and the default branch is going to be dev-gd3 for "nightly" versions, and there will be another dev-gd4 branch similarly.

    Also note that the module is currently imitating the branching/versioning model similarly to Godot, for consistency. So might be worth naming development branches as master-gd3 branch similarly instead of dev-gd3.

  • Fix bindings and doc generation issues

    Fix bindings and doc generation issues

    Closes #21.

    There was a missing VisualAccidentalNoiseNode class which wasn't exposed as virtual, so likely binding generator fails.

    Another issue is that enum types were reused from within anl namespace directly so this can also cause errors I think.

  • Impossible to design noise visually, only from code

    Impossible to design noise visually, only from code

    Creating noise with ANL can be quite a spaghetti:

    var f0 = n.constant(2)
    var n = n.zero()
    var basis = n.cellular_basis(
    	f0, n, n, n, n, n, n, n,
    	n.zero(), n.constant(seed_id)
    )
    var scaled = n.scale(basis, n.constant(1.25))
    var scale_offset = n.scale_offset(scaled, 0.5, 0.1)
    var select = n.select(
    	n.zero(),
    	n.one(),
    	scale_offset,
    	n.constant(0.45),
    	n.zero()
    )
    

    So there needs to be a way to design noise more visually, like Godot's VisualShader editor plugin does.

    Also, see a nice use case already implemented in other engine by original author of Accidental Noise Library:

    Example designing noise using graph nodes in Urho3D engine.

    This feature is a possible prerequisite for #4 to get implemented so that noise can be saved as a resource.

  • Elementary noise generators are missing

    Elementary noise generators are missing

    Value, gradient, gradval, white and simplex noise generators are not exposed to the module:

    ...
    double value_noise2D(double x, double y, unsigned int seed, interp_func interp);
    double gradient_noise2D(double x, double y, unsigned int seed, interp_func interp);
    double gradval_noise2D(double x, double y, unsigned int seed, interp_func interp);
    double white_noise2D(double x, double y, unsigned int seed, interp_func interp);
    double simplex_noise2D(double x, double y, unsigned int seed, interp_func interp);
    ...
    

    I'm not sure whether they're needed since the noise can be obtained from constructed kernel. But I think having those wouldn't hurt.

  • Fixed compiling issues on Godot

    Fixed compiling issues on Godot

    In noise.cpp, 4 of the functions were not referencing a pointer to an object, causing it to give out errors. In vm.cpp, some of the if & else if statements from lines 1469-1474 utilized a boolean 'and' rather than '&&', causing some errors.

    Afterwards, I was able to compile godot successfully following the build instructions on their website. On Windows.

  • Autocorrect module?

    Autocorrect module?

    On the http://accidentalnoise.sourceforge.net/minecraftworlds.html page, the autocorrect module is used to map ranges to 0..1, by iirc first sampling values to determine ~ min max.

    Is this present in this module, or am I missing something?

  • Calculate normal/bump map

    Calculate normal/bump map

    I've noticed the underlying library has methods for generating normal/bump maps:

    void calcNormalMap(CArray2Dd *map, CArray2Drgba *bump, float spacing, bool normalize, bool wrap);
    void calcBumpMap(CArray2Dd *map, CArray2Dd *bump, float light[3], float spacing, bool wrap);
    

    I'm not proficient in 3D but I think many would benefit from these, so it's worth to bind them.

  • [3.2] Mono bindings won't generate

    [3.2] Mono bindings won't generate

    Module version: 2.1-stable

    OS/device including version: Windows 10 x64

    Issue description: Mono binding wasn't generated.

    Steps to reproduce:

    1. Download 2.1-stable.{zip/tar.gz}
    2. Download Godot 3.2-stable sources.
    3. Unpack 2.1-stable to "modules" folder of Godot 3.2 source code.
    4. Compile with Mono, but without glue.
    5. Try to generate Mono glue.
    6. Catch a generator error to your face.
  • Remove module-specific configuration regarding C++11

    Remove module-specific configuration regarding C++11

    Godot's entire codebase has shifted towards C++11 support:

    godotengine/godot@5dae2ea

    Postponing merging to remain potential compatibility with previous versions of Godot.

  • Create a selector node to choose between noise nodes

    Create a selector node to choose between noise nodes

    Module version: 2.1

    Issue description: A selector node would be similar to transition node in animation blend tree that can be used to quickly choose what noise chain to pass to other nodes. This would serve as a replacement to manual connecting/disconnecting multiple nodes to the same node.

  • Duplicating a noise node duplicates all nodes

    Duplicating a noise node duplicates all nodes

    Module version: 2.0 (tested in 3516b01)

    Issue description: Attempting to duplicate a noise node leads to duplicating all nodes, including those that weren't selected.

    Steps to reproduce:

    1. Create some nodes
    2. Select a node (or don't select at all)
    3. Ctrl+D to duplicate nodes.
    4. See how all nodes get duplicated.
  • Provide Texture and Texture3d resources

    Provide Texture and Texture3d resources

    Provide Texture and Texture3d resources and if possible refactor the engine so both Texture and Texture3d opensimplex and anl classes can coexist from the same parent class.

Poseidon -- An Enhanced V2Ray(based on v2ray-core)

Poseidon -- An Enhanced V2Ray(based on v2ray-core) Support SSRPanel(VNetPanel), V2board, SSpanel-v3-Uim Features Sync user from your panel to v2ray Lo

Nov 14, 2021
Minecraft noise searching tool written in go

Commotion A minecraft world generation imitation library written in golang. TODO

Aug 7, 2022
Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call

speedex-standalone Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call. Notes from Geoff About Tato

Dec 1, 2021
Simple Nginx Load Balancing Use Docker Engine
Simple Nginx Load Balancing Use Docker Engine

Load Balancing Menggunakan Nginx Load Balancing adalah sebuah mekanisme untuk membagi atau mendistribusikan trafik ke beberapa server. Nginx selain be

Dec 14, 2021
Core is the next-generation digital data engine.
Core is the next-generation digital data engine.

tKeel-Core The digital engine of world ?? Core is the data centre of the tKeel IoT Open Platform, a high-performance, scalable and lightweight next-ge

Mar 28, 2022
An implementation of the Information Concealment Engine cipher in Go
An implementation of the Information Concealment Engine cipher in Go

An implementation of the Information Concealment Engine cipher in Go

Jan 26, 2022
Grcon - Lib for Source Engine's RCON protocol in Go

grcon A basic Golang library for the RCON Protocol. Features Max control over th

Mar 5, 2022
A library for the MIGP (Might I Get Pwned) protocolA library for the MIGP (Might I Get Pwned) protocol

MIGP library This contains a library for the MIGP (Might I Get Pwned) protocol. MIGP can be used to build privacy-preserving compromised credential ch

Dec 3, 2022
A library to simplify writing applications using TCP sockets to stream protobuff messages

BuffStreams Streaming Protocol Buffers messages over TCP in Golang What is BuffStreams? BuffStreams is a set of abstraction over TCPConns for streamin

Dec 13, 2022
DNS library in Go

Alternative (more granular) approach to a DNS library Less is more. Complete and usable DNS library. All Resource Records are supported, including the

Jan 8, 2023
πŸš€Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
πŸš€Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev δΈ­ζ–‡ | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

Jan 6, 2023
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1 and V5 in golang

δΈ­ζ–‡ζ–‡ζ‘£ Gmqtt News: MQTT V5 is now supported. But due to those new features in v5, there area lots of breaking changes. If you have any migration problem

Jan 5, 2023
golibwireshark - Package use libwireshark library to decode pcap file and analyse dissection data.

golibwireshark Package golibwireshark use libwireshark library to decode pcap file and analyse dissection data. This package can only be used in OS li

Nov 26, 2022
An SNMP library written in GoLang.

gosnmp GoSNMP is an SNMP client library fully written in Go. It provides Get, GetNext, GetBulk, Walk, BulkWalk, Set and Traps. It supports IPv4 and IP

Jan 7, 2023
A library for working with IP addresses and networks in Go

IPLib I really enjoy Python's ipaddress library and Ruby's ipaddr, I think you can write a lot of neat software if some of the little problems around

Dec 20, 2022
A Crypto-Secure, Production-Grade Reliable-UDP Library for golang with FEC
 A Crypto-Secure, Production-Grade Reliable-UDP Library for golang with FEC

Introduction kcp-go is a Production-Grade Reliable-UDP library for golang. This library intents to provide a smooth, resilient, ordered, error-checked

Dec 28, 2022
Simple mDNS client/server library in Golang

mdns Simple mDNS client/server library in Golang. mDNS or Multicast DNS can be used to discover services on the local network without the use of an au

Jan 4, 2023
Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman:
Pure-Go library for cross-platform local peer discovery using UDP multicast :woman: :repeat: :woman:

peerdiscovery Pure-go library for cross-platform thread-safe local peer discovery using UDP multicast. I needed to use peer discovery for croc and eve

Jan 8, 2023