• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    C++
  • License
    Other
  • Created about 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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?

More Repositories

1

godot-editor-icons-previewer

Plugin to preview all available icons in Godot Editor.
GDScript
51
star
2

godot-clipper

[DEPRECATED] Clipper library wrapper in Godot Engine
C++
20
star
3

godot-imagetools

[DEPRECATED] The module is available as a component of Goost.
C++
20
star
4

godot-vector-resource

Visually edit and store Vector2/3 core data types as resources in Godot Engine.
GDScript
18
star
5

godot-quickset

[WIP] Godot plugin to expose editor and project settings in a dock for quick access
GDScript
14
star
6

godot-mesh-instance-collision-2d

An example project demonstrating an ability to create collision shapes from sprites via mesh instances in 2D
GDScript
12
star
7

box2d-lite-gdscript

Box2D Lite C++ physics engine ported to pure GDScript
GDScript
12
star
8

godot-editor-plugin-tools

Collection of useful editor plugin utility methods and tools.
GDScript
12
star
9

gdgen

Code generator for Godot Engine (modules)
Python
11
star
10

godot-geomtools

[DEPRECATED] The module is available as a component of Goost.
C++
10
star
11

godot-vector-bench

Godot project intended to reveal mysterious operations that can be performed on vectors in 2D space
GDScript
6
star
12

godot-testbed

[WIP] CI automatic testing environment for Godot Engine
GDScript
4
star
13

godot-inside-godot

An example project demonstrating the ability to render Godot editor inside Godot's editor own viewport.
GDScript
4
star
14

godot-physicstools

[DEPRECATED] The module is available as a component of Goost.
C++
4
star
15

godot-input-state-demo

A demo/proposal project showcasing the usage of the new InputState class in Godot
GDScript
3
star
16

godot-editor-settings

My editor settings for Godot editor
3
star
17

godot-pjnath

[WIP, UNMAINTAINED] PJNATH: ICE, STUN, and TURN Library wrapper for Godot Engine
Python
3
star
18

godot-vscode-snippets

Snippets for Godot development
Python
3
star
19

godot-image-indexed-example

GDScript
2
star
20

godot-anl-visual-builder-prototype

GDScript
1
star