mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Turned pattern.mmg to notes.
This commit is contained in:
parent
d6148fd43c
commit
b622bb2f73
@ -1,6 +1,8 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
#pattern.mmg
|
||||
|
||||
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)
|
||||
@ -152,46 +154,97 @@ static func transform(uv : Vector2, translate : Vector2, rotate : float, scale :
|
||||
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);
|
||||
|
||||
static func fractf(x : float) -> float:
|
||||
return x - floor(x)
|
||||
|
||||
#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);
|
||||
|
@ -3,11 +3,21 @@ extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#beehive.mmg
|
||||
#Outputs: 3 beehive_1c, beehive_2c, beehive_3c
|
||||
#Inputs:
|
||||
#size, vector2, default: 2, min: 1, max: 64, step: 1
|
||||
|
||||
#----------------------
|
||||
#pattern.mmg
|
||||
#Outputs: $(name)_fct($(uv))
|
||||
|
||||
#Combiner, enum, default: 0, values (CombinerType): Multiply, Add, Max, Min, Xor, Pow
|
||||
#Pattern_x_type, enum, default: 5, values (CombinerAxisType): Sine, Triangle, Square, Sawtooth, Constant, Bounce
|
||||
#Pattern_y_type, enum, default: 5, values (CombinerAxisType): Sine, Triangle, Square, Sawtooth, Constant, Bounce
|
||||
#Pattern_Repeat, vector2, min: 0, max: 32, default:4, step: 1
|
||||
|
||||
enum CombinerAxisType {
|
||||
SINE,
|
||||
TRIANGLE,
|
||||
@ -26,11 +36,14 @@ enum CombinerType {
|
||||
POW
|
||||
}
|
||||
|
||||
#float $(name)_fct(vec2 uv) {\n\t
|
||||
# return mix_$(mix)(wave_$(x_wave)($(x_scale)*uv.x), wave_$(y_wave)($(y_scale)*uv.y));
|
||||
#}
|
||||
|
||||
static func pattern(uv : Vector2, x_scale : float, y_scale : float, ct : int, catx : int, caty : int) -> float:
|
||||
var x : float = 0
|
||||
var y : float = 0
|
||||
|
||||
#in c++ these ifs should be function pointers or macros in the caller
|
||||
if catx == CombinerAxisType.SINE:
|
||||
x = Commons.wave_sine(x_scale * uv.x)
|
||||
elif catx == CombinerAxisType.TRIANGLE:
|
||||
|
@ -1,160 +0,0 @@
|
||||
{
|
||||
"name": "pattern",
|
||||
"node_position": {
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"parameters": {
|
||||
"mix": 0,
|
||||
"x_scale": 4,
|
||||
"x_wave": 0,
|
||||
"y_scale": 4,
|
||||
"y_wave": 0
|
||||
},
|
||||
"shader_model": {
|
||||
"code": "",
|
||||
"global": "float wave_constant(float x) {\n\treturn 1.0;\n}\n\nfloat wave_sine(float x) {\n\treturn 0.5-0.5*cos(3.14159265359*2.0*x);\n}\n\nfloat wave_triangle(float x) {\n\tx = fract(x);\n\treturn min(2.0*x, 2.0-2.0*x);\n}\n\nfloat wave_sawtooth(float x) {\n\treturn fract(x);\n}\n\nfloat wave_square(float x) {\n\treturn (fract(x) < 0.5) ? 0.0 : 1.0;\n}\n\nfloat wave_bounce(float x) {\n\tx = 2.0*(fract(x)-0.5);\n\treturn sqrt(1.0-x*x);\n}\n\nfloat mix_mul(float x, float y) {\n\treturn x*y;\n}\n\nfloat mix_add(float x, float y) {\n\treturn min(x+y, 1.0);\n}\n\nfloat mix_max(float x, float y) {\n\treturn max(x, y);\n}\n\nfloat mix_min(float x, float y) {\n\treturn min(x, y);\n}\n\nfloat mix_xor(float x, float y) {\n\treturn min(x+y, 2.0-x-y);\n}\n\nfloat mix_pow(float x, float y) {\n\treturn pow(x, y);\n}",
|
||||
"inputs": [
|
||||
|
||||
],
|
||||
"instance": "float $(name)_fct(vec2 uv) {\n\treturn mix_$(mix)(wave_$(x_wave)($(x_scale)*uv.x), wave_$(y_wave)($(y_scale)*uv.y));\n}",
|
||||
"name": "Pattern",
|
||||
"outputs": [
|
||||
{
|
||||
"f": "$(name)_fct($(uv))",
|
||||
"longdesc": "A greyscale image that combines the horizontal and vertical patterns",
|
||||
"shortdesc": "Output",
|
||||
"type": "f"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"default": 0,
|
||||
"label": "Combiner",
|
||||
"longdesc": "The operation used to combine the horizontal and the vertical 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": 5,
|
||||
"label": "X",
|
||||
"longdesc": "Pattern generated along the X axis",
|
||||
"name": "x_wave",
|
||||
"shortdesc": "X Pattern",
|
||||
"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": "X Repeat",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
},
|
||||
{
|
||||
"default": 5,
|
||||
"label": "Y",
|
||||
"longdesc": "Pattern generated along the Y axis",
|
||||
"name": "y_wave",
|
||||
"shortdesc": "Y Pattern",
|
||||
"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": "Y Repeat",
|
||||
"step": 1,
|
||||
"type": "float"
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": "shader"
|
||||
}
|
Loading…
Reference in New Issue
Block a user