core/math/noise

math_noise

Types

3

Constants

28

PRIME_X

PRIME_X :: i64 = i64(0x5205402B9270C86F)Source

OpenSimplex2 noise implementation.

Ported from https://github.com/KdotJPG/OpenSimplex2.
	Copyright 2022 Yuki2 (https://github.com/NoahR02)
Private implementation details follow.

Variables

3

GRADIENTS_2D

GRADIENTS_2D :: [N_GRADS_2D * 2]f32 = [N_GRADS_2D * 2]f32{ 0h4218d2da, 0h42b87975, 0h42b87975, 0h4218d2da, 0h42b87975, 0hc218d2da, 0h4218d2da, 0hc2b87975, 0hc218d2da, 0hc2b87975, 0hc2b87975, 0hc218d2da, 0hc2b87975, 0h4218d2da, 0hc218d2da, 0h42b87975, 0h4150804d, 0h42c5f72a, 0h42731b78, 0hSource

GRADIENTS_3D

GRADIENTS_3D :: [N_GRADS_3D * 4]f32 = [N_GRADS_3D * 4]f32{ 0h41df5103, 0h41df5103, 0hc148c1c5, 0h00000000, 0h41df5103, 0h41df5103, 0h4148c1c5, 0h00000000, 0h421ae5b8, 0h416b5146, 0h00000000, 0h00000000, 0h416b5146, 0h421ae5b8, 0h00000000, 0h00000000, 0hc1df5103, 0h41df5103, 0hc148c1c5, 0hSource

GRADIENTS_4D

GRADIENTS_4D :: [N_GRADS_4D * 4]f32 = [N_GRADS_4D * 4]f32{ 0hc1f50507, 0hc16b8e00, 0hc16b8e00, 0h41d2a716, 0hc208695c, 0hc19194b0, 0h40de6d7d, 0h41b6d966, 0hc208695c, 0h40de6d7d, 0hc19194b0, 0h41b6d966, 0hc22076c5, 0h406d72bf, 0h406d72bf, 0h41a58418, 0hc1a58418, 0hc06d72bf, 0hc06d72bf, 0h42Source

Procedures

17

noise_2d_improve_x

noise_2d_improve_x :: proc(seed: i64, coord: Vec2) -> (value: f32)Source

2D Simplex noise, with Y pointing down the main diagonal.

Might be better for a 2D sandbox style game, where Y is vertical.
	Probably slightly less optimal for heightmaps or continent maps,
	unless your map is centered around an equator. It's a subtle
	difference, but the option is here to make it an easy choice.

noise_3d_fallback

noise_3d_fallback :: proc(seed: i64, coord: Vec3) -> (value: f32)Source

3D OpenSimplex2 noise, fallback rotation option

Use `noise_3d_improve_xy` or `noise_3d_improve_xz` instead, wherever appropriate.
	They have less diagonal bias. This function's best use is as a fallback.

noise_3d_improve_xy

noise_3d_improve_xy :: proc(seed: i64, coord: Vec3) -> (value: f32)Source

3D OpenSimplex2 noise, with better visual isotropy in (X, Y).

Recommended for 3D terrain and time-varied animations.
	The Z coordinate should always be the "different" coordinate in whatever your use case is.
	If Y is vertical in world coordinates, call `noise_3d_improve_xz(x, z, Y)` or use `noise_3d_xz_before_y`.
	If Z is vertical in world coordinates, call `noise_3d_improve_xz(x, y, Z)`.
	For a time varied animation, call `noise_3d_improve_xz(x, y, T)`.

noise_3d_improve_xz

noise_3d_improve_xz :: proc(seed: i64, coord: Vec3) -> (value: f32)Source

3D OpenSimplex2 noise, with better visual isotropy in (X, Z).

Recommended for 3D terrain and time-varied animations.
	The Y coordinate should always be the "different" coordinate in whatever your use case is.
	If Y is vertical in world coordinates, call `noise_3d_improve_xz(x, Y, z)`.
	If Z is vertical in world coordinates, call `noise_3d_improve_xz(x, Z, y)` or use `noise_3d_improve_xy`.
	For a time varied animation, call `noise_3d_improve_xz(x, T, y)` or use `noise_3d_improve_xy`.

Procedure Groups

1

Reference search

Find anything

Documentation preferences

Settings

System theme variants

Used only while Theme is set to System.