mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-02-08 14:50:05 +01:00
Removed the now unneded files.
This commit is contained in:
parent
b1791d1f11
commit
4207b778a0
File diff suppressed because it is too large
Load Diff
@ -1,393 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
#pattern.mmg
|
||||
|
||||
#----------------------
|
||||
#hlsl_defs.tmpl
|
||||
|
||||
##define hlsl_atan(x,y) atan2(x, y)
|
||||
##define mod(x,y) ((x)-(y)*floor((x)/(y)))
|
||||
#inline float4 textureLod(sampler2D tex, float2 uv, float lod) {
|
||||
# return tex2D(tex, uv);
|
||||
#}
|
||||
#inline float2 tofloat2(float x) {
|
||||
# return float2(x, x);
|
||||
#}
|
||||
#inline float2 tofloat2(float x, float y) {
|
||||
# return float2(x, y);
|
||||
#}
|
||||
#inline float3 tofloat3(float x) {
|
||||
# return float3(x, x, x);
|
||||
#}
|
||||
#inline float3 tofloat3(float x, float y, float z) {
|
||||
# return float3(x, y, z);
|
||||
#}
|
||||
#inline float3 tofloat3(float2 xy, float z) {
|
||||
# return float3(xy.x, xy.y, z);
|
||||
#}
|
||||
#inline float3 tofloat3(float x, float2 yz) {
|
||||
# return float3(x, yz.x, yz.y);
|
||||
#}
|
||||
#inline float4 tofloat4(float x, float y, float z, float w) {
|
||||
# return float4(x, y, z, w);
|
||||
#}
|
||||
#inline float4 tofloat4(float x) {
|
||||
# return float4(x, x, x, x);
|
||||
#}
|
||||
#inline float4 tofloat4(float x, float3 yzw) {
|
||||
# return float4(x, yzw.x, yzw.y, yzw.z);
|
||||
#}
|
||||
#inline float4 tofloat4(float2 xy, float2 zw) {
|
||||
# return float4(xy.x, xy.y, zw.x, zw.y);
|
||||
#}
|
||||
#inline float4 tofloat4(float3 xyz, float w) {
|
||||
# return float4(xyz.x, xyz.y, xyz.z, w);
|
||||
#}
|
||||
#inline float2x2 tofloat2x2(float2 v1, float2 v2) {
|
||||
# return float2x2(v1.x, v1.y, v2.x, v2.y);
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#glsl_defs.tmpl
|
||||
|
||||
#float rand(vec2 x) {
|
||||
# return fract(cos(mod(dot(x, vec2(13.9898, 8.141)), 3.14)) * 43758.5453);
|
||||
#}
|
||||
|
||||
#vec2 rand2(vec2 x) {
|
||||
# return fract(cos(mod(vec2(dot(x, vec2(13.9898, 8.141)),
|
||||
# dot(x, vec2(3.4562, 17.398))), vec2(3.14))) * 43758.5453);
|
||||
#}
|
||||
|
||||
#vec3 rand3(vec2 x) {
|
||||
# return fract(cos(mod(vec3(dot(x, vec2(13.9898, 8.141)),
|
||||
# dot(x, vec2(3.4562, 17.398)),
|
||||
# dot(x, vec2(13.254, 5.867))), vec3(3.14))) * 43758.5453);
|
||||
#}
|
||||
|
||||
#float param_rnd(float minimum, float maximum, float seed) {
|
||||
# return minimum+(maximum-minimum)*rand(vec2(seed));
|
||||
#}
|
||||
|
||||
#vec3 rgb2hsv(vec3 c) {
|
||||
# vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
# vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);
|
||||
# vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);
|
||||
#
|
||||
# float d = q.x - min(q.w, q.y);
|
||||
# float e = 1.0e-10;
|
||||
# return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
#}
|
||||
|
||||
#vec3 hsv2rgb(vec3 c) {
|
||||
# vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
# vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
# return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
|
||||
static func clampv3(v : Vector3, mi : Vector3, ma : Vector3) -> Vector3:
|
||||
v.x = clamp(v.x, mi.x, ma.x)
|
||||
v.y = clamp(v.y, mi.y, ma.y)
|
||||
v.z = clamp(v.z, mi.z, ma.z)
|
||||
|
||||
return v
|
||||
|
||||
static func floorc(a : Color) -> Color:
|
||||
var v : Color = Color()
|
||||
|
||||
v.r = floor(a.r)
|
||||
v.g = floor(a.g)
|
||||
v.b = floor(a.b)
|
||||
v.a = floor(a.a)
|
||||
|
||||
return v
|
||||
|
||||
static func floorv2(a : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = floor(a.x)
|
||||
v.y = floor(a.y)
|
||||
|
||||
return v
|
||||
|
||||
static func floorv3(a : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = floor(a.x)
|
||||
v.y = floor(a.y)
|
||||
v.z = floor(a.z)
|
||||
|
||||
return v
|
||||
|
||||
static func smoothstepv2(a : float, b : float, c : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = smoothstep(a, b, c.x)
|
||||
v.y = smoothstep(a, b, c.y)
|
||||
|
||||
return v
|
||||
|
||||
static func maxv2(a : Vector2, b : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = max(a.x, b.x)
|
||||
v.y = max(a.y, b.y)
|
||||
|
||||
return v
|
||||
|
||||
static func maxv3(a : Vector3, b : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = max(a.x, b.x)
|
||||
v.y = max(a.y, b.y)
|
||||
v.z = max(a.z, b.z)
|
||||
|
||||
return v
|
||||
|
||||
static func absv2(v : Vector2) -> Vector2:
|
||||
v.x = abs(v.x)
|
||||
v.y = abs(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func absv3(v : Vector3) -> Vector3:
|
||||
v.x = abs(v.x)
|
||||
v.y = abs(v.y)
|
||||
v.z = abs(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func cosv2(v : Vector2) -> Vector2:
|
||||
v.x = cos(v.x)
|
||||
v.y = cos(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func cosv3(v : Vector3) -> Vector3:
|
||||
v.x = cos(v.x)
|
||||
v.y = cos(v.y)
|
||||
v.z = cos(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func powv2(x : Vector2, y : Vector2) -> Vector2:
|
||||
x.x = pow(x.x, y.x)
|
||||
x.y = pow(x.y, y.y)
|
||||
|
||||
return x
|
||||
|
||||
static func modv3(a : Vector3, b : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = modf(a.x, b.x)
|
||||
v.y = modf(a.y, b.y)
|
||||
v.z = modf(a.z, b.z)
|
||||
|
||||
return v
|
||||
|
||||
|
||||
static func modv2(a : Vector2, b : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = modf(a.x, b.x)
|
||||
v.y = modf(a.y, b.y)
|
||||
|
||||
return v
|
||||
|
||||
static func modf(x : float, y : float) -> float:
|
||||
return x - y * floor(x / y)
|
||||
|
||||
static func fractv2(v : Vector2) -> Vector2:
|
||||
v.x = v.x - floor(v.x)
|
||||
v.y = v.y - floor(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func fractv3(v : Vector3) -> Vector3:
|
||||
v.x = v.x - floor(v.x)
|
||||
v.y = v.y - floor(v.y)
|
||||
v.z = v.z - floor(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func fract(f : float) -> float:
|
||||
return f - floor(f)
|
||||
|
||||
static func clampv2(v : Vector2, pmin : Vector2, pmax : Vector2) -> Vector2:
|
||||
v.x = clamp(v.x, pmin.x, pmax.x)
|
||||
v.y = clamp(v.y, pmin.y, pmax.y)
|
||||
|
||||
return v
|
||||
|
||||
static func minv2(v1 : Vector2, v2 : Vector2) -> Vector2:
|
||||
v1.x = min(v1.x, v2.x)
|
||||
v1.y = min(v1.y, v2.y)
|
||||
|
||||
return v1
|
||||
|
||||
static func minv3(v1 : Vector3, v2 : Vector3) -> Vector3:
|
||||
v1.x = min(v1.x, v2.x)
|
||||
v1.y = min(v1.y, v2.y)
|
||||
v1.z = min(v1.z, v2.z)
|
||||
|
||||
return v1
|
||||
|
||||
static func rand(x : Vector2) -> float:
|
||||
return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453);
|
||||
|
||||
static func rand2(x : Vector2) -> Vector2:
|
||||
return fractv2(cosv2(Vector2(x.dot(Vector2(13.9898, 8.141)),
|
||||
x.dot(Vector2(3.4562, 17.398)))) * 43758.5453);
|
||||
|
||||
static func rand3(x : Vector2) -> Vector3:
|
||||
return fractv3(cosv3(Vector3(x.dot(Vector2(13.9898, 8.141)),
|
||||
x.dot(Vector2(3.4562, 17.398)),
|
||||
x.dot(Vector2(13.254, 5.867)))) * 43758.5453);
|
||||
|
||||
static func step(edge : float, x : float) -> float:
|
||||
if x < edge:
|
||||
return 0.0
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
static func stepv2(edge : Vector2, x : Vector2) -> Vector2:
|
||||
edge.x = step(edge.x, x.x)
|
||||
edge.y = step(edge.y, x.y)
|
||||
|
||||
return edge
|
||||
|
||||
static func signv2(x : Vector2) -> Vector2:
|
||||
x.x = sign(x.x)
|
||||
x.y = sign(x.y)
|
||||
|
||||
return x
|
||||
|
||||
static func transform(uv : Vector2, translate : Vector2, rotate : float, scale : Vector2, repeat : bool) -> Vector2:
|
||||
var rv : Vector2 = Vector2();
|
||||
uv -= translate;
|
||||
uv -= Vector2(0.5, 0.5);
|
||||
rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;
|
||||
rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;
|
||||
rv /= scale;
|
||||
rv += Vector2(0.5, 0.5);
|
||||
|
||||
if (repeat):
|
||||
return fractv2(rv);
|
||||
else:
|
||||
return clampv2(rv, Vector2(0, 0), Vector2(1, 1));
|
||||
|
||||
static func fractf(x : float) -> float:
|
||||
return x - floor(x)
|
||||
|
||||
#float mix_mul(float x, float y) {
|
||||
# return x*y;
|
||||
#}
|
||||
|
||||
static func mix_mul(x : float, y : float) -> float:
|
||||
return x*y;
|
||||
|
||||
#float mix_add(float x, float y) {
|
||||
# return min(x+y, 1.0);
|
||||
#}
|
||||
|
||||
static func mix_add(x : float, y : float) -> float:
|
||||
return min(x+y, 1.0);
|
||||
|
||||
#float mix_max(float x, float y) {
|
||||
# return max(x, y);
|
||||
#}
|
||||
|
||||
static func mix_max(x : float, y : float) -> float:
|
||||
return max(x, y);
|
||||
|
||||
#float mix_min(float x, float y) {
|
||||
# return min(x, y);
|
||||
#}
|
||||
|
||||
static func mix_min(x : float, y : float) -> float:
|
||||
return min(x, y);
|
||||
|
||||
#float mix_xor(float x, float y) {
|
||||
# return min(x+y, 2.0-x-y);
|
||||
#}
|
||||
|
||||
static func mix_xor(x : float, y : float) -> float:
|
||||
return min(x+y, 2.0-x-y);
|
||||
|
||||
#float mix_pow(float x, float y) {
|
||||
# return pow(x, y);
|
||||
#}
|
||||
|
||||
static func mix_pow(x : float, y : float) -> float:
|
||||
return pow(x, y);
|
||||
|
||||
|
||||
#float wave_constant(float x) {
|
||||
# return 1.0;
|
||||
#}
|
||||
|
||||
static func wave_constant(x : float) -> float:
|
||||
return 1.0;
|
||||
|
||||
#float wave_sine(float x) {
|
||||
# return 0.5-0.5*cos(3.14159265359*2.0*x);
|
||||
#}
|
||||
|
||||
static func wave_sine(x : float) -> float:
|
||||
return 0.5-0.5*cos(3.14159265359*2.0*x);
|
||||
|
||||
#float wave_triangle(float x) {
|
||||
# x = fract(x);
|
||||
# return min(2.0*x, 2.0-2.0*x);
|
||||
#}
|
||||
|
||||
static func wave_triangle(x : float) -> float:
|
||||
x = fractf(x);
|
||||
return min(2.0*x, 2.0-2.0*x);
|
||||
|
||||
#float wave_sawtooth(float x) {
|
||||
# return fract(x);
|
||||
#}
|
||||
|
||||
static func wave_sawtooth(x : float) -> float:
|
||||
return fractf(x);
|
||||
|
||||
#float wave_square(float x) {
|
||||
# return (fract(x) < 0.5) ? 0.0 : 1.0;
|
||||
#}
|
||||
|
||||
static func wave_square(x : float) -> float:
|
||||
if (fractf(x) < 0.5):
|
||||
return 0.0
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
#float wave_bounce(float x) {
|
||||
# x = 2.0*(fract(x)-0.5);
|
||||
# return sqrt(1.0-x*x);
|
||||
#}
|
||||
|
||||
static func wave_bounce(x : float) -> float:
|
||||
x = 2.0*(fractf(x)-0.5);
|
||||
return sqrt(1.0-x*x);
|
||||
|
||||
static func sinewave(uv : Vector2, amplitude : float, frequency : float, phase : float) -> Color:
|
||||
var f : float = 1.0- abs(2.0 * (uv.y-0.5) - amplitude * sin((frequency* uv.x + phase) * 6.28318530718));
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#from runes.mmg (old)
|
||||
|
||||
static func ThickLine(uv : Vector2, posA : Vector2, posB : Vector2, radiusInv : float) -> float:
|
||||
var dir : Vector2 = posA - posB;
|
||||
var dirLen : float = dir.length()
|
||||
var dirN : Vector2 = dir.normalized()
|
||||
var dotTemp : float = clamp((uv - posB).dot(dirN), 0.0, dirLen);
|
||||
var proj : Vector2 = dotTemp * dirN + posB;
|
||||
var d1 : float = (uv - proj).length()
|
||||
var finalGray : float = clamp(1.0 - d1 * radiusInv, 0.0, 1.0);
|
||||
|
||||
return finalGray;
|
@ -1,85 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#Based on MaterialMaker's curve.gd
|
||||
|
||||
#Curve PoolRealArray: p.x, p.y, ls, rs, p.x, p.y ....
|
||||
|
||||
#class Point:
|
||||
# var p : Vector2
|
||||
# var ls : float
|
||||
# var rs : float
|
||||
|
||||
#func get_shader(name) -> String:
|
||||
# var shader
|
||||
# shader = "float "+name+"_curve_fct(float x) {\n"
|
||||
# for i in range(points.size()-1):
|
||||
# if i < points.size()-2:
|
||||
# shader += "if (x <= p_"+name+"_"+str(i+1)+"_x) "
|
||||
#
|
||||
# shader += "{\n"
|
||||
# shader += "float dx = x - p_"+name+"_"+str(i)+"_x;\n"
|
||||
# shader += "float d = p_"+name+"_"+str(i+1)+"_x - p_"+name+"_"+str(i)+"_x;\n"
|
||||
# shader += "float t = dx/d;\n"
|
||||
# shader += "float omt = (1.0 - t);\n"
|
||||
# shader += "float omt2 = omt * omt;\n"
|
||||
# shader += "float omt3 = omt2 * omt;\n"
|
||||
# shader += "float t2 = t * t;\n"
|
||||
# shader += "float t3 = t2 * t;\n"
|
||||
# shader += "d /= 3.0;\n"
|
||||
# shader += "float y1 = p_"+name+"_"+str(i)+"_y;\n"
|
||||
# shader += "float yac = p_"+name+"_"+str(i)+"_y + d*p_"+name+"_"+str(i)+"_rs;\n"
|
||||
# shader += "float ybc = p_"+name+"_"+str(i+1)+"_y - d*p_"+name+"_"+str(i+1)+"_ls;\n"
|
||||
# shader += "float y2 = p_"+name+"_"+str(i+1)+"_y;\n"
|
||||
# shader += "return y1*omt3 + yac*omt2*t*3.0 + ybc*omt*t2*3.0 + y2*t3;\n"
|
||||
# shader += "}\n"
|
||||
#
|
||||
# shader += "}\n"
|
||||
# return shader
|
||||
|
||||
static func curve(x : float, points : PoolRealArray) -> float:
|
||||
if points.size() % 4 != 0 || points.size() < 8:
|
||||
return 0.0
|
||||
|
||||
var ps : int = points.size() / 4
|
||||
|
||||
for i in range(ps - 1):
|
||||
var pi : int = i * 4
|
||||
var pip1 : int = (i + 1) * 4
|
||||
|
||||
if i < ps - 2:
|
||||
# if (x <= p_"+name+"_"+str(i+1)+"_x)
|
||||
if x > points[pip1]:
|
||||
continue
|
||||
|
||||
#float dx = x - p_"+name+"_"+str(i)+"_x;
|
||||
var dx : float = x - points[pi];
|
||||
|
||||
#var d : float = p_"+name+"_"+str(i+1)+"_x - p_"+name+"_"+str(i)+"_x;
|
||||
var d : float = points[pip1] - points[pi];
|
||||
|
||||
var t : float = dx / d
|
||||
var omt : float = (1.0 - t)
|
||||
var omt2 : float = omt * omt
|
||||
var omt3 : float = omt2 * omt
|
||||
var t2 : float = t * t
|
||||
var t3 : float = t2 * t
|
||||
d /= 3.0
|
||||
|
||||
# var y1 : float = p_"+name+"_"+str(i)+"_y
|
||||
var y1 : float = points[pi + 1]
|
||||
|
||||
# var yac : float = p_"+name+"_"+str(i)+"_y + d*p_"+name+"_"+str(i)+"_rs
|
||||
var yac : float = points[pi + 1] + d * points[pi + 3]
|
||||
|
||||
# var ybc : float = p_"+name+"_"+str(i+1)+"_y - d*p_"+name+"_"+str(i+1)+"_ls
|
||||
var ybc : float = points[pip1 + 1] - d * points[pip1 + 2]
|
||||
|
||||
# var y2 : float = p_"+name+"_"+str(i+1)+"_y
|
||||
var y2 : float = points[pip1 + 1]
|
||||
|
||||
return y1 * omt3 + yac * omt2 * t * 3.0 + ybc * omt * t2 * 3.0 + y2 * t3;
|
||||
|
||||
return 0.0
|
@ -1,521 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#dilate.mmg
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_1",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_1",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_4",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_3",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2_3",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2_2",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_3",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_4",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "default_color",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 1,
|
||||
# "to": "default_color",
|
||||
# "to_port": 0
|
||||
# }
|
||||
# ],
|
||||
# "label": "Dilate",
|
||||
# "longdesc": "Dilates the white areas of a mask, using the colors of an optional input",
|
||||
# "name": "dilate",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "buffer",
|
||||
# "node_position": {
|
||||
# "x": -473.691315,
|
||||
# "y": -200.988342
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2",
|
||||
# "node_position": {
|
||||
# "x": -255.691315,
|
||||
# "y": -123.988342
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -140.306458,
|
||||
# "y": -377.953613
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 9,
|
||||
# "param1": 0.1,
|
||||
# "param2": 0,
|
||||
# "param3": 0
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "buffer",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2_2",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_1",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2_3",
|
||||
# "widget": "size"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The resolution of the input images",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_1",
|
||||
# "widget": "d"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "d"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The length of the dilate effect",
|
||||
# "name": "param1",
|
||||
# "shortdesc": "Length",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_3",
|
||||
# "widget": "amount"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "0 to generate a gradient to black while dilating, 1 to fill with input color",
|
||||
# "name": "param2",
|
||||
# "shortdesc": "Fill",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "distance"
|
||||
# }
|
||||
# ],
|
||||
# "name": "param3",
|
||||
# "shortdesc": "Distance function",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -872.306458,
|
||||
# "y": -171.4814
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The input mask whose white areas will be dilated",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The optional source for colors",
|
||||
# "name": "source",
|
||||
# "shortdesc": "Source",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": 254.21106,
|
||||
# "y": -64.4814
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "Shows the dilated image",
|
||||
# "name": "out",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "seed_value": -14401,
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2_2",
|
||||
# "node_position": {
|
||||
# "x": -255.323547,
|
||||
# "y": -44.695679
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_1",
|
||||
# "node_position": {
|
||||
# "x": -252.698792,
|
||||
# "y": -201.368988
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 71939,
|
||||
# "type": "dilate_pass_1"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_3",
|
||||
# "node_position": {
|
||||
# "x": -31.698792,
|
||||
# "y": -72.368988
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 0
|
||||
# },
|
||||
# "type": "dilate_pass_3"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_4",
|
||||
# "node_position": {
|
||||
# "x": -31.689392,
|
||||
# "y": -186.577301
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "distance": 0,
|
||||
# "s": 9
|
||||
# },
|
||||
# "type": "dilate_pass_2"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2_3",
|
||||
# "node_position": {
|
||||
# "x": -46.966125,
|
||||
# "y": -0.711548
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "default_color",
|
||||
# "node_position": {
|
||||
# "x": -469.868713,
|
||||
# "y": -98.02066
|
||||
# },
|
||||
# "parameters": {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1,
|
||||
# "type": "Color"
|
||||
# }
|
||||
# },
|
||||
# "type": "default_color"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 9,
|
||||
# "param1": 0.1,
|
||||
# "param2": 0,
|
||||
# "param3": 0
|
||||
# },
|
||||
# "shortdesc": "Dilate",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_1.mmg
|
||||
|
||||
#{
|
||||
# "name": "distance_pass_1",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 8258,
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec3 $(name)_distance_h(vec2 uv) {\n\tvec2 e = vec2(1.0/$s, 0.0);\n\tint steps = int($s*$d);\n\tfloat rv = 0.0;\n\tvec2 source_uv;\n\tfor (int i = 0; i < steps; ++i) {\n\t\tsource_uv = uv+float(i)*e;\n\t\tif ($in(source_uv) > 0.5) {\n\t\t\trv = 1.0-float(i)*e.x/$d;\n\t\t\tbreak;\n\t\t}\n\t\tsource_uv = uv-float(i)*e;\n\t\tif ($in(source_uv) > 0.5) {\n\t\t\trv = 1.0-float(i)*e.x/$d;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn vec3(rv, source_uv);\n}\n",
|
||||
# "name": "Distance pass 1",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$(name)_distance_h($uv)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_2.mmg
|
||||
|
||||
#{
|
||||
# "name": "dilate_pass_2",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.25,
|
||||
# "distance": 0,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 44978,
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "float dilate_distance_euclidian(float x, float y, float d) {\n\treturn 1.0-sqrt((1.0-x)*(1.0-x)+y*y/d/d);\n}\n\nfloat dilate_distance_manhattan(float x, float y, float d) {\n\treturn 1.0-(abs(1.0-x)+abs(y)/d);\n}\n\nfloat dilate_distance_chebyshev(float x, float y, float d) {\n\treturn 1.0-max(abs(1.0-x), abs(y)/d);\n}\n\n",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec3 $(name)_distance_v(vec2 uv) {\n\tvec2 e = vec2(0.0, 1.0/$s);\n\tint steps = int($s*$d);\n\tvec3 p = $in(uv);\n\tfor (int i = 0; i < steps; ++i) {\n\t\tvec2 dx = float(i)*e;\n\t\tvec3 p2 = $in(uv+dx);\n\t\tif (p2.x > p.x) {\n\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);\n\t\t\tp = mix(p, p2, step(p.x, p2.x));\n\t\t}\n\t\tp2 = $in(uv-dx);\n\t\tif (p2.x > p.x) {\n\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);\n\t\t\tp = mix(p, p2, step(p.x, p2.x));\n\t\t}\n\t}\n\treturn p;\n}\n",
|
||||
# "name": "Distance pass 2",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$(name)_distance_v($uv)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "",
|
||||
# "name": "distance",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Euclidian",
|
||||
# "value": "euclidian"
|
||||
# },
|
||||
# {
|
||||
# "name": "Manhattan",
|
||||
# "value": "manhattan"
|
||||
# },
|
||||
# {
|
||||
# "name": "Chebyshev",
|
||||
# "value": "chebyshev"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_3.mmg
|
||||
|
||||
#{
|
||||
# "name": "distance_pass_3",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 0
|
||||
# },
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "name": "distance",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "name": "source",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "",
|
||||
# "name": "Distance pass 3",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$source($distance($uv).yz)*mix($distance($uv).x, 1.0, $amount)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "amount",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
@ -1,223 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
#An edge detect filter that detects edges along all directions and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec3 e_base = vec3(1.0/$size, -1.0/$size, 0);\n\tvec3 ref = $in(uv);\n\tvec3 e = vec3(0);\n\tfloat rv = 0.0;\n\tfor (int i = 0; i < int($width); ++i) {\n\t\te += e_base;\n\t\trv += length($in(uv+e.xy)-ref);\n\t\trv += length($in(uv-e.xy)-ref);\n\t\trv += length($in(uv+e.xx)-ref);\n\t\trv += length($in(uv-e.xx)-ref);\n\t\trv += length($in(uv+e.xz)-ref);\n\t\trv += length($in(uv-e.xz)-ref);\n\t\trv += length($in(uv+e.zx)-ref);\n\t\trv += length($in(uv-e.zx)-ref);\n\t\trv *= 2.0;\n\t}\n\treturn rv*pow(2.0, -$width);\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp(100.0*($(name)_fct($uv)-$threshold), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Width",
|
||||
# "max": 5,
|
||||
# "min": 1,
|
||||
# "name": "width",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Threshold",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "threshold",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_1.mmg
|
||||
#An edge detect filter that detects edges along all directions and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec3 e = vec3(1.0/$size, -1.0/$size, 0);\n\tvec3 rv = 8.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.xx);\n\trv -= $in(uv-e.xx);\n\trv -= $in(uv+e.xz);\n\trv -= $in(uv-e.xz);\n\trv -= $in(uv+e.zx);\n\trv -= $in(uv-e.zx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_2.mmg
|
||||
#An edge detect filter that detects edges horizontally and vertically and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(1.0/$size, 0.0);\n\tvec3 rv = 4.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.yx);\n\trv -= $in(uv-e.yx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_3.mmg
|
||||
#An edge detect filter that detects edges along diagonals and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(1.0/$size, -1.0/$size);\n\tvec3 rv = 4.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.xx);\n\trv -= $in(uv-e.xx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mul_detect.mmg
|
||||
|
||||
# "code": "float $(name_uv)_d = ($in($uv)-$v)/$t;",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "label": "",
|
||||
# "name": "mul",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "",
|
||||
# "name": "MulDetect",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$mul($uv)*clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0)",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Value",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "v",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.1,
|
||||
# "label": "Tolerance",
|
||||
# "max": 1,
|
||||
# "min": 0.01,
|
||||
# "name": "t",
|
||||
# "step": 0.001,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
@ -1,559 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#fill.mmg
|
||||
#Fills areas defined by white outlines of its input
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "iterate_buffer",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "iterate_buffer",
|
||||
# "from_port": 1,
|
||||
# "to": "fill_iterate",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "fill_iterate",
|
||||
# "from_port": 0,
|
||||
# "to": "iterate_buffer",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "fill_preprocess",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "fill_preprocess",
|
||||
# "from_port": 0,
|
||||
# "to": "iterate_buffer",
|
||||
# "to_port": 0
|
||||
# }
|
||||
# ],
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "iterate_buffer",
|
||||
# "node_position": {
|
||||
# "x": -129.307083,
|
||||
# "y": -370.480591
|
||||
# },
|
||||
# "parameters": {
|
||||
# "iterations": 10,
|
||||
# "size": 8
|
||||
# },
|
||||
# "seed_value": 29168,
|
||||
# "type": "iterate_buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -542.307068,
|
||||
# "y": -370.662445
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The input image whose white outlines must be filled",
|
||||
# "name": "port0",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": 198.267258,
|
||||
# "y": -362.662445
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "Generates fill data, to be connected to a fill companion node",
|
||||
# "name": "port0",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -171.110138,
|
||||
# "y": -541.509705
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 8,
|
||||
# "param1": 10
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "iterate_buffer",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "fill_preprocess",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "fill_iterate",
|
||||
# "widget": "s"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The resolution of the inptu image",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "iterate_buffer",
|
||||
# "widget": "iterations"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The number of iterations of the algorithm. The optimal value depends a lot on the input image.",
|
||||
# "name": "param1",
|
||||
# "shortdesc": "Iterations",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "fill_iterate",
|
||||
# "node_position": {
|
||||
# "x": -92.913391,
|
||||
# "y": -290.886963
|
||||
# },
|
||||
# "parameters": {
|
||||
# "s": 8
|
||||
# },
|
||||
# "type": "fill_iterate"
|
||||
# },
|
||||
# {
|
||||
# "name": "fill_preprocess",
|
||||
# "node_position": {
|
||||
# "x": -110.443481,
|
||||
# "y": -427.202026
|
||||
# },
|
||||
# "parameters": {
|
||||
# "s": 8
|
||||
# },
|
||||
# "type": "fill_preprocess"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 8,
|
||||
# "param1": 10
|
||||
# },
|
||||
# "shortdesc": "Fill",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#fill_iterate.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 $(name)_fill(vec2 uv) {\n\tfloat size = $s;\n\tint iterations = min(int(size), 256);\n\tvec4 color = $in(fract(uv));\n\tif (color.z+color.w < 1.0/size) {\n\t\treturn vec4(0.0);\n\t}\n\tvec2 offsets[8] = { vec2(1.0, 0.0), vec2(-1.0, 0.0), vec2(0.0, 1.0), vec2(0.0, -1.0), vec2(1.0, 1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(-1.0, -1.0) };\n\tfor (int o = 0; o < 8; ++o) {\n\t\tvec2 uv2 = uv;\n\t\tvec2 offset = offsets[o]/size;\n\t\tfor (int i = 1; i < iterations; i += 1) {\n\t\t\tuv2 += offset;\n\t\t\tvec4 color2 = $in(fract(uv2));\n\t\t\tif (color2.z+color2.w == 0.0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvec2 p1 = color.xy+floor(uv-color.xy);\n\t\t\tvec2 p2 = color2.xy+floor(uv2-color2.xy);\n\t\t\tvec2 p = min(p1, p2);\n\t\t\tvec2 s = max(p1+color.zw, p2+color2.zw)-p;\n\t\t\tcolor = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(fract(p), s), step(s.xyxy, vec4(1.0)));\n\t\t}\n\t}\n\treturn floor(color*size)/size;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgba": "$(name)_fill($uv)",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#fill_preprocess.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgba": "flood_fill_preprocess($uv, $in($uv), $s)",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 10,
|
||||
# "first": 0,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ]
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------
|
||||
#fill_to_color.mmg
|
||||
#A fill companion node that fills each area with a color taken from a color map image
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The image from which colors are taken",
|
||||
# "name": "map",
|
||||
# "shortdesc": "Color map",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output image",
|
||||
# "rgba": "mix($edgecolor, $map(fract($(name_uv)_bb.xy+0.5*$(name_uv)_bb.zw)), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "Edge Color",
|
||||
# "longdesc": "The color used to draw outlines",
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_position.mmg
|
||||
#A fill companion node that fills each area with a greyscale value that depends on its position
|
||||
|
||||
# "code": "vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$axis",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "",
|
||||
# "longdesc": "The position value to be used:\n- X for horizontal axis\n- Y for vertical axis\n- Radial for distance to center",
|
||||
# "name": "axis",
|
||||
# "shortdesc": "Position",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "X",
|
||||
# "value": "$(name_uv)_c.x"
|
||||
# },
|
||||
# {
|
||||
# "name": "Y",
|
||||
# "value": "$(name_uv)_c.y"
|
||||
# },
|
||||
# {
|
||||
# "name": "Radial",
|
||||
# "value": "length($(name_uv)_c-vec2(0.5))"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_random_color.mmg
|
||||
#A fill companion node that fills each area with a random color
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output image",
|
||||
# "rgb": "mix($edgecolor.rgb, rand3(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "Edge Color",
|
||||
# "longdesc": "The color used for outlines",
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_random_grey.mmg
|
||||
#A fill companion node that fills each area with a random greyscale value
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "mix($edgecolor, rand(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Edge color",
|
||||
# "longdesc": "The value used for the outlines",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_size.mmg
|
||||
#A fill companion node that fills each area with a greyscale value that depends on its size
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$formula",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The size value to be used (area, width, height or maximum between width and height)",
|
||||
# "name": "formula",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Area",
|
||||
# "value": "sqrt($(name_uv)_bb.z*$(name_uv)_bb.w)"
|
||||
# },
|
||||
# {
|
||||
# "name": "Width",
|
||||
# "value": "$(name_uv)_bb.z"
|
||||
# },
|
||||
# {
|
||||
# "name": "Height",
|
||||
# "value": "$(name_uv)_bb.w"
|
||||
# },
|
||||
# {
|
||||
# "name": "max(W, H)",
|
||||
# "value": "max($(name_uv)_bb.z, $(name_uv)_bb.w)"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_uv.mmg
|
||||
#A fill companion node that generated an UV map that follows each filled area
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output UV map, to be connected to a Custom UV node",
|
||||
# "rgb": "fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The mode decides how the UVs are layed out on each bounding box:\n- Stretch mode where the UV layout is stretched to the bounding box. \n- Square mode where the UV layout is even and centerered based on the longest axis of the bounding box.",
|
||||
# "name": "mode",
|
||||
# "shortdesc": "Mode",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Stretch",
|
||||
# "value": "stretch"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#vec4 flood_fill_preprocess(vec2 uv, float c, float s) {
|
||||
# if (c > 0.5) {
|
||||
# return vec4(0.0);
|
||||
# } else {
|
||||
# return vec4(floor(uv*s)/s, vec2(1.0/s));
|
||||
# }
|
||||
#}
|
||||
|
||||
static func flood_fill_preprocess(uv : Vector2, c : float, s : float) -> Color:
|
||||
if (c > 0.5):
|
||||
return Color(0, 0, 0, 0)
|
||||
else:
|
||||
uv = Commons.floorv2(uv * s) / s
|
||||
var f : float = 1.0 / s
|
||||
return Color(uv.x, uv.y, f, f)
|
||||
|
||||
#vec3 fill_to_uv_stretch(vec2 coord, vec4 bb, float seed) {
|
||||
# vec2 uv_islands = fract(coord-bb.xy)/bb.zw;
|
||||
# float random_value = rand(vec2(seed)+bb.xy+bb.zw);
|
||||
# return vec3(uv_islands, random_value);
|
||||
#}
|
||||
|
||||
static func fill_to_uv_stretch(coord : Vector2, bb : Color, pseed : float) -> Vector3:
|
||||
var uv_islands : Vector2 = Commons.fractv2(coord - Vector2(bb.r, bb.g)) / Vector2(bb.b, bb.a)
|
||||
var random_value : float = Commons.rand(Vector2(pseed, pseed) + Vector2(bb.r, bb.g) + Vector2(bb.b, bb.a))
|
||||
return Vector3(uv_islands.x, uv_islands.y, random_value)
|
||||
|
||||
#vec3 fill_to_uv_square(vec2 coord, vec4 bb, float seed) {
|
||||
# vec2 uv_islands;
|
||||
#
|
||||
# if (bb.z > bb.w) {
|
||||
# vec2 adjusted_coord = coord + vec2(0.0, (bb.z - bb.w) / 2.0);
|
||||
# uv_islands = fract(adjusted_coord-bb.xy)/bb.zz;
|
||||
# } else {
|
||||
# vec2 adjusted_coord = coord + vec2((bb.w - bb.z) / 2.0, 0.0);
|
||||
# uv_islands = fract(adjusted_coord-bb.xy)/bb.ww;
|
||||
# }
|
||||
#
|
||||
# float random_value = rand(vec2(seed)+bb.xy+bb.zw);
|
||||
# return vec3(uv_islands, random_value);
|
||||
#}
|
||||
|
||||
static func fill_to_uv_square(coord : Vector2, bb : Color, pseed : float) -> Vector3:
|
||||
var uv_islands : Vector2 = Vector2()
|
||||
|
||||
if (bb.b > bb.a):
|
||||
var adjusted_coord : Vector2 = coord + Vector2(0.0, (bb.b - bb.a) / 2.0);
|
||||
uv_islands = Commons.fractv2(adjusted_coord - Vector2(bb.r, bb.g)) / Vector2(bb.b, bb.b)
|
||||
else:
|
||||
var adjusted_coord : Vector2 = coord + Vector2((bb.a - bb.b) / 2.0, 0.0);
|
||||
uv_islands = Commons.fractv2(adjusted_coord - Vector2(bb.r, bb.g)) / Vector2(bb.a, bb.a)
|
||||
|
||||
var random_value : float = Commons.rand(Vector2(pseed, pseed) + Vector2(bb.r, bb.g) + Vector2(bb.b, bb.a))
|
||||
return Vector3(uv_islands.x, uv_islands.y, random_value)
|
File diff suppressed because it is too large
Load Diff
@ -1,225 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#note: data : PoolRealArray -> pos, r, g, b, a, pos, r, g, b, a ....
|
||||
|
||||
#gradient.mmg
|
||||
|
||||
#float $(name_uv)_r = 0.5+(cos($rotate*0.01745329251)*($uv.x-0.5)+sin($rotate*0.01745329251)*($uv.y-0.5))/(cos(abs(mod($rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);"
|
||||
|
||||
#output: $gradient(fract($(name_uv)_r*$repeat))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
#rotate: default: 0, min: -180, max: 180, step: 0.1
|
||||
|
||||
#default: "interpolation": 1,
|
||||
# "points": [{"a": 1,"b": 0,"g": 0,"pos": 0,"r": 0},{"a": 1,"b": 1,"g": 1,"pos": 1,"r": 1} ],
|
||||
|
||||
#radial_gradient.mmg
|
||||
|
||||
#output: $gradient(fract($repeat*1.41421356237*length(fract($uv)-vec2(0.5, 0.5))))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
|
||||
#circular_gradient.mmg
|
||||
|
||||
#output: gradient(fract($repeat*0.15915494309*atan($uv.y-0.5, $uv.x-0.5)))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
|
||||
#gradient.gd
|
||||
|
||||
static func radial_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_2(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_2(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_3(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_3(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
|
||||
|
||||
static func normal_gradient_type_1(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_1(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_2(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_2(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_3(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_3(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_4(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_4(Commons.fractf(rr * repeat), data)
|
||||
|
||||
|
||||
|
||||
static func circular_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_2(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_2(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_3(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_3(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
|
||||
static func gradient_type_1(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size() - 5, 5):
|
||||
if x < 0.5 * (data[i] + data[i + 5]):
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func gradient_type_2(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size(), 5):
|
||||
if x < data[i]:
|
||||
if i == 0:
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var cprev : Color = Color(data[i - 4], data[i - 3], data[i - 2], data[i - 1])
|
||||
var ccurr : Color = Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return lerp(cprev, ccurr, (x - data[i - 5]) / (data[i] - data[i - 5]));
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func gradient_type_3(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size(), 5):
|
||||
if x < data[i]:
|
||||
if i == 0:
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var cprev : Color = Color(data[i - 4], data[i - 3], data[i - 2], data[i - 1])
|
||||
var ccurr : Color = Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return lerp(cprev, ccurr, 0.5 - 0.5 * cos(3.14159265359 * ((x - data[i - 5]) / (data[i] - data[i - 5]))))
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func get_data_color(index : int, data : PoolRealArray) -> Color:
|
||||
var i : int = index * 5
|
||||
|
||||
return Color(data[i + 1], data[i + 2],data[i + 3], data[i + 4])
|
||||
|
||||
static func get_data_pos(index : int, data : PoolRealArray) -> float:
|
||||
return data[index * 5]
|
||||
|
||||
static func gradient_type_4(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return get_data_color(i, data)
|
||||
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.a)
|
||||
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
return get_data_color(ds - 1, data)
|
||||
|
||||
#todo make it selectable
|
||||
static func gradient_type_5(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return get_data_color(i, data)
|
||||
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i+1, data), get_data_color(i+2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.a)
|
||||
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
return get_data_color(ds - 1, data)
|
@ -1,705 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#mwf_create_map.mmg
|
||||
#Creates a workflow map using a heightmap and an optional seed map. The workflow map contains height information as well as orientation and a seed for random offset for the material it will be applied to.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input height map",
|
||||
# "name": "h",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input offset seed map",
|
||||
# "name": "o",
|
||||
# "shortdesc": "Offset",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated workflow map, to be connected to a MixMap or an ApplyMap node",
|
||||
# "rgb": "vec3($height*$h($uv), $angle*0.00277777777+0.5, rand(vec2(float($seed)+$o($uv))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Height",
|
||||
# "longdesc": "The maximum height of the workflow map, used as multiplier for the input height map",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "height",
|
||||
# "shortdesc": "Height",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Angle",
|
||||
# "longdesc": "The angle stored in the workflow map",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "angle",
|
||||
# "shortdesc": "Angle",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_mix_maps.mmg
|
||||
#Mixes up to 4 workflow maps, to be used with the same base material
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The first workflow map",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The second workflow map",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The third input map",
|
||||
# "name": "in3",
|
||||
# "shortdesc": "Input3",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The fourth input map",
|
||||
# "name": "in4",
|
||||
# "shortdesc": "Input4",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Generates a merged workflow map",
|
||||
# "rgb": "matmap_mix(matmap_mix($in1($uv), $in2($uv)), matmap_mix($in3($uv), $in4($uv)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_map.mmg
|
||||
#"Applies a workflow map to a base material, and generates height information as well as PBR channels for the result.\nThe height input must be connected to a Create Map or Mix Maps node. The other inputs must be connected to a base material.\nThe outputs must be connected to the Mix or the Output node, or a workflow filter node.
|
||||
|
||||
# "code": "float $(name_uv)_angle = 6.28318530718*($map($uv).y-0.5);\nvec2 $(name_uv)_uv = matmap_uv($uv, $(name_uv)_angle, $map($uv).z);\n",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0, 0.5, 0.0)",
|
||||
# "label": "Map",
|
||||
# "longdesc": "The input workflow map",
|
||||
# "name": "map",
|
||||
# "shortdesc": "Map",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "group_size": 4,
|
||||
# "label": "Albedo",
|
||||
# "longdesc": "The Albedo channel of the input base material",
|
||||
# "name": "mat1",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the input material",
|
||||
# "name": "mat2",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission",
|
||||
# "longdesc": "The emission channel of the input material",
|
||||
# "name": "mat3",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal",
|
||||
# "longdesc": "The normal map of the input material",
|
||||
# "name": "mat4",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$map($uv).x",
|
||||
# "group_size": 5,
|
||||
# "longdesc": "The height map of the result",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The albedo channel of the result",
|
||||
# "rgb": "$mat1($(name_uv)_uv)",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the result",
|
||||
# "rgb": "$mat2($(name_uv)_uv)",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The emission channel of the result",
|
||||
# "rgb": "$mat3($(name_uv)_uv)",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The normal map of the result",
|
||||
# "rgb": "matmap_rotate_nm($mat4($(name_uv)_uv), -$(name_uv)_angle)",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_mix.mmg
|
||||
#Combines the outputs of 2 mapped base materials (keeping the \"highest\" material).
|
||||
|
||||
# "code": "float $(name_uv)_a1 = step($h1($uv), $h2($uv));",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "group_size": 5,
|
||||
# "label": "Height 1",
|
||||
# "longdesc": "The height map of the first input",
|
||||
# "name": "h1",
|
||||
# "shortdesc": "Height1",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Albedo 1",
|
||||
# "longdesc": "The albedo channel of the first input",
|
||||
# "name": "c1",
|
||||
# "shortdesc": "Albedo1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM 1",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the first input",
|
||||
# "name": "orm1",
|
||||
# "shortdesc": "ORM1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission 1",
|
||||
# "longdesc": "The emission channel of the first input",
|
||||
# "name": "em1",
|
||||
# "shortdesc": "Emission1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal 1",
|
||||
# "longdesc": "The normal map of the first input",
|
||||
# "name": "nm1",
|
||||
# "shortdesc": "Normal1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "group_size": 5,
|
||||
# "label": "Height 2",
|
||||
# "longdesc": "The height map of the second input",
|
||||
# "name": "h2",
|
||||
# "shortdesc": "Height2",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Albedo 2",
|
||||
# "longdesc": "The albedo channel of the second input",
|
||||
# "name": "c2",
|
||||
# "shortdesc": "Albedo2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM 2",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the second input",
|
||||
# "name": "orm2",
|
||||
# "shortdesc": "ORM2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission 2",
|
||||
# "longdesc": "The emission channel of the second input",
|
||||
# "name": "em2",
|
||||
# "shortdesc": "Emission2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal 2",
|
||||
# "longdesc": "The normal map of the second input",
|
||||
# "name": "nm2",
|
||||
# "shortdesc": "Normal2",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "max($h1($uv), $h2($uv))",
|
||||
# "group_size": 5,
|
||||
# "longdesc": "Generates the height of the result",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output albedo channel",
|
||||
# "rgb": "mix($c1($uv), $c2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output ambient occlusion, roughness and metallic channels",
|
||||
# "rgb": "mix($orm1($uv), $orm2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output emission channel",
|
||||
# "rgb": "mix($em1($uv), $em2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output normal map",
|
||||
# "rgb": "mix($nm1($uv), $nm2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
|
||||
#----------------------
|
||||
#mwf_output.mmg
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "colorize_3",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 6
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "colorize_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "occlusion",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "occlusion",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 5
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 2,
|
||||
# "to": "decompose",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "decompose",
|
||||
# "from_port": 1,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 2
|
||||
# },
|
||||
# {
|
||||
# "from": "decompose",
|
||||
# "from_port": 2,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "blend_2",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 4
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 1,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 3,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 3
|
||||
# },
|
||||
# {
|
||||
# "from": "brightness_contrast",
|
||||
# "from_port": 0,
|
||||
# "to": "blend_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 4,
|
||||
# "to": "brightness_contrast",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "normal_map_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "normal_map_2",
|
||||
# "from_port": 0,
|
||||
# "to": "blend_2",
|
||||
# "to_port": 1
|
||||
# }
|
||||
# ],
|
||||
# "label": "Output",
|
||||
# "longdesc": "Converts a workflow mapped material (from an Apply Map or a Mix node) for a Material node",
|
||||
# "name": "mwf_output",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "colorize_3",
|
||||
# "node_position": {
|
||||
# "x": -939.637451,
|
||||
# "y": 871.842407
|
||||
# },
|
||||
# "parameters": {
|
||||
# "gradient": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 0,
|
||||
# "r": 1
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 1,
|
||||
# "r": 0
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# }
|
||||
# },
|
||||
# "type": "colorize"
|
||||
# },
|
||||
# {
|
||||
# "name": "occlusion",
|
||||
# "node_position": {
|
||||
# "x": -994.845825,
|
||||
# "y": 786.968262
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 10,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "type": "occlusion"
|
||||
# },
|
||||
# {
|
||||
# "name": "decompose",
|
||||
# "node_position": {
|
||||
# "x": -924.371338,
|
||||
# "y": 570.25
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "type": "decompose"
|
||||
# },
|
||||
# {
|
||||
# "name": "blend_2",
|
||||
# "node_position": {
|
||||
# "x": -931.305542,
|
||||
# "y": 677.328491
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 1,
|
||||
# "blend_type": 4
|
||||
# },
|
||||
# "type": "blend"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -1626.805542,
|
||||
# "y": 608.758606
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 5,
|
||||
# "name": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": -635.305542,
|
||||
# "y": 597.758606
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 7,
|
||||
# "longdesc": "",
|
||||
# "name": "Albedo",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Metallic",
|
||||
# "shortdesc": "Metallic",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Roughness",
|
||||
# "shortdesc": "Roughness",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Emission",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Normal",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Occlusion",
|
||||
# "shortdesc": "Occlusion",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Depth",
|
||||
# "shortdesc": "Depth",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -1104.881836,
|
||||
# "y": 425.25
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 1,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "Occlusion",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "occlusion",
|
||||
# "widget": "param2"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The strength of the calculated occlusion effect",
|
||||
# "name": "param2",
|
||||
# "shortdesc": "Occlusion",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "Mat Normal",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "blend_2",
|
||||
# "widget": "amount"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The strength of normals from the base materials (compared to the normal generated from height information))",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "MatNormal",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "brightness_contrast",
|
||||
# "node_position": {
|
||||
# "x": -1177.223877,
|
||||
# "y": 677.062317
|
||||
# },
|
||||
# "parameters": {
|
||||
# "brightness": 0,
|
||||
# "contrast": 1
|
||||
# },
|
||||
# "type": "brightness_contrast"
|
||||
# },
|
||||
# {
|
||||
# "name": "normal_map_2",
|
||||
# "node_position": {
|
||||
# "x": -1152.5,
|
||||
# "y": 544.75
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 10,
|
||||
# "param1": 1.02,
|
||||
# "param2": 0,
|
||||
# "param4": 1
|
||||
# },
|
||||
# "type": "normal_map"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 1,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "shortdesc": "Output",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
|
||||
#vec3 matmap_mix(vec3 in1, vec3 in2) {\n\t
|
||||
# float is_in1 = step(in2.x, in1.x);\n\t
|
||||
# //return vec3(max(in1.x, in2.x), in1.yz*is_in1+in2.yz*(1.0-is_in1));\n\t
|
||||
# return vec3(max(in1.x, in2.x), mix(in2.yz, in1.yz, is_in1));\n
|
||||
#}
|
||||
|
||||
#vec2 matmap_uv(vec2 uv, float angle, float seed) {\n\t
|
||||
# uv -= vec2(0.5);\n\tvec2 rv;\n\t
|
||||
# rv.x = uv.x*cos(angle)+uv.y*sin(angle);\n\t
|
||||
# rv.y = -uv.x*sin(angle)+uv.y*cos(angle);\n\t
|
||||
# return fract(rv + rand2(vec2(seed)));\n
|
||||
#}
|
||||
|
||||
#vec3 matmap_rotate_nm(vec3 input, float angle) {\n\t
|
||||
# vec2 uv = input.xy - vec2(0.5);\n\t
|
||||
# vec2 rv;\n\t
|
||||
# rv.x = uv.x*cos(angle)+uv.y*sin(angle);\n\t
|
||||
# rv.y = -uv.x*sin(angle)+uv.y*cos(angle);\n\t
|
||||
# return vec3(rv + vec2(0.5), input.z);\n
|
||||
#}
|
||||
|
@ -1,691 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#fbm2.mmg (and fbm.mmg)
|
||||
|
||||
#Output:
|
||||
#$(name)_fbm($(uv), vec2($(scale_x), $(scale_y)), int($(folds)), int($(iterations)), $(persistence), float($(seed)))
|
||||
|
||||
#Instance:
|
||||
#float $(name)_fbm(vec2 coord, vec2 size, int folds, int octaves, float persistence, float seed) {
|
||||
# float normalize_factor = 0.0;
|
||||
# float value = 0.0;
|
||||
# float scale = 1.0;
|
||||
#
|
||||
# for (int i = 0; i < octaves; i++) {
|
||||
# float noise = fbm_$noise(coord*size, size, seed);
|
||||
#
|
||||
# for (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;
|
||||
#}
|
||||
|
||||
#Inputs:
|
||||
#noise, enum, default: 2, values: Value, Perlin, Simplex, Cellular, Cellular2, Cellular3, Cellular4, Cellular5, Cellular6
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#folds, float, default: 0, min: 0, max: 5, step: 1
|
||||
#iterations (octaves), float, default: 3, min: 1, max: 10, step: 1
|
||||
#persistence, float, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
|
||||
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, 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, 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 simplex(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = fbm_simplexf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
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, 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, 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, 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, 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, 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)
|
||||
|
||||
|
||||
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++) {
|
||||
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, 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++) {
|
||||
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, 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++) {
|
||||
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 fbm_simplexf(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++) {
|
||||
var noise : float = fbm_simplex(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, 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++) {
|
||||
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, 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++) {
|
||||
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, 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++) {
|
||||
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, 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++) {
|
||||
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, 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++) {
|
||||
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, 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++) {
|
||||
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;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
|
||||
#float fbm_value(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
#
|
||||
# float p00 = rand(mod(o, size));
|
||||
# float p01 = rand(mod(o + vec2(0.0, 1.0), size));
|
||||
# float p10 = rand(mod(o + vec2(1.0, 0.0), size));
|
||||
# float p11 = rand(mod(o + vec2(1.0, 1.0), size));
|
||||
#
|
||||
# vec2 t = f * f * (3.0 - 2.0 * f);
|
||||
#
|
||||
# return mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);
|
||||
#}
|
||||
|
||||
static func fbm_value(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var p00 : float = Commons.rand(Commons.modv2(o, size));
|
||||
var p01 : float = Commons.rand(Commons.modv2(o + Vector2(0.0, 1.0), size));
|
||||
var p10 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 0.0), size));
|
||||
var p11 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 1.0), size));
|
||||
|
||||
var t : Vector2 = f * f * (Vector2(3, 3) - 2.0 * f);
|
||||
return lerp(lerp(p00, p10, t.x), lerp(p01, p11, t.x), t.y);
|
||||
|
||||
|
||||
#float fbm_perlin(vec2 coord, vec2 size, float seed) {
|
||||
# tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
#
|
||||
# float a00 = rand(mod(o, size)) * 6.28318530718;
|
||||
# float a01 = rand(mod(o + vec2(0.0, 1.0), size)) * 6.28318530718;
|
||||
# float a10 = rand(mod(o + vec2(1.0, 0.0), size)) * 6.28318530718;
|
||||
# float a11 = rand(mod(o + vec2(1.0, 1.0), size)) * 6.28318530718;
|
||||
#
|
||||
# vec2 v00 = vec2(cos(a00), sin(a00));
|
||||
# vec2 v01 = vec2(cos(a01), sin(a01));
|
||||
# vec2 v10 = vec2(cos(a10), sin(a10));
|
||||
# vec2 v11 = vec2(cos(a11), sin(a11));
|
||||
#
|
||||
# float p00 = dot(v00, f);
|
||||
# float p01 = dot(v01, f - vec2(0.0, 1.0));
|
||||
# float p10 = dot(v10, f - vec2(1.0, 0.0));
|
||||
# float p11 = dot(v11, f - vec2(1.0, 1.0));
|
||||
#
|
||||
# vec2 t = f * f * (3.0 - 2.0 * f);
|
||||
#
|
||||
# return 0.5 + mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);
|
||||
#}
|
||||
|
||||
static func fbm_perlin(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var a00 : float = Commons.rand(Commons.modv2(o, size)) * 6.28318530718;
|
||||
var a01 : float = Commons.rand(Commons.modv2(o + Vector2(0.0, 1.0), size)) * 6.28318530718;
|
||||
var a10 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 0.0), size)) * 6.28318530718;
|
||||
var a11 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 1.0), size)) * 6.28318530718;
|
||||
var v00 : Vector2 = Vector2(cos(a00), sin(a00));
|
||||
var v01 : Vector2 = Vector2(cos(a01), sin(a01));
|
||||
var v10 : Vector2 = Vector2(cos(a10), sin(a10));
|
||||
var v11 : Vector2 = Vector2(cos(a11), sin(a11));
|
||||
var p00 : float = v00.dot(f);
|
||||
var p01 : float = v01.dot(f - Vector2(0.0, 1.0));
|
||||
var p10 : float = v10.dot(f - Vector2(1.0, 0.0));
|
||||
var p11 : float = v11.dot(f - Vector2(1.0, 1.0));
|
||||
|
||||
var t : Vector2 = f * f * (Vector2(3, 3) - 2.0 * f);
|
||||
|
||||
return 0.5 + lerp(lerp(p00, p10, t.x), lerp(p01, p11, t.x), t.y);
|
||||
|
||||
#float fbm_perlinabs(vec2 coord, vec2 size, float seed) {
|
||||
# return abs(2.0*fbm_perlin(coord, size, seed)-1.0);
|
||||
#}
|
||||
|
||||
static func fbm_perlinabs(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
return abs(2.0*fbm_perlin(coord, size, pseed)-1.0)
|
||||
|
||||
#vec2 rgrad2(vec2 p, float rot, float seed) {
|
||||
# float u = rand(p + vec2(seed, 1.0-seed));
|
||||
# u = fract(u) * 6.28318530718; // 2*pi
|
||||
# return vec2(cos(u), sin(u));
|
||||
#}
|
||||
|
||||
static func rgrad2(p : Vector2, rot : float, pseed : float) -> Vector2:
|
||||
var u : float = Commons.rand(p + Vector2(pseed, 1.0-pseed));
|
||||
u = Commons.fract(u) * 6.28318530718; # 2*pi
|
||||
return Vector2(cos(u), sin(u))
|
||||
|
||||
#float fbm_simplex(vec2 coord, vec2 size, float seed) {
|
||||
# coord *= 2.0; // needed for it to tile
|
||||
# coord += rand2(vec2(seed, 1.0-seed)) + size;
|
||||
# size *= 2.0; // needed for it to tile
|
||||
# coord.y += 0.001;
|
||||
#
|
||||
# vec2 uv = vec2(coord.x + coord.y*0.5, coord.y);
|
||||
# vec2 i0 = floor(uv); vec2 f0 = fract(uv);
|
||||
# vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
# vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
|
||||
# vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
|
||||
# vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
|
||||
#
|
||||
# i1 = i0 + i1;
|
||||
#
|
||||
# vec2 i2 = i0 + vec2(1.0, 1.0);
|
||||
# vec2 d0 = coord - p0;
|
||||
# vec2 d1 = coord - p1;
|
||||
# vec2 d2 = coord - p2;
|
||||
#
|
||||
# vec3 xw = mod(vec3(p0.x, p1.x, p2.x), size.x);
|
||||
# vec3 yw = mod(vec3(p0.y, p1.y, p2.y), size.y);
|
||||
#
|
||||
# vec3 iuw = xw + 0.5 * yw;
|
||||
# vec3 ivw = yw;
|
||||
#
|
||||
# vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), 0.0, seed);
|
||||
# vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), 0.0, seed);
|
||||
# vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), 0.0, seed);
|
||||
#
|
||||
# vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
|
||||
# vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
|
||||
#
|
||||
# t = max(t, vec3(0.0));
|
||||
# vec3 t2 = t * t;
|
||||
# vec3 t4 = t2 * t2;
|
||||
# float n = dot(t4, w);
|
||||
#
|
||||
# return 0.5 + 5.5 * n;
|
||||
#}
|
||||
|
||||
static func fbm_simplex(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
coord *= 2.0; # needed for it to tile
|
||||
coord += Commons.rand2(Vector2(pseed, 1.0-pseed)) + size;
|
||||
size *= 2.0; # needed for it to tile
|
||||
coord.y += 0.001;
|
||||
|
||||
var uv : Vector2 = Vector2(coord.x + coord.y*0.5, coord.y);
|
||||
var i0 : Vector2 = Commons.floorv2(uv);
|
||||
var f0 : Vector2 = Commons.fractv2(uv);
|
||||
var i1 : Vector2
|
||||
|
||||
if (f0.x > f0.y):
|
||||
i1 = Vector2(1.0, 0.0)
|
||||
else:
|
||||
i1 = Vector2(0.0, 1.0);
|
||||
|
||||
var p0 : Vector2 = Vector2(i0.x - i0.y * 0.5, i0.y);
|
||||
var p1 : Vector2 = Vector2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
|
||||
var p2 : Vector2 = Vector2(p0.x + 0.5, p0.y + 1.0);
|
||||
|
||||
i1 = i0 + i1;
|
||||
|
||||
var i2 : Vector2 = i0 + Vector2(1.0, 1.0);
|
||||
var d0 : Vector2 = coord - p0;
|
||||
var d1 : Vector2 = coord - p1;
|
||||
var d2 : Vector2 = coord - p2;
|
||||
|
||||
var xw : Vector3 = Commons.modv3(Vector3(p0.x, p1.x, p2.x), Vector3(size.x, size.x, size.x));
|
||||
var yw : Vector3 = Commons.modv3(Vector3(p0.y, p1.y, p2.y), Vector3(size.y, size.y, size.y));
|
||||
|
||||
var iuw : Vector3 = xw + 0.5 * yw;
|
||||
var ivw : Vector3 = yw;
|
||||
|
||||
var g0 : Vector2 = rgrad2(Vector2(iuw.x, ivw.x), 0.0, pseed);
|
||||
var g1 : Vector2 = rgrad2(Vector2(iuw.y, ivw.y), 0.0, pseed);
|
||||
var g2 : Vector2 = rgrad2(Vector2(iuw.z, ivw.z), 0.0, pseed);
|
||||
|
||||
var w : Vector3 = Vector3(g0.dot(d0), g1.dot(d1), g2.dot(d2));
|
||||
var t : Vector3 = Vector3(0.8, 0.8, 0.8) - Vector3(d0.dot(d0), d1.dot(d1), d2.dot(d2));
|
||||
|
||||
t = Commons.maxv3(t, Vector3());
|
||||
var t2 : Vector3 = t * t;
|
||||
var t4 : Vector3 = t2 * t2;
|
||||
var n : float = t4.dot(w);
|
||||
|
||||
return 0.5 + 5.5 * n;
|
||||
|
||||
#float fbm_cellular(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular2(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular2(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
|
||||
var dist : float = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2-min_dist1;
|
||||
|
||||
#float fbm_cellular3(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);
|
||||
# float dist = abs((f - node).x) + abs((f - node).y);
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular3(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size))*0.5 + Vector2(x, y);
|
||||
|
||||
var dist : float = abs((f - node).x) + abs((f - node).y);
|
||||
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular4(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);
|
||||
# float dist = abs((f - node).x) + abs((f - node).y);
|
||||
#
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular4(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size))*0.5 + Vector2(x, y);
|
||||
|
||||
var dist : float = abs((f - node).x) + abs((f - node).y);
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2 - min_dist1;
|
||||
|
||||
#float fbm_cellular5(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = max(abs((f - node).x), abs((f - node).y));
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular5(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = max(abs((f - node).x), abs((f - node).y));
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular6(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = max(abs((f - node).x), abs((f - node).y));
|
||||
#
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular6(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = max(abs((f - node).x), abs((f - node).y));
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2 - min_dist1;
|
@ -1,157 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#perlin.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - Shows a greyscale value noise
|
||||
#perlin($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#iterations, float, min: 0, max: 10, default: 3, step:1
|
||||
#persistence, float, min: 0, max: 1, default: 0.5, step:0.05
|
||||
|
||||
#----------------------
|
||||
#perlin_color.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgb) - Shows a color value noise
|
||||
#perlin_color($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#iterations, float, min: 0, max: 10, default: 3, step:1
|
||||
#persistence, float, min: 0, max: 1, default: 0.5, step:0.05
|
||||
|
||||
static func perlinc(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Color:
|
||||
var f : float = perlin(uv, size, iterations, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
|
||||
#float perlin(vec2 uv, vec2 size, int iterations, float persistence, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# float rv = 0.0;
|
||||
# float coef = 1.0;
|
||||
# float acc = 0.0;
|
||||
#
|
||||
# for (int i = 0; i < iterations; ++i) {
|
||||
# vec2 step = vec2(1.0)/size;
|
||||
# vec2 xy = floor(uv*size);
|
||||
#
|
||||
# float f0 = rand(seed2+mod(xy, size));
|
||||
# float f1 = rand(seed2+mod(xy+vec2(1.0, 0.0), size));
|
||||
# float f2 = rand(seed2+mod(xy+vec2(0.0, 1.0), size));
|
||||
# float f3 = rand(seed2+mod(xy+vec2(1.0, 1.0), size));
|
||||
#
|
||||
# vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));
|
||||
# rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);
|
||||
# acc += coef;
|
||||
# size *= 2.0;
|
||||
# coef *= persistence;
|
||||
# }
|
||||
#
|
||||
# return rv / acc;
|
||||
#}
|
||||
|
||||
static func perlin(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
var rv : float = 0.0;
|
||||
var coef : float = 1.0;
|
||||
var acc : float = 0.0;
|
||||
|
||||
for i in range(iterations):
|
||||
var step : Vector2 = Vector2(1, 1) / size;
|
||||
var xy : Vector2 = Commons.floorv2(uv * size);
|
||||
var f0 : float = Commons.rand(seed2 + Commons.modv2(xy, size));
|
||||
var f1 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(1.0, 0.0), size));
|
||||
var f2 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(0.0, 1.0), size));
|
||||
var f3 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(1.0, 1.0), size));
|
||||
|
||||
var mixval : Vector2 = Commons.smoothstepv2(0.0, 1.0, Commons.fractv2(uv * size));
|
||||
|
||||
rv += coef * lerp(lerp(f0, f1, mixval.x), lerp(f2, f3, mixval.x), mixval.y);
|
||||
acc += coef;
|
||||
size *= 2.0;
|
||||
coef *= persistence;
|
||||
|
||||
return rv / acc;
|
||||
|
||||
#vec3 perlin_color(vec2 uv, vec2 size, int iterations, float persistence, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# vec3 rv = vec3(0.0);
|
||||
# float coef = 1.0;
|
||||
# float acc = 0.0;
|
||||
#
|
||||
# for (int i = 0; i < iterations; ++i) {
|
||||
# vec2 step = vec2(1.0)/size;
|
||||
# vec2 xy = floor(uv*size);
|
||||
# vec3 f0 = rand3(seed2+mod(xy, size));
|
||||
# vec3 f1 = rand3(seed2+mod(xy+vec2(1.0, 0.0), size));
|
||||
# vec3 f2 = rand3(seed2+mod(xy+vec2(0.0, 1.0), size));
|
||||
# vec3 f3 = rand3(seed2+mod(xy+vec2(1.0, 1.0), size));
|
||||
# vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));
|
||||
#
|
||||
# rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);
|
||||
# acc += coef;
|
||||
# size *= 2.0;
|
||||
# coef *= persistence;
|
||||
# }
|
||||
#
|
||||
# return rv / acc;
|
||||
#}
|
||||
|
||||
static func perlin_color(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Vector3:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
var rv : Vector3 = Vector3();
|
||||
var coef : float = 1.0;
|
||||
var acc : float = 0.0;
|
||||
|
||||
for i in range(iterations):
|
||||
var step : Vector2 = Vector2(1, 1) / size;
|
||||
var xy : Vector2 = Commons.floorv2(uv * size);
|
||||
var f0 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy, size));
|
||||
var f1 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(1.0, 0.0), size));
|
||||
var f2 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(0.0, 1.0), size));
|
||||
var f3 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(1.0, 1.0), size));
|
||||
|
||||
var mixval : Vector2 = Commons.smoothstepv2(0.0, 1.0, Commons.fractv2(uv * size));
|
||||
|
||||
rv += coef * lerp(lerp(f0, f1, mixval.x), lerp(f2, f3, mixval.x), mixval.y)
|
||||
acc += coef;
|
||||
size *= 2.0;
|
||||
coef *= persistence;
|
||||
|
||||
return rv / acc;
|
||||
|
||||
static func perlin_colorc(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Color:
|
||||
var f : Vector3 = perlin_color(uv, size, iterations, persistence, pseed)
|
||||
|
||||
return Color(f.x, f.y, f.z, 1)
|
||||
|
||||
static func perlin_warp_1(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int, translate : Vector2, rotate : float, size2 : Vector2) -> Color:
|
||||
var f : float = perlin(uv, size2, iterations, persistence, pseed)
|
||||
var vt : Vector2 = Commons.transform(uv, Vector2(translate.x*(2.0*f-1.0), translate.y*(2.0*f-1.0)), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
var ff : float = perlin(vt, size2, iterations, persistence, pseed)
|
||||
|
||||
return Color(ff, ff, ff, 1)
|
||||
|
||||
static func perlin_warp_2(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int, translate : Vector2, rotate : float, size2 : Vector2) -> Color:
|
||||
var f = perlin(uv, size2, iterations, persistence, pseed)
|
||||
var vt : Vector2 = Commons.transform(uv, Vector2(translate.x*(2.0*f-1.0), translate.y*(2.0*f-1.0)), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
var ff : float = perlin(vt, size2, iterations, persistence, pseed)
|
||||
|
||||
var rgba : Vector3 = Vector3(ff, ff, ff)
|
||||
|
||||
var tf : Vector2 = Commons.transform(uv, Vector2(translate.x * (2.0 * (rgba.dot(Vector3(1, 1, 1) / 3.0) - 1.0)), translate.y*(2.0*(rgba.dot(Vector3(1, 1, 1) /3.0)-1.0))), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
|
||||
var fff : float = perlin(tf, size2, iterations, persistence, pseed);
|
||||
|
||||
return Color(fff, fff, fff, 1)
|
||||
|
@ -1,141 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#voronoi.mmg
|
||||
|
||||
#voronoi_1, 2, 3, 4 -> different outputs
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
|
||||
|
||||
#Nodes - float - A greyscale pattern based on the distance to cell centers
|
||||
#$(name_uv)_xyzw.z
|
||||
|
||||
#Borders - float - A greyscale pattern based on the distance to borders
|
||||
#$(name_uv)_xyzw.w
|
||||
|
||||
#Random color - rgb - A color pattern that assigns a random color to each cell
|
||||
#rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)))
|
||||
|
||||
#Fill - rgba - An output that should be plugged into a Fill companion node
|
||||
#vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))
|
||||
|
||||
#Inputs:
|
||||
|
||||
#scale, min: 1, max: 32, step: 1, default: 4
|
||||
#stretch, min: 0.01, max: 1, step: 0.01, default: 1
|
||||
#intensity, min: 0, max: 1, step: 0.01, default: 0.75
|
||||
#randomness, min: 0, max: 1, step: 0.01, default: 1
|
||||
|
||||
#vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
|
||||
|
||||
#note this is newer than what I have TODO
|
||||
|
||||
#// Based on https://www.shadertoy.com/view/ldl3W8
|
||||
#// The MIT License
|
||||
#// Copyright © 2013 Inigo Quilez
|
||||
#vec3 iq_voronoi(vec2 x, vec2 size, vec2 stretch, float randomness, vec2 seed) {
|
||||
# vec2 n = floor(x);
|
||||
# vec2 f = fract(x);
|
||||
# vec2 mg, mr, mc;
|
||||
# float md = 8.0;
|
||||
#
|
||||
# for (int j=-1; j<=1; j++)
|
||||
# for (int i=-1; i<=1; i++) {
|
||||
# vec2 g = vec2(float(i),float(j));
|
||||
# vec2 o = randomness*rand2(seed + mod(n + g + size, size));
|
||||
# vec2 c = g + o;
|
||||
# vec2 r = c - f;
|
||||
# vec2 rr = r*stretch;
|
||||
# float d = dot(rr,rr);
|
||||
# if (d<md) {
|
||||
# mc = c;
|
||||
# md = d;
|
||||
# mr = r;
|
||||
# mg = g;
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# md = 8.0;
|
||||
#
|
||||
# for (int j=-2; j<=2; j++)
|
||||
# for (int i=-2; i<=2; i++) {
|
||||
# vec2 g = mg + vec2(float(i),float(j));
|
||||
# vec2 o = randomness*rand2(seed + mod(n + g + size, size));
|
||||
# vec2 r = g + o - f;
|
||||
# vec2 rr = (mr-r)*stretch;
|
||||
#
|
||||
# if (dot(rr,rr)>0.00001)
|
||||
# md = min(md, dot(0.5*(mr+r)*stretch, normalize((r-mr)*stretch)));
|
||||
# }
|
||||
#
|
||||
# return vec3(md, mc+n);
|
||||
#}
|
||||
#
|
||||
#vec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, float seed) {
|
||||
# uv *= size;
|
||||
# vec3 v = iq_voronoi(uv, size, stretch, randomness, rand2(vec2(seed, 1.0-seed)));
|
||||
# return vec4(v.yz, intensity*length((uv-v.yz)*stretch), v.x);
|
||||
#}
|
||||
|
||||
static func voronoi(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
uv *= size;
|
||||
var best_distance0 : float = 1.0;
|
||||
var best_distance1 : float = 1.0;
|
||||
var point0 : Vector2;
|
||||
var point1 : Vector2;
|
||||
var p0 : Vector2 = Commons.floorv2(uv);
|
||||
|
||||
for dx in range(-1, 2):# (int dx = -1; dx < 2; ++dx) {
|
||||
for dy in range(-1, 2):# (int dy = -1; dy < 2; ++dy) {
|
||||
var d : Vector2 = Vector2(float(dx), float(dy));
|
||||
var p : Vector2 = p0+d;
|
||||
|
||||
p += randomness * Commons.rand2(seed2 + Commons.modv2(p, size));
|
||||
var distance : float = (stretch * (uv - p) / size).length();
|
||||
|
||||
if (best_distance0 > distance):
|
||||
best_distance1 = best_distance0;
|
||||
best_distance0 = distance;
|
||||
point1 = point0;
|
||||
point0 = p;
|
||||
elif (best_distance1 > distance):
|
||||
best_distance1 = distance;
|
||||
point1 = p;
|
||||
|
||||
var edge_distance : float = (uv - 0.5*(point0+point1)).dot((point0-point1).normalized());
|
||||
|
||||
return Color(point0.x, point0.y, best_distance0 * (size).length() * intensity, edge_distance);
|
||||
|
||||
#$(name_uv)_xyzw.z
|
||||
|
||||
static func voronoi_1(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
return Color(c.b, c.b, c.b, 1)
|
||||
|
||||
#$(name_uv)_xyzw.w
|
||||
|
||||
static func voronoi_2(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
return Color(c.a, c.a, c.a, 1)
|
||||
|
||||
#rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)))
|
||||
|
||||
static func voronoi_3(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
var vv : Vector2 = Vector2(c.r, c.g)
|
||||
|
||||
var v : Vector3 = Commons.rand3(Commons.fractv2(vv));
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
||||
#vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))
|
||||
|
||||
#voronoi_4 todo
|
@ -1,122 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#color_noise.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgb) - Shows the noise pattern
|
||||
#color_dots($(uv), 1.0/$(size), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#size, float, default: 8, min: 2, max: 12, step: 1
|
||||
|
||||
#----------------------
|
||||
#noise.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#float $(name)_f(vec2 uv) {
|
||||
# return dots(uv, 1.0/$(size), $(density), $(seed));
|
||||
#}
|
||||
|
||||
#Output - (float) - Shows the noise pattern
|
||||
#$(name)_f($(uv))
|
||||
|
||||
#Inputs:
|
||||
#grid_size, float, default: 4, min: 2, max: 12, step: 1
|
||||
#density, float, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
|
||||
#----------------------
|
||||
#noise_anisotropic.mmg
|
||||
#Generates x-axis interpolated value noise
|
||||
|
||||
#Output:
|
||||
#Output (float) - Shows a greyscale value noise
|
||||
#anisotropic($(uv), vec2($(scale_x), $(scale_y)), $(seed), $(smoothness), $(interpolation))
|
||||
|
||||
#Input:
|
||||
#scale, Vector2, min: 1, 1, max: 32, 1024, step: 1, 1, default 4, 256
|
||||
#smoothness, float, min: 0, max: 1, step: 0,01, default: 1
|
||||
#Interpolation, float, min: 0, max: 1, step: 0,01, default: 1
|
||||
|
||||
#float dots(vec2 uv, float size, float density, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# float color = step(rand(seed2+point_pos), density);
|
||||
# return color;
|
||||
#}
|
||||
|
||||
static func dots(uv : Vector2, size : float, density : float, pseed : float) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
uv /= size
|
||||
var point_pos : Vector2 = Commons.floorv2(uv) + Vector2(0.5, 0.5)
|
||||
var color : float = Commons.step(Commons.rand2(seed2 + point_pos).x, density);
|
||||
return color
|
||||
|
||||
static func anisotropicc(uv : Vector2, size : Vector2, pseed : float, smoothness : float, interpolation : float) -> Color:
|
||||
var v : float = anisotropic(uv, size, pseed, smoothness, interpolation)
|
||||
|
||||
return Color(v, v, v, 1)
|
||||
|
||||
#float anisotropic(vec2 uv, vec2 size, float seed, float smoothness, float interpolation) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# vec2 xy = floor(uv*size);
|
||||
# vec2 offset = vec2(rand(seed2 + xy.y), 0.0);
|
||||
# vec2 xy_offset = floor(uv * size + offset );
|
||||
#
|
||||
# float f0 = rand(seed2+mod(xy_offset, size));
|
||||
# float f1 = rand(seed2+mod(xy_offset+vec2(1.0, 0.0), size));
|
||||
# float mixer = clamp( (fract(uv.x*size.x+offset.x) -.5) / smoothness + 0.5, 0.0, 1.0 );
|
||||
# float smooth_mix = smoothstep(0.0, 1.0, mixer);
|
||||
# float linear = mix(f0, f1, mixer);
|
||||
# float smoothed = mix(f0, f1, smooth_mix);
|
||||
#
|
||||
# return mix(linear, smoothed, interpolation);
|
||||
#}
|
||||
|
||||
static func anisotropic(uv : Vector2, size : Vector2, pseed : float, smoothness : float, interpolation : float) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
|
||||
var xy : Vector2 = Commons.floorv2(uv * size)
|
||||
var s2xy : Vector2 = seed2
|
||||
s2xy.x += xy.y
|
||||
s2xy.y += xy.y
|
||||
|
||||
var offset : Vector2 = Vector2(Commons.rand(s2xy), 0.0)
|
||||
var xy_offset : Vector2 = Commons.floorv2(uv * size + offset)
|
||||
|
||||
var f0 : float = Commons.rand(seed2 + Commons.modv2(xy_offset, size));
|
||||
var f1 : float = Commons.rand(seed2 + Commons.modv2(xy_offset + Vector2(1.0, 0.0), size))
|
||||
var mixer : float = clamp((Commons.fract(uv.x * size.x + offset.x) - 0.5) / smoothness + 0.5, 0.0, 1.0)
|
||||
var smooth_mix : float = smoothstep(0.0, 1.0, mixer)
|
||||
var linear : float = lerp(f0, f1, mixer)
|
||||
var smoothed : float = lerp(f0, f1, smooth_mix)
|
||||
|
||||
return lerp(linear, smoothed, interpolation)
|
||||
|
||||
#vec3 color_dots(vec2 uv, float size, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# return rand3(seed2+point_pos);
|
||||
#}
|
||||
|
||||
static func color_dots(uv : Vector2, size : float, pseed : float) -> Vector3:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
|
||||
uv /= size
|
||||
|
||||
var point_pos : Vector2 = Commons.floorv2(uv) + Vector2(0.5, 0.5)
|
||||
|
||||
return Commons.rand3(seed2 + point_pos)
|
||||
|
||||
static func noise_color(uv : Vector2, size : float, pseed : float) -> Color:
|
||||
var v : Vector3 = color_dots(uv, 1.0 / size, pseed)
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,789 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#sdf3d_box.mmg
|
||||
#Generates a rounded box as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Common
|
||||
#vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);
|
||||
|
||||
#Output - (sdf3d) - Shows the rounded box
|
||||
#length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r
|
||||
|
||||
#Inputs:
|
||||
#size, vector3, min: 0, max: 1, default:0.5, step:0.01
|
||||
#size, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_sphere.mmg
|
||||
#Generates a sphere as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3d) - Shows the sphere
|
||||
#length($uv)-$r
|
||||
|
||||
#Inputs:
|
||||
#radius, vector3, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_capsule.mmg
|
||||
#Generates a capsule as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Common
|
||||
#vec3 $(name_uv)_p = $uv;
|
||||
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
|
||||
|
||||
#Output - (sdf3d) - Shows the capsule
|
||||
#length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: x, y, z
|
||||
#length, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
#radius, float, min: 0, max: 1, default:0.2, step:0.01
|
||||
#profile, curve, default: (ls, rs, x, z) 0, 0, 0, 1, 0, 0, 1, 1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_cone.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#+X: $axis = length($uv.yz),-$uv.x
|
||||
#-X: $axis = length($uv.yz),$uv.x
|
||||
#+Y: $axis = length($uv.xz),$uv.y
|
||||
#-Y: $axis = length($uv.xz),-$uv.y
|
||||
#+Z: $axis = length($uv.xy),-$uv.z
|
||||
#-Z: $axis = length($uv.xy),$uv.z
|
||||
|
||||
#Output - (sdf3d)
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default:5, values: +X, -X, +Y, -Y, +Z, -Z
|
||||
#angle, float, min: 0, max: 90, default:30, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_repeat.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (sdf3d)
|
||||
#Output - (sdf3dc) - The shape generated by the repeat operation
|
||||
#$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#X, int, min: 1, max: 32, default:4, step:1
|
||||
#Y, int, min: 1, max: 32, default:4, step:1
|
||||
#R, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_rotate.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3dc) - The rotated object
|
||||
#$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#rotation, vector3, min: -180, max: 180, default:0, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_cylinder.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3dc) - Shows the cylinder
|
||||
#min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0) + length(max($(name_uv)_d,0.0))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
#length, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
#radius, float, min: 0, max: 1, default:0.2, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_plane.mmg
|
||||
#Generates a plane that can be used to cut other shapes
|
||||
|
||||
#Outputs:
|
||||
|
||||
#X: $axis = x
|
||||
#Y: $axis = y
|
||||
#Z: $axis = z
|
||||
|
||||
#Output - (sdf3dc) - Shows the plane
|
||||
#$uv.$axis
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
|
||||
#----------------------
|
||||
#sdf3d_torus.mmg
|
||||
#Generates a torus as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#X: $axis = length($uv.yz)-$R,$uv.x
|
||||
#Y: $axis = length($uv.zx)-$R,$uv.y
|
||||
#Z: $axis = length($uv.xy)-$R,$uv.z
|
||||
#vec2 $(name_uv)_q = vec2($axis);
|
||||
|
||||
#Output - (sdf3dc) - Shows the torus
|
||||
#length($(name_uv)_q)-$r
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
#R, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
#r, float, min: 0, max: 1, default:0.1, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_boolean.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Union: $op = sdf3dc_union
|
||||
#Subtraction $op = sdf3dc_sub
|
||||
#Intersection $op = sdf3dc_inter
|
||||
|
||||
#Output - (sdf3dc) - The shape generated by the boolean operation
|
||||
#$op($in1($uv), $in2($uv))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 2, values: Union, Subtraction, Intersection
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_circle_repeat.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (sdf3dc) - The shape generated by the boolean operation
|
||||
#$in(circle_repeat_transform($uv, $c))
|
||||
|
||||
#Inputs:
|
||||
#count, float, min: 1, max: 32, default:5, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_angle.mmg (includes sdf3d_rotate.mmg)
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Shows the angleThe shape generated by the boolean operation
|
||||
#$(name_uv)_d
|
||||
|
||||
#X: $axis = xyz
|
||||
#Y: $axis = yzx
|
||||
#Z: $axis = zxy
|
||||
|
||||
#vec3 $(name_uv)_uv = $uv.$axis;
|
||||
#float $(name_uv)_rotated = rotate3d($(name_uv)_uv, vec3(($angle-180.0)*0.01745329251, 0.0, 0.0)).y;
|
||||
#float $(name_uv)_d1 = max($(name_uv)_uv.y, $(name_uv)_rotated);
|
||||
#float $(name_uv)_d2 = min($(name_uv)_uv.y, $(name_uv)_rotated);
|
||||
#float $(name_uv)_d = (mod($angle, 360.0) < 180.0) ? $(name_uv)_d1 : $(name_uv)_d2;
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 0, values: X, Y, Z
|
||||
#angle, float, min: 0, max: 360, default:180, step:0.1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_color.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc - The colored 3D object
|
||||
#vec2($in($uv), $c)
|
||||
|
||||
#Inputs:
|
||||
#color_index, float, min: 0, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_translate.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($uv-vec3($x, $y, $z))
|
||||
|
||||
#Inputs:
|
||||
#translation, vector3, min: -1, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_scale.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_in = $in(($uv)/$s);
|
||||
|
||||
#Output - sdf3dc
|
||||
#vec2($(name_uv)_in.x*$s, $(name_uv)_in.y)
|
||||
|
||||
#Inputs:
|
||||
#scale_factor, float, min: 0, max: 5, default:1, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_rounded.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_v = $in($uv);
|
||||
|
||||
#Output - sdf3dc
|
||||
#vec2($(name_uv)_v.x-$r, $(name_uv)_v.y)
|
||||
|
||||
#Inputs:
|
||||
#radius, float, min: 0, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_revolution.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_q = vec2(length($uv.xy)-$d+0.5, $uv.z+0.5);
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($(name_uv)_q)
|
||||
|
||||
#Inputs:
|
||||
#d, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
#input, float, default:10.0, (sdf2d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_smoothboolean.mmg
|
||||
#Performs a smooth boolean operation (union, intersection or difference) between two shapes
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Union: $op = union
|
||||
#Subtraction: $op = subtraction
|
||||
#Intersection: $op = intersection
|
||||
|
||||
#Output - sdf3dc
|
||||
#sdf3d_smooth_$op($in1($uv), $in2($uv), $k)
|
||||
|
||||
#Inputs:
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#operation, enum, default: 1, values: Union, Subtraction, Intersection
|
||||
#smoothness, float, min: 0, max: 1, default:0, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_elongation.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($uv-clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
#elongation, vector3, min: 0, max: 1, default:0, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_extrusion.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);
|
||||
|
||||
#Output - sdf3dc
|
||||
#min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))
|
||||
|
||||
#Inputs:
|
||||
#in, sdf2d, default:100, (input)
|
||||
#length, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_morph.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3d
|
||||
#mix($in1($uv), $in2($uv), $amount)
|
||||
|
||||
#Inputs:
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#amount, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#raymarching.mmg (raymarching_preview.mmg)
|
||||
#Raymarches a 3D object (described as signed distance function with optional color index)
|
||||
#to render a heightmap, a normal map and a color index map.
|
||||
|
||||
#raymarch_$name = sdf3d_raymarch
|
||||
#vec2 $(name_uv)_d = raymarch_$name($uv);
|
||||
|
||||
#Outputs:
|
||||
|
||||
#HeightMap - float - The generated height map
|
||||
#1.0-$(name_uv)_d.x
|
||||
|
||||
#NormalMap - rgb - The generated normal map
|
||||
#vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d.x))
|
||||
|
||||
#ColorMap - float - The generated color index map
|
||||
#$(name_uv)_d.y
|
||||
|
||||
#Inputs:
|
||||
#input, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#raymarching_preview.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (rgb)
|
||||
#render_$name($uv-vec2(0.5))
|
||||
|
||||
#Inputs:
|
||||
#input, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
static func raymarch(uv : Vector2) -> Color:
|
||||
var d : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
var f : float = 1.0 - d.x;
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func raymarch2(uv : Vector2) -> Color:
|
||||
var d : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
var v : Vector3 = Vector3(0.5, 0.5, 0.5) + 0.5 * sdf3d_normal(Vector3(uv.x - 0.5, uv.y - 0.5, 1.0 - d.x));
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
||||
static func raymarch3(uv : Vector2) -> Color:
|
||||
var v : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
return Color(v.y, v.y, v.y, 1)
|
||||
|
||||
#length($uv)-$r
|
||||
|
||||
static func sdf3d_sphere(p : Vector3, r : float) -> Vector2:
|
||||
var s : float = p.length() - r;
|
||||
|
||||
return Vector2(s, 0.0);
|
||||
|
||||
#vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);
|
||||
#length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r
|
||||
|
||||
static func sdf3d_box(p : Vector3, sx : float, sy : float, sz : float, r : float) -> Vector2:
|
||||
var v : Vector3 = Commons.absv3((p)) - Vector3(sx, sy, sz);
|
||||
var f : float = (Commons.maxv3(v,Vector3())).length() + min(max(v.x,max(v.y, v.z)),0.0) - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#Y: $axis = length($uv.xz),$uv.y
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_y(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.x, p.z).length(),(p).y)) - Vector2(r,l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#X: $axis = length($uv.yz),$uv.x
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_x(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.y, p.z).length(),(p).x)) - Vector2(r, l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#Z: $axis = length($uv.xy),$uv.z
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_z(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.x, p.y).length(),(p).z)) - Vector2(r, l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#vec3 $(name_uv)_p = $uv;
|
||||
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
|
||||
#return length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
|
||||
|
||||
static func sdf3d_capsule_y(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.y -= clamp(v.y, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_capsule_x(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.x -= clamp(v.x, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_capsule_z(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.z -= clamp(v.z, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+X: $axis = length($uv.yz),-$uv.x
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_px(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(), - (p).x));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#-X: $axis = length($uv.yz),$uv.x
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_nx(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(),(p).x));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+Y: $axis = length($uv.xz),$uv.y
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_py(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),(p).y));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#-Y: $axis = length($uv.xz),-$uv.y
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_ny(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),-(p).y));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+Z: $axis = length($uv.xy),-$uv.z
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_pz(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),-(p).z));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
|
||||
#-Z: $axis = length($uv.xy),$uv.z
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_nz(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),(p).z));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_x(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.y, p.z).length() - R,(p).x);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_y(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.z, p.x).length() - R,(p).y);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_z(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.x, p.y).length() - R,(p).z);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
|
||||
#vec2 raymarch_$name(vec2 uv) {
|
||||
# vec3 ro = vec3(uv-vec2(0.5), 1.0);
|
||||
# vec3 rd = vec3(0.0, 0.0, -1.0);
|
||||
# float dO = 0.0;
|
||||
# float c = 0.0;
|
||||
#
|
||||
# for (int i=0; i < 100; i++) {
|
||||
# vec3 p = ro + rd*dO;
|
||||
# vec2 dS = $sdf(p);
|
||||
# dO += dS.x;
|
||||
#
|
||||
# if (dO >= 1.0) {
|
||||
# break;
|
||||
# } else if (dS.x < 0.0001) {
|
||||
# c = dS.y;
|
||||
# break;
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return vec2(dO, c);
|
||||
#}
|
||||
|
||||
static func sdf3d_raymarch(uv : Vector2) -> Vector2:
|
||||
var ro : Vector3 = Vector3(uv.x - 0.5, uv.y - 0.5, 1.0);
|
||||
var rd : Vector3 = Vector3(0.0, 0.0, -1.0);
|
||||
var dO : float = 0.0;
|
||||
var c : float = 0.0;
|
||||
|
||||
for i in range(100):
|
||||
var p : Vector3 = ro + rd * dO;
|
||||
var dS : Vector2 = sdf3d_input(p);
|
||||
|
||||
dO += dS.x;
|
||||
|
||||
if (dO >= 1.0):
|
||||
break;
|
||||
elif (dS.x < 0.0001):
|
||||
c = dS.y;
|
||||
break;
|
||||
|
||||
return Vector2(dO, c);
|
||||
|
||||
#vec3 normal_$name(vec3 p) {
|
||||
# if (p.z <= 0.0) {
|
||||
# return vec3(0.0, 0.0, 1.0);
|
||||
# }
|
||||
#
|
||||
# float d = $sdf(p).x;
|
||||
# float e = .001;
|
||||
# vec3 n = d - vec3(
|
||||
# $sdf(p-vec3(e, 0.0, 0.0)).x,
|
||||
# $sdf(p-vec3(0.0, e, 0.0)).x,
|
||||
# $sdf(p-vec3(0.0, 0.0, e)).x);
|
||||
#
|
||||
# return vec3(-1.0, -1.0, -1.0)*normalize(n);
|
||||
#}
|
||||
|
||||
static func sdf3d_normal(p : Vector3) -> Vector3:
|
||||
if (p.z <= 0.0):
|
||||
return Vector3(0.0, 0.0, 1.0);
|
||||
|
||||
var d : float = sdf3d_input(p).x;
|
||||
var e : float = .001;
|
||||
|
||||
var n : Vector3 = Vector3(
|
||||
d - sdf3d_input(p - Vector3(e, 0.0, 0.0)).x,
|
||||
d - sdf3d_input(p - Vector3(0.0, e, 0.0)).x,
|
||||
d - sdf3d_input(p - Vector3(0.0, 0.0, e)).x);
|
||||
|
||||
return Vector3(-1.0, -1.0, -1.0) * n.normalized();
|
||||
|
||||
#vec2 sdf3dc_union(vec2 a, vec2 b) {
|
||||
# return vec2(min(a.x, b.x), mix(b.y, a.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_union(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(min(a.x, b.x), lerp(b.y, a.y, Commons.step(a.x, b.x)));
|
||||
|
||||
#vec2 sdf3dc_sub(vec2 a, vec2 b) {
|
||||
# return vec2(max(-a.x, b.x), a.y);
|
||||
#}
|
||||
|
||||
static func sdf3dc_sub(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(-a.x, b.x), a.y);
|
||||
|
||||
#vec2 sdf3dc_inter(vec2 a, vec2 b) {
|
||||
# return vec2(max(a.x, b.x), mix(a.y, b.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_inter(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(a.x, b.x), lerp(a.y, b.y, Commons.step(a.x, b.x)));
|
||||
|
||||
#vec2 sdf3d_smooth_union(vec2 d1, vec2 d2, float k) {
|
||||
# float h = clamp(0.5+0.5*(d2.x-d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, d1.x, h)-k*h*(1.0-h), mix(d2.y, d1.y, step(d1.x, d2.x)));
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_union(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 + 0.5 * (d2.x - d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, d1.x, h)-k*h*(1.0 - h), lerp(d2.y, d1.y, Commons.step(d1.x, d2.x)));
|
||||
|
||||
#vec2 sdf3d_smooth_subtraction(vec2 d1, vec2 d2, float k ) {
|
||||
# float h = clamp(0.5-0.5*(d2.x+d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_subtraction(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 - 0.5 * (d2.x + d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);
|
||||
|
||||
#vec2 sdf3d_smooth_intersection(vec2 d1, vec2 d2, float k ) {
|
||||
# float h = clamp(0.5-0.5*(d2.x-d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, d1.x, h)+k*h*(1.0-h), mix(d1.y, d2.y, step(d1.x, d2.x)));
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_intersection(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 - 0.5 * (d2.x - d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, d1.x, h)+k*h*(1.0-h), lerp(d1.y, d2.y, Commons.step(d1.x, d2.x)));
|
||||
|
||||
static func sdf3d_rounded(v : Vector2, r : float) -> Vector2:
|
||||
return Vector2(v.x - r, v.y);
|
||||
|
||||
static func sdf3d_elongation(p : Vector3, v : Vector3) -> Vector3:
|
||||
return ((p) - Commons.clampv3((p), - Commons.absv3(v), Commons.absv3(v)))
|
||||
|
||||
static func sdf3d_repeat(p : Vector3, r : Vector2, randomness : float, pseed : int) -> Vector3:
|
||||
#$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))
|
||||
return repeat(p, Vector3(1.0 / r.x, 1.0 / r.y, 0.00001), float(pseed), randomness)
|
||||
|
||||
#vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {
|
||||
# vec3 a = (rand3(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;
|
||||
# p = mod(p+0.5*r,r)-0.5*r;
|
||||
#
|
||||
# vec3 rv;
|
||||
# float c;
|
||||
# float s;
|
||||
#
|
||||
# c = cos(a.x);
|
||||
# s = sin(a.x);
|
||||
#
|
||||
# rv.x = p.x;
|
||||
# rv.y = p.y*c+p.z*s;rv.z = -p.y*s+p.z*c;
|
||||
#
|
||||
# c = cos(a.y);
|
||||
# s = sin(a.y);
|
||||
#
|
||||
# p.x = rv.x*c+rv.z*s;
|
||||
# p.y = rv.y;
|
||||
# p.z = -rv.x*s+rv.z*c;
|
||||
#
|
||||
# c = cos(a.z);
|
||||
# s = sin(a.z);
|
||||
#
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
#
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float) -> Vector3:
|
||||
var a : Vector3 = (Commons.rand3(Commons.floorv2(Commons.modv2((Vector2(p.x, p.y) + Vector2(0.5, 0.5) * Vector2(r.x, r.y)) / Vector2(r.x, r.y), Vector2(1, 1) / Vector2(r.x, r.y)) + Vector2(pseed, pseed))) - Vector3(0.5, 0.5, 0.5)) * 6.28 * randomness
|
||||
p = Commons.modv3(p + Vector3(0.5, 0.5, 0.5) * r, r) - Vector3(0.5, 0.5, 0.5) * r;
|
||||
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = 0
|
||||
var s : float = 0
|
||||
|
||||
c = cos(a.x);
|
||||
s = sin(a.x);
|
||||
|
||||
rv.x = p.x;
|
||||
rv.y = p.y* c + p.z * s;
|
||||
rv.z = -p.y * s + p.z * c;
|
||||
|
||||
c = cos(a.y);
|
||||
s = sin(a.y);
|
||||
|
||||
p.x = rv.x*c+rv.z*s;
|
||||
p.y = rv.y;
|
||||
p.z = -rv.x*s+rv.z*c;
|
||||
|
||||
c = cos(a.z);
|
||||
s = sin(a.z);
|
||||
|
||||
rv.x = p.x * c + p.y * s;
|
||||
rv.y = -p.x * s + p.y * c;
|
||||
rv.z = p.z;
|
||||
|
||||
return rv;
|
||||
|
||||
#vec3 rotate3d(vec3 p, vec3 a) {
|
||||
# vec3 rv;
|
||||
# float c;
|
||||
# float s;
|
||||
# c = cos(a.x);
|
||||
# s = sin(a.x);
|
||||
# rv.x = p.x;
|
||||
# rv.y = p.y*c+p.z*s;
|
||||
# rv.z = -p.y*s+p.z*c;
|
||||
# c = cos(a.y);
|
||||
# s = sin(a.y);
|
||||
# p.x = rv.x*c+rv.z*s;
|
||||
# p.y = rv.y;
|
||||
# p.z = -rv.x*s+rv.z*c;
|
||||
# c = cos(a.z);
|
||||
# s = sin(a.z);
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func rotate3d(p : Vector3, a : Vector3) -> Vector3:
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = 0
|
||||
var s : float = 0
|
||||
c = cos(a.x)
|
||||
s = sin(a.x)
|
||||
rv.x = p.x
|
||||
rv.y = p.y * c + p.z * s
|
||||
rv.z = -p.y * s + p.z * c
|
||||
c = cos(a.y)
|
||||
s = sin(a.y)
|
||||
p.x = rv.x * c + rv.z * s
|
||||
p.y = rv.y
|
||||
p.z = -rv.x * s + rv.z * c
|
||||
c = cos(a.z)
|
||||
s = sin(a.z)
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
rv.z = p.z
|
||||
|
||||
return rv
|
||||
|
||||
#vec3 circle_repeat_transform(vec3 p, float count) {
|
||||
# float r = 6.28/count;
|
||||
# float pa = atan(p.x, p.y);
|
||||
# float a = mod(pa+0.5*r, r)-0.5*r;
|
||||
# vec3 rv;
|
||||
# float c = cos(a-pa);
|
||||
# float s = sin(a-pa);
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func circle_repeat_transform(p : Vector3, count : float) -> Vector3:
|
||||
var r : float = 6.28 / count
|
||||
var pa : float = atan2(p.x, p.y)
|
||||
var a : float = Commons.modf(pa + 0.5 * r, r) - 0.5 * r
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = cos(a-pa)
|
||||
var s : float = sin(a-pa)
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
rv.z = p.z
|
||||
return rv
|
||||
|
||||
#todo this needs to be solved
|
||||
static func sdf3d_input(p : Vector3) -> Vector2:
|
||||
return sdf3d_sphere(p, 0.5)
|
||||
|
||||
#raymarching_preview.mmg
|
||||
#vec3 render_$name(vec2 uv) {
|
||||
# vec3 p = vec3(uv, 2.0-raymarch_$name(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));
|
||||
# vec3 n = normal_$name(p);
|
||||
# vec3 l = vec3(5.0, 5.0, 10.0);
|
||||
# vec3 ld = normalize(l-p);
|
||||
#
|
||||
# float o = step(p.z, 0.001);
|
||||
# float shadow = 1.0-0.75*step(raymarch_$name(l, -ld), length(l-p)-0.01);
|
||||
# float light = 0.3+0.7*dot(n, ld)*shadow;
|
||||
#
|
||||
# return vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light;
|
||||
#}
|
||||
|
||||
#static func sdf3d_render(p : Vector2) -> Vector3:
|
||||
# return Vector3()
|
@ -1,292 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#sphere.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - A heightmap of the specified sphere
|
||||
#sphere($uv, vec2($cx, $cy), $r)
|
||||
|
||||
#Inputs:
|
||||
#center, vector2, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
#radius, float, min: 0, max: 1, default: 0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#shape.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - Shows a white shape on a black background
|
||||
#shape_$(shape)($(uv), $(sides), $(radius)*$radius_map($uv), $(edge)*$edge_map($uv))
|
||||
|
||||
#Inputs:
|
||||
#shape, enum, default: 0, values: circle, ploygon, star, curved_star, rays
|
||||
#sides, int, min: 2, max: 32, default: 3, step:1
|
||||
#radius, float, min: 0, max: 1, default: 1, step:0.01 (universal input)
|
||||
#edge, float, min: 0, max: 1, default: 0.2, step:0.01 (universal input)
|
||||
|
||||
#----------------------
|
||||
#box.mmg
|
||||
#A heightmap of the specified box
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "1.0-box($uv, vec3($cx, $cy, $cz), vec3($sx, $sy, $sz), 0.01745329251*vec3($rx, $ry, $rz))",
|
||||
# "longdesc": "A heightmap of the specified box",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Center X",
|
||||
# "longdesc": "X coordinate of the center of the box",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "cx",
|
||||
# "shortdesc": "Center.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Center Y",
|
||||
# "longdesc": "Y coordinate of the center of the box",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "cy",
|
||||
# "shortdesc": "Center.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Center Z",
|
||||
# "longdesc": "Z coordinate of the center of the box",
|
||||
# "max": 0.5,
|
||||
# "min": -0.5,
|
||||
# "name": "cz",
|
||||
# "shortdesc": "Center.z",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size X",
|
||||
# "longdesc": "Size along X axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sx",
|
||||
# "shortdesc": "Size.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size Y",
|
||||
# "longdesc": "Size along Y axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sy",
|
||||
# "shortdesc": "Size.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size Z",
|
||||
# "longdesc": "Size along Z axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sz",
|
||||
# "shortdesc": "Size.z",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot X",
|
||||
# "longdesc": "Rotation angle around X axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "rx",
|
||||
# "shortdesc": "Rot.x",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot Y",
|
||||
# "longdesc": "Rotation angle around Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ry",
|
||||
# "shortdesc": "Rot.y",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot Z",
|
||||
# "longdesc": "Rotation angle around Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "rz",
|
||||
# "shortdesc": "Rot.z",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#float sphere(vec2 uv, vec2 c, float r) {
|
||||
# uv -= c;
|
||||
# uv /= r;
|
||||
# return 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv)));
|
||||
#}
|
||||
|
||||
static func sphere(uv : Vector2, c : Vector2, r : float) -> float:
|
||||
return 0.0
|
||||
|
||||
#float shape_circle(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float distance = length(uv);
|
||||
# return clamp((1.0-distance/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_circle(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8)
|
||||
|
||||
var distance : float = uv.length()
|
||||
|
||||
return clamp((1.0 - distance / size) / edge, 0.0, 1.0)
|
||||
|
||||
#float shape_polygon(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = atan(uv.x, uv.y)+3.14159265359;
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-(cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_polygon(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8)
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = atan(uv.y / uv.x) + 3.14159265359
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(0.5 + angle / slice) * slice - angle) * uv.length()) / (edge * size), 0.0, 1.0)
|
||||
|
||||
#float shape_star(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = atan(uv.x, uv.y);
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-(cos(floor(angle*sides/6.28318530718-0.5+2.0*step(fract(angle*sides/6.28318530718), 0.5))*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_star(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8);
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = atan(uv.y / uv.x)
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(1.5 + angle / slice - 2.0 * Commons.step(0.5 * slice, Commons.modf(angle, slice))) * slice - angle) * uv.length()) / (edge * size), 0.0, 1.0);
|
||||
|
||||
#float shape_curved_star(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = 2.0*(atan(uv.x, uv.y)+3.14159265359);
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv)/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_curved_star(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8);
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = 2.0*(atan(uv.y / uv.x) + 3.14159265359)
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(0.5 + 0.5 * angle / slice) * 2.0 * slice - angle) * uv.length())/(edge * size), 0.0, 1.0);
|
||||
|
||||
#float shape_rays(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = 0.5*max(edge, 1.0e-8)*size;
|
||||
# float slice = 6.28318530718/sides;
|
||||
# float angle = mod(atan(uv.x, uv.y)+3.14159265359, slice)/slice;
|
||||
# return clamp(min((size-angle)/edge, angle/edge), 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_rays(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = 0.5 * max(edge, 1.0e-8) * size
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var slice : float = 6.28318530718 / sides
|
||||
var angle : float = Commons.modf(atan(uv.y / uv.x) + 3.14159265359, slice) / slice
|
||||
|
||||
return clamp(min((size - angle) / edge, angle / edge), 0.0, 1.0);
|
||||
|
||||
#float box(vec2 uv, vec3 center, vec3 rad, vec3 rot) {\n\t
|
||||
# vec3 ro = vec3(uv, 1.0)-center;\n\t
|
||||
# vec3 rd = vec3(0.0000001, 0.0000001, -1.0);\n\t
|
||||
# mat3 r = mat3(vec3(1, 0, 0), vec3(0, cos(rot.x), -sin(rot.x)), vec3(0, sin(rot.x), cos(rot.x)));\n\t
|
||||
#
|
||||
# r *= mat3(vec3(cos(rot.y), 0, -sin(rot.y)), vec3(0, 1, 0), vec3(sin(rot.y), 0, cos(rot.y)));\n\t
|
||||
# r *= mat3(vec3(cos(rot.z), -sin(rot.z), 0), vec3(sin(rot.z), cos(rot.z), 0), vec3(0, 0, 1));\n\t
|
||||
# ro = r * ro;\n\t
|
||||
# rd = r * rd;\n
|
||||
# vec3 m = 1.0/rd;\n
|
||||
# vec3 n = m*ro;\n
|
||||
# vec3 k = abs(m)*rad;\n
|
||||
# vec3 t1 = -n - k;\n
|
||||
# vec3 t2 = -n + k;\n\n
|
||||
#
|
||||
# float tN = max(max(t1.x, t1.y), t1.z);\n
|
||||
# float tF = min(min(t2.x, t2.y), t2.z);\n
|
||||
#
|
||||
# if(tN>tF || tF<0.0) return 1.0;\n
|
||||
#
|
||||
# return tN;\n
|
||||
#}
|
||||
|
@ -1,147 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#profile.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "dot($gradient($uv.x).xyz, vec3(1.0/3.0))",
|
||||
# "label": "2:",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "draw_profile_$style($uv, $in($uv), (dot($gradient($uv.x+0.001).xyz, vec3(1.0/3.0))-dot($gradient($uv.x-0.001).xyz, vec3(1.0/3.0)))/0.002, max(0.0001, $width))",
|
||||
# "longdesc": "An image showing the profile defined by the gradient",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "Style of the output image (fill or curve)",
|
||||
# "name": "style",
|
||||
# "shortdesc": "Style",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Curve",
|
||||
# "value": "curve"
|
||||
# },
|
||||
# {
|
||||
# "name": "Fill",
|
||||
# "value": "fill"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "default": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 0,
|
||||
# "r": 0
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 1,
|
||||
# "r": 1
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "Gradient that defines the profile to be shown",
|
||||
# "name": "gradient",
|
||||
# "shortdesc": "Gradient",
|
||||
# "type": "gradient"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.05,
|
||||
# "label": "",
|
||||
# "longdesc": "Width of the curve",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "width",
|
||||
# "shortdesc": "Width",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#uniform.mmg
|
||||
#Draws a uniform image
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "A uniform image of the selected color",
|
||||
# "rgba": "$(color)",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "Color of the uniform image",
|
||||
# "name": "color",
|
||||
# "shortdesc": "Color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#uniform_greyscale.mmg
|
||||
#Draws a uniform greyscale image
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$(color)",
|
||||
# "longdesc": "A uniform image of the selected value",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "longdesc": "The value of the uniform greyscale image",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "color",
|
||||
# "shortdesc": "Value",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#float draw_profile_fill(vec2 uv, float y, float dy, float w) {\n\t
|
||||
# return 1.0-clamp(sin(1.57079632679-atan(dy))*(1.0-uv.y-y)/w, 0.0, 1.0);\n
|
||||
#}
|
||||
|
||||
#float draw_profile_curve(vec2 uv, float y, float dy, float w) {\n\t
|
||||
# return 1.0-clamp(sin(1.57079632679-atan(dy))*abs(1.0-uv.y-y)/w, 0.0, 1.0);\n
|
||||
#}
|
||||
|
@ -1,979 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
#Applies 3D textures to a rendered 3D signed distance function scene.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "Height",
|
||||
# "longdesc": "The height map generated by the Render node",
|
||||
# "name": "z",
|
||||
# "shortdesc": "HeightMap",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "Color",
|
||||
# "longdesc": "The color map generated by the Render node",
|
||||
# "name": "c",
|
||||
# "shortdesc": "ColorMap",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Texture",
|
||||
# "longdesc": "The 3D texture",
|
||||
# "name": "t",
|
||||
# "shortdesc": "Tex3D",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The textured 3D scene",
|
||||
# "rgb": "$t(vec4($uv, $z($uv), $c($uv)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply_invuvmap.mmg
|
||||
#This node applies a 3D texture to an object using its inverse UV map.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Texture",
|
||||
# "longdesc": "The input 3D texture",
|
||||
# "name": "t",
|
||||
# "shortdesc": "Texture",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Inv. UV Map",
|
||||
# "longdesc": "The inverse UV map of the object",
|
||||
# "name": "map",
|
||||
# "shortdesc": "InvUVMap",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated texture",
|
||||
# "rgb": "$t(vec4($map($uv), 0.0))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_blend.mmg
|
||||
#Blends its 3D texture inputs, using an optional mask
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3($uv.x, 1.0, 1.0)",
|
||||
# "label": "Source1",
|
||||
# "longdesc": "The foreground input",
|
||||
# "name": "s1",
|
||||
# "shortdesc": "Foreground",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0, $uv.y, 1.0)",
|
||||
# "label": "Source2",
|
||||
# "longdesc": "The background input",
|
||||
# "name": "s2",
|
||||
# "shortdesc": "Background",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Opacity",
|
||||
# "longdesc": "The optional opacity mask",
|
||||
# "name": "a",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The 3D texture generated by the blend operation",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "blend3d_$blend_type($s1($uv).rgb, $s2($uv).rgb, $amount*dot($a($uv), vec3(1.0))/3.0)",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The algorithm used to blend the inputs",
|
||||
# "name": "blend_type",
|
||||
# "shortdesc": "Blend mode",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Normal",
|
||||
# "value": "normal"
|
||||
# },
|
||||
# {
|
||||
# "name": "Multiply",
|
||||
# "value": "multiply"
|
||||
# },
|
||||
# {
|
||||
# "name": "Screen",
|
||||
# "value": "screen"
|
||||
# },
|
||||
# {
|
||||
# "name": "Overlay",
|
||||
# "value": "overlay"
|
||||
# },
|
||||
# {
|
||||
# "name": "Hard Light",
|
||||
# "value": "hard_light"
|
||||
# },
|
||||
# {
|
||||
# "name": "Soft Light",
|
||||
# "value": "soft_light"
|
||||
# },
|
||||
# {
|
||||
# "name": "Burn",
|
||||
# "value": "burn"
|
||||
# },
|
||||
# {
|
||||
# "name": "Dodge",
|
||||
# "value": "dodge"
|
||||
# },
|
||||
# {
|
||||
# "name": "Lighten",
|
||||
# "value": "lighten"
|
||||
# },
|
||||
# {
|
||||
# "name": "Darken",
|
||||
# "value": "darken"
|
||||
# },
|
||||
# {
|
||||
# "name": "Difference",
|
||||
# "value": "difference"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "3:",
|
||||
# "longdesc": "The opacity of the blend operation",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "amount",
|
||||
# "shortdesc": "Opacity",
|
||||
# "step": 0,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_colorize.mmg
|
||||
#Remaps a greyscale 3D texture to a custom gradient
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3($uv.x+0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input greyscale 3D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The remapped color 3D texture ",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$g(dot($in($uv), vec3(1.0))/3.0).rgb",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 0,
|
||||
# "r": 0
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 1,
|
||||
# "r": 1
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "The gradient to which the input is remapped",
|
||||
# "name": "g",
|
||||
# "shortdesc": "Gradient",
|
||||
# "type": "gradient"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_distort.mmg
|
||||
#Distorts its input 3D texture using another 3D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture to be distorted",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture used to distort Input1",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The distorted 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in1(vec4($uv.xyz+($in2($uv)*$Distort*0.5-0.5), 0.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Distort",
|
||||
# "longdesc": "The strength of the distort effect",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "Distort",
|
||||
# "shortdesc": "Strength",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_fbm.mmg
|
||||
#Generates a 3D noise made of several octaves of a simple noise
|
||||
|
||||
# "instance": "float $(name)_fbm(vec3 coord, vec3 size, int octaves, float persistence, float seed) {\n\tfloat normalize_factor = 0.0;\n\tfloat value = 0.0;\n\tfloat scale = 1.0;\n\tfor (int i = 0; i < octaves; i++) {\n\t\tvalue += tex3d_fbm_$noise(coord*size, size, seed) * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows a greyscale 3D texture of the generated noise",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "vec3($(name)_fbm($(uv).xyz, vec3($(scale_x), $(scale_y), $(scale_z)), int($(iterations)), $(persistence), float($(seed))))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "Noise",
|
||||
# "longdesc": "The simple noise type",
|
||||
# "name": "noise",
|
||||
# "shortdesc": "Noise type",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Value",
|
||||
# "value": "value"
|
||||
# },
|
||||
# {
|
||||
# "name": "Perlin",
|
||||
# "value": "perlin"
|
||||
# },
|
||||
# {
|
||||
# "name": "Cellular",
|
||||
# "value": "cellular"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of the first octave along the X axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of the first octave along the Y axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale Z",
|
||||
# "longdesc": "The scale of the first octave along the Z axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_z",
|
||||
# "shortdesc": "Scale.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 3,
|
||||
# "label": "Iterations",
|
||||
# "longdesc": "The number of noise octaves",
|
||||
# "max": 10,
|
||||
# "min": 1,
|
||||
# "name": "iterations",
|
||||
# "shortdesc": "Octaves",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Persistence",
|
||||
# "longdesc": "The persistence between two consecutive octaves",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "persistence",
|
||||
# "shortdesc": "Persistence",
|
||||
# "step": 0.05,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_from2d.mmg
|
||||
#Creates a 3D texture from a 2D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input 2D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in($uv.xy+vec2(0.5))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_pattern.mmg
|
||||
#A greyscale 3D texture that combines patterns along all 3 axes
|
||||
|
||||
# "instance": "float $(name)_fct(vec3 uv) {\n\treturn mix3d_$(mix)(wave3d_$(x_wave)($(x_scale)*uv.x), wave3d_$(y_wave)($(y_scale)*uv.y), wave3d_$(z_wave)($(z_scale)*uv.z));\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "vec3($(name)_fct($(uv).xyz))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Combiner",
|
||||
# "longdesc": "The operation used to combine the X, Y and Z patterns",
|
||||
# "name": "mix",
|
||||
# "shortdesc": "Combine",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Multiply",
|
||||
# "value": "mul"
|
||||
# },
|
||||
# {
|
||||
# "name": "Add",
|
||||
# "value": "add"
|
||||
# },
|
||||
# {
|
||||
# "name": "Max",
|
||||
# "value": "max"
|
||||
# },
|
||||
# {
|
||||
# "name": "Min",
|
||||
# "value": "min"
|
||||
# },
|
||||
# {
|
||||
# "name": "Xor",
|
||||
# "value": "xor"
|
||||
# },
|
||||
# {
|
||||
# "name": "Pow",
|
||||
# "value": "pow"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "X",
|
||||
# "longdesc": "Pattern generated along the X axis",
|
||||
# "name": "x_wave",
|
||||
# "shortdesc": "Pattern.x",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "2:",
|
||||
# "longdesc": "Repetitions of the pattern along X axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "x_scale",
|
||||
# "shortdesc": "Repeat.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Y",
|
||||
# "longdesc": "Pattern generated along the Y axis",
|
||||
# "name": "y_wave",
|
||||
# "shortdesc": "Pattern.y",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "3:",
|
||||
# "longdesc": "Repetitions of the pattern along Y axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "y_scale",
|
||||
# "shortdesc": "Repeat.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Z",
|
||||
# "longdesc": "Pattern generated along the Z axis",
|
||||
# "name": "z_wave",
|
||||
# "shortdesc": "Pattern.z",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "4:",
|
||||
# "longdesc": "Repetitions of the pattern along Z axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "z_scale",
|
||||
# "shortdesc": "Repeat.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_rotate.mmg
|
||||
#Rotates a 3D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input 3D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The rotated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in(vec4(tex3d_rotate($uv.xyz, -vec3($ax, $ay, $az)*0.01745329251), $uv.w))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "X",
|
||||
# "longdesc": "The rotation around the X axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ax",
|
||||
# "shortdesc": "Rotate.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Y",
|
||||
# "longdesc": "The rotation around the Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ay",
|
||||
# "shortdesc": "Rotate.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Z",
|
||||
# "longdesc": "The rotation around the Z axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "az",
|
||||
# "shortdesc": "Rotate.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_select.mmg
|
||||
#Selects a 3D texture for a given color index. This can be used to map several textures into a single 3D scene.
|
||||
|
||||
# "code": "float $(name_uv)_d = ($uv.w-$v)/$t;",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture associated to the specified color index",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture(s) associated to other color indices",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The merged 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "mix($in1($uv), $in2($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Value",
|
||||
# "longdesc": "The value of the selected color index",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "v",
|
||||
# "shortdesc": "Value",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.1,
|
||||
# "label": "Tolerance",
|
||||
# "longdesc": "The tolerance used when comparing color indices",
|
||||
# "max": 1,
|
||||
# "min": 0.01,
|
||||
# "name": "t",
|
||||
# "shortdesc": "Tolerance",
|
||||
# "step": 0.001,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_select_shape.mmg
|
||||
#Selects a 3D texture inside, and another outside a shape. This can be used to map several textures into a single 3D scene.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture associated to the specified color index",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture(s) associated to other color indices",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The shape in which input1 is applied",
|
||||
# "name": "shape",
|
||||
# "shortdesc": "Shape",
|
||||
# "type": "sdf3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The merged 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "mix($in1($uv), $in2($uv), clamp($shape($uv.xyz)/max($d, 0.0001), 0.0, 1.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Smoothness",
|
||||
# "longdesc": "The width of the transition area between both textures",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "shortdesc": "Smoothness",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*c1 + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*c1*c2 + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_overlay_f(float c1, float c2) {\n\t
|
||||
# return (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_overlay_f(c1.x, c2.x), blend3d_overlay_f(c1.y, c2.y), blend3d_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_soft_light_f(float c1, float c2) {\n\t
|
||||
# return (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_soft_light_f(c1.x, c2.x), blend3d_soft_light_f(c1.y, c2.y), blend3d_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_burn_f(float c1, float c2) {\n\t
|
||||
# return (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_burn_f(c1.x, c2.x), blend3d_burn_f(c1.y, c2.y), blend3d_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_dodge_f(float c1, float c2) {\n\t
|
||||
# return (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_dodge_f(c1.x, c2.x), blend3d_dodge_f(c1.y, c2.y), blend3d_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_lighten(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*max(c1, c2) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_darken(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*min(c1, c2) + (1.0-opacity)*c2;
|
||||
#}
|
||||
|
||||
#vec3 blend3d_difference(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float rand31(vec3 p) {\n\t
|
||||
# return fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123);\n
|
||||
#}
|
||||
|
||||
#vec3 rand33(vec3 p) {\n\t
|
||||
# p = vec3( dot(p,vec3(127.1,311.7, 74.7)),
|
||||
# dot(p,vec3(269.5,183.3,246.1)),\n\t\t\t
|
||||
# dot(p,vec3(113.5,271.9,124.6)));\n\n\t
|
||||
#
|
||||
# return -1.0 + 2.0*fract(sin(p)*43758.5453123);
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_value(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\t
|
||||
# float p000 = rand31(mod(o, size));\n\t
|
||||
# float p001 = rand31(mod(o + vec3(0.0, 0.0, 1.0), size));\n\t
|
||||
# float p010 = rand31(mod(o + vec3(0.0, 1.0, 0.0), size));\n\t
|
||||
# float p011 = rand31(mod(o + vec3(0.0, 1.0, 1.0), size));\n\t
|
||||
# float p100 = rand31(mod(o + vec3(1.0, 0.0, 0.0), size));\n\t
|
||||
# float p101 = rand31(mod(o + vec3(1.0, 0.0, 1.0), size));\n\t
|
||||
# float p110 = rand31(mod(o + vec3(1.0, 1.0, 0.0), size));\n\t
|
||||
# float p111 = rand31(mod(o + vec3(1.0, 1.0, 1.0), size));\n\t
|
||||
#
|
||||
# vec3 t = f * f * (3.0 - 2.0 * f);\n\t
|
||||
#
|
||||
# return mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);\n
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_perlin(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\t
|
||||
# vec3 v000 = normalize(rand33(mod(o, size))-vec3(0.5));\n\t
|
||||
# vec3 v001 = normalize(rand33(mod(o + vec3(0.0, 0.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v010 = normalize(rand33(mod(o + vec3(0.0, 1.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v011 = normalize(rand33(mod(o + vec3(0.0, 1.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v100 = normalize(rand33(mod(o + vec3(1.0, 0.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v101 = normalize(rand33(mod(o + vec3(1.0, 0.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v110 = normalize(rand33(mod(o + vec3(1.0, 1.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v111 = normalize(rand33(mod(o + vec3(1.0, 1.0, 1.0), size))-vec3(0.5));\n\t
|
||||
#
|
||||
# float p000 = dot(v000, f);\n\tfloat p001 = dot(v001, f - vec3(0.0, 0.0, 1.0));\n\t
|
||||
# float p010 = dot(v010, f - vec3(0.0, 1.0, 0.0));\n\t
|
||||
# float p011 = dot(v011, f - vec3(0.0, 1.0, 1.0));\n\t
|
||||
# float p100 = dot(v100, f - vec3(1.0, 0.0, 0.0));\n\t
|
||||
# float p101 = dot(v101, f - vec3(1.0, 0.0, 1.0));\n\t
|
||||
# float p110 = dot(v110, f - vec3(1.0, 1.0, 0.0));\n\t
|
||||
# float p111 = dot(v111, f - vec3(1.0, 1.0, 1.0));\n\t
|
||||
#
|
||||
# vec3 t = f * f * (3.0 - 2.0 * f);\n\t
|
||||
#
|
||||
# return 0.5 + mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_cellular(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\tfloat min_dist = 3.0;\n\t
|
||||
#
|
||||
# for (float x = -1.0; x <= 1.0; x++) {\n\t\t
|
||||
# for (float y = -1.0; y <= 1.0; y++) {\n\t\t\t
|
||||
# for (float z = -1.0; z <= 1.0; z++) {\n\t\t\t\t
|
||||
# vec3 node = 0.4*rand33(mod(o + vec3(x, y, z), size)) + vec3(x, y, z);\n\t\t\t\t
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y + (f - node).z * (f - node).z);\n\t\t\t\t
|
||||
# min_dist = min(min_dist, dist);\n\t\t\t
|
||||
# }\n\t\t
|
||||
#
|
||||
# }\n\t
|
||||
#
|
||||
# }\n\t
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
|
||||
#float wave3d_constant(float x) {\n\t
|
||||
# return 1.0;\n
|
||||
#}
|
||||
|
||||
#float wave3d_sine(float x) {\n\t
|
||||
# return 0.5-0.5*cos(3.14159265359*2.0*x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_triangle(float x) {\n\t
|
||||
# x = fract(x);\n\t
|
||||
# return min(2.0*x, 2.0-2.0*x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_sawtooth(float x) {\n\t
|
||||
# return fract(x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_square(float x) {\n\t
|
||||
# return (fract(x) < 0.5) ? 0.0 : 1.0;\n
|
||||
#}
|
||||
|
||||
#float wave3d_bounce(float x) {\n\t
|
||||
# x = 2.0*(fract(x)-0.5);\n\t
|
||||
# return sqrt(1.0-x*x);\n
|
||||
#}
|
||||
|
||||
#float mix3d_mul(float x, float y, float z) {\n\t
|
||||
# return x*y*z;\n
|
||||
#}
|
||||
|
||||
#float mix3d_add(float x, float y, float z) {\n\t
|
||||
# return min(x+y+z, 1.0);\n
|
||||
#}
|
||||
|
||||
#float mix3d_max(float x, float y, float z) {\n\t
|
||||
# return max(max(x, y), z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_min(float x, float y, float z) {\n\t
|
||||
# return min(min(x, y), z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_xor(float x, float y, float z) {\n\t
|
||||
# float xy = min(x+y, 2.0-x-y);\n\t
|
||||
# return min(xy+z, 2.0-xy-z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_pow(float x, float y, float z) {\n\t
|
||||
# return pow(pow(x, y), z);\n
|
||||
#}
|
||||
|
||||
#vec3 tex3d_rotate(vec3 p, vec3 a) {\n\t
|
||||
# vec3 rv;\n\t
|
||||
# float c;\n\t
|
||||
# float s;\n\t
|
||||
# c = cos(a.x);\n\t
|
||||
# s = sin(a.x);\n\t
|
||||
# rv.x = p.x;\n\t
|
||||
# rv.y = p.y*c+p.z*s;\n\t
|
||||
# rv.z = -p.y*s+p.z*c;\n\t
|
||||
# c = cos(a.y);\n\t
|
||||
# s = sin(a.y);\n\t
|
||||
# p.x = rv.x*c+rv.z*s;\n\t
|
||||
# p.y = rv.y;\n\t
|
||||
# p.z = -rv.x*s+rv.z*c;\n\t
|
||||
# c = cos(a.z);\n\t
|
||||
# s = sin(a.z);\n\t
|
||||
# rv.x = p.x*c+p.y*s;\n\t
|
||||
# rv.y = -p.x*s+p.y*c;\n\t
|
||||
# rv.z = p.z;\n\t
|
||||
# return rv;\n
|
||||
#}
|
||||
|
@ -1,707 +0,0 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#tile2x2.mmg
|
||||
#Places 4 input images into a single output to create an atlas of 4 images.
|
||||
#Chaining Tile2x2 nodes can be useful to create 16 images atlases.
|
||||
#Atlases are used by remapping nodes such as CustomUV, Tiler and Splatter.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The first input",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The second input",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The third input",
|
||||
# "name": "in3",
|
||||
# "shortdesc": "Input3",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The fourth input",
|
||||
# "name": "in4",
|
||||
# "shortdesc": "Input4",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated atlas",
|
||||
# "rgba": "($uv.y < 0.5) ? (($uv.x < 0.5) ? ($in1(2.0*$uv)) : ($in2(2.0*$uv-vec2(1.0, 0.0)))) : (($uv.x < 0.5) ? ($in3(2.0*$uv-vec2(0.0, 1.0))) : ($in4(2.0*$uv-vec2(1.0, 1.0))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tile2x2_variations.mmg
|
||||
#Places 4 input images into a single output to create an atlas of 4 images.
|
||||
#Chaining Tile2x2 nodes can be useful to create 16 images atlases.
|
||||
#Atlases are used by remapping nodes such as CustomUV, Tiler and Splatter.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The first input",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated atlas",
|
||||
# "rgba": "($uv.y < 0.5) ? (($uv.x < 0.5) ? ($in.variation(2.0*$uv, $seed)) : ($in.variation(2.0*$uv-vec2(1.0, 0.0), $seed+0.1))) : (($uv.x < 0.5) ? ($in.variation(2.0*$uv-vec2(0.0, 1.0), $seed+0.2)) : ($in.variation(2.0*$uv-vec2(1.0, 1.0), $seed+0.3)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
#vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)));
|
||||
|
||||
#instance
|
||||
#vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed) {\n\t
|
||||
# float c = 0.0;\n\t
|
||||
# vec3 rc = vec3(0.0);\n\t
|
||||
# vec3 rc1;\n\t
|
||||
# for (int dx = -overlap; dx <= overlap; ++dx) {\n\t\t
|
||||
# for (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\t
|
||||
# vec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\t
|
||||
# vec2 seed = rand2(pos+_seed);\n\t\t\t
|
||||
# rc1 = rand3(seed);\n\t\t\t
|
||||
# pos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\n\t\t\t
|
||||
# float mask = $mask(fract(pos+vec2(0.5)));\n\t\t\t
|
||||
#
|
||||
# if (mask > 0.01) {\n\t\t\t\t
|
||||
# vec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\t\t
|
||||
# float ca = cos(angle);\n\t\t\t\t
|
||||
# float sa = sin(angle);\n\t\t\t\t
|
||||
# pv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\t
|
||||
# pv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\t
|
||||
# pv /= vec2($scale_x, $scale_y);\n\t\t\t\t
|
||||
# pv += vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# vec2 clamped_pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\t\t
|
||||
# if (pv.x != clamped_pv.x || pv.y != clamped_pv.y) {\n\t\t\t\t\t
|
||||
# continue;\n\t\t\t\t
|
||||
# }\n\t\t\t\t
|
||||
#
|
||||
# $select_inputs\n\t\t\t\t
|
||||
#
|
||||
# float c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask*(1.0-$value*seed.x);\n\t\t\t\t
|
||||
# c = max(c, c1);\n\t\t\t\t
|
||||
# rc = mix(rc, rc1, step(c, c1));\n\t\t\t
|
||||
# }\n\t\t
|
||||
# }\n\t
|
||||
# }\n\t
|
||||
#
|
||||
# return vec4(rc, c);\n
|
||||
#}
|
||||
|
||||
#Inputs:
|
||||
|
||||
#in, float, default: 0, - The input image or atlas of 4 or 16 input images
|
||||
#Mask, float, default: 1, - The mask applied to the pattern
|
||||
|
||||
#Outputs:
|
||||
#Output, float, Shows the generated pattern
|
||||
#$(name_uv)_rch.a
|
||||
|
||||
#Instance map, rgb, Shows a random color for each instance of the input image
|
||||
#$(name_uv)_rch.rgb
|
||||
|
||||
#select_inputs enum
|
||||
#1, " "
|
||||
#4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
#16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
|
||||
#Parameters:
|
||||
#tile, Vector2, default 4, min:1, max:64, step:1 - The number of columns of the tiles pattern
|
||||
#overlap, float, default 1, min 0, max 5, step 1 - The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.
|
||||
#select_inputs (Inputs), enum, default 0, values 1, 4, 16
|
||||
#scale, Vector2, default 1, min:0, max:2, step:0.01 - "The scale of input images on the X axis
|
||||
#fixed_offset, float, default 0.5, min 0, max 1, step 0.01 - The relative offset of odd rows
|
||||
#offset (rnd_offset), float, default 0.5, min 0, max 1, step 0.01
|
||||
#rotate (rnd_rotate), float, default 0, min 0, max 180, step 0.1
|
||||
#scale (rnd_scale), float, default 0.5, min 0, max 1, step 0.01 - The random scale applied to each image instance
|
||||
#value (rnd_value), float, default 0.5, min 0, max 1, step 0.01 - The random greyscale value applied to each image instance
|
||||
#variations, bool, default false, (disabled) - Check to tile variations of the input
|
||||
|
||||
#----------------------
|
||||
#tiler_advanced.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
# "code": "vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed));",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image or atlas of 4 or 16 input images",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The mask applied to the pattern",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2($uv+vec2(float($seed))), rand2($uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 1 output",
|
||||
# "name": "color1",
|
||||
# "shortdesc": "Color map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2(-$uv+vec2(float($seed))), rand2(-$uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 2 output",
|
||||
# "name": "color2",
|
||||
# "shortdesc": "Color map 2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "5:",
|
||||
# "longdesc": "A map for translation along the X axis",
|
||||
# "name": "tr_x",
|
||||
# "shortdesc": "Translate map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for translation along the Y axis",
|
||||
# "name": "tr_y",
|
||||
# "shortdesc": "Translate map Y",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for rotation",
|
||||
# "name": "r",
|
||||
# "shortdesc": "Rotate map",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the X axis",
|
||||
# "name": "sc_x",
|
||||
# "shortdesc": "Scale map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the Y axis",
|
||||
# "name": "sc_y",
|
||||
# "shortdesc": "Scale map Y",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, float _seed) {\n\tfloat c = 0.0;\n\tvec2 map_uv = vec2(0.0);\n\tfor (int dx = -overlap; dx <= overlap; ++dx) {\n\t\tfor (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\tvec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\tfloat mask = $mask(fract(pos+vec2(0.5)));\n\t\t\tif (mask > 0.01) {\n\t\t\t\tvec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\tpos = fract(pos+vec2(0.5));\n\t\t\t\tpv -= vec2($translate_x*$tr_x(pos), $translate_y*$tr_y(pos))/tile;\n\t\t\t\tfloat angle = $r(pos) * $rotate * 0.01745329251;\n\t\t\t\tfloat ca = cos(angle);\n\t\t\t\tfloat sa = sin(angle);\n\t\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\tpv /= vec2($scale_x*$sc_x(pos), $scale_y*$sc_y(pos));\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvec2 seed = rand2(vec2(_seed)+pos);\n\t\t\t\t$select_inputs\n\t\t\t\tfloat c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask;\n\t\t\t\tc = max(c, c1);\n\t\t\t\tmap_uv = mix(map_uv, pos, step(c, c1));\n\t\t\t}\n\t\t}\n\t}\n\treturn vec4(map_uv, 0.0, c);\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$(name_uv)_rch.a",
|
||||
# "longdesc": "Shows the generated pattern",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color1($(name_uv)_rch.rg)",
|
||||
# "shortdesc": "Instance map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color2($(name_uv)_rch.rg)",
|
||||
# "shortdesc": "Instance map 2",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile X",
|
||||
# "longdesc": "The number of columns of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "tx",
|
||||
# "shortdesc": "Tile.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile Y",
|
||||
# "longdesc": "The number of rows of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "ty",
|
||||
# "shortdesc": "Tile.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Overlap",
|
||||
# "longdesc": "The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.",
|
||||
# "max": 5,
|
||||
# "min": 0,
|
||||
# "name": "overlap",
|
||||
# "shortdesc": "Overlap",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Inputs",
|
||||
# "longdesc": "The input type of the node:\n- 1: single image\n- 4: atlas of 4 images\n- 16: atlas of 16 images\nAtlases can be created using the Tile2x2 node.",
|
||||
# "name": "select_inputs",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "1",
|
||||
# "value": " "
|
||||
# },
|
||||
# {
|
||||
# "name": "4",
|
||||
# "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
# },
|
||||
# {
|
||||
# "name": "16",
|
||||
# "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate X",
|
||||
# "longdesc": "The translation along the X axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_x",
|
||||
# "shortdesc": "Translate.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate Y",
|
||||
# "longdesc": "The translation along the Y axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_y",
|
||||
# "shortdesc": "Translate.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rotate",
|
||||
# "longdesc": "The angle of instances of the input",
|
||||
# "max": 180,
|
||||
# "min": 0,
|
||||
# "name": "rotate",
|
||||
# "shortdesc": "Rotate",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of input images on the X axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of input images on the Y axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": false,
|
||||
# "label": "Variations",
|
||||
# "longdesc": "Check to tile variations of the input",
|
||||
# "name": "variations",
|
||||
# "shortdesc": "Variations",
|
||||
# "type": "boolean"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler_advanced_color.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
# "code": "vec2 $(name_uv)_mapuv;\nvec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed), $(name_uv)_mapuv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(1.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image or atlas of 4 or 16 input images",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The mask applied to the pattern",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2($uv+vec2(float($seed))), rand2($uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 1 output",
|
||||
# "name": "color1",
|
||||
# "shortdesc": "Color map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2(-$uv+vec2(float($seed))), rand2(-$uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 2 output",
|
||||
# "name": "color2",
|
||||
# "shortdesc": "Color map 2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "5:",
|
||||
# "longdesc": "A map for translation along the X axis",
|
||||
# "name": "tr_x",
|
||||
# "shortdesc": "Translate map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for translation along the Y axis",
|
||||
# "name": "tr_y",
|
||||
# "shortdesc": "Translate map Y",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for rotation",
|
||||
# "name": "r",
|
||||
# "shortdesc": "Rotate map",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the X axis",
|
||||
# "name": "sc_x",
|
||||
# "shortdesc": "Scale map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the Y axis",
|
||||
# "name": "sc_y",
|
||||
# "shortdesc": "Scale map Y",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, float _seed, out vec2 outmapuv) {\n\t// $seed\n\tvec4 c = vec4(0.0);\n\toutmapuv = vec2(0.0);\n\tfor (int dx = -overlap; dx <= overlap; ++dx) {\n\t\tfor (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\tvec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\tfloat mask = $mask(fract(pos+vec2(0.5)));\n\t\t\tif (mask > 0.01) {\n\t\t\t\tvec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\tpos = fract(pos+vec2(0.5));\n\t\t\t\tpv -= vec2($translate_x*$tr_x(pos), $translate_y*$tr_y(pos))/tile;\n\t\t\t\tfloat angle = $r(pos) * $rotate * 0.01745329251;\n\t\t\t\tfloat ca = cos(angle);\n\t\t\t\tfloat sa = sin(angle);\n\t\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\tpv /= vec2($scale_x*$sc_x(pos), $scale_y*$sc_y(pos));\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvec2 seed = rand2(vec2(_seed)+pos);\n\t\t\t\t$select_inputs\n\t\t\t\tvec4 n = $in.variation(pv, $variations ? seed.x : 0.0);\n\t\t\t\tfloat na = n.a*mask;\n\t\t\t\toutmapuv = mix(outmapuv, pos, step(c.a, na));\n\t\t\t\tc = mix(c, n, na);\n\t\t\t}\n\t\t}\n\t}\n\treturn c;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated pattern",
|
||||
# "rgba": "$(name_uv)_rch",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color1($(name_uv)_mapuv)",
|
||||
# "shortdesc": "Instance map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color2($(name_uv)_mapuv)",
|
||||
# "shortdesc": "Instance map 2",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile X",
|
||||
# "longdesc": "The number of columns of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "tx",
|
||||
# "shortdesc": "Tile.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile Y",
|
||||
# "longdesc": "The number of rows of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "ty",
|
||||
# "shortdesc": "Tile.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Overlap",
|
||||
# "longdesc": "The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.",
|
||||
# "max": 5,
|
||||
# "min": 0,
|
||||
# "name": "overlap",
|
||||
# "shortdesc": "Overlap",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Inputs",
|
||||
# "longdesc": "The input type of the node:\n- 1: single image\n- 4: atlas of 4 images\n- 16: atlas of 16 images\nAtlases can be created using the Tile2x2 node.",
|
||||
# "name": "select_inputs",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "1",
|
||||
# "value": " "
|
||||
# },
|
||||
# {
|
||||
# "name": "4",
|
||||
# "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
# },
|
||||
# {
|
||||
# "name": "16",
|
||||
# "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate X",
|
||||
# "longdesc": "The translation along the X axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_x",
|
||||
# "shortdesc": "Translate.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate Y",
|
||||
# "longdesc": "The translation along the Y axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_y",
|
||||
# "shortdesc": "Translate.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rotate",
|
||||
# "longdesc": "The angle of instances of the input",
|
||||
# "max": 180,
|
||||
# "min": 0,
|
||||
# "name": "rotate",
|
||||
# "shortdesc": "Rotate",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of input images on the X axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of input images on the Y axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": false,
|
||||
# "label": "Variations",
|
||||
# "longdesc": "Check to tile variations of the input",
|
||||
# "name": "variations",
|
||||
# "shortdesc": "Variations",
|
||||
# "type": "boolean"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler_color.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
#vec3 $(name_uv)_random_color;\n
|
||||
#vec4 $(name_uv)_tiled_output = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)), $(name_uv)_random_color);
|
||||
|
||||
#vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed, out vec3 random_color) {\n\t
|
||||
# vec4 c = vec4(0.0);\n\t
|
||||
# vec3 rc = vec3(0.0);\n\t
|
||||
# vec3 rc1;\n\t
|
||||
#
|
||||
# for (int dx = -overlap; dx <= overlap; ++dx) {\n\t\t
|
||||
# for (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\t
|
||||
# vec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\t
|
||||
# vec2 seed = rand2(pos+_seed);\n\t\t\t
|
||||
# rc1 = rand3(seed);\n\t\t\t
|
||||
# pos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\n\t\t\t
|
||||
# float mask = $mask(fract(pos+vec2(0.5)));\n\t\t\t
|
||||
# if (mask > 0.01) {\n\t\t\t\t
|
||||
# vec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\t\t
|
||||
# float ca = cos(angle);\n\t\t\t\t
|
||||
# float sa = sin(angle);\n\t\t\t\t
|
||||
# pv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\t
|
||||
# pv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\t
|
||||
# pv /= vec2($scale_x, $scale_y);\n\t\t\t\t
|
||||
# pv += vec2(0.5);\n\t\t\t\t
|
||||
# pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\t\t
|
||||
#
|
||||
# $select_inputs\n\t\t\t\t
|
||||
#
|
||||
# vec4 n = $in.variation(pv, $variations ? seed.x : 0.0);\n\t\t\t\t
|
||||
#
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float na = n.a*mask*(1.0-$opacity*seed.x);\n\t\t\t\t
|
||||
# float a = (1.0-c.a)*(1.0*na);\n\t\t\t\t
|
||||
#
|
||||
# c = mix(c, n, na);\n\t\t\t\t
|
||||
# rc = mix(rc, rc1, n.a);\n\t\t\t
|
||||
# }\n\t\t
|
||||
# }\n\t
|
||||
# }\n\t
|
||||
#
|
||||
# random_color = rc;\n\t
|
||||
# return c;\n
|
||||
#}
|
||||
|
||||
|
||||
#Inputs:
|
||||
|
||||
#in, rgba, default: 0, - The input image or atlas of 4 or 16 input images
|
||||
#Mask, float, default: 1, - The mask applied to the pattern
|
||||
|
||||
#Outputs:
|
||||
#Output, float, Shows the generated pattern
|
||||
#$(name_uv)_tiled_output
|
||||
|
||||
#Instance map, rgb, Shows a random color for each instance of the input image
|
||||
#$(name_uv)_random_color
|
||||
|
||||
#select_inputs enum
|
||||
#1, " "
|
||||
#4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
#16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
|
||||
#Parameters:
|
||||
#tile, Vector2, default 4, min:1, max:64, step:1 - The number of columns of the tiles pattern
|
||||
#overlap, float, default 1, min 0, max 5, step 1 - The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.
|
||||
#select_inputs (Inputs), enum, default 0, values 1, 4, 16
|
||||
#scale, Vector2, default 1, min:0, max:2, step:0.01 - "The scale of input images on the X axis
|
||||
#fixed_offset, float, default 0.5, min 0, max 1, step 0.01 - The relative offset of odd rows
|
||||
#offset (rnd_offset), float, default 0.5, min 0, max 1, step 0.01
|
||||
#rotate (rnd_rotate), float, default 0, min 0, max 180, step 0.1
|
||||
#scale (rnd_scale), float, default 0.5, min 0, max 1, step 0.01 - The random scale applied to each image instance
|
||||
#opacity (rnd_opacity), float, default 0, min 0, max 1, step 0.01 - The random greyscale value applied to each image instance
|
||||
#variations, bool, default false, (disabled) - Check to tile variations of the input
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user