Added more notes to colors.gd, and removed the corresponding material maker mmg files.

This commit is contained in:
Relintai 2021-10-10 09:00:39 +02:00
parent c07ca3d8d8
commit bfd32409d2
4 changed files with 11 additions and 211 deletions
game/addons/mat_maker_gd/nodes

View File

@ -66,6 +66,8 @@ static func hsv_to_rgb(c : Vector3) -> Vector3:
#saturation, min: 0, max: 2, step: 0, default: 1
#value, min: 0, max: 2, step: 0, default: 1
#output: vec4(hsv_to_rgb($(name_uv)_hsv), $(name_uv)_rbga.a)
static func adjust_hsv(color : Color, hue : float, saturation : float, value : float) -> Color:
var hsv : Vector3 = rgb_to_hsv(Vector3(color.r, color.g, color.b));
@ -80,7 +82,9 @@ static func adjust_hsv(color : Color, hue : float, saturation : float, value : f
#brightness, min: -1, max: 1, step: 0.01, default: 0
#contrast, min: -1, max: 1, step: 0.01, default: 1
#vec4(clamp($in($uv).rgb*$contrast+vec3($brightness)+0.5-$contrast*0.5, vec3(0.0), vec3(1.0)), $in($uv).a)
#input: default: vec4(0.5 ,0.5, 0.5, 1.0) -> img
#output: vec4(clamp($in($uv).rgb*$contrast+vec3($brightness)+0.5-$contrast*0.5, vec3(0.0), vec3(1.0)), $in($uv).a)
static func brightness_contrast(color : Color, brightness : float, contrast : float) -> Color:
var bv : Vector3 = Vector3(brightness, brightness, brightness)
@ -92,6 +96,12 @@ static func brightness_contrast(color : Color, brightness : float, contrast : fl
return Color(v.x, v.y, v.z, 1);
#greyscale
#input: default: vec3(0.0). (Image)
#output: gs_$mode($in($uv))
#mode: enum: Lightness, Average, Luminosity, Min, Max. default: 4
#float gs_min(vec3 c) {
# return min(c.r, min(c.g, c.b));
#}

View File

@ -1,77 +0,0 @@
{
"name": "adjust_hsv",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"hue": 0,
"saturation": 1,
"value": 1
},
"shader_model": {
"code": "vec4 $(name_uv)_rbga = $in($(uv));\nvec3 $(name_uv)_hsv = rgb_to_hsv($(name_uv)_rbga.rgb);\n$(name_uv)_hsv.x += $(hue);\n$(name_uv)_hsv.y = clamp($(name_uv)_hsv.y*$(saturation), 0.0, 1.0);\n$(name_uv)_hsv.z = clamp($(name_uv)_hsv.z*$(value), 0.0, 1.0);\n\t",
"global": "vec3 rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv_to_rgb(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n",
"inputs": [
{
"default": "vec4($uv.x, $uv.y, 0.0, 1.0)",
"label": "",
"longdesc": "The input image",
"name": "in",
"shortdesc": "Input",
"type": "rgba"
}
],
"instance": "",
"longdesc": "Adjusts the Hue, Saturation and Value of its input",
"name": "AdjustHSV",
"outputs": [
{
"longdesc": "Shows the image with adjusted Hue, Saturation and Value",
"rgba": "vec4(hsv_to_rgb($(name_uv)_hsv), $(name_uv)_rbga.a)",
"shortdesc": "Output",
"type": "rgba"
}
],
"parameters": [
{
"control": "None",
"default": 0,
"label": "Hue",
"longdesc": "The Hue adjustment",
"max": 0.5,
"min": -0.5,
"name": "hue",
"shortdesc": "Hue",
"step": 0,
"type": "float"
},
{
"control": "None",
"default": 1,
"label": "Saturation",
"longdesc": "The Saturation adjustment",
"max": 2,
"min": 0,
"name": "saturation",
"shortdesc": "Saturation",
"step": 0,
"type": "float"
},
{
"control": "None",
"default": 1,
"label": "Value",
"longdesc": "The Value adjustment",
"max": 2,
"min": 0,
"name": "value",
"shortdesc": "Value",
"step": 0,
"type": "float"
}
],
"shortdesc": "Adjust HSV"
},
"type": "shader"
}

View File

@ -1,64 +0,0 @@
{
"name": "brightness_contrast",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"brightness": 0,
"contrast": 1
},
"shader_model": {
"code": "",
"global": "",
"inputs": [
{
"default": "vec4(0.5 ,0.5, 0.5, 1.0)",
"label": "",
"longdesc": "The input image",
"name": "in",
"shortdesc": "Input",
"type": "rgba"
}
],
"instance": "",
"longdesc": "Adjusts the Brightness and Contrast of its input",
"name": "Brightness/Contrast",
"outputs": [
{
"longdesc": "Shows the image with modified Brightness and Contrast",
"rgba": "vec4(clamp($in($uv).rgb*$contrast+vec3($brightness)+0.5-$contrast*0.5, vec3(0.0), vec3(1.0)), $in($uv).a)",
"shortdesc": "Output",
"type": "rgba"
}
],
"parameters": [
{
"control": "None",
"default": 0,
"label": "Brightness",
"longdesc": "The Brightness adjustment",
"max": 1,
"min": -1,
"name": "brightness",
"shortdesc": "Brightness",
"step": 0.01,
"type": "float"
},
{
"control": "None",
"default": 1,
"label": "Contrast",
"longdesc": "The Contrast adjustment",
"max": 2,
"min": 0,
"name": "contrast",
"shortdesc": "Contrast",
"step": 0.01,
"type": "float"
}
],
"shortdesc": "Brightness/Contrast"
},
"type": "shader"
}

View File

@ -1,69 +0,0 @@
{
"name": "greyscale",
"node_position": {
"x": 0,
"y": 0
},
"parameters": {
"mode": 2
},
"shader_model": {
"code": "",
"global": "float gs_min(vec3 c) {\n\treturn min(c.r, min(c.g, c.b));\n}\nfloat gs_max(vec3 c) {\n\treturn max(c.r, max(c.g, c.b));\n}\nfloat gs_lightness(vec3 c) {\n\treturn 0.5*(max(c.r, max(c.g, c.b)) + min(c.r, min(c.g, c.b)));\n}\nfloat gs_average(vec3 c) {\n\treturn 0.333333333333*(c.r + c.g + c.b);\n}\nfloat gs_luminosity(vec3 c) {\n\treturn 0.21 * c.r + 0.72 * c.g + 0.07 * c.b;\n}\n",
"inputs": [
{
"default": "vec3(0.0)",
"label": "",
"longdesc": "The input image",
"name": "in",
"shortdesc": "Input",
"type": "rgb"
}
],
"instance": "",
"longdesc": "Converts its input into greyscale",
"name": "Greyscale",
"outputs": [
{
"f": "gs_$mode($in($uv))",
"longdesc": "Shows the image converted to greyscale",
"shortdesc": "Output",
"type": "f"
}
],
"parameters": [
{
"default": 4,
"label": "",
"longdesc": "The algorithm used to convert the input into greyscale",
"name": "mode",
"shortdesc": "Mode",
"type": "enum",
"values": [
{
"name": "Lightness",
"value": "lightness"
},
{
"name": "Average",
"value": "average"
},
{
"name": "Luminosity",
"value": "luminosity"
},
{
"name": "Min",
"value": "min"
},
{
"name": "Max",
"value": "max"
}
]
}
],
"shortdesc": "Greyscale"
},
"type": "shader"
}