Updated noise_fbm code based on the new shaders.

This commit is contained in:
Relintai 2021-10-05 13:33:27 +02:00
parent 49f9cf7d01
commit a80d0334a1
2 changed files with 89 additions and 44 deletions

View File

@ -3,48 +3,48 @@ extends Reference
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
static func fbmval(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = fbmf(uv, size, octaves, persistence, pseed)
static func fbmval(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = fbmf(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func perlin(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = perlinf(uv, size, octaves, persistence, pseed)
static func perlin(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = perlinf(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func perlinabs(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = perlinf(uv, size, octaves, persistence, pseed)
static func perlinabs(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = perlinf(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellularf(uv, size, octaves, persistence, pseed)
static func cellular(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellularf(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular2(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular2f(uv, size, octaves, persistence, pseed)
static func cellular2(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular2f(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular3(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular3f(uv, size, octaves, persistence, pseed)
static func cellular3(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular3f(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular4(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular4f(uv, size, octaves, persistence, pseed)
static func cellular4(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular4f(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular5(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular5f(uv, size, octaves, persistence, pseed)
static func cellular5(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular5f(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
static func cellular6(uv : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular6f(uv, size, octaves, persistence, pseed)
static func cellular6(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
var f : float = cellular6f(uv, size, folds, octaves, persistence, pseed)
return Color(f, f, f, 1)
@ -70,117 +70,162 @@ static func cellular6(uv : Vector2, size : Vector2, octaves : int, persistence :
# return value / normalize_factor;
#}
static func fbmf(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func fbmf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_value(coord * size, size, pseed) * scale;
var noise : float = fbm_value(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func perlinf(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func perlinf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_perlin(coord*size, size, pseed) * scale;
var noise : float = fbm_perlin(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func perlinabsf(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func perlinabsf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_perlinabs(coord*size, size, pseed) * scale;
var noise : float = fbm_perlinabs(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellularf(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellularf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellular2f(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellular2f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular2(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular2(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellular3f(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellular3f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular3(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular3(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellular4f(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellular4f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular4(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular4(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellular5f(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellular5f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular5(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular5(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;
return value / normalize_factor;
static func cellular6f(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float:
static func cellular6f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
var normalize_factor : float = 0.0;
var value : float = 0.0;
var scale : float = 1.0;
for i in range(octaves):# (int i = 0; i < octaves; i++) {
value += fbm_cellular6(coord*size, size, pseed) * scale;
var noise : float = fbm_cellular6(coord*size, size, pseed)
for j in range(folds):# (int f = 0; f < folds; ++f) {
noise = abs(2.0*noise-1.0);
value += noise * scale
normalize_factor += scale;
size *= 2.0;
scale *= persistence;

View File

@ -64,28 +64,28 @@ var p_o33355_iterations = 5.000000000;
var p_o33355_persistence = 0.500000000;
func fbmval(uv : Vector2) -> Color:
return NoiseFBM.fbmval(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.fbmval(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func perlin(uv : Vector2) -> Color:
return NoiseFBM.perlin(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.perlin(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular(uv : Vector2) -> Color:
return NoiseFBM.cellular(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular2(uv : Vector2) -> Color:
return NoiseFBM.cellular2(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular2(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular3(uv : Vector2) -> Color:
return NoiseFBM.cellular3(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular3(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular4(uv : Vector2) -> Color:
return NoiseFBM.cellular4(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular4(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular5(uv : Vector2) -> Color:
return NoiseFBM.cellular5(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular5(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func cellular6(uv : Vector2) -> Color:
return NoiseFBM.cellular6(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
return NoiseFBM.cellular6(uv, Vector2(p_o33355_scale_x, p_o33355_scale_y), 1, int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355))
func reffg():
return false