diff --git a/game/addons/.gitignore b/game/addons/.gitignore index 8b72fd6a..4ad2e5bd 100644 --- a/game/addons/.gitignore +++ b/game/addons/.gitignore @@ -11,5 +11,7 @@ !mesh_data_resource_editor/** !multirun !multirun/** +!mat_maker_gd +!mat_maker_gd/** !addon_versions diff --git a/game/addons/mat_maker_gd/LICENSE.md b/game/addons/mat_maker_gd/LICENSE.md new file mode 100644 index 00000000..ca6aeaf3 --- /dev/null +++ b/game/addons/mat_maker_gd/LICENSE.md @@ -0,0 +1,22 @@ +# MIT License + +Copyright (c) 2020 Péter Magyar +Copyright (c) 2018-2020 Rodolphe Suescun and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/game/addons/mat_maker_gd/README.md b/game/addons/mat_maker_gd/README.md new file mode 100644 index 00000000..7543b79a --- /dev/null +++ b/game/addons/mat_maker_gd/README.md @@ -0,0 +1,6 @@ +# mat_maker_gd + +My goal with this project is to take Material Maker's ( https://github.com/RodZill4/material-maker ) code, +and make it an in-godot texture/image generator. + +If it turns out well I'll probably turn it into a c++ engine module eventually. diff --git a/game/addons/mat_maker_gd/filter/filter.gd b/game/addons/mat_maker_gd/filter/filter.gd new file mode 100644 index 00000000..95c51b17 --- /dev/null +++ b/game/addons/mat_maker_gd/filter/filter.gd @@ -0,0 +1,324 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + var f : float = shape_circle(v, 3, 1.0 * 1.0, 1.0) + var c : Color = Color(f, f, f, 1) + +# c = invert(c) +# c = brightness_contrast(c) + + #needs work + c = adjust_hsv(c) + + image.set_pixel(x, y, c) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func invert(color : Color) -> Color: + return Color(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a); + +var p_o91644_brightness = 0.000000000; +var p_o91644_contrast = 1.000000000; + +func brightness_contrast(color : Color) -> Color: + var bv : Vector3 = Vector3(p_o91644_brightness, p_o91644_brightness, p_o91644_brightness) + var cvv : Vector3 = Vector3(color.r * p_o91644_contrast, color.g * p_o91644_contrast, color.b * p_o91644_contrast) + + var cv : Vector3 = cvv + bv + Vector3(0.5, 0.5, 0.5) - (Vector3(p_o91644_contrast, p_o91644_contrast, p_o91644_contrast) * 0.5) + + var v : Vector3 = clampv3(cv, Vector3(), Vector3(1, 1, 1)) + + return Color(v.x, v.y, v.z, 1); + +var p_o102649_hue = 0.000000000; +var p_o102649_saturation = 1.000000000; +var p_o102649_value = 1.000000000; + +func adjust_hsv(color : Color) -> Color: + var hsv : Vector3 = rgb_to_hsv(Vector3(color.r, color.g, color.b)); + + var x : float = fract(hsv.x + p_o102649_hue) + var y : float = clamp(hsv.y * p_o102649_saturation, 0.0, 1.0) + var z : float = clamp(hsv.z * p_o102649_value, 0.0, 1.0) + + var h : Vector3 = hsv_to_rgb(Vector3(x, y, z)) + + return Color(h.x, h.y, h.z, color.a); + +func rgb_to_hsv(c : Vector3) -> Vector3: + var K : Color = Color(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + + var p : Color + + if c.y < c.z: + p = Color(c.z, c.y, K.a, K.b) + else: + p = Color(c.y, c.z, K.r, K.g); + + var q : Color + + if c.x < p.r: + q = Color(p.r, p.g, p.a, c.x) + else: + q = Color(c.x, p.g, p.b, p.r); + + var d : float = q.r - min(q.a, q.g); + var e : float = 1.0e-10; + + return Vector3(abs(q.b + (q.a - q.g) / (6.0 * d + e)), d / (q.r + e), q.r); + +func hsv_to_rgb(c : Vector3) -> Vector3: + var K : Color = Color(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + + var p : Vector3 = absv3(fractv3(Vector3(c.x, c.x, c.x) + Vector3(K.r, K.g, K.b)) * 6.0 - Vector3(K.a, K.a, K.a)); + + return c.z * lerp(Vector3(K.r, K.r, K.r), clampv3(p - Vector3(K.r, K.r, K.r), Vector3(), Vector3(1, 1, 1)), c.y); + +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) + + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/filter/filter.tscn b/game/addons/mat_maker_gd/filter/filter.tscn new file mode 100644 index 00000000..3edd6489 --- /dev/null +++ b/game/addons/mat_maker_gd/filter/filter.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/filter/filter.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/filter/grayscale.gd b/game/addons/mat_maker_gd/filter/grayscale.gd new file mode 100644 index 00000000..f12b04f1 --- /dev/null +++ b/game/addons/mat_maker_gd/filter/grayscale.gd @@ -0,0 +1,286 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + var f : float = shape_circle(v, 3, 1.0 * 1.0, 1.0) + + f = gs_luminosity(Vector3(f, f, f)); + + var c : Color = Color(f, f, f, 1) + +# c = invert(c) +# c = brightness_contrast(c) + + #needs work + + image.set_pixel(x, y, c) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func invert(color : Color) -> Color: + return Color(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a); + + +func gs_min(c : Vector3) -> float: + return min(c.x, min(c.y, c.z)); + +func gs_max(c : Vector3) -> float: + return max(c.x, max(c.y, c.z)); + +func gs_lightness(c : Vector3) -> float: + return 0.5*(max(c.x, max(c.y, c.z)) + min(c.x, min(c.y, c.z))); + +func gs_average(c : Vector3) -> float: + return 0.333333333333*(c.x + c.y + c.z); + +func gs_luminosity(c : Vector3) -> float: + return 0.21 * c.x + 0.72 * c.y + 0.07 * c.z; + + +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) + + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#vec3 rgb2hsv(vec3 c) { +# vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); +# vec4 p = c.y < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy); +# vec4 q = c.x < 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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/filter/grayscale.tscn b/game/addons/mat_maker_gd/filter/grayscale.tscn new file mode 100644 index 00000000..eca88d62 --- /dev/null +++ b/game/addons/mat_maker_gd/filter/grayscale.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/filter/grayscale.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/filter/sharpen.gd b/game/addons/mat_maker_gd/filter/sharpen.gd new file mode 100644 index 00000000..ab82e7b6 --- /dev/null +++ b/game/addons/mat_maker_gd/filter/sharpen.gd @@ -0,0 +1,265 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + var f : Vector3 = sharpen(v) + + var c : Color = Color(f.x, f.y, f.z, 1) + +# c = invert(c) +# c = brightness_contrast(c) + + #needs work + + image.set_pixel(x, y, c) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func o11853_input_in(uv : Vector2) -> Vector3: + var f : float = shape_circle(uv, 3, 1.0 * 1.0, 1.0) + + return Vector3(f, f, f); + +func sharpen(uv : Vector2) -> Vector3: + var e : Vector2 = Vector2(1.0 / 32.000000000, 0.0); + var rv : Vector3 = 5.0 * o11853_input_in(uv); + + rv -= o11853_input_in(uv + Vector2(e.x, e.y)); + rv -= o11853_input_in(uv - Vector2(e.x, e.y)); + rv -= o11853_input_in(uv + Vector2(e.y, e.x)); + rv -= o11853_input_in(uv - Vector2(e.y, e.x)); + + return rv + +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) + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#vec3 rgb2hsv(vec3 c) { +# vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); +# vec4 p = c.y < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy); +# vec4 q = c.x < 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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/filter/sharpen.tscn b/game/addons/mat_maker_gd/filter/sharpen.tscn new file mode 100644 index 00000000..1dabce1c --- /dev/null +++ b/game/addons/mat_maker_gd/filter/sharpen.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/filter/sharpen.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/material_maker_nodes/adjust_hsv.mmg b/game/addons/mat_maker_gd/material_maker_nodes/adjust_hsv.mmg new file mode 100644 index 00000000..e86d7600 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/adjust_hsv.mmg @@ -0,0 +1,77 @@ +{ + "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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/arc_pavement.mmg b/game/addons/mat_maker_gd/material_maker_nodes/arc_pavement.mmg new file mode 100644 index 00000000..7b7dd921 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/arc_pavement.mmg @@ -0,0 +1,109 @@ +{ + "name": "arc_pavement", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0.2, + "bricks": 8, + "mortar": 0.05, + "repeat": 2, + "rows": 12 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "vec2 $(name_uv)_uv = fract($uv)*vec2($repeat, -1.0);\nvec2 $(name_uv)_seed;\nvec4 $(name_uv)_ap = arc_pavement($(name_uv)_uv, $rows, $bricks, $(name_uv)_seed);\n", + "global": "float pavement(vec2 uv, float bevel, float mortar) {\n\tuv = abs(uv-vec2(0.5));\n\treturn clamp((0.5*(1.0-mortar)-max(uv.x, uv.y))/max(0.0001, bevel), 0.0, 1.0);\n}\n\nvec4 arc_pavement(vec2 uv, float acount, float lcount, out vec2 seed) {\n\tfloat PI = 3.141592654;\n\tfloat radius = (0.5/sqrt(2.0));\n float uvx = uv.x;\n uv.x = 0.5*fract(uv.x+0.5)+0.25;\n float center = (uv.x-0.5)/radius;\n center *= center;\n center = floor(acount*(uv.y-radius*sqrt(1.0-center))+0.5)/acount;\n vec2 v = uv-vec2(0.5, center);\n float cornerangle = 0.85/acount+0.25*PI;\n float acountangle = (PI-2.0*cornerangle)/(lcount+floor(mod(center*acount, 2.0)));\n float angle = mod(atan(v.y, v.x), 2.0*PI);\n\tfloat base_angle;\n\tfloat local_uvy = 0.5+acount*(length(v)-radius)*(1.54-0.71*cos(1.44*(angle-PI*0.5)));\n\tvec2 local_uv;\n if (angle < cornerangle) {\n base_angle = 0.25*PI;\n\t\tlocal_uv = vec2((angle-0.25*PI)/cornerangle*0.38*acount+0.5, 1.0-local_uvy);\n\t\tseed = vec2(fract(center), 0.0);\n } else if (angle > PI-cornerangle) {\n base_angle = 0.75*PI;\n\t\tlocal_uv = vec2(local_uvy, 0.5-(0.75*PI-angle)/cornerangle*0.38*acount);\n\t\tseed = vec2(fract(center), 0.0);\n } else {\n base_angle = cornerangle+(floor((angle-cornerangle)/acountangle)+0.5)*acountangle;\n\t\tlocal_uv = vec2((angle-base_angle)/acountangle+0.5, 1.0-local_uvy);\n\t\tseed = vec2(fract(center), base_angle);\n }\n vec2 brick_center = vec2(0.5, center)+radius*vec2(cos(base_angle), sin(base_angle));\n return vec4(brick_center.x+uvx-uv.x, brick_center.y, local_uv);\n}\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "Draws a white shape on a black background", + "name": "Arc pavement", + "outputs": [ + { + "f": "pavement($(name_uv)_ap.zw, $bevel, 2.0*$mortar)", + "longdesc": "A greyscale image that shows the bricks pattern", + "shortdesc": "Bricks pattern", + "type": "f" + }, + { + "longdesc": "A random color for each brick", + "rgb": "rand3($(name_uv)_seed)", + "shortdesc": "Random color", + "type": "rgb" + }, + { + "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", + "rgb": "vec3($(name_uv)_ap.zw, 0.0)", + "shortdesc": "Brick UV", + "type": "rgb" + } + ], + "parameters": [ + { + "control": "None", + "default": 2, + "label": "Repeat:", + "longdesc": "The number of repetitions of the whole pattern", + "max": 4, + "min": 1, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 8, + "label": "Rows:", + "longdesc": "The number of rows", + "max": 16, + "min": 4, + "name": "rows", + "shortdesc": "Rows", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 8, + "label": "Bricks:", + "longdesc": "The number of bricks per row", + "max": 16, + "min": 4, + "name": "bricks", + "shortdesc": "Bricks", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Mortar:", + "longdesc": "The width of the space between bricks", + "max": 0.5, + "min": 0, + "name": "mortar", + "shortdesc": "Mortar", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Bevel:", + "longdesc": "The width of the edge of each brick", + "max": 0.5, + "min": 0, + "name": "bevel", + "shortdesc": "Bevel", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/auto_tones.mmg b/game/addons/mat_maker_gd/material_maker_nodes/auto_tones.mmg new file mode 100644 index 00000000..3958a373 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/auto_tones.mmg @@ -0,0 +1,386 @@ +{ + "connections": [ + { + "from": "graph", + "from_port": 0, + "to": "tones_map", + "to_port": 1 + }, + { + "from": "graph", + "from_port": 1, + "to": "tones_map", + "to_port": 2 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "graph", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "tones_map", + "to_port": 0 + }, + { + "from": "tones_map", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Auto Tones", + "longdesc": "Finds the minimum and maximum values in the input texture and tone maps it to the full 0.0 - 1.0 range.", + "name": "auto_tones", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "connections": [ + { + "from": "combine", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 0 + }, + { + "from": "decompose", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "decompose", + "from_port": 1, + "to": "gen_outputs", + "to_port": 1 + }, + { + "from": "iterate_buffer", + "from_port": 0, + "to": "decompose", + "to_port": 0 + }, + { + "from": "iterate_buffer", + "from_port": 1, + "to": "14423", + "to_port": 0 + }, + { + "from": "14423", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "combine", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "combine", + "to_port": 1 + } + ], + "label": "Find Min Max", + "longdesc": "", + "name": "graph", + "node_position": { + "x": 1105.399902, + "y": -179.398849 + }, + "nodes": [ + { + "name": "14423", + "node_position": { + "x": 344, + "y": 217 + }, + "parameters": { + "size": 10 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec3 $(name)_compare(vec2 uv, float size) {\n\tfloat iter = $in(uv).b;\n\tsize = size / pow(2.0, (iter * 100.0) );\n\titer += 0.01;\n\tfloat pixel_offset = 1.0 / size;\n\tvec2 half_res_uv = floor(uv * size / 2.0) / size * 2.0 + pixel_offset / 2.0;\n\tvec3 values[4];\n\tvalues[0] = $in(half_res_uv);\n\tvalues[1] = $in(half_res_uv + vec2(pixel_offset, 0.0));\n\tvalues[2] = $in(half_res_uv + vec2(0.0, pixel_offset));\n\tvalues[3] = $in(half_res_uv + vec2(pixel_offset, pixel_offset));\n\t\n\tfloat lowest = 1.0;\n\tfloat highest = 0.0;\n\t\n\tfor (int i = 0; i < 4; i++) {\n\t\tlowest = values[i].r < lowest ? values[i].r : lowest;\n\t\thighest = values[i].g > highest ? values[i].g : highest;\n\t}\n\t\n\treturn vec3( lowest, highest , iter);\n}", + "name": "Compare Neighbor", + "outputs": [ + { + "rgb": "$(name)_compare($uv, $size)", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 10, + "first": 1, + "label": "", + "last": 13, + "name": "size", + "type": "size" + } + ] + }, + "type": "shader" + }, + { + "name": "iterate_buffer", + "node_position": { + "x": 328, + "y": 63 + }, + "parameters": { + "filter": false, + "iterations": 13, + "mipmap": false, + "size": 10 + }, + "seed_value": 29168, + "type": "iterate_buffer" + }, + { + "name": "combine", + "node_position": { + "x": 376, + "y": -75 + }, + "parameters": { + + }, + "type": "combine" + }, + { + "name": "decompose", + "node_position": { + "x": 605, + "y": 64 + }, + "parameters": { + + }, + "type": "decompose" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -199, + "y": 23 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "", + "name": "in", + "shortdesc": "In", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 831, + "y": 42 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "", + "name": "min", + "shortdesc": "Min", + "type": "f" + }, + { + "group_size": 0, + "longdesc": "", + "name": "max", + "shortdesc": "Max", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": 248.399994, + "y": -292 + }, + "parameters": { + "param0": 10 + }, + "type": "remote", + "widgets": [ + { + "label": "Size", + "linked_widgets": [ + { + "node": "iterate_buffer", + "widget": "size" + }, + { + "node": "14423", + "widget": "size" + } + ], + "name": "param0", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "param0": 10 + }, + "shortdesc": "", + "type": "graph" + }, + { + "name": "tones_map", + "node_position": { + "x": 1142.528442, + "y": -88.26989 + }, + "parameters": { + + }, + "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": "f" + }, + { + "default": "0.0", + "label": "", + "name": "in_min", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "name": "in_max", + "type": "f" + } + ], + "instance": "", + "longdesc": "Maps linearly an input tones interval to an output tones interval.", + "name": "Mapping", + "outputs": [ + { + "f": "($in($uv)-$in_min($uv))/($in_max($uv)-$in_min($uv))", + "longdesc": "Shows the generated remapped image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + + ], + "shortdesc": "Tones map" + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": 665.528564, + "y": -136.535721 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 1425.400024, + "y": -135.535721 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the generated remapped image", + "name": "out", + "shortdesc": "Output", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": 1024.664307, + "y": -298.400757 + }, + "parameters": { + "param0": 10 + }, + "type": "remote", + "widgets": [ + { + "label": "", + "linked_widgets": [ + { + "node": "graph", + "widget": "param0" + } + ], + "longdesc": "Buffers are used to find the mininum and maximum values for the input image. If the input has small details a higher resolution buffer might be needed to capture precise min and max values.\n\nNote: The output itself will not be buffered.", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "param0": 10 + }, + "shortdesc": "Auto Tones", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/beehive.mmg b/game/addons/mat_maker_gd/material_maker_nodes/beehive.mmg new file mode 100644 index 00000000..c4a6fc6e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/beehive.mmg @@ -0,0 +1,69 @@ +{ + "name": "beehive", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "sx": 4, + "sy": 4 + }, + "shader_model": { + "code": "vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);\nvec4 $(name_uv)_center = beehive_center($(name_uv)_uv);", + "global": "float beehive_dist(vec2 p){\n\tvec2 s = vec2(1.0, 1.73205080757);\n p = abs(p);\n return max(dot(p, s*.5), p.x);\n}\n\nvec4 beehive_center(vec2 p) {\n\tvec2 s = vec2(1.0, 1.73205080757);\n vec4 hC = floor(vec4(p, p - vec2(.5, 1))/vec4(s,s)) + .5;\n vec4 h = vec4(p - hC.xy*s, p - (hC.zw + .5)*s);\n return dot(h.xy, h.xy)tF || tF<0.0) return 1.0;\n return tN;\n}", + "inputs": [ + + ], + "instance": "", + "name": "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" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/bricks.mmg b/game/addons/mat_maker_gd/material_maker_nodes/bricks.mmg new file mode 100644 index 00000000..36595c01 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/bricks.mmg @@ -0,0 +1,225 @@ +{ + "name": "bricks", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0.1, + "columns": 3, + "corner": 0.3, + "mortar": 0.1, + "pattern": 0, + "repeat": 1, + "round": 0, + "row_offset": 0.5, + "rows": 6 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);\nvec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));\n", + "global": "vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {\n\tfloat color;\n\tvec2 size = bmax - bmin;\n\tfloat min_size = min(size.x, size.y);\n\tmortar *= min_size;\n\tbevel *= min_size;\n\tround *= min_size;\n\tvec2 center = 0.5*(bmin+bmax);\n vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);\n color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;\n\tcolor = clamp(-color/bevel, 0.0, 1.0);\n\tvec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));\n\treturn vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);\n}\n\nvec3 brick_random_color(vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\treturn rand3(fract(center + vec2(seed)));\n}\n\nvec3 brick_uv(vec2 uv, vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\tvec2 size = bmax - bmin;\n\tfloat max_size = max(size.x, size.y);\n\treturn vec3(0.5+(uv-center)/max_size, rand(fract(center)+vec2(seed)));\n}\n\nvec3 brick_corner_uv(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float corner, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\tvec2 size = bmax - bmin;\n\tfloat max_size = max(size.x, size.y);\n\tfloat min_size = min(size.x, size.y);\n\tmortar *= min_size;\n\tcorner *= min_size;\n\treturn vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed)+ceil(vec2(uv-center))));\n}\n\nvec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset) {\n\tcount *= repeat;\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn vec4(bmin, bmin+vec2(1.0)/count);\n}\n\nvec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset) {\n\tcount *= repeat;\n\tfloat x_offset = offset*step(0.5, fract(uv.y*count.y*0.5));\n\tcount.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5)));\n\tvec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y));\n\tbmin.x += x_offset;\n\tbmin /= count;\n\treturn vec4(bmin, bmin+vec2(1.0)/count);\n}\n\nvec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset) {\n\tfloat pc = count.x+count.y;\n\tfloat c = pc*repeat;\n\tvec2 corner = floor(uv*c);\n\tfloat cdiff = mod(corner.x-corner.y, pc);\n\tif (cdiff < count.x) {\n\t\treturn vec4((corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c);\n\t} else {\n\t\treturn vec4((corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c);\n\t}\n}\n\nvec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset) {\n\tvec2 c = 2.0*count*repeat;\n\tfloat mc = max(c.x, c.y);\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = count*floor(repeat*2.0*uv);\n\tfloat cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0);\n\tvec2 corner;\n\tvec2 size;\n\tif (cdiff == 0.0) {\n\t\tcorner = vec2(corner1.x, corner2.y);\n\t\tsize = vec2(1.0, count.y);\n\t} else {\n\t\tcorner = vec2(corner2.x, corner1.y);\n\t\tsize = vec2(count.x, 1.0);\n\t}\n\treturn vec4(corner/c, (corner+size)/c);\n}\n\nvec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset) {\n\tvec2 c = (count+vec2(1.0))*repeat;\n\tfloat mc = max(c.x, c.y);\n\tvec2 corner1 = floor(uv*c);\n\tvec2 corner2 = (count+vec2(1.0))*floor(repeat*uv);\n\tvec2 rcorner = corner1 - corner2;\n\tvec2 corner;\n\tvec2 size;\n\tif (rcorner.x == 0.0 && rcorner.y < count.y) {\n\t\tcorner = corner2;\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == 0.0) {\n\t\tcorner = corner2+vec2(1.0, 0.0);\n\t\tsize = vec2(count.x, 1.0);\n\t} else if (rcorner.x == count.x) {\n\t\tcorner = corner2+vec2(count.x, 1.0);\n\t\tsize = vec2(1.0, count.y);\n\t} else if (rcorner.y == count.y) {\n\t\tcorner = corner2+vec2(0.0, count.y);\n\t\tsize = vec2(count.x, 1.0);\n\t} else {\n\t\tcorner = corner2+vec2(1.0);\n\t\tsize = vec2(count.x-1.0, count.y-1.0);\n\t}\n\treturn vec4(corner/c, (corner+size)/c);\n}", + "inputs": [ + { + "default": "1.0", + "label": "6:", + "longdesc": "A map that affects the Mortar parameter", + "name": "mortar_map", + "shortdesc": "Mortar map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Bevel parameter", + "name": "bevel_map", + "shortdesc": "Bevel map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Round parameter", + "name": "round_map", + "shortdesc": "Round map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates different bricks patterns, with many useful outputs.", + "name": "Bricks", + "outputs": [ + { + "f": "$(name_uv).x", + "longdesc": "A greyscale image that shows the bricks pattern", + "shortdesc": "Bricks pattern", + "type": "f" + }, + { + "longdesc": "A random color for each brick", + "rgb": "brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", + "shortdesc": "Random color", + "type": "rgb" + }, + { + "f": "$(name_uv).y", + "longdesc": "The position of each brick along the X axis", + "shortdesc": "Position.x", + "type": "f" + }, + { + "f": "$(name_uv).z", + "longdesc": "The position of each brick along the Y axis", + "shortdesc": "Position.y", + "type": "f" + }, + { + "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", + "rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", + "shortdesc": "Brick UV", + "type": "rgb" + }, + { + "longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node", + "rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))", + "shortdesc": "Corner UV", + "type": "rgb" + }, + { + "f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)", + "longdesc": "The direction of each brick (white: horizontal, black: vertical)", + "shortdesc": "Direction", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "The type of brick pattern", + "name": "pattern", + "shortdesc": "Pattern", + "type": "enum", + "values": [ + { + "name": "Running bond", + "value": "rb" + }, + { + "name": "Running bond (2)", + "value": "rb2" + }, + { + "name": "HerringBone", + "value": "hb" + }, + { + "name": "Basket weave", + "value": "bw" + }, + { + "name": "Spanish bond", + "value": "sb" + } + ] + }, + { + "control": "None", + "default": 1, + "label": "Repeat:", + "longdesc": "The number of repetitions of the whole pattern", + "max": 8, + "min": 1, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 6, + "label": "Rows:", + "longdesc": "The number of rows of a pattern", + "max": 64, + "min": 1, + "name": "rows", + "shortdesc": "Rows", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 3, + "label": "Columns:", + "longdesc": "The number of columns of a pattern", + "max": 64, + "min": 1, + "name": "columns", + "shortdesc": "Columns", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Offset:", + "longdesc": "The offset of the pattern (not useful for all patterns)", + "max": 1, + "min": 0, + "name": "row_offset", + "shortdesc": "Offset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Mortar:", + "longdesc": "The width of the space between bricks", + "max": 0.5, + "min": 0, + "name": "mortar", + "shortdesc": "Mortar", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Bevel:", + "longdesc": "The width of the edge of each brick", + "max": 0.5, + "min": 0, + "name": "bevel", + "shortdesc": "Bevel", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Round:", + "longdesc": "The radius of the round corners of bricks", + "max": 0.5, + "min": 0, + "name": "round", + "shortdesc": "Round", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Corner:", + "longdesc": "The size of the corner part of each brick (only used by the Corner UV output)", + "max": 0.5, + "min": 0, + "name": "corner", + "shortdesc": "Corner", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Simple bricks patterns" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/bricks_nontileable.mmg b/game/addons/mat_maker_gd/material_maker_nodes/bricks_nontileable.mmg new file mode 100644 index 00000000..7de37349 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/bricks_nontileable.mmg @@ -0,0 +1,228 @@ +{ + "name": "bricks_nontileable", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0.1, + "columns": 3, + "corner": 0.3, + "mortar": 0.1, + "pattern": 0, + "repeat": 1, + "round": 0, + "row_offset": 0.5, + "rows": 6 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);\nvec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));\n", + "global": "vec3 brick_infinite_random_color(vec2 bmin, vec2 bmax, float seed) {\n\tvec2 center = 0.5*(bmin + bmax);\n\treturn rand3(center + vec2(seed));\n}\n", + "includes": [ + "bricks" + ], + "inputs": [ + { + "default": "1.0", + "label": "6:", + "longdesc": "A map that affects the Mortar parameter", + "name": "mortar_map", + "shortdesc": "Mortar map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Bevel parameter", + "name": "bevel_map", + "shortdesc": "Bevel map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Round parameter", + "name": "round_map", + "shortdesc": "Round map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates different bricks patterns, with many useful outputs.", + "name": "Bricks NonTileable", + "outputs": [ + { + "f": "$(name_uv).x", + "longdesc": "A greyscale image that shows the bricks pattern", + "shortdesc": "Bricks pattern", + "type": "f" + }, + { + "longdesc": "A random color for each brick", + "rgb": "brick_infinite_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", + "shortdesc": "Random color", + "type": "rgb" + }, + { + "f": "$(name_uv).y", + "longdesc": "The position of each brick along the X axis", + "shortdesc": "Position.x", + "type": "f" + }, + { + "f": "$(name_uv).z", + "longdesc": "The position of each brick along the Y axis", + "shortdesc": "Position.y", + "type": "f" + }, + { + "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", + "rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", + "shortdesc": "Brick UV", + "type": "rgb" + }, + { + "longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node", + "rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))", + "shortdesc": "Corner UV", + "type": "rgb" + }, + { + "f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)", + "longdesc": "The direction of each brick (white: horizontal, black: vertical)", + "shortdesc": "Direction", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "The type of brick pattern", + "name": "pattern", + "shortdesc": "Pattern", + "type": "enum", + "values": [ + { + "name": "Running bond", + "value": "rb" + }, + { + "name": "Running bond (2)", + "value": "rb2" + }, + { + "name": "HerringBone", + "value": "hb" + }, + { + "name": "Basket weave", + "value": "bw" + }, + { + "name": "Spanish bond", + "value": "sb" + } + ] + }, + { + "control": "None", + "default": 1, + "label": "Repeat:", + "longdesc": "The number of repetitions of the whole pattern", + "max": 8, + "min": 1, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 6, + "label": "Rows:", + "longdesc": "The number of rows of a pattern", + "max": 64, + "min": 1, + "name": "rows", + "shortdesc": "Rows", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 3, + "label": "Columns:", + "longdesc": "The number of columns of a pattern", + "max": 64, + "min": 1, + "name": "columns", + "shortdesc": "Columns", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Offset:", + "longdesc": "The offset of the pattern (not useful for all patterns)", + "max": 1, + "min": 0, + "name": "row_offset", + "shortdesc": "Offset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Mortar:", + "longdesc": "The width of the space between bricks", + "max": 0.5, + "min": 0, + "name": "mortar", + "shortdesc": "Mortar", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Bevel:", + "longdesc": "The width of the edge of each brick", + "max": 0.5, + "min": 0, + "name": "bevel", + "shortdesc": "Bevel", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Round:", + "longdesc": "The radius of the round corners of bricks", + "max": 0.5, + "min": 0, + "name": "round", + "shortdesc": "Round", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Corner:", + "longdesc": "The size of the corner part of each brick (only used by the Corner UV output)", + "max": 0.5, + "min": 0, + "name": "corner", + "shortdesc": "Corner", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Simple bricks patterns" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/bricks_uneven.mmg b/game/addons/mat_maker_gd/material_maker_nodes/bricks_uneven.mmg new file mode 100644 index 00000000..d54992a3 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/bricks_uneven.mmg @@ -0,0 +1,184 @@ +{ + "name": "bricks_uneven", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0.01, + "corner": 0, + "iterations": 8, + "min_size": 0.3, + "mortar": 0.01, + "randomness": 0.5, + "round": 0 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rect = bricks_uneven($uv, int($iterations), $min_size, $randomness, float($seed));\nvec4 $(name_uv) = brick2($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.00001, $bevel*$bevel_map($uv)));\n", + "global": "vec4 brick2(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) {\n\tfloat color;\n\tvec2 size = bmax - bmin;\n\tvec2 center = 0.5*(bmin+bmax);\n vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar);\n color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round;\n\tcolor = clamp(-color/bevel, 0.0, 1.0);\n\tvec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0));\n\treturn vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y);\n}\n\nvec4 bricks_uneven(vec2 uv, int iterations, float min_size, float randomness, float seed) {\n\tvec2 a = vec2(0.0);\n\tvec2 b = vec2(1.0);\n\t\n\tfor (int i = 0; i < iterations; ++i) {\n\t\tvec2 size = b-a;\n\t\tif (max(size.x, size.y) < min_size) {\n\t\tbreak;\n\t\t}\n\t\tfloat x = rand(rand2(vec2(rand(a+b), seed)))*randomness+(1.0-randomness)*0.5;\n\t\tif (size.x > size.y) {\n\t\t\tx *= size.x;\n\t\t\tif (uv.x > a.x+x) {\n\t\t\t\ta.x += x;\n\t\t\t} else {\n\t\t\t\tb.x = a.x + x;\n\t\t\t}\n\t\t} else {\n\t\t\tx *= size.y;\n\t\t\tif (uv.y > a.y+x) {\n\t\t\t\ta.y += x;\n\t\t\t} else {\n\t\t\t\tb.y = a.y + x;\n\t\t\t}\n\t\t}\n\t}\n\treturn vec4(a, b);\n}\n", + "includes": [ + "bricks" + ], + "inputs": [ + { + "default": "1.0", + "label": "4:", + "longdesc": "A map that affects the Mortar parameter", + "name": "mortar_map", + "shortdesc": "Mortar map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Bevel parameter", + "name": "bevel_map", + "shortdesc": "Bevel map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "A map that affects the Round parameter", + "name": "round_map", + "shortdesc": "Round map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates an uneven bricks pattern.", + "name": "Uneven Bricks", + "outputs": [ + { + "f": "$(name_uv).x", + "longdesc": "A greyscale image that shows the bricks pattern", + "shortdesc": "Bricks pattern", + "type": "f" + }, + { + "longdesc": "A random color for each brick", + "rgb": "rand3(fract($(name_uv)_rect.xy)+rand2(vec2(float($seed))))", + "shortdesc": "Random color", + "type": "rgb" + }, + { + "f": "$(name_uv).y", + "longdesc": "The position of each brick along the X axis", + "shortdesc": "Position.x", + "type": "f" + }, + { + "f": "$(name_uv).z", + "longdesc": "The position of each brick along the Y axis", + "shortdesc": "Position.y", + "type": "f" + }, + { + "longdesc": "An UV map output for each brick, to be connected to the Map input of a CustomUV node", + "rgb": "brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))", + "shortdesc": "Brick UV", + "type": "rgb" + }, + { + "longdesc": "An UV map output for each brick corner, to be connected to the Map input of a CustomUV node", + "rgb": "brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))", + "shortdesc": "Corner UV", + "type": "rgb" + }, + { + "f": "0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)", + "longdesc": "The direction of each brick (white: horizontal, black: vertical)", + "shortdesc": "Direction", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 8, + "label": "Iterations", + "longdesc": "The number of iterations of the brick split operation", + "max": 16, + "min": 1, + "name": "iterations", + "shortdesc": "Iterations", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.3, + "label": "Min size:", + "longdesc": "The minimum size of a brick", + "max": 0.5, + "min": 0, + "name": "min_size", + "shortdesc": "Minimum size", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Randomness", + "longdesc": "The randomness of the pattern", + "max": 1, + "min": 0, + "name": "randomness", + "shortdesc": "Randomness", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.05, + "label": "Mortar:", + "longdesc": "The width of the space between bricks", + "max": 0.5, + "min": 0, + "name": "mortar", + "shortdesc": "Mortar", + "step": 0.001, + "type": "float" + }, + { + "control": "None", + "default": 0.05, + "label": "Bevel:", + "longdesc": "The width of the edge of each brick", + "max": 0.5, + "min": 0, + "name": "bevel", + "shortdesc": "Bevel", + "step": 0.001, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Round:", + "longdesc": "The radius of the round corners of bricks", + "max": 0.5, + "min": 0, + "name": "round", + "shortdesc": "Round", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.1, + "label": "Corner:", + "longdesc": "The size of the corner part of each brick (only used by the Corner UV output)", + "max": 0.5, + "min": 0, + "name": "corner", + "shortdesc": "Corner", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Uneven bricks" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/brightness_contrast.mmg b/game/addons/mat_maker_gd/material_maker_nodes/brightness_contrast.mmg new file mode 100644 index 00000000..66ffaadd --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/brightness_contrast.mmg @@ -0,0 +1,64 @@ +{ + "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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/brush.mmg b/game/addons/mat_maker_gd/material_maker_nodes/brush.mmg new file mode 100644 index 00000000..950bf9d2 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/brush.mmg @@ -0,0 +1,169 @@ +{ + "name": "brush", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "has_albedo": true, + "has_depth": false, + "has_emission": false, + "has_normal": false, + "has_metallic": true, + "has_roughness": true, + "mode": 0 + }, + "is_brush": true, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "clamp(1.0-2.0*length($uv-vec2(0.5)), 0.0, 1.0)", + "label": "Brush", + "name": "brush", + "type": "f" + }, + { + "default": "vec4(1.0)", + "group_size": 5, + "label": "Albedo", + "name": "albedo", + "type": "rgba" + }, + { + "default": "0.0", + "label": "Metallic", + "name": "metallic", + "type": "f" + }, + { + "default": "0.0", + "label": "Roughness", + "name": "roughness", + "type": "f" + }, + { + "default": "vec4(0.0)", + "label": "Emission", + "name": "emission", + "type": "rgba" + }, + { + "default": "vec4(0.5, 0.5, 0.0, 0.0)", + "label": "Normal", + "name": "normal", + "type": "rgba" + }, + { + "default": "0.0", + "label": "Depth", + "name": "depth", + "type": "f" + }, + { + "default": "1.0", + "label": "Occlusion", + "name": "ao", + "type": "f" + } + ], + "instance": "", + "name": "Brush", + "outputs": [ + { + "f": "$brush($uv)", + "type": "f" + }, + { + "rgba": "$albedo($uv)", + "type": "rgba" + }, + { + "rgba": "vec4($metallic($uv), $roughness($uv), $has_metallic ? $albedo($uv).a : 0.0, $has_roughness ? $albedo($uv).a : 0.0)", + "type": "rgba" + }, + { + "rgba": "$emission($uv)", + "type": "rgba" + }, + { + "rgba": "$normal($uv)", + "type": "rgba" + }, + { + "rgba": "vec4($depth($uv), $ao($uv), $has_depth ? $albedo($uv).a : 0.0, $has_ao ? $albedo($uv).a : 0.0)", + "type": "rgba" + }, + { + "rgba": "vec4(vec3(1.0), $albedo($uv).a)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "name": "mode", + "type": "enum", + "values": [ + { + "name": "Stamp", + "value": "stamp" + }, + { + "name": "Pattern", + "value": "pattern" + }, + { + "name": "UV Pattern", + "value": "uv_pattern" + } + ] + }, + { + "default": true, + "label": "", + "name": "has_albedo", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_metallic", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_roughness", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_emission", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_normal", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_depth", + "type": "boolean" + }, + { + "default": false, + "label": "", + "name": "has_ao", + "type": "boolean" + } + ] + }, + "type": "brush_node" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/brush_select_from_id.mmg b/game/addons/mat_maker_gd/material_maker_nodes/brush_select_from_id.mmg new file mode 100644 index 00000000..3c541c27 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/brush_select_from_id.mmg @@ -0,0 +1,56 @@ +{ + "name": "brush_select_from_id", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "id": { + "a": 1, + "b": 1, + "g": 1, + "r": 0, + "type": "Color" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "vec4(1.0)", + "label": "", + "name": "ids", + "type": "rgba" + } + ], + "instance": "", + "name": "Select From ID", + "outputs": [ + { + "rgba": "$in($uv)*vec4(1.0, 1.0, 1.0, step(length($ids($uv)-$id), 0.01))", + "type": "rgba" + } + ], + "parameters": [ + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "", + "name": "id", + "type": "color" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/circle_map.mmg b/game/addons/mat_maker_gd/material_maker_nodes/circle_map.mmg new file mode 100644 index 00000000..fa0b634f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/circle_map.mmg @@ -0,0 +1,64 @@ +{ + "name": "circle_map", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "radius": 1, + "repeat": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be remapped", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Maps its input into a circle", + "name": "CircleMap", + "outputs": [ + { + "longdesc": "Shows the remapped image", + "rgba": "$in(vec2(fract($repeat*atan($uv.y-0.5, $uv.x-0.5)*0.15915494309), min(0.99999, 2.0/$radius*length($uv-vec2(0.5)))))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "Radius", + "longdesc": "The radius of the circle where the input is mapped", + "max": 1.5, + "min": 0, + "name": "radius", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Repeat", + "longdesc": "The number of repetitions of the input image around the circle", + "max": 16, + "min": 0, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + } + ], + "shortdesc": "CircleMap" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter.mmg b/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter.mmg new file mode 100644 index 00000000..39313f2f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter.mmg @@ -0,0 +1,219 @@ +{ + "name": "circle_splatter", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 20, + "i_rotate": 0, + "i_scale": 0, + "radius": 0.4, + "rings": 2, + "rotate": 0, + "scale": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "spiral": 0, + "value": 0 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rch = splatter_$(name)($uv, int($count), int($rings), vec2(float($seed)));", + "global": "", + "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" + } + ], + "instance": "vec4 splatter_$(name)(vec2 uv, int count, int rings, vec2 seed) {\n\tfloat c = 0.0;\n\tvec3 rc = vec3(0.0);\n\tvec3 rc1;\n\tseed = rand2(seed);\n\tfor (int i = 0; i < count; ++i) {\n\t\tfloat a = -1.57079632679+6.28318530718*float(i)*$rings/float(count);\n\t\tfloat rings_distance = ceil(float(i+1)*float(rings)/float(count))/float(rings);\n\t\tfloat spiral_distance = float(i+1)/float(count);\n\t\tvec2 pos = $radius*mix(rings_distance, spiral_distance, $spiral)*vec2(cos(a), sin(a));\n\t\tfloat mask = $mask(fract(pos-vec2(0.5)));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = uv-0.5-pos;\n\t\t\trc1 = rand3(seed);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251 + (a+1.57079632679) * $i_rotate;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv /= mix(1.0, float(i+1)/float(count+1), $i_scale);\n\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv += vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t$select_inputs\n\t\t\tfloat c1 = $in(pv)*mask*(1.0-$value*seed.x);\n\t\t\tc = max(c, c1);\n\t\t\trc = mix(rc, rc1, step(c, c1));\n\t\t}\n\t}\n\treturn vec4(rc, c);\n}\n", + "longdesc": "Spreads several occurences of an input image in a circle or spiral pattern.", + "name": "Circle Splatter", + "outputs": [ + { + "f": "$(name_uv)_rch.a", + "longdesc": "Shows the generated pattern", + "shortdesc": "Output", + "type": "f" + }, + { + "longdesc": "Shows a random color for each instance of the input image", + "rgb": "$(name_uv)_rch.rgb", + "shortdesc": "Instance map", + "type": "rgb" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "longdesc": "The number of occurences of the input image", + "max": 256, + "min": 1, + "name": "count", + "shortdesc": "Count", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Rings", + "longdesc": "The number of rings of the circle pattern", + "max": 16, + "min": 1, + "name": "rings", + "shortdesc": "Rings", + "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": 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" + }, + { + "control": "None", + "default": 0.25, + "label": "Radius", + "longdesc": "The radius of the outer circle pattern", + "max": 0.5, + "min": 0, + "name": "radius", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Spiral", + "longdesc": "The type of pattern:\n- 0: circles\n- 1: spiral", + "max": 1, + "min": 0, + "name": "spiral", + "shortdesc": "Spiral", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Inc Rotate", + "longdesc": "The rotate increment along the pattern", + "max": 1, + "min": 0, + "name": "i_rotate", + "shortdesc": "IncRotate", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Inc Scale", + "longdesc": "The scale increment of the pattern", + "max": 1, + "min": 0, + "name": "i_scale", + "shortdesc": "IncScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Value", + "longdesc": "The random greyscale value applied to each image instance", + "max": 1, + "min": 0, + "name": "value", + "shortdesc": "RndValue", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter_color.mmg new file mode 100644 index 00000000..158fefeb --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/circle_splatter_color.mmg @@ -0,0 +1,213 @@ +{ + "name": "circle_splatter_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 20, + "i_rotate": 0, + "i_scale": 0, + "opacity": 0, + "radius": 0.4, + "rings": 2, + "rotate": 0, + "scale": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "spiral": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(0.0, 0.0, 0.0, 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" + } + ], + "instance": "vec4 splatter_$(name)(vec2 uv, int count, int rings, vec2 seed) {\n\tvec4 c = vec4(0.0);\n\tvec3 rc = vec3(0.0);\n\tvec3 rc1;\n\tseed = rand2(seed);\n\tfor (int i = 0; i < count; ++i) {\n\t\tfloat a = -1.57079632679+6.28318530718*float(i)*$rings/float(count);\n\t\tfloat rings_distance = ceil(float(i+1)*float(rings)/float(count))/float(rings);\n\t\tfloat spiral_distance = float(i+1)/float(count);\n\t\tvec2 pos = $radius*mix(rings_distance, spiral_distance, $spiral)*vec2(cos(a), sin(a));\n\t\tfloat mask = $mask(fract(pos-vec2(0.5)));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = uv-0.5-pos;\n\t\t\trc1 = rand3(seed);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251 + (a+1.57079632679) * $i_rotate;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv /= mix(1.0, float(i+1)/float(count+1), $i_scale);\n\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv += vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t$select_inputs\n\t\t\tvec4 n = $in(pv);\n\t\t\tfloat na = n.a*mask*(1.0-$opacity*seed.x);\n\t\t\tc = mix(c, n, na);\n\t\t}\n\t}\n\treturn c;\n}\n", + "longdesc": "Spreads several occurences of an input image in a circle or spiral pattern.", + "name": "Color Circle Splatter", + "outputs": [ + { + "longdesc": "Shows the generated pattern", + "rgba": "splatter_$(name)($uv, int($count), int($rings), vec2(float($seed)))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "longdesc": "The number of occurences of the input image", + "max": 256, + "min": 1, + "name": "count", + "shortdesc": "Count", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Rings", + "longdesc": "The number of rings of the circle pattern", + "max": 16, + "min": 1, + "name": "rings", + "shortdesc": "Rings", + "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": 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" + }, + { + "control": "None", + "default": 0.25, + "label": "Radius", + "longdesc": "The radius of the outer circle pattern", + "max": 0.5, + "min": 0, + "name": "radius", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Spiral", + "longdesc": "The type of pattern:\n- 0: circles\n- 1: spiral", + "max": 1, + "min": 0, + "name": "spiral", + "shortdesc": "Spiral", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Inc Rotate", + "longdesc": "The rotate increment along the pattern", + "max": 1, + "min": 0, + "name": "i_rotate", + "shortdesc": "IncRotate", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Inc Scale", + "longdesc": "The scale increment of the pattern", + "max": 1, + "min": 0, + "name": "i_scale", + "shortdesc": "IncScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Opacity", + "longdesc": "The random opacity applied to each image instance", + "max": 1, + "min": 0, + "name": "opacity", + "shortdesc": "RndOpacity", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/circular_gradient.mmg b/game/addons/mat_maker_gd/material_maker_nodes/circular_gradient.mmg new file mode 100644 index 00000000..c86d37f1 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/circular_gradient.mmg @@ -0,0 +1,89 @@ +{ + "name": "circular_gradient", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "gradient": { + "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" + }, + "repeat": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Circular Gradient", + "outputs": [ + { + "longdesc": "Number of repetitions of the gradient", + "rgba": "$gradient(fract($repeat*0.15915494309*atan($uv.y-0.5, $uv.x-0.5)))", + "shortdesc": "Repeat", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "Repeat", + "longdesc": "Number of repetitions of the gradient", + "max": 32, + "min": 1, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + }, + { + "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": "Gradient", + "longdesc": "Gradient to be spread on the image", + "name": "gradient", + "shortdesc": "Gradient", + "type": "gradient" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/color_noise.mmg b/game/addons/mat_maker_gd/material_maker_nodes/color_noise.mmg new file mode 100644 index 00000000..91ee52d1 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/color_noise.mmg @@ -0,0 +1,42 @@ +{ + "name": "color_noise", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 9 + }, + "shader_model": { + "code": "", + "global": "vec3 color_dots(vec2 uv, float size, float seed) {\n\tvec2 seed2 = rand2(vec2(seed, 1.0-seed));\n\tuv /= size;\n\tvec2 point_pos = floor(uv)+vec2(0.5);\n\treturn rand3(seed2+point_pos);\n}", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a grid made of random color squares", + "name": "Color Noise", + "outputs": [ + { + "longdesc": "Shows the noise pattern", + "rgb": "color_dots($(uv), 1.0/$(size), $(seed))", + "shortdesc": "Output", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 8, + "first": 2, + "label": "Grid Size:", + "last": 12, + "longdesc": "The grid size", + "name": "size", + "shortdesc": "Size", + "type": "size" + } + ], + "shortdesc": "Color Noise" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/colorize.mmg b/game/addons/mat_maker_gd/material_maker_nodes/colorize.mmg new file mode 100644 index 00000000..6fc9f528 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/colorize.mmg @@ -0,0 +1,85 @@ +{ + "name": "colorize", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "gradient": { + "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" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "$uv.x", + "label": "", + "longdesc": "The input greyscale image", + "name": "input", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Remaps a greyscale image to a custom gradient", + "name": "Colorize", + "outputs": [ + { + "longdesc": "The remapped RGBA image", + "rgba": "$gradient($input($uv))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "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": "gradient", + "shortdesc": "Gradient", + "type": "gradient" + } + ], + "shortdesc": "Colorize" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/combine.mmg b/game/addons/mat_maker_gd/material_maker_nodes/combine.mmg new file mode 100644 index 00000000..bd9d6452 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/combine.mmg @@ -0,0 +1,64 @@ +{ + "name": "combine", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "R", + "longdesc": "The greyscale input for the red channel", + "name": "r", + "shortdesc": "Red", + "type": "f" + }, + { + "default": "0.0", + "label": "G", + "longdesc": "The greyscale input for the green channel", + "name": "g", + "shortdesc": "Green", + "type": "f" + }, + { + "default": "0.0", + "label": "B", + "longdesc": "The greyscale input for the blue channel", + "name": "b", + "shortdesc": "Blue", + "type": "f" + }, + { + "default": "1.0", + "label": "A", + "longdesc": "The greyscale input for the alpha channel", + "name": "a", + "shortdesc": "Alpha", + "type": "f" + } + ], + "instance": "", + "longdesc": "Combines 4 greyscale inputs into an RGBA image", + "name": "Combine", + "outputs": [ + { + "longdesc": "Shows the combined RGBA image", + "rgba": "vec4($r($uv), $g($uv), $b($uv), $a($uv))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + + ], + "shortdesc": "Combine" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/compare.mmg b/game/addons/mat_maker_gd/material_maker_nodes/compare.mmg new file mode 100644 index 00000000..40199e65 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/compare.mmg @@ -0,0 +1,40 @@ +{ + "name": "compare", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in1", + "type": "rgba" + }, + { + "default": "0.0", + "label": "", + "name": "in2", + "type": "rgba" + } + ], + "instance": "", + "name": "Compare", + "outputs": [ + { + "f": "dot(abs($in1($uv)-$in2($uv)), vec4(1.0))", + "type": "f" + } + ], + "parameters": [ + + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/curve.mmg b/game/addons/mat_maker_gd/material_maker_nodes/curve.mmg new file mode 100644 index 00000000..5e7121c3 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/curve.mmg @@ -0,0 +1,140 @@ +{ + "name": "curve", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "ax": -0.4, + "ay": -0.3, + "bx": 0, + "by": 0.5, + "cx": 0.4, + "cy": -0.3, + "repeat": 1, + "width": 0.05 + }, + "shader_model": { + "code": "vec2 $(name_uv)_bezier = sdBezier($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5), vec2($cx+0.5, $cy+0.5));\nvec2 $(name_uv)_uv = vec2($(name_uv)_bezier.x, $(name_uv)_bezier.y/$width+0.5);\nvec2 $(name_uv)_uvtest = step(vec2(0.5), abs($(name_uv)_uv-vec2(0.5)));\n$(name_uv)_uv = mix(vec2(fract($repeat*$(name_uv)_uv.x), $(name_uv)_uv.y), vec2(0.0), max($(name_uv)_uvtest.x, $(name_uv)_uvtest.y));\n", + "global": "float cross2( in vec2 a, in vec2 b ) { return a.x*b.y - a.y*b.x; }\n\n// signed distance to a quadratic bezier\nvec2 sdBezier( in vec2 pos, in vec2 A, in vec2 B, in vec2 C ) { \n vec2 a = B - A;\n vec2 b = A - 2.0*B + C;\n vec2 c = a * 2.0;\n vec2 d = A - pos;\n\n float kk = 1.0/dot(b,b);\n float kx = kk * dot(a,b);\n float ky = kk * (2.0*dot(a,a)+dot(d,b))/3.0;\n float kz = kk * dot(d,a); \n\n float res = 0.0;\n float sgn = 0.0;\n\n float p = ky - kx*kx;\n float p3 = p*p*p;\n float q = kx*(2.0*kx*kx - 3.0*ky) + kz;\n float h = q*q + 4.0*p3;\n\tfloat rvx;\n\n if( h>=0.0 ) { // 1 root\n h = sqrt(h);\n vec2 x = (vec2(h,-h)-q)/2.0;\n vec2 uv = sign(x)*pow(abs(x), vec2(1.0/3.0));\n\t\trvx = uv.x+uv.y-kx;\n float t = clamp(rvx, 0.0, 1.0);\n vec2 q2 = d+(c+b*t)*t;\n res = dot(q2, q2);\n \tsgn = cross2(c+2.0*b*t, q2);\n } else { // 3 roots\n float z = sqrt(-p);\n float v = acos(q/(p*z*2.0))/3.0;\n float m = cos(v);\n float n = sin(v)*1.732050808;\n vec3 t = clamp(vec3(m+m,-n-m,n-m)*z-kx, 0.0, 1.0);\n vec2 qx=d+(c+b*t.x)*t.x; float dx=dot(qx, qx), sx = cross2(c+2.0*b*t.x,qx);\n vec2 qy=d+(c+b*t.y)*t.y; float dy=dot(qy, qy), sy = cross2(c+2.0*b*t.y,qy);\n if( dx 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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_2.mmg new file mode 100644 index 00000000..5b587d40 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_2.mmg @@ -0,0 +1,75 @@ +{ + "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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_3.mmg b/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_3.mmg new file mode 100644 index 00000000..7564e906 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/dilate_pass_3.mmg @@ -0,0 +1,49 @@ +{ + "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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/directional_blur.mmg b/game/addons/mat_maker_gd/material_maker_nodes/directional_blur.mmg new file mode 100644 index 00000000..54e0e47e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/directional_blur.mmg @@ -0,0 +1,234 @@ +{ + "connections": [ + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "edge_detect_3_3_2", + "to_port": 0 + }, + { + "from": "edge_detect_3_3_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "edge_detect_3_3_2", + "to_port": 1 + } + ], + "label": "Directional Blur", + "longdesc": "Applies a directional gaussian blur to its input", + "name": "directional_blur", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer", + "node_position": { + "x": -381.25, + "y": -270.75 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -436.666626, + "y": -413.666656 + }, + "parameters": { + "param0": 9, + "param1": 50, + "param2": 45 + }, + "type": "remote", + "widgets": [ + { + "label": "Grid size:", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "edge_detect_3_3_2", + "widget": "size" + } + ], + "longdesc": "The resolution of the input", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Sigma", + "linked_widgets": [ + { + "node": "edge_detect_3_3_2", + "widget": "sigma" + } + ], + "longdesc": "The strength of the blur filter", + "name": "param1", + "shortdesc": "Sigma", + "type": "linked_control" + }, + { + "label": "Angle", + "linked_widgets": [ + { + "node": "edge_detect_3_3_2", + "widget": "angle" + } + ], + "longdesc": "The angle of the directional blur effect", + "name": "param2", + "shortdesc": "Angle", + "type": "linked_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -779.666626, + "y": -247.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + }, + { + "group_size": 0, + "longdesc": "A map that controls the strength of the blur filter", + "name": "amount", + "shortdesc": "Strength map", + "type": "f" + } + ], + "seed_value": 91624, + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -45.452393, + "y": -195.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the generated blurred image", + "name": "port0", + "shortdesc": "Output", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "edge_detect_3_3_2", + "node_position": { + "x": -376.725464, + "y": -184.178955 + }, + "parameters": { + "angle": 45, + "sigma": 50, + "size": 9 + }, + "seed_value": -47470, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "Label", + "name": "amount", + "type": "f" + } + ], + "instance": "vec4 $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(cos($angle*0.01745329251), -sin($angle*0.01745329251))/$size;\n\tvec4 rv = vec4(0.0);\n\tfloat sum = 0.0;\n\tfloat sigma = $sigma*$amount(uv);\n\tfor (float i = -50.0; i <= 50.0; i += 1.0) {\n\t\tfloat coef = exp(-0.5*(pow(i/sigma, 2.0)))/(6.28318530718*sigma*sigma);\n\t\trv += $in(uv+i*e)*coef;\n\t\tsum += coef;\n\t}\n\treturn rv/sum;\n}", + "name": "Directional Blur", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 50, + "min": 0, + "name": "sigma", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Angle", + "max": 180, + "min": -180, + "name": "angle", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" + } + ], + "parameters": { + "param0": 9, + "param1": 50, + "param2": 45 + }, + "shortdesc": "Directional blur", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/edge_detect.mmg b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect.mmg new file mode 100644 index 00000000..c3dab20f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect.mmg @@ -0,0 +1,72 @@ +{ + "name": "edge_detect", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 9, + "threshold": 0.4, + "width": 2 + }, + "shader_model": { + "code": "", + "global": "", + "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}", + "longdesc": "An edge detect filter that detects edges along all directions and draws them in white on a black background", + "name": "Edge detect", + "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" + } + ], + "shortdesc": "Edge detect" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_1.mmg b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_1.mmg new file mode 100644 index 00000000..2ba400a1 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_1.mmg @@ -0,0 +1,50 @@ +{ + "name": "edge_detect_1", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 6 + }, + "shader_model": { + "code": "", + "global": "", + "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}", + "longdesc": "An edge detect filter that detects edges along all directions and draws them in white on a black background", + "name": "Edge detect 1", + "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" + } + ], + "shortdesc": "Edge detect" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_2.mmg new file mode 100644 index 00000000..12b07104 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_2.mmg @@ -0,0 +1,50 @@ +{ + "name": "edge_detect_2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 6 + }, + "shader_model": { + "code": "", + "global": "", + "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}", + "longdesc": "An edge detect filter that detects edges horizontally and vertically and draws them in white on a black background", + "name": "Edge detect 2", + "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" + } + ], + "shortdesc": "Edge detect" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_3.mmg b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_3.mmg new file mode 100644 index 00000000..69c4172b --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/edge_detect_3.mmg @@ -0,0 +1,50 @@ +{ + "name": "edge_detect_3", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 6 + }, + "shader_model": { + "code": "", + "global": "", + "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}", + "longdesc": "An edge detect filter that detects edges along diagonals and draws them in white on a black background", + "name": "Edge detect 3", + "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" + } + ], + "shortdesc": "Edge detect" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/emboss.mmg b/game/addons/mat_maker_gd/material_maker_nodes/emboss.mmg new file mode 100644 index 00000000..468789eb --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/emboss.mmg @@ -0,0 +1,242 @@ +{ + "connections": [ + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "598", + "to_port": 0 + }, + { + "from": "598", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Emboss", + "longdesc": "Creates highlights and shadows from an input heightmap", + "name": "emboss", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer", + "node_position": { + "x": -65.493774, + "y": -609.5 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "seed_value": 10109, + "type": "buffer" + }, + { + "name": "598", + "node_position": { + "x": -77.579605, + "y": -529.738281 + }, + "parameters": { + "amount": 5, + "angle": 0, + "size": 9, + "width": 1 + }, + "shader_model": { + "code": "", + "global": "", + "includes": [ + "" + ], + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "float $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tfloat rv = 0.0;\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy))*cos(atan(dy, dx)-$angle*3.14159265359/180.0)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Emboss", + "outputs": [ + { + "f": "$(name)_fct($uv)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0, + "label": "Angle", + "max": 180, + "min": -180, + "name": "angle", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -461.57959, + "y": -574.119141 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input height map", + "name": "port0", + "shortdesc": "Input", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 187.506226, + "y": -557.119141 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The generated image", + "name": "port0", + "shortdesc": "Output", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -111.036682, + "y": -777.5 + }, + "parameters": { + "param0": 9, + "param1": 0, + "param2": 5, + "param3": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Size", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "598", + "widget": "size" + } + ], + "longdesc": "The resolution of the input image", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Angle", + "linked_widgets": [ + { + "node": "598", + "widget": "angle" + } + ], + "longdesc": "The angle of the simulated light", + "name": "param1", + "shortdesc": "Angle", + "type": "linked_control" + }, + { + "label": "Amount", + "linked_widgets": [ + { + "node": "598", + "widget": "amount" + } + ], + "longdesc": "The strength of the emboss effect", + "name": "param2", + "shortdesc": "Strength", + "type": "linked_control" + }, + { + "label": "Width", + "linked_widgets": [ + { + "node": "598", + "widget": "width" + } + ], + "longdesc": "The width (in pixels) of the area sampled for each pixel", + "name": "param3", + "shortdesc": "Width", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "param0": 9, + "param1": 0, + "param2": 5, + "param3": 1 + }, + "shortdesc": "Emboss", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fast_blur.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fast_blur.mmg new file mode 100644 index 00000000..de9bad34 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fast_blur.mmg @@ -0,0 +1,156 @@ +{ + "connections": [ + { + "from": "buffer_2", + "from_port": 0, + "to": "fast_blur_shader", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "fast_blur_shader", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Fast Blur", + "longdesc": "", + "name": "fast_blur", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "fast_blur_shader", + "node_position": { + "x": -168, + "y": 120 + }, + "parameters": { + "quality": 1, + "sigma": 100 + }, + "type": "fast_blur_shader" + }, + { + "name": "buffer_2", + "node_position": { + "x": -187, + "y": 61.5 + }, + "parameters": { + "size": 11 + }, + "type": "buffer", + "version": 1 + }, + { + "name": "gen_inputs", + "node_position": { + "x": -602, + "y": 91.75 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input image", + "name": "input", + "shortdesc": "Input", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 88, + "y": 61.75 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The generated blurred image", + "name": "output", + "shortdesc": "Output", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -254.5, + "y": -122.5 + }, + "parameters": { + "param0": 11, + "param1": 100, + "param2": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Resolution", + "linked_widgets": [ + { + "node": "buffer_2", + "widget": "size" + } + ], + "longdesc": "The resolution used to sample the input image", + "name": "param0", + "shortdesc": "Resolution", + "type": "linked_control" + }, + { + "label": "Sigma", + "linked_widgets": [ + { + "node": "fast_blur_shader", + "widget": "sigma" + } + ], + "longdesc": "The standard deviation of the gaussian distribution", + "name": "param1", + "shortdesc": "Sigma", + "type": "linked_control" + }, + { + "label": "Quality", + "linked_widgets": [ + { + "node": "fast_blur_shader", + "widget": "quality" + } + ], + "longdesc": "The quality of the effect (increasing quality increases compute time)", + "name": "param2", + "shortdesc": "Quality", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "param0": 11, + "param1": 100, + "param2": 1 + }, + "shortdesc": "", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fast_blur_shader.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fast_blur_shader.mmg new file mode 100644 index 00000000..ed332ab9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fast_blur_shader.mmg @@ -0,0 +1,55 @@ +{ + "name": "fast_blur_shader", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "quality": 1, + "sigma": 100 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "vec4 $(name)_blur(vec2 uv, vec2 scale, float sigma, int quality) {\n vec4 O = vec4(0.0);\n\tfloat samples = sigma * 4.0; \n\tint LOD = max(0, int(log2(float(samples)))-quality-2);\n\tint sLOD = 1 << LOD;\n int s = max(1, int(samples/float(sLOD)));\n\tfloat sum = 0.0;\n for (int i = 0; i < s*s; i++) {\n vec2 d = vec2(float(i%s), float(i/s))*float(sLOD) - 0.5*float(samples);\n\t\tvec2 dd = d / sigma;\n\t\tfloat g = exp(-.5*dot(dd,dd))/(6.28*sigma*sigma);\n O += g * textureLod($in.texture, uv + scale * d, float(LOD));\n\t\tsum += g;\n }\n \n return O / sum;\n}\n", + "name": "Fast Blur", + "outputs": [ + { + "rgba": "$(name)_blur($uv, vec2(1.0)/$in.size, max(1.0, floor($sigma*$in.size/2048.0)), int($quality))", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "", + "max": 256, + "min": 1, + "name": "sigma", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "", + "max": 3, + "min": 0, + "name": "quality", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fbm.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fbm.mmg new file mode 100644 index 00000000..c858e377 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fbm.mmg @@ -0,0 +1,139 @@ +{ + "name": "fbm", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "folds": 0, + "iterations": 5, + "noise": 0, + "persistence": 0.5, + "scale_x": 2, + "scale_y": 2 + }, + "shader_model": { + "code": "", + "global": "float fbm_value(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat p00 = rand(mod(o, size));\n\tfloat p01 = rand(mod(o + vec2(0.0, 1.0), size));\n\tfloat p10 = rand(mod(o + vec2(1.0, 0.0), size));\n\tfloat p11 = rand(mod(o + vec2(1.0, 1.0), size));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_perlin(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat a00 = rand(mod(o, size)) * 6.28318530718;\n\tfloat a01 = rand(mod(o + vec2(0.0, 1.0), size)) * 6.28318530718;\n\tfloat a10 = rand(mod(o + vec2(1.0, 0.0), size)) * 6.28318530718;\n\tfloat a11 = rand(mod(o + vec2(1.0, 1.0), size)) * 6.28318530718;\n\tvec2 v00 = vec2(cos(a00), sin(a00));\n\tvec2 v01 = vec2(cos(a01), sin(a01));\n\tvec2 v10 = vec2(cos(a10), sin(a10));\n\tvec2 v11 = vec2(cos(a11), sin(a11));\n\tfloat p00 = dot(v00, f);\n\tfloat p01 = dot(v01, f - vec2(0.0, 1.0));\n\tfloat p10 = dot(v10, f - vec2(1.0, 0.0));\n\tfloat p11 = dot(v11, f - vec2(1.0, 1.0));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn 0.5 + mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_perlinabs(vec2 coord, vec2 size, float seed) {\n\treturn abs(2.0*fbm_perlin(coord, size, seed)-1.0);\n}\n\nfloat fbm_cellular(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular2(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n\nfloat fbm_cellular3(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);\n\t\t\tfloat dist = abs((f - node).x) + abs((f - node).y);\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular4(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);\n\t\t\tfloat dist = abs((f - node).x) + abs((f - node).y);\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n\nfloat fbm_cellular5(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = max(abs((f - node).x), abs((f - node).y));\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular6(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = max(abs((f - node).x), abs((f - node).y));\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n", + "inputs": [ + + ], + "instance": "float $(name)_fbm(vec2 coord, vec2 size, int folds, 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\tfloat noise = fbm_$noise(coord*size, size, seed);\n\t\tfor (int f = 0; f < folds; ++f) {\n\t\t\tnoise = abs(2.0*noise-1.0);\n\t\t}\n\t\tvalue += noise * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n", + "longdesc": "Generates a noise made of several octaves of a simple noise", + "name": "FBM", + "outputs": [ + { + "f": "$(name)_fbm($(uv), vec2($(scale_x), $(scale_y)), int($(folds)), int($(iterations)), $(persistence), float($(seed)))", + "longdesc": "Shows a greyscale image of the generated noise", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "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" + }, + { + "name": "Cellular2", + "value": "cellular2" + }, + { + "name": "Cellular3", + "value": "cellular3" + }, + { + "name": "Cellular4", + "value": "cellular4" + }, + { + "name": "Cellular5", + "value": "cellular5" + }, + { + "name": "Cellular6", + "value": "cellular6" + } + ] + }, + { + "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": 0, + "label": "Folds", + "longdesc": "The number of times the basic noise is folded", + "max": 5, + "min": 0, + "name": "folds", + "shortdesc": "Folds", + "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.01, + "type": "float" + } + ], + "shortdesc": "Fractional Brownian Motion Noise" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fbm2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fbm2.mmg new file mode 100644 index 00000000..faa4b56e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fbm2.mmg @@ -0,0 +1,143 @@ +{ + "name": "fbm2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "folds": 0, + "iterations": 5, + "noise": 0, + "persistence": 0.5, + "scale_x": 2, + "scale_y": 2 + }, + "shader_model": { + "code": "", + "global": "float fbm_value(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat p00 = rand(mod(o, size));\n\tfloat p01 = rand(mod(o + vec2(0.0, 1.0), size));\n\tfloat p10 = rand(mod(o + vec2(1.0, 0.0), size));\n\tfloat p11 = rand(mod(o + vec2(1.0, 1.0), size));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_perlin(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat a00 = rand(mod(o, size)) * 6.28318530718;\n\tfloat a01 = rand(mod(o + vec2(0.0, 1.0), size)) * 6.28318530718;\n\tfloat a10 = rand(mod(o + vec2(1.0, 0.0), size)) * 6.28318530718;\n\tfloat a11 = rand(mod(o + vec2(1.0, 1.0), size)) * 6.28318530718;\n\tvec2 v00 = vec2(cos(a00), sin(a00));\n\tvec2 v01 = vec2(cos(a01), sin(a01));\n\tvec2 v10 = vec2(cos(a10), sin(a10));\n\tvec2 v11 = vec2(cos(a11), sin(a11));\n\tfloat p00 = dot(v00, f);\n\tfloat p01 = dot(v01, f - vec2(0.0, 1.0));\n\tfloat p10 = dot(v10, f - vec2(1.0, 0.0));\n\tfloat p11 = dot(v11, f - vec2(1.0, 1.0));\n\tvec2 t = f * f * (3.0 - 2.0 * f);\n\treturn 0.5 + mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);\n}\n\nfloat fbm_perlinabs(vec2 coord, vec2 size, float seed) {\n\treturn abs(2.0*fbm_perlin(coord, size, seed)-1.0);\n}\n\nvec2 rgrad2(vec2 p, float rot, float seed) {\n\tfloat u = rand(p + vec2(seed, 1.0-seed));\n\tu = fract(u) * 6.28318530718; // 2*pi\n\treturn vec2(cos(u), sin(u));\n}\n\nfloat fbm_simplex(vec2 coord, vec2 size, float seed) {\n\tcoord *= 2.0; // needed for it to tile\n\tcoord += rand2(vec2(seed, 1.0-seed)) + size;\n\tsize *= 2.0; // needed for it to tile\n\tcoord.y += 0.001;\n vec2 uv = vec2(coord.x + coord.y*0.5, coord.y);\n vec2 i0 = floor(uv);\n vec2 f0 = fract(uv);\n vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);\n vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);\n vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);\n vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);\n i1 = i0 + i1;\n vec2 i2 = i0 + vec2(1.0, 1.0);\n vec2 d0 = coord - p0;\n vec2 d1 = coord - p1;\n vec2 d2 = coord - p2;\n vec3 xw = mod(vec3(p0.x, p1.x, p2.x), size.x);\n vec3 yw = mod(vec3(p0.y, p1.y, p2.y), size.y);\n vec3 iuw = xw + 0.5 * yw;\n vec3 ivw = yw;\n vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), 0.0, seed);\n vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), 0.0, seed);\n vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), 0.0, seed);\n vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));\n vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));\n t = max(t, vec3(0.0));\n vec3 t2 = t * t;\n vec3 t4 = t2 * t2;\n float n = dot(t4, w);\n return 0.5 + 5.5 * n;\n}\n\nfloat fbm_cellular(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular2(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n\nfloat fbm_cellular3(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);\n\t\t\tfloat dist = abs((f - node).x) + abs((f - node).y);\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular4(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);\n\t\t\tfloat dist = abs((f - node).x) + abs((f - node).y);\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n\nfloat fbm_cellular5(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = max(abs((f - node).x), abs((f - node).y));\n\t\t\tmin_dist = min(min_dist, dist);\n\t\t}\n\t}\n\treturn min_dist;\n}\n\nfloat fbm_cellular6(vec2 coord, vec2 size, float seed) {\n\tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;\n\tvec2 f = fract(coord);\n\tfloat min_dist1 = 2.0;\n\tfloat min_dist2 = 2.0;\n\tfor(float x = -1.0; x <= 1.0; x++) {\n\t\tfor(float y = -1.0; y <= 1.0; y++) {\n\t\t\tvec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);\n\t\t\tfloat dist = max(abs((f - node).x), abs((f - node).y));\n\t\t\tif (min_dist1 > dist) {\n\t\t\t\tmin_dist2 = min_dist1;\n\t\t\t\tmin_dist1 = dist;\n\t\t\t} else if (min_dist2 > dist) {\n\t\t\t\tmin_dist2 = dist;\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist2-min_dist1;\n}\n", + "inputs": [ + + ], + "instance": "float $(name)_fbm(vec2 coord, vec2 size, int folds, 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\tfloat noise = fbm_$noise(coord*size, size, seed);\n\t\tfor (int f = 0; f < folds; ++f) {\n\t\t\tnoise = abs(2.0*noise-1.0);\n\t\t}\n\t\tvalue += noise * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n", + "longdesc": "Generates a noise made of several octaves of a simple noise", + "name": "FBM Noise", + "outputs": [ + { + "f": "$(name)_fbm($(uv), vec2($(scale_x), $(scale_y)), int($(folds)), int($(iterations)), $(persistence), float($(seed)))", + "longdesc": "Shows a greyscale image of the generated noise", + "shortdesc": "Output", + "type": "f" + } + ], + "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": "Simplex", + "value": "simplex" + }, + { + "name": "Cellular", + "value": "cellular" + }, + { + "name": "Cellular2", + "value": "cellular2" + }, + { + "name": "Cellular3", + "value": "cellular3" + }, + { + "name": "Cellular4", + "value": "cellular4" + }, + { + "name": "Cellular5", + "value": "cellular5" + }, + { + "name": "Cellular6", + "value": "cellular6" + } + ] + }, + { + "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": 0, + "label": "Folds", + "longdesc": "The number of times the basic noise is folded", + "max": 5, + "min": 0, + "name": "folds", + "shortdesc": "Folds", + "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.01, + "type": "float" + } + ], + "shortdesc": "Fractional Brownian Motion Noise" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill.mmg new file mode 100644 index 00000000..d7420846 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill.mmg @@ -0,0 +1,172 @@ +{ + "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 + } + ], + "label": "Fill", + "longdesc": "Fills areas defined by white outlines of its input", + "name": "fill", + "node_position": { + "x": 0, + "y": 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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_iterate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_iterate.mmg new file mode 100644 index 00000000..2e245578 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_iterate.mmg @@ -0,0 +1,42 @@ +{ + "name": "fill_iterate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "s": 11 + }, + "shader_model": { + "code": "", + "global": "", + "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", + "name": "Fill iterate", + "outputs": [ + { + "rgba": "$(name)_fill($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "", + "last": 12, + "name": "s", + "type": "size" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_preprocess.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_preprocess.mmg new file mode 100644 index 00000000..d05d0652 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_preprocess.mmg @@ -0,0 +1,42 @@ +{ + "name": "fill_preprocess", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "s": 8 + }, + "shader_model": { + "code": "", + "global": "vec4 flood_fill_preprocess(vec2 uv, float c, float s) {\n\tif (c > 0.5) {\n\t\treturn vec4(0.0);\n\t} else {\n\t\treturn vec4(floor(uv*s)/s, vec2(1.0/s));\n\t}\n}", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "", + "name": "Fill preprocess", + "outputs": [ + { + "rgba": "flood_fill_preprocess($uv, $in($uv), $s)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 10, + "first": 0, + "label": "", + "last": 12, + "name": "s", + "type": "size" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_color.mmg new file mode 100644 index 00000000..9b67ffc4 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_color.mmg @@ -0,0 +1,66 @@ +{ + "name": "fill_to_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "edgecolor": { + "a": 1, + "b": 0, + "g": 0, + "r": 0, + "type": "Color" + } + }, + "shader_model": { + "code": "vec4 $(name_uv)_bb = $in($uv);", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that fills each area with a color taken from a color map image", + "name": "Fill to Color", + "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" + } + ], + "shortdesc": "Fill to color" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_position.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_position.mmg new file mode 100644 index 00000000..f11d3262 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_position.mmg @@ -0,0 +1,61 @@ +{ + "name": "fill_to_position", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "axis": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that fills each area with a greyscale value that depends on its position", + "name": "Fill to Position", + "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))" + } + ] + } + ], + "shortdesc": "Fill to position" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_color.mmg new file mode 100644 index 00000000..91555918 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_color.mmg @@ -0,0 +1,58 @@ +{ + "name": "fill_to_random_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "edgecolor": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + } + }, + "shader_model": { + "code": "vec4 $(name_uv)_bb = $in($uv);", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that fills each area with a random color", + "name": "Fill to Random Color ", + "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" + } + ], + "shortdesc": "Fill to random color" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_grey.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_grey.mmg new file mode 100644 index 00000000..8f446068 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_random_grey.mmg @@ -0,0 +1,51 @@ +{ + "name": "fill_to_random_grey", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "edgecolor": 1 + }, + "shader_model": { + "code": "vec4 $(name_uv)_bb = $in($uv);", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that fills each area with a random greyscale value", + "name": "Fill to Random Grey", + "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" + } + ], + "shortdesc": "Fill to random grey" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_size.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_size.mmg new file mode 100644 index 00000000..b80f2d55 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_size.mmg @@ -0,0 +1,66 @@ +{ + "name": "fill_to_size", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "formula": 0 + }, + "seed_value": -52887, + "shader_model": { + "code": "vec4 $(name_uv)_bb = $in($uv);", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that fills each area with a greyscale value that depends on its size", + "name": "Fill to Size", + "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)" + } + ] + } + ], + "shortdesc": "Fill to size" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/fill_to_uv.mmg b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_uv.mmg new file mode 100644 index 00000000..1ea34619 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/fill_to_uv.mmg @@ -0,0 +1,57 @@ +{ + "name": "fill_to_uv", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "mode": 0 + }, + "shader_model": { + "code": "vec4 $(name_uv)_bb = $in($uv);", + "global": "vec3 fill_to_uv_stretch(vec2 coord, vec4 bb, float seed) {\n\tvec2 uv_islands = fract(coord-bb.xy)/bb.zw;\n\tfloat random_value = rand(vec2(seed)+bb.xy+bb.zw);\n\treturn vec3(uv_islands, random_value);\n}\n\nvec3 fill_to_uv_square(vec2 coord, vec4 bb, float seed) {\n\tvec2 uv_islands;\n\tif (bb.z > bb.w) {\n\t\tvec2 adjusted_coord = coord + vec2(0.0, (bb.z - bb.w) / 2.0);\n\t\tuv_islands = fract(adjusted_coord-bb.xy)/bb.zz;\n\t} else {\n\t\tvec2 adjusted_coord = coord + vec2((bb.w - bb.z) / 2.0, 0.0);\n\t\tuv_islands = fract(adjusted_coord-bb.xy)/bb.ww;\n\t}\n\tfloat random_value = rand(vec2(seed)+bb.xy+bb.zw);\n\treturn vec3(uv_islands, random_value);\n}", + "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" + } + ], + "instance": "", + "longdesc": "A fill companion node that generated an UV map that follows each filled area", + "name": "Fill to UV ", + "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" + } + ] + } + ], + "shortdesc": "Fill to UV" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur.mmg b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur.mmg new file mode 100644 index 00000000..e1a957c5 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur.mmg @@ -0,0 +1,343 @@ +{ + "connections": [ + { + "from": "switch", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "switch", + "from_port": 0, + "to": "switch_2", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "switch", + "to_port": 1 + }, + { + "from": "buffer", + "from_port": 0, + "to": "gaussian_blur_x", + "to_port": 0 + }, + { + "from": "gaussian_blur_x", + "from_port": 0, + "to": "switch", + "to_port": 0 + }, + { + "from": "gaussian_blur_y", + "from_port": 0, + "to": "switch_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "gaussian_blur_y", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "gaussian_blur_x", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "gaussian_blur_y", + "to_port": 1 + }, + { + "from": "buffer_3", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "switch_2", + "from_port": 0, + "to": "buffer_3", + "to_port": 0 + } + ], + "label": "Gaussian Blur", + "longdesc": "Applys a gaussian blur on its input", + "name": "gaussian_blur", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer_2", + "node_position": { + "x": -399.875, + "y": -43.625 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "switch", + "node_position": { + "x": -496.452393, + "y": -130.166656 + }, + "parameters": { + "choices": 2, + "outputs": 1, + "source": 0 + }, + "type": "switch" + }, + { + "name": "switch_2", + "node_position": { + "x": -240.452393, + "y": -133.666656 + }, + "parameters": { + "choices": 2, + "outputs": 1, + "source": 0 + }, + "type": "switch" + }, + { + "name": "buffer", + "node_position": { + "x": -402.25, + "y": -315.75 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -439.666626, + "y": -456.666656 + }, + "parameters": { + "param0": 9, + "param1": 50, + "param2": 0 + }, + "type": "remote", + "widgets": [ + { + "label": "Grid size:", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + }, + { + "node": "gaussian_blur_x", + "widget": "size" + }, + { + "node": "gaussian_blur_y", + "widget": "size" + }, + { + "node": "buffer_3", + "widget": "size" + } + ], + "longdesc": "The resolution of the input image", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Sigma:", + "linked_widgets": [ + { + "node": "gaussian_blur_x", + "widget": "sigma" + }, + { + "node": "gaussian_blur_y", + "widget": "sigma" + } + ], + "longdesc": "The strength of the blur filter", + "name": "param1", + "shortdesc": "Sigma", + "type": "linked_control" + }, + { + "configurations": { + "Both": [ + { + "node": "switch", + "value": 0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 0, + "widget": "source" + } + ], + "X": [ + { + "node": "switch", + "value": 0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 1, + "widget": "source" + } + ], + "Y": [ + { + "node": "switch", + "value": 1, + "widget": "source" + }, + { + "node": "switch_2", + "value": 0, + "widget": "source" + } + ] + }, + "label": "Direction:", + "linked_widgets": [ + { + "node": "switch", + "widget": "source" + }, + { + "node": "switch_2", + "widget": "source" + } + ], + "longdesc": "Apply the blur filter horizontally, vertically of in both directions", + "name": "param2", + "shortdesc": "Direction", + "type": "config_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -928.666626, + "y": -188.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input image", + "name": "input", + "shortdesc": "Input", + "type": "rgba" + }, + { + "group_size": 0, + "longdesc": "A map that controls the strength of the blur filter", + "name": "amount", + "shortdesc": "Strength map", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 193.547607, + "y": -135.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the generated blurred image", + "name": "port0", + "shortdesc": "Output", + "type": "rgba" + } + ], + "seed_value": 77778, + "type": "ios" + }, + { + "name": "gaussian_blur_x", + "node_position": { + "x": -412.993408, + "y": -221.281738 + }, + "parameters": { + "sigma": 50, + "size": 9 + }, + "type": "gaussian_blur_x" + }, + { + "name": "gaussian_blur_y", + "node_position": { + "x": -405.993408, + "y": 38.718262 + }, + "parameters": { + "sigma": 50, + "size": 9 + }, + "seed_value": 12279, + "type": "gaussian_blur_y" + }, + { + "name": "buffer_3", + "node_position": { + "x": -50.246796, + "y": -133.96936 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + } + ], + "parameters": { + "param0": 9, + "param1": 50, + "param2": 0 + }, + "shortdesc": "Gaussian blur", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_x.mmg b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_x.mmg new file mode 100644 index 00000000..e6342add --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_x.mmg @@ -0,0 +1,60 @@ +{ + "name": "gaussian_blur_x", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "sigma": 35.700001, + "size": 9 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "amount", + "type": "f" + } + ], + "instance": "vec4 $(name)_fct(vec2 uv) {\n\tfloat e = 1.0/$size;\n\tvec4 rv = vec4(0.0);\n\tfloat sum = 0.0;\n\tfloat sigma = max(0.000001, $sigma*$amount(uv));\n\tfor (float i = -50.0; i <= 50.0; i += 1.0) {\n\t\tfloat coef = exp(-0.5*(pow(i/sigma, 2.0)))/(6.28318530718*sigma*sigma);\n\t\trv += $in(uv+vec2(i*e, 0.0))*coef;\n\t\tsum += coef;\n\t}\n\treturn rv/sum;\n}", + "name": "Gaussian blur X", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 50, + "min": 0, + "name": "sigma", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_y.mmg b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_y.mmg new file mode 100644 index 00000000..c59848da --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/gaussian_blur_y.mmg @@ -0,0 +1,60 @@ +{ + "name": "gaussian_blur_y", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "sigma": 35.700001, + "size": 9 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "amount", + "type": "f" + } + ], + "instance": "vec4 $(name)_fct(vec2 uv) {\n\tfloat e = 1.0/$size;\n\tvec4 rv = vec4(0.0);\n\tfloat sum = 0.0;\n\tfloat sigma = max(0.000001, $sigma*$amount(uv));\n\tfor (float i = -50.0; i <= 50.0; i += 1.0) {\n\t\tfloat coef = exp(-0.5*(pow(i/sigma, 2.0)))/(6.28318530718*sigma*sigma);\n\t\trv += $in(uv+vec2(0.0, i*e))*coef;\n\t\tsum += coef;\n\t}\n\treturn rv/sum;\n}", + "name": "Gaussian blur Y", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 50, + "min": 0, + "name": "sigma", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/glsl_defs.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/glsl_defs.tmpl new file mode 100644 index 00000000..d4dc1851 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/glsl_defs.tmpl @@ -0,0 +1,34 @@ +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); +} diff --git a/game/addons/mat_maker_gd/material_maker_nodes/godot.tres.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/godot.tres.tmpl new file mode 100644 index 00000000..35283e15 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/godot.tres.tmpl @@ -0,0 +1,64 @@ +[gd_resource type="SpatialMaterial" load_steps=5 format=2] + +$if $(connected:albedo_tex) +[ext_resource path="$(file_prefix)_albedo.png" type="Texture" id=1] +$fi +$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex) +[ext_resource path="$(file_prefix)_orm.png" type="Texture" id=2] +$fi +$if $(connected:normal_tex) +[ext_resource path="$(file_prefix)_normal.png" type="Texture" id=3] +$fi +$if $(connected:depth_tex) +[ext_resource path="$(file_prefix)_depth.png" type="Texture" id=4] +$fi +$if $(connected:emission_tex) +[ext_resource path="$(file_prefix)_emission.png" type="Texture" id=5] +$fi + + +[resource] +albedo_color = Color($(param:albedo_color.r), $(param:albedo_color.g), $(param:albedo_color.b), $(param:albedo_color.a)) +$if $(connected:albedo_tex) +albedo_texture = ExtResource( 1 ) +$fi +metallic = $(param:metallic) +$if $(connected:metallic_tex) +metallic_texture = ExtResource( 2 ) +metallic_texture_channel = 2 +$fi +roughness = $(param:roughness) +$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex) +roughness_texture = ExtResource( 2 ) +roughness_texture_channel = 1 +$fi +$if $(connected:normal_tex) +normal_enabled = true +normal_scale = $(param:normal) +normal_texture = ExtResource( 3 ) +$fi +$if $(connected:emission_tex) +emission_enabled = true +emission = Color( 0, 0, 0, 1 ) +emission_energy = $(param:emission_energy) +emission_operator = 0 +emission_on_uv2 = false +emission_texture = ExtResource( 5 ) +$fi +$if $(connected:ao_tex) +ao_enabled = true +ao_light_affect = $(param:ao) +ao_texture = ExtResource( 2 ) +ao_on_uv2 = false +ao_texture_channel = 0 +$fi +$if $(connected:depth_tex) +depth_enabled = true +depth_scale = $(expr:0.2*$(param:depth_scale)) +depth_deep_parallax = true +depth_min_layers = 8 +depth_max_layers = 32 +depth_flip_tangent = false +depth_flip_binormal = false +depth_texture = ExtResource( 4 ) +$fi diff --git a/game/addons/mat_maker_gd/material_maker_nodes/gradient.mmg b/game/addons/mat_maker_gd/material_maker_nodes/gradient.mmg new file mode 100644 index 00000000..e0758a2b --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/gradient.mmg @@ -0,0 +1,102 @@ +{ + "name": "gradient", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "gradient": { + "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" + }, + "repeat": 1, + "rotate": 0 + }, + "shader_model": { + "code": "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);", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Gradient", + "outputs": [ + { + "longdesc": "An image showing the gradient", + "rgba": "$gradient(fract($(name_uv)_r*$repeat))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "Repeat", + "longdesc": "Number of repetitions of the gradient", + "max": 32, + "min": 1, + "name": "repeat", + "shortdesc": "Repeat", + "step": 1, + "type": "float" + }, + { + "control": "Radius1.a", + "default": 0, + "label": "Rotate", + "longdesc": "Angle of the gradient pattern", + "max": 180, + "min": -180, + "name": "rotate", + "shortdesc": "Rotate", + "step": 0.1, + "type": "float" + }, + { + "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": "Gradient", + "longdesc": "Gradient to be spread on the image", + "name": "gradient", + "shortdesc": "Gradient", + "type": "gradient" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/greyscale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/greyscale.mmg new file mode 100644 index 00000000..fe256d43 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/greyscale.mmg @@ -0,0 +1,69 @@ +{ + "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" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/height_to_angle.mmg b/game/addons/mat_maker_gd/material_maker_nodes/height_to_angle.mmg new file mode 100644 index 00000000..35340e19 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/height_to_angle.mmg @@ -0,0 +1,52 @@ +{ + "name": "height_to_angle", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "angle": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The input heightmap", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "float $(name)_fct(vec2 uv, float epsilon) {\n\tvec3 e = vec3(epsilon, -epsilon, 0);\n\tvec2 rv = vec2(1.0, -1.0)*$in(uv+e.xy);\n\trv += vec2(-1.0, 1.0)*$in(uv-e.xy);\n\trv += vec2(1.0, 1.0)*$in(uv+e.xx);\n\trv += vec2(-1.0, -1.0)*$in(uv-e.xx);\n\trv += vec2(2.0, 0.0)*$in(uv+e.xz);\n\trv += vec2(-2.0, 0.0)*$in(uv-e.xz);\n\trv += vec2(0.0, 2.0)*$in(uv+e.zx);\n\trv += vec2(0.0, -2.0)*$in(uv-e.zx);\n\treturn atan(rv.y, rv.x)/3.141592;\n}", + "longdesc": "Generates an angle map to be used by Advances Tiler nodes from a heightmap", + "name": "Height To Angle", + "outputs": [ + { + "f": "$(name)_fct($uv, 0.0001)+$angle/180.0", + "longdesc": "The generated angle map. Values are between -1 and 1 and the corresponding Advanced Tiler parameter (Rotate) must be set to 180.", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The offset angle applied to the generated map", + "max": 180, + "min": -180, + "name": "angle", + "shortdesc": "Angle", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Height to angle" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/hlsl_defs.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/hlsl_defs.tmpl new file mode 100644 index 00000000..a3722db8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/hlsl_defs.tmpl @@ -0,0 +1,41 @@ +#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); +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/iching.mmg b/game/addons/mat_maker_gd/material_maker_nodes/iching.mmg new file mode 100644 index 00000000..4a5fafd2 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/iching.mmg @@ -0,0 +1,57 @@ +{ + "name": "iching", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "columns": 4, + "rows": 4 + }, + "shader_model": { + "code": "", + "global": "float IChing(vec2 uv, float seed) {\n\tint value = int(32.0*rand(floor(uv)+vec2(seed)));\n\tfloat base = step(0.5, fract(fract(uv.y)*6.5))*step(0.04, fract(uv.y+0.02))*step(0.2, fract(uv.x+0.1));\n\tint bit = int(fract(uv.y)*6.5);\n\treturn base*step(0.1*step(float(bit & value), 0.5), fract(uv.x+0.55));\n}\n\n\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "This node generates a grid of random I Ching hexagrams.", + "name": "I Ching", + "outputs": [ + { + "f": "IChing(vec2($columns, $rows)*$uv, float($seed))", + "longdesc": "A greyscale image showing random I Ching hexagrams.", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Size X", + "longdesc": "The number of columns of the grid", + "max": 32, + "min": 2, + "name": "columns", + "shortdesc": "Size.x", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Size Y", + "longdesc": "The number of rows of the grid", + "max": 32, + "min": 2, + "name": "rows", + "shortdesc": "Size.y", + "step": 1, + "type": "float" + } + ], + "shortdesc": "I Ching hexagrams generator" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/invert.mmg b/game/addons/mat_maker_gd/material_maker_nodes/invert.mmg new file mode 100644 index 00000000..ffaa8e86 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/invert.mmg @@ -0,0 +1,40 @@ +{ + "name": "invert", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0, 1.0, 1.0, 1.0)", + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "A filter that inverts the R, G, and B channels of its input while keeping the A channel unchanged", + "name": "Invert", + "outputs": [ + { + "longdesc": "Shows the inverted image", + "rgba": "vec4(vec3(1.0)-$in($uv).rgb, $in($uv).a)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + + ], + "shortdesc": "Invert filter" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/io_types.mmt b/game/addons/mat_maker_gd/material_maker_nodes/io_types.mmt new file mode 100644 index 00000000..22930189 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/io_types.mmt @@ -0,0 +1,112 @@ +[ + { + "name":"f", + "label":"Greyscale", + "type":"float", + "paramdefs":"vec2 uv", + "params":"uv", + "slot_type":0, + "convert":[ + { "type":"rgb", "expr":"vec3($(value))" }, + { "type":"rgba", "expr":"vec4(vec3($(value)), 1.0)" } + ], + "color":{ "r":0.5, "g":0.5, "b":0.5, "a":1.0 } + }, + { + "name":"rgb", + "label":"Color", + "type":"vec3", + "paramdefs":"vec2 uv", + "params":"uv", + "slot_type":0, + "convert":[ + { "type":"f", "expr":"(dot($(value), vec3(1.0))/3.0)" }, + { "type":"rgba", "expr":"vec4($(value), 1.0)" } + ], + "color":{ "r":0.5, "g":0.5, "b":1.0, "a":1.0 } + }, + { + "name":"rgba", + "label":"RGBA", + "type":"vec4", + "paramdefs":"vec2 uv", + "params":"uv", + "slot_type":0, + "convert":[ + { "type":"f", "expr":"(dot(($(value)).rgb, vec3(1.0))/3.0)" }, + { "type":"rgb", "expr":"(($(value)).rgb)" } + ], + "color":{ "r":0.0, "g":0.5, "b":0.0, "a":0.5 } + }, + { + "name":"sdf2d", + "label":"SDF2D", + "type":"float", + "paramdefs":"vec2 uv", + "params":"uv", + "slot_type":1, + "color":{ "r":1.0, "g":0.5, "b":0.0, "a":1.0 } + }, + { + "name":"sdf3d", + "label":"SDF3D", + "type":"float", + "paramdefs":"vec3 p", + "params":"p", + "slot_type":2, + "convert":[ + { "type":"sdf3dc", "expr":"vec2($(value), 0.0)" } + ], + "color":{ "r":0.5, "g":0.0, "b":0.0, "a":1.0 } + }, + { + "name":"sdf3dc", + "label":"SDF3D-C", + "type":"vec2", + "paramdefs":"vec3 p", + "params":"p", + "slot_type":2, + "convert":[ + { "type":"sdf3d", "expr":"($(value)).x" } + ], + "color":{ "r":1.0, "g":0.0, "b":0.0, "a":1.0 } + }, + { + "name":"tex3d_gs", + "label":"Greyscale TEX3D", + "type":"float", + "paramdefs":"vec4 p", + "params":"p", + "slot_type":3, + "convert":[ + { "type":"tex3d", "expr":"vec3($(value))" } + ], + "color":{ "r":0.8, "g":0.0, "b":1.0, "a":1.0 } + }, + { + "name":"tex3d", + "label":"TEX3D", + "type":"vec3", + "paramdefs":"vec4 p", + "params":"p", + "slot_type":3, + "convert":[ + { "type":"tex3d_gs", "expr":"(dot($(value), vec3(1.0))/3.0)" } + ], + "color":{ "r":1.0, "g":0.0, "b":1.0, "a":1.0 } + }, + { + "name":"v4v4", + "label":"V4->V4", + "type":"vec4", + "paramdefs":"vec4 p", + "params":"p", + "slot_type":4, + "color":{ "r":0.6, "g":0.4, "b":0.1, "a":1.0 } + }, + { + "name":"any", + "slot_type":42, + "color":{ "r":1.0, "g":1.0, "b":1.0, "a":1.0 } + } +] diff --git a/game/addons/mat_maker_gd/material_maker_nodes/kaleidoscope.mmg b/game/addons/mat_maker_gd/material_maker_nodes/kaleidoscope.mmg new file mode 100644 index 00000000..dde275df --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/kaleidoscope.mmg @@ -0,0 +1,64 @@ +{ + "name": "kaleidoscope", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 5, + "offset": 0 + }, + "shader_model": { + "code": "", + "global": "vec2 kal_rotate(vec2 uv, float count, float offset) {\n\tfloat pi = 3.14159265359;\n\toffset *= pi/180.0;\n\toffset += pi*(1.0/count+0.5);\n\tuv -= vec2(0.5);\n\tfloat l = length(uv);\n\tfloat a = mod(atan(uv.y, uv.x)+offset, 2.0*pi/count)-offset;\n\treturn vec2(0.5)+l*vec2(cos(a), sin(a));\n}", + "inputs": [ + { + "default": "vec4($uv, 0, 1)", + "label": "", + "longdesc": "The input image", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Replicated an angle of the input image several times around the center.", + "name": "Kaleidoscope", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$i(kal_rotate($uv, $count, $offset))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The number of replications of an angle of the input", + "max": 10, + "min": 2, + "name": "count", + "shortdesc": "Count", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The angular offset of the replicated angle of the input", + "max": 180, + "min": -180, + "name": "offset", + "shortdesc": "Offset", + "step": 0.1, + "type": "float" + } + ], + "shortdesc": "Kaleidoscope" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/magnify.mmg b/game/addons/mat_maker_gd/material_maker_nodes/magnify.mmg new file mode 100644 index 00000000..e0b90dbf --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/magnify.mmg @@ -0,0 +1,85 @@ +{ + "name": "magnify", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "scale": 1.98 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be transformed", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "max(1.0-2.0*length($uv-vec2(0.5)), 0.0)", + "label": "", + "longdesc": "The magnifying glass shape", + "name": "s", + "shortdesc": "Shape", + "type": "f" + } + ], + "instance": "", + "longdesc": "Magnifying glass effect", + "name": "Magnify", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$i(vec2($cx+0.5, $cy+0.5)+($uv-vec2($cx+0.5, $cy+0.5))/mix(1.0, $scale, $s($uv-vec2($cx, $cy))))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "Center X:", + "longdesc": "X coordinate of the magnifying glass center", + "max": 0.5, + "min": -0.5, + "name": "cx", + "shortdesc": "center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y:", + "longdesc": "Y coordinate of the magnifying glass center", + "max": 0.5, + "min": -0.5, + "name": "cy", + "shortdesc": "center.y", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Scale:", + "longdesc": "The maximum scaling factor for the magnifying glass", + "max": 10, + "min": 0, + "name": "scale", + "shortdesc": "Scale", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Magnify" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/make_tileable.mmg b/game/addons/mat_maker_gd/material_maker_nodes/make_tileable.mmg new file mode 100644 index 00000000..ec5b9a86 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/make_tileable.mmg @@ -0,0 +1,51 @@ +{ + "name": "make_tileable", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "w": 0.1 + }, + "shader_model": { + "code": "", + "longdesc": "Creates a tileable version of its input image by moving different parts around to hide seams.", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "longdesc": "The image to be made tileable", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "vec4 make_tileable_$(name)(vec2 uv, float w) {\n\tvec4 a = $in(uv);\n\tvec4 b = $in(fract(uv+vec2(0.5)));\n\tfloat coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));\n\tvec4 c = $in(fract(uv+vec2(0.25)));\n\tfloat coef_abc = sin(1.57079632679*clamp((min(min(length(uv-vec2(0.0, 0.5)), length(uv-vec2(0.5, 0.0))), min(length(uv-vec2(1.0, 0.5)), length(uv-vec2(0.5, 1.0))))-w)/w, 0.0, 1.0));\n\treturn mix(c, mix(a, b, coef_ab), coef_abc);\n}\n", + "name": "Make Tileable", + "outputs": [ + { + "longdesc": "A tileable version of the input image", + "rgba": "make_tileable_$(name)($uv, 0.5*$w)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.1, + "label": "", + "longdesc": "Width of the transition areas between parts of the input image", + "max": 0.25, + "min": 0, + "name": "w", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/material.mmg b/game/addons/mat_maker_gd/material_maker_nodes/material.mmg new file mode 100644 index 00000000..6385c0e4 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/material.mmg @@ -0,0 +1,544 @@ +{ + "export": { + + }, + "name": "material", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "albedo_color": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "ao": 1, + "depth_scale": 0.5, + "emission_energy": 1, + "flags_transparent": false, + "metallic": 0, + "normal": 1, + "roughness": 1, + "size": 11, + "sss": 0 + }, + "shader_model": { + "code": "", + "custom": "", + "exports": { + "Blender": { + "export_extension": "tres", + "files": [ + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.exr", + "output": 0, + "type": "texture" + }, + { + "conditions": "$(connected:roughness_tex)", + "file_name": "$(path_prefix)_rough.exr", + "output": 13, + "type": "texture" + }, + { + "conditions": "$(connected:metallic_tex)", + "file_name": "$(path_prefix)_metal.exr", + "output": 12, + "type": "texture" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.exr", + "output": 10, + "type": "texture" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_displace.exr", + "output": 8, + "type": "texture" + }, + { + "conditions": "$(connected:sss_tex)", + "file_name": "$(path_prefix)_sss.exr", + "output": 5, + "type": "texture" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.exr", + "output": 2, + "type": "texture" + }, + { + "conditions": "$(connected:ao_tex)", + "file_name": "$(path_prefix)_occlusion.exr", + "output": 9, + "type": "texture" + } + ] + }, + "Godot": { + "export_extension": "tres", + "files": [ + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png", + "output": 0, + "type": "texture" + }, + { + "conditions": "$(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_orm.png", + "output": 1, + "type": "texture" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png", + "output": 2, + "type": "texture" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png", + "output": 3, + "type": "texture" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_depth.png", + "output": 4, + "type": "texture" + }, + { + "conditions": "$(connected:sss_tex)", + "file_name": "$(path_prefix)_sss.png", + "output": 5, + "type": "texture" + }, + { + "file_name": "$(path_prefix).tres", + "template": "[gd_resource type=\"SpatialMaterial\" load_steps=5 format=2]\n$if $(connected:albedo_tex)\n[ext_resource path=\"$(file_prefix)_albedo.png\" type=\"Texture\" id=1]\n$fi\n$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)\n[ext_resource path=\"$(file_prefix)_orm.png\" type=\"Texture\" id=2]\n$fi\n$if $(connected:normal_tex)\n[ext_resource path=\"$(file_prefix)_normal.png\" type=\"Texture\" id=3]\n$fi\n$if $(connected:depth_tex)\n[ext_resource path=\"$(file_prefix)_depth.png\" type=\"Texture\" id=4]\n$fi\n$if $(connected:emission_tex)\n[ext_resource path=\"$(file_prefix)_emission.png\" type=\"Texture\" id=5]\n$fi\n[resource]\nalbedo_color = Color($(param:albedo_color.r), $(param:albedo_color.g), $(param:albedo_color.b), $(param:albedo_color.a))\n$if $(connected:albedo_tex)\nalbedo_texture = ExtResource( 1 )\n$fi\nmetallic = $(param:metallic)\n$if $(connected:metallic_tex)\nmetallic_texture = ExtResource( 2 )\nmetallic_texture_channel = 2\n$fi\nroughness = $(param:roughness)\n$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)\nroughness_texture = ExtResource( 2 )\nroughness_texture_channel = 1\n$fi\n$if $(connected:normal_tex)\nnormal_enabled = true\nnormal_scale = $(param:normal)\nnormal_texture = ExtResource( 3 )\n$fi\n$if $(connected:emission_tex)\nemission_enabled = true\nemission = Color( 0, 0, 0, 1 )\nemission_energy = $(param:emission_energy)\nemission_operator = 0\nemission_on_uv2 = false\nemission_texture = ExtResource( 5 )\n$fi\n$if $(connected:ao_tex)\nao_enabled = true\nao_light_affect = $(param:ao)\nao_texture = ExtResource( 2 )\nao_on_uv2 = false\nao_texture_channel = 0\n$fi\n$if $(connected:depth_tex)\ndepth_enabled = true\ndepth_scale = $(expr:0.2*$(param:depth_scale))\ndepth_deep_parallax = true\ndepth_min_layers = 8\ndepth_max_layers = 32\ndepth_flip_tangent = false\ndepth_flip_binormal = false\ndepth_texture = ExtResource( 4 )\n$fi\n", + "type": "template" + } + ] + }, + "Unity - 3D": { + "export_extension": "mat", + "files": [ + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png", + "output": 0, + "type": "texture" + }, + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(0)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_metal_smoothness.png", + "output": 6, + "type": "texture" + }, + { + "conditions": "$(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_metal_smoothness.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(1)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png", + "output": 7, + "type": "texture" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(2)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 0\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 1\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_height.png", + "output": 8, + "type": "texture" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_height.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(3)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:ao_tex)", + "file_name": "$(path_prefix)_occlusion.png", + "output": 9, + "type": "texture" + }, + { + "conditions": "$(connected:ao_tex)", + "file_name": "$(path_prefix)_occlusion.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(4)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png", + "output": 2, + "type": "texture" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(5)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "file_name": "$(path_prefix).mat", + "template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test\n m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}\n m_ShaderKeywords: _METALLICGLOSSMAP _NORMALMAP _PARALLAXMAP\n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses: []\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _BumpMap:\n$if $(connected:normal_tex)\n m_Texture: {fileID: 2800000, guid: $uid(2), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _DetailAlbedoMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _DetailMask:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _DetailNormalMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _EmissionMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _MainTex:\n$if $(connected:albedo_tex)\n m_Texture: {fileID: 2800000, guid: $uid(0), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _MetallicGlossMap:\n$if $(connected:roughness_tex) or $(connected:metallic_tex)\n m_Texture: {fileID: 2800000, guid: $uid(1), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _OcclusionMap:\n$if $(connected:ao_tex)\n m_Texture: {fileID: 2800000, guid: $uid(4), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _ParallaxMap:\n$if $(connected:depth_tex)\n m_Texture: {fileID: 2800000, guid: $uid(3), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n m_Floats:\n - _BumpScale: 1\n - _Cutoff: 0.5\n - _DetailNormalMapScale: 1\n - _DstBlend: 0\n - _GlossMapScale: 1\n - _Glossiness: 0.5\n - _GlossyReflections: 1\n - _Metallic: 0\n - _Mode: 0\n - _OcclusionStrength: 1\n - _Parallax: 0.02\n - _SmoothnessTextureChannel: 0\n - _SpecularHighlights: 1\n - _SrcBlend: 1\n - _UVSec: 0\n - _ZWrite: 1\n m_Colors:\n - _Color: {r: 1, g: 1, b: 1, a: 1}\n - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}\n", + "type": "template" + } + ], + "uids": 6 + }, + "Unity - HDRP": { + "export_extension": "mat", + "files": [ + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png", + "output": 0, + "type": "texture" + }, + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(0)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_maskmap.png", + "output": 11, + "type": "texture" + }, + { + "conditions": "$(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_maskmap.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(1)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png", + "output": 7, + "type": "texture" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(2)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 0\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 1\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_height.png", + "output": 8, + "type": "texture" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_height.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(3)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png", + "output": 2, + "type": "texture" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(4)\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 10\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + }, + { + "file_name": "$(path_prefix).mat", + "template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test\n m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3}\n m_ShaderKeywords: _NORMALMAP_TANGENT_SPACE _NORMALMAP _HEIGHTMAP _PIXEL_DISPLACEMENT _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE _DISPLACEMENT_LOCK_TILING_SCALE _MASKMAP _EMISSIVE_COLOR_MAP\n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses:\n - DistortionVectors\n - MOTIONVECTORS\n - TransparentDepthPrepass\n - TransparentDepthPostpass\n - TransparentBackface\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _AnisotropyMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _BaseColorMap:\n$if $(connected:albedo_tex)\n m_Texture: {fileID: 2800000, guid: $uid(0), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _BentNormalMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _BentNormalMapOS:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _CoatMaskMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _DetailMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _DistortionVectorMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _EmissiveColorMap:\n$if $(connected:emission_tex)\n m_Texture: {fileID: 2800000, guid: $uid(4), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _HeightMap:\n$if $(connected:depth_tex)\n m_Texture: {fileID: 2800000, guid: $uid(3), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _IridescenceMaskMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _IridescenceThicknessMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _MainTex:\n$if $(connected:albedo_tex)\n m_Texture: {fileID: 2800000, guid: $uid(0), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _MaskMap:\n$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)\n m_Texture: {fileID: 2800000, guid: $uid(1), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _NormalMap:\n$if $(connected:normal_tex)\n m_Texture: {fileID: 2800000, guid: $uid(2), type: 3}\n$else\n m_Texture: {fileID: 0}\n$fi\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _NormalMapOS:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _SpecularColorMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _SubsurfaceMaskMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _TangentMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _TangentMapOS:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _ThicknessMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n - _TransmittanceColorMap:\n m_Texture: {fileID: 0}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n m_Floats:\n - _AORemapMax: 1\n - _AORemapMin: 0\n - _ATDistance: 1\n - _AddPrecomputedVelocity: 0\n - _AlbedoAffectEmissive: 0\n - _AlphaCutoff: 0.5\n - _AlphaCutoffEnable: 0\n - _AlphaCutoffPostpass: 0.5\n - _AlphaCutoffPrepass: 0.5\n - _AlphaCutoffShadow: 0.5\n - _AlphaDstBlend: 0\n - _AlphaSrcBlend: 1\n - _Anisotropy: 0\n - _BlendMode: 0\n - _CoatMask: 0\n - _CullMode: 2\n - _CullModeForward: 2\n - _Cutoff: 0.5\n - _DepthOffsetEnable: 0\n - _DetailAlbedoScale: 1\n - _DetailNormalScale: 1\n - _DetailSmoothnessScale: 1\n - _DiffusionProfile: 0\n - _DiffusionProfileHash: 0\n - _DisplacementLockObjectScale: 1\n - _DisplacementLockTilingScale: 1\n$if $(connected:depth_tex)\n - _DisplacementMode: 2\n$else\n - _DisplacementMode: 0\n$fi\n - _DistortionBlendMode: 0\n - _DistortionBlurBlendMode: 0\n - _DistortionBlurDstBlend: 1\n - _DistortionBlurRemapMax: 1\n - _DistortionBlurRemapMin: 0\n - _DistortionBlurScale: 1\n - _DistortionBlurSrcBlend: 1\n - _DistortionDepthTest: 1\n - _DistortionDstBlend: 1\n - _DistortionEnable: 0\n - _DistortionScale: 1\n - _DistortionSrcBlend: 1\n - _DistortionVectorBias: -1\n - _DistortionVectorScale: 2\n - _DoubleSidedEnable: 0\n - _DoubleSidedNormalMode: 1\n - _DstBlend: 0\n - _EmissiveColorMode: 1\n - _EmissiveExposureWeight: 1\n - _EmissiveIntensity: 1\n - _EmissiveIntensityUnit: 0\n - _EnableBlendModePreserveSpecularLighting: 1\n - _EnableFogOnTransparent: 1\n - _EnableGeometricSpecularAA: 0\n - _EnergyConservingSpecularColor: 1\n - _HeightAmplitude: $(expr:0.08*$(param:depth_scale))\n - _HeightCenter: 1\n - _HeightMapParametrization: 0\n - _HeightMax: 1\n - _HeightMin: -1\n - _HeightOffset: 0\n - _HeightPoMAmplitude: $(expr:8*$(param:depth_scale))\n - _HeightTessAmplitude: 2\n - _HeightTessCenter: 0.5\n - _InvTilingScale: 1\n - _Ior: 1.5\n - _IridescenceMask: 1\n - _IridescenceThickness: 1\n - _LinkDetailsWithBase: 1\n - _MaterialID: 1\n - _Metallic: $(param:metallic)\n - _NormalMapSpace: 0\n - _NormalScale: $(param:normal)\n - _PPDLodThreshold: 5\n - _PPDMaxSamples: 15\n - _PPDMinSamples: 5\n - _PPDPrimitiveLength: 1\n - _PPDPrimitiveWidth: 1\n - _ReceivesSSR: 1\n - _RefractionModel: 0\n - _SSRefractionProjectionModel: 0\n - _Smoothness: 1\n - _SmoothnessRemapMax: 1\n - _SmoothnessRemapMin: $(expr:1-$(param:roughness))\n - _SpecularAAScreenSpaceVariance: 0.1\n - _SpecularAAThreshold: 0.2\n - _SpecularOcclusionMode: 1\n - _SrcBlend: 1\n - _StencilRef: 0\n - _StencilRefDepth: 8\n - _StencilRefDistortionVec: 4\n - _StencilRefGBuffer: 10\n - _StencilRefMV: 40\n - _StencilWriteMask: 6\n - _StencilWriteMaskDepth: 8\n - _StencilWriteMaskDistortionVec: 4\n - _StencilWriteMaskGBuffer: 14\n - _StencilWriteMaskMV: 40\n - _SubsurfaceMask: 1\n - _SupportDecals: 1\n - _SurfaceType: 0\n - _TexWorldScale: 1\n - _TexWorldScaleEmissive: 1\n - _Thickness: 1\n - _TransmissionEnable: 1\n - _TransparentBackfaceEnable: 0\n - _TransparentCullMode: 2\n - _TransparentDepthPostpassEnable: 0\n - _TransparentDepthPrepassEnable: 0\n - _TransparentSortPriority: 0\n - _TransparentWritingMotionVec: 0\n - _TransparentZWrite: 0\n - _UVBase: 0\n - _UVDetail: 0\n - _UVEmissive: 0\n - _UseEmissiveIntensity: 0\n - _UseShadowThreshold: 0\n - _ZTestDepthEqualForOpaque: 3\n - _ZTestGBuffer: 4\n - _ZTestModeDistortion: 4\n - _ZTestTransparent: 4\n - _ZWrite: 1\n m_Colors:\n - _BaseColor: {r: 1, g: 1, b: 1, a: 1}\n - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0}\n - _Color: {r: 1, g: 1, b: 1, a: 1}\n - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0}\n - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}\n - _EmissionColor: {r: 1, g: 1, b: 1, a: 1}\n - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}\n - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1}\n - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}\n - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}\n - _SpecularColor: {r: 1, g: 1, b: 1, a: 1}\n - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}\n - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}\n - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}\n - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}\n - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}\n--- !u!114 &8466335806480081788\nMonoBehaviour:\n m_ObjectHideFlags: 11\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_GameObject: {fileID: 0}\n m_Enabled: 1\n m_EditorHideFlags: 0\n m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3}\n m_Name: \n m_EditorClassIdentifier: \n version: 2\n", + "type": "template" + } + ], + "uids": 5 + }, + "Unreal": { + "export_extension": "mm2ue", + "files": [ + { + "conditions": "$(connected:albedo_tex)", + "file_name": "$(path_prefix)_albedo.png", + "output": 0, + "type": "texture" + }, + { + "conditions": "$(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)", + "file_name": "$(path_prefix)_orm.png", + "output": 1, + "type": "texture" + }, + { + "conditions": "$(connected:emission_tex)", + "file_name": "$(path_prefix)_emission.png", + "output": 2, + "type": "texture" + }, + { + "conditions": "$(connected:normal_tex)", + "file_name": "$(path_prefix)_normal.png", + "output": 10, + "type": "texture" + }, + { + "conditions": "$(connected:depth_tex)", + "file_name": "$(path_prefix)_height.png", + "output": 8, + "type": "texture" + }, + { + "file_name": "$(path_prefix).mm2ue", + "template": "/*\nInstructions to setup this material:\n- copy material.uasset and open the copy\n- copy the shader code below and paste it into the Custom node\n$if $(connected:albedo_tex)\n- assign $(file_prefix)_albedo.png to the Albedo texture in the graph\n$fi\n$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex)\n- assign $(file_prefix)_orm.png to the ORM texture in the graph\n$fi\n$if $(connected:emission_tex)\n- assign $(file_prefix)_emission.png to the Emission texture in the graph\n$fi\n$if $(connected:normal_tex)\n- assign $(file_prefix)_normal.png to the Normal texture in the graph\n$fi\n$if $(connected:depth_tex)\n- assign $(file_prefix)_height.png to the Height texture in the graph\n$fi\n*/\n", + "type": "template" + } + ] + } + }, + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "group_size": 7, + "label": "", + "name": "albedo_tex", + "type": "rgb" + }, + { + "default": "1.0", + "label": "", + "name": "metallic_tex", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "name": "roughness_tex", + "type": "f" + }, + { + "default": "vec3(0.0)", + "label": "", + "name": "emission_tex", + "type": "rgb" + }, + { + "default": "vec3(0.5)", + "label": "", + "name": "normal_tex", + "type": "rgb" + }, + { + "default": "1.0", + "label": "", + "name": "ao_tex", + "type": "f" + }, + { + "default": "0.0", + "label": "", + "name": "depth_tex", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "name": "opacity_tex", + "type": "f" + }, + { + "default": "0.0", + "label": "", + "name": "sss_tex", + "type": "f" + } + ], + "instance": "", + "name": "Static PBR Material", + "outputs": [ + { + "rgba": "vec4($albedo_tex($uv), $opacity_tex($uv))", + "type": "rgba" + }, + { + "rgb": "vec3($ao_tex($uv), $roughness_tex($uv), $metallic_tex($uv))", + "type": "rgb" + }, + { + "rgb": "$emission_tex($uv)", + "type": "rgb" + }, + { + "rgb": "$normal_tex($uv)*vec3(-1.0, 1.0, 1.0)+vec3(1.0, 0.0, 0.0)", + "type": "rgb" + }, + { + "f": "$depth_tex($uv)", + "type": "f" + }, + { + "f": "$sss_tex($uv)", + "type": "f" + }, + { + "rgba": "vec4(vec3($metallic_tex($uv)), 1.0-$roughness_tex($uv))", + "type": "rgba" + }, + { + "rgb": "$normal_tex($uv)*vec3(-1.0, 1.0, -1.0)+vec3(1.0, 0.0, 1.0)", + "type": "rgb" + }, + { + "f": "1.0-$depth_tex($uv)", + "type": "f" + }, + { + "f": "$ao_tex($uv)", + "type": "f" + }, + { + "rgb": "$normal_tex($uv)*vec3(-1.0)+vec3(1.0)", + "type": "rgb" + }, + { + "rgba": "vec4($metallic_tex($uv), $ao_tex($uv), 1.0, 1.0-$roughness_tex($uv))", + "type": "rgba" + }, + { + "f": "$metallic_tex($uv)", + "type": "f" + }, + { + "f": "$roughness_tex($uv)", + "type": "f" + } + ], + "parameters": [ + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "Albedo", + "name": "albedo_color", + "type": "color" + }, + { + "control": "None", + "default": 1, + "label": "Metallic", + "max": 1, + "min": 0, + "name": "metallic", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Roughness", + "max": 1, + "min": 0, + "name": "roughness", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Emission", + "max": 1, + "min": 0, + "name": "emission_energy", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Normal", + "max": 10, + "min": 0, + "name": "normal", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Ambient occlusion", + "max": 1, + "min": 0, + "name": "ao", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Depth", + "max": 1, + "min": 0, + "name": "depth_scale", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Transparency", + "name": "flags_transparent", + "type": "boolean" + }, + { + "control": "None", + "default": 0, + "label": "Subsurf. scatter.", + "max": 1, + "min": 0, + "name": "sss", + "step": 0.01, + "type": "float" + }, + { + "default": 11, + "first": 6, + "label": "Size", + "last": 13, + "name": "size", + "type": "size" + } + ], + "preview_shader": "shader_type spatial;\nrender_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_burley,specular_schlick_ggx;\nuniform sampler2D texture_albedo : hint_albedo; // $output(0)\nuniform sampler2D texture_emission : hint_black_albedo; // $output(2)\nuniform sampler2D texture_normal : hint_normal; // $output(3)\nuniform sampler2D texture_orm : hint_white; // $output(1)\nuniform sampler2D texture_subsurface_scattering : hint_white; // $output(5)\nuniform sampler2D texture_depth : hint_black; // $output(4)\nuniform int depth_min_layers = 8;\nuniform int depth_max_layers = 32;\nuniform vec2 depth_flip = vec2(1.0);\n\nuniform vec3 uv1_scale;\nuniform vec3 uv1_offset;\n\n$definitions\n\nvoid vertex() {\n\tUV=UV*uv1_scale.xy+uv1_offset.xy;\n}\n\nvoid fragment() {\n\tvec2 base_uv = UV;\n\t{\n$begin_generate\n\t\tfloat depth_scale = 0.2*$depth_scale;\n$end_generate\n\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n\t\tfloat layer_depth = 1.0 / num_layers;\n\t\tfloat current_layer_depth = 0.0;\n\t\tvec2 P = view_dir.xy * depth_scale;\n\t\tvec2 delta = P / num_layers;\n\t\tvec2 ofs = base_uv;\n\t\tfloat depth = textureLod(texture_depth, ofs,0.0).r;\n\t\tfloat current_depth = 0.0;\n\t\twhile(current_depth < depth) {\n\t\t\tofs -= delta;\n\t\t\tdepth = textureLod(texture_depth, ofs,0.0).r;\n\t\t\tcurrent_depth += layer_depth;\n\t\t}\n\t\tvec2 prev_ofs = ofs + delta;\n\t\tfloat after_depth = depth - current_depth;\n\t\tfloat before_depth = textureLod(texture_depth, prev_ofs, 0.0).r - current_depth + layer_depth;\n\t\tfloat weight = after_depth / (after_depth - before_depth);\n\t\tofs = mix(ofs,prev_ofs,weight);\n\t\tbase_uv=ofs;\n\t}\n$begin_generate\n\tvec4 albedo_tex = texture(texture_albedo, base_uv);\n\tALBEDO = $albedo_color.rgb * albedo_tex.rgb;\n\tvec4 orm_tex = texture(texture_orm, base_uv);\n\tMETALLIC = $metallic*orm_tex.b;\n\tROUGHNESS = $roughness*orm_tex.g;\n\tSPECULAR = 0.5;\n\tNORMALMAP = texture(texture_normal, base_uv).rgb;\n\tNORMALMAP_DEPTH = $normal;\n\tvec3 emission_tex = texture(texture_emission, base_uv).rgb;\n\tEMISSION = emission_tex*$emission_energy;\n\tAO = orm_tex.r;\n\tAO_LIGHT_AFFECT = $ao;\n\tif ($flags_transparent) {\n\t\tALPHA = albedo_tex.a;\n\t}\n\tfloat sss_tex = texture(texture_subsurface_scattering, base_uv).r;\n\tSSS_STRENGTH=$sss*sss_tex;\n$end_generate\n}\n" + }, + "type": "material_export" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/material_dynamic.mmg b/game/addons/mat_maker_gd/material_maker_nodes/material_dynamic.mmg new file mode 100644 index 00000000..19a0b2b0 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/material_dynamic.mmg @@ -0,0 +1,233 @@ +{ + "export": { + + }, + "name": "material_dynamic", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "albedo_color": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "ao": 1, + "depth_scale": 0.5, + "emission_energy": 1, + "flags_transparent": false, + "metallic": 0, + "normal": 1, + "roughness": 1 + }, + "shader_model": { + "code": "", + "custom": "", + "exports": { + "Godot": { + "export_extension": "tres", + "files": [ + { + "file_name": "$(path_prefix).tres", + "template": "[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]\n[ext_resource path=\"$(file_prefix).shader\" type=\"Shader\" id=1]\n$begin_buffers\n[ext_resource path=\"res://$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]\n$end_buffers\n[resource]\nshader = ExtResource( 1 )\n$begin_buffers\nshader_param/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )\n$end_buffers\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader", + "template": "shader_type spatial;\nuniform vec3 uv1_scale = vec3(1.0, 1.0, 1.0);\nuniform int depth_min_layers = 8;\nuniform int depth_max_layers = 16;\nuniform vec2 depth_flip = vec2(1.0);\nuniform float variation = 0.0;\nvarying float elapsed_time;\nvoid vertex() {\n\telapsed_time = TIME;\n}\n$definitions float_uniform_to_const,rename_buffers\nvoid fragment() {\n\tfloat _seed_variation_ = variation;\n\tvec2 uv = fract(UV*uv1_scale.xy);\n$if $(connected:depth_tex)\n$begin_generate rename_buffers\n\t{\n\t\tfloat depth_scale = 0.2*$depth_scale;\n\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n\t\tfloat layer_depth = 1.0 / num_layers;\n\t\tfloat current_layer_depth = 0.0;\n\t\tvec2 P = view_dir.xy * depth_scale;\n\t\tvec2 delta = P / num_layers;\n\t\tvec2 ofs = uv;\n\t\tfloat depth = $depth_tex(ofs);\n\t\tfloat current_depth = 0.0;\n\t\twhile(current_depth < depth) {\n\t\t\tofs -= delta;\n\t\t\tdepth = $depth_tex(ofs);\n\t\t\tcurrent_depth += layer_depth;\n\t\t}\n\t\tvec2 prev_ofs = ofs + delta;\n\t\tfloat after_depth = depth - current_depth;\n\t\tfloat before_depth = $depth_tex(prev_ofs) - current_depth + layer_depth;\n\t\tfloat weight = after_depth / (after_depth - before_depth);\n\t\tofs = mix(ofs,prev_ofs,weight);\n\t\tuv = ofs;\n\t}\n$end_generate\n$fi\n$begin_generate rename_buffers\n\tvec3 albedo_tex = $albedo_tex(uv).rgb;\n\talbedo_tex = mix(pow((albedo_tex + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex * (1.0 / 12.92),lessThan(albedo_tex,vec3(0.04045)));\n\tALBEDO = albedo_tex*$albedo_color.rgb;\n\tMETALLIC = $metallic_tex(uv)*$metallic;\n\tROUGHNESS = $roughness_tex(uv)*$roughness;\n\tNORMALMAP = $normal_tex(uv);\n\tEMISSION = $emission_tex(uv)*$emission_energy;\n\tALPHA = $opacity_tex(uv);\n$end_generate\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + } + ] + }, + "Unity": { + "export_extension": "mat", + "files": [ + { + "file_name": "$(path_prefix).shader", + "template": "Shader \"Custom/NewSurfaceShader\"\n{\n Properties {\n$begin_buffers\n\t texture_$(buffer_index) (\"Texture $(buffer_index)\", 2D) = \"white\" {}\n$end_buffers\n\t _MainTex (\"Foo\", 2D) = \"white\" {}\n }\n SubShader {\n Tags { \"RenderType\"=\"Opaque\" }\n LOD 200\n CGPROGRAM\n #pragma surface surf Standard fullforwardshadows\n #pragma target 3.0\n\t\t\n sampler2D _MainTex;\n struct Input {\n float2 uv_MainTex;\n };\n UNITY_INSTANCING_BUFFER_START(Props)\n UNITY_INSTANCING_BUFFER_END(Props)\n\t\t\n$definitions hlsl,rename_buffers,unity\n\t\t\n void surf (Input IN, inout SurfaceOutputStandard o) {\n\t\t\tfloat2 uv = IN.uv_MainTex;\n$begin_generate hlsl,rename_buffers,unity\n\t\t\to.Albedo = $albedo_tex(uv).rgb*$albedo_color.rgb;\n o.Metallic = $metallic_tex(uv)*$metallic;\n o.Smoothness = 1.0-$roughness_tex(uv)*$roughness;\n o.Alpha = 1.0;\n\t\t\to.Normal = $normal_tex(uv)*vec3(-1.0, 1.0, -1.0)+vec3(1.0, 0.0, 1.0);\n$end_generate\n }\n ENDCG\n }\n FallBack \"Diffuse\"\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(tex_$(buffer_index))\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 11\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n vTOnly: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n flipbookRows: 1\n flipbookColumns: 1\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n ignorePngGamma: 0\n applyGammaDecoding: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "buffer_templates" + }, + { + "file_name": "$(path_prefix).mat", + "template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test2\n m_Shader: {fileID: 4800000, guid: $uid(shader), type: 3}\n m_ShaderKeywords: \n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses: []\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _MainTex:\n m_Texture: {fileID: 2800000, guid: 6c5d2d4e94384751a0ce7d6619e0d49a, type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$begin_buffers\n - texture_$(buffer_index):\n m_Texture: {fileID: 2800000, guid: $uid(tex_$(buffer_index)), type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$end_buffers\n m_BuildTextureStacks: []\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader.meta", + "template": "fileFormatVersion: 2\nguid: $uid(shader)\nShaderImporter:\n externalObjects: {}\n defaultTextures: []\n nonModifiableTextures: []\n preprocessorOverride: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + } + ] + }, + "Unreal": { + "export_extension": "mm2ue", + "files": [ + { + "file_name": "$(path_prefix).mm2ue", + "template": "/*\nInstructions to setup this material:\n- copy material_dynamic.uasset and open the copy\n$begin_buffers\n- create a TextureObject for $(file_prefix)_texture_$(buffer_index).png in the graph\n and a new input for texture_$(buffer_index) in the custom node, and connect them\n$end_buffers\n- copy the shader code below and paste it into the Custom node\n*/\nstruct Functions {\n$definitions hlsl,rename_buffers,unreal\n\tfixed4 generated_shader(float2 uv, out float metallic, out float roughness, out float3 normal) {\n$begin_generate hlsl,rename_buffers,unreal\n // sample the generated texture\n\t\tfixed4 rv = tofloat4($albedo_tex(uv), 1.0)*$albedo_color;\n\t\tmetallic = $metallic_tex(uv)*$metallic;\n\t\troughness = $roughness_tex(uv)*$roughness;\n\t\tnormal = $normal_tex(uv)*float3(-1.0, -1.0, -1.0)+float3(1.0, 1.0, 1.0);\n return rv;\n$end_generate\n }\n};\nFunctions f;\nfixed4 albedo = f.generated_shader(TexCoords, metallic, roughness, normal);\nreturn albedo;\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + } + ] + } + }, + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "group_size": 7, + "label": "", + "name": "albedo_tex", + "type": "rgb" + }, + { + "default": "1.0", + "label": "", + "name": "metallic_tex", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "name": "roughness_tex", + "type": "f" + }, + { + "default": "vec3(0.0)", + "label": "", + "name": "emission_tex", + "type": "rgb" + }, + { + "default": "vec3(0.5)", + "label": "", + "name": "normal_tex", + "type": "rgb" + }, + { + "default": "1.0", + "label": "", + "name": "ao_tex", + "type": "f" + }, + { + "default": "0.0", + "function": true, + "label": "", + "name": "depth_tex", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "name": "opacity_tex", + "type": "f" + } + ], + "instance": "", + "name": "Dynamic PBR Material", + "outputs": [ + + ], + "parameters": [ + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "Albedo", + "name": "albedo_color", + "type": "color" + }, + { + "control": "None", + "default": 1, + "label": "Metallic", + "max": 1, + "min": 0, + "name": "metallic", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Roughness", + "max": 1, + "min": 0, + "name": "roughness", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Emission", + "max": 1, + "min": 0, + "name": "emission_energy", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Normal", + "max": 10, + "min": 0, + "name": "normal", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Ambient occlusion", + "max": 1, + "min": 0, + "name": "ao", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Depth", + "max": 1, + "min": 0, + "name": "depth_scale", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Transparency", + "name": "flags_transparent", + "type": "boolean" + } + ], + "preview_shader": "shader_type spatial;\nrender_mode blend_mix,depth_draw_alpha_prepass,cull_back,diffuse_burley,specular_schlick_ggx;\n\nuniform vec3 uv1_offset = vec3(1.0, 1.0, 1.0);\nuniform vec3 uv1_scale = vec3(1.0, 1.0, 1.0);\nuniform int depth_min_layers = 8;\nuniform int depth_max_layers = 32;\nuniform vec2 depth_flip = vec2(1.0);\nuniform float variation = 0.0;\n\nvarying float elapsed_time;\n\nvoid vertex() {\n\telapsed_time = TIME;\n\tUV = UV*uv1_scale.xy+uv1_offset.xy;\n}\n\n//---\n\n\n$definitions\n\nvoid fragment() {\n\tfloat _seed_variation_ = variation;\n\tvec2 uv = fract(UV);\n$begin_generate\n\t{\n\t\tfloat depth_scale = 0.2*$depth_scale;\n\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n\t\tfloat layer_depth = 1.0 / num_layers;\n\t\tfloat current_layer_depth = 0.0;\n\t\tvec2 P = view_dir.xy * depth_scale;\n\t\tvec2 delta = P / num_layers;\n\t\tvec2 ofs = uv;\n\t\tfloat depth = $depth_tex(ofs);\n\t\tfloat current_depth = 0.0;\n\t\twhile(current_depth < depth) {\n\t\t\tofs -= delta;\n\t\t\tdepth = $depth_tex(ofs);\n\t\t\tcurrent_depth += layer_depth;\n\t\t}\n\t\tvec2 prev_ofs = ofs + delta;\n\t\tfloat after_depth = depth - current_depth;\n\t\tfloat before_depth = $depth_tex(prev_ofs) - current_depth + layer_depth;\n\t\tfloat weight = after_depth / (after_depth - before_depth);\n\t\tofs = mix(ofs,prev_ofs,weight);\n\t\tuv = ofs;\n\t}\n$end_generate\n$begin_generate\n\tvec3 albedo_tex = $albedo_tex(uv);\n\talbedo_tex = mix(pow((albedo_tex + vec3(0.055)) * (1.0 / (1.0 + 0.055)),vec3(2.4)),albedo_tex * (1.0 / 12.92),lessThan(albedo_tex,vec3(0.04045)));\n\tALBEDO = albedo_tex.rgb*$albedo_color.rgb;\n\tMETALLIC = $metallic_tex(uv)*$metallic;\n\tROUGHNESS = $roughness_tex(uv)*$roughness;\n\tNORMALMAP = $normal_tex(uv);\n\tNORMALMAP_DEPTH = $normal;\n\tEMISSION = $emission_tex(uv)*$emission_energy;\n\tAO = $ao*$ao_tex(uv);\n\tif ($flags_transparent) {\n\t\tALPHA = $opacity_tex(uv);\n\t}\n$end_generate\n}\n" + }, + "type": "material_export" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/material_raymarching.mmg b/game/addons/mat_maker_gd/material_maker_nodes/material_raymarching.mmg new file mode 100644 index 00000000..031bfcd0 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/material_raymarching.mmg @@ -0,0 +1,124 @@ +{ + "export": { + + }, + "name": "material_raymarching", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "seed": 12723, + "seed_locked": false, + "shader_model": { + "code": "", + "custom": "", + "exports": { + "Godot": { + "export_extension": "tres", + "files": [ + { + "file_name": "$(path_prefix).tres", + "template": "[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]\n[ext_resource path=\"$(file_prefix).shader\" type=\"Shader\" id=1]\n$begin_buffers\n[ext_resource path=\"res://$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]\n$end_buffers\n[resource]\nshader = ExtResource( 1 )\n$begin_buffers\nshader_param/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )\n$end_buffers\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader", + "template": "shader_type spatial;\nvarying float elapsed_time;\nvarying vec3 world_camera;\nvarying vec3 world_position;\nconst int MAX_STEPS = 100;\nconst float MAX_DIST = 100.0;\nconst float SURF_DIST = 1e-3;\n$definitions float_uniform_to_const,rename_buffers\nvec2 GetDist(vec3 p) {\n\tfloat _seed_variation_ = 0.0;\n\t\n$begin_generate rename_buffers\n\tvec2 d = $distance(p);\n$end_generate\n\treturn d;\n}\nvec2 RayMarch(vec3 ro, vec3 rd) {\n\tfloat dO = 0.0;\n\tfloat color = 0.0;\n\tvec2 dS;\n\t\n\tfor (int i = 0; i < MAX_STEPS; i++) {\n\t\tvec3 p = ro + dO * rd;\n\t\tdS = GetDist(p);\n\t\tdO += dS.x;\n\t\t\n\t\tif (dS.x < SURF_DIST || dO > MAX_DIST) {\n\t\t\tcolor = dS.y;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn vec2(dO, color);\n}\nvec3 GetNormal(vec3 p) {\n\tvec2 e = vec2(1e-2, 0);\n\t\n\tvec3 n = GetDist(p).x - vec3(\n\t\tGetDist(p - e.xyy).x,\n\t\tGetDist(p - e.yxy).x,\n\t\tGetDist(p - e.yyx).x\n\t);\n\t\n\treturn normalize(n);\n}\nvoid vertex() {\n\telapsed_time = TIME;\n\tworld_position = VERTEX;\n\tworld_camera = (inverse(MODELVIEW_MATRIX) * vec4(0, 0, 0, 1)).xyz; //object space\n\t//world_camera = ( CAMERA_MATRIX * vec4(0, 0, 0, 1)).xyz; //uncomment this to raymarch in world space\n}\nvoid fragment() {\n\tfloat _seed_variation_ = 0.0;\n\t\n\tvec3 ro = world_camera;\n\tvec3 rd = normalize(world_position - ro);\n\t\n\tvec2 rm = RayMarch(ro, rd);\n\tfloat d = rm.x;\n\tif (d >= MAX_DIST) {\n\t\tdiscard;\n\t} else {\n\t\tvec3 p = ro + rd * d;\n$begin_generate rename_buffers\n\t\tALBEDO = $albedo(vec4(p, rm.y));\n\t\tROUGHNESS = $roughness(vec4(p, rm.y)).x;\n\t\tMETALLIC = $metallic(vec4(p, rm.y)).x;\n$end_generate\n\t\tNORMAL = (INV_CAMERA_MATRIX*WORLD_MATRIX*vec4(GetNormal(p), 0.0)).xyz;\n\t}\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + } + ] + }, + "Unity": { + "export_extension": "mat", + "files": [ + { + "file_name": "$(path_prefix).shader", + "template": "Shader \"Custom/NewSurfaceShader\"\n{\n Properties {\n$begin_buffers\n\t texture_$(buffer_index) (\"Texture $(buffer_index)\", 2D) = \"white\" {}\n$end_buffers\n }\n SubShader\n {\n Tags { \"RenderType\"=\"Opaque\" }\n LOD 200\n CGPROGRAM\n // Physically based Standard lighting model, and enable shadows on all light types\n #pragma surface surf Standard fullforwardshadows\n // Use shader model 3.0 target, to get nicer looking lighting\n #pragma target 3.0\n struct Input\n {\n float3 worldPos;\n float3 viewDir;\n };\n UNITY_INSTANCING_BUFFER_START(Props)\n // put more per-instance properties here\n UNITY_INSTANCING_BUFFER_END(Props)\n$definitions hlsl,rename_buffers,unity\n float2 sceneSDF(float3 p) {\n$begin_generate hlsl,rename_buffers,unity\n return $distance(p);\n$end_generate\n }\n#define MAX_STEPS 128\n#define SURF_DIST 0.001\n#define MAX_DIST 1000.0\n float2 RayMarch(float3 ro, float3 rd) {\n float dO = 0.0;\n float color = 0.0;\n float2 dS;\n \n for (int i = 0; i < MAX_STEPS; i++) {\n float3 p = ro + dO * rd;\n dS = sceneSDF(p);\n dO += dS.x;\n \n if (dS.x < SURF_DIST || dO > MAX_DIST) {\n color = dS.y;\n break;\n }\n }\n return float2(dO, color);\n }\n float3 GetNormal(float3 p) {\n float2 e = float2(1e-2, 0);\n \n float3 n = sceneSDF(p).x - float3(\n sceneSDF(p - e.xyy).x,\n sceneSDF(p - e.yxy).x,\n sceneSDF(p - e.yyx).x\n );\n \n return normalize(n);\n }\n void surf (Input IN, inout SurfaceOutputStandard o) {\n float3 ro = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos, 1.0));\n float3 rd = normalize(mul(unity_WorldToObject, float4(IN.worldPos, 1.0))-ro);\n float2 dist = RayMarch(ro, rd);\n if (dist.x > 99.0) {\n discard;\n }\n float3 p = ro+rd*dist.x;\n$begin_generate hlsl,rename_buffers,unity\n o.Albedo = $albedo(vec4(p, dist.y));\n o.Metallic = $metallic(vec4(p, dist.y)).x;\n o.Smoothness = 1.0-$roughness(vec4(p, dist.y)).x;\n o.Normal = GetNormal(p);\n$end_generate\n }\n ENDCG\n }\n FallBack \"Diffuse\"\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(tex_$(buffer_index))\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 11\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n vTOnly: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n flipbookRows: 1\n flipbookColumns: 1\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n ignorePngGamma: 0\n applyGammaDecoding: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "buffer_templates" + }, + { + "file_name": "$(path_prefix).mat", + "template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test2\n m_Shader: {fileID: 4800000, guid: $uid(shader), type: 3}\n m_ShaderKeywords: \n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses: []\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _MainTex:\n m_Texture: {fileID: 2800000, guid: 6c5d2d4e94384751a0ce7d6619e0d49a, type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$begin_buffers\n - texture_$(buffer_index):\n m_Texture: {fileID: 2800000, guid: $uid(tex_$(buffer_index)), type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$end_buffers\n m_BuildTextureStacks: []\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader.meta", + "template": "fileFormatVersion: 2\nguid: $uid(shader)\nShaderImporter:\n externalObjects: {}\n defaultTextures: []\n nonModifiableTextures: []\n preprocessorOverride: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + } + ] + }, + "Unreal": { + "export_extension": "mm2ue", + "files": [ + { + "file_name": "$(path_prefix).mm2ue", + "template": "/*\nInstructions to setup this material:\n- copy material_raymarching.uasset and open the copy\n- copy the shader code below and paste it into the Custom node\n$begin_buffers\n- create a TextureObject for $(file_prefix)_texture_$(buffer_index).png in the graph\n and a new input for texture_$(buffer_index) in the custom node, and connect them\n$end_buffers\n*/\nstruct Functions {\n$definitions hlsl,rename_buffers,unreal\n float2 sceneSDF(float3 p) {\n\t\tp = p.xzy/Scale;\n$begin_generate hlsl,rename_buffers,unreal\n\t\tfloat2 d = $distance(p);\n$end_generate\n return float2(d.x*Scale, d.y);\n }\n#define MAX_STEPS 128\n#define SURF_DIST 0.1\n#define MAX_DIST 1000.0\n float2 RayMarch(float3 ro, float3 rd) {\n float dO = 0.0;\n float color = 0.0;\n float2 dS;\n \n for (int i = 0; i < MAX_STEPS; i++) {\n float3 p = ro + dO * rd;\n dS = sceneSDF(p);\n dO += dS.x;\n \n if (dS.x < SURF_DIST || dO > MAX_DIST) {\n color = dS.y;\n break;\n }\n }\n return float2(dO, color);\n }\n float3 GetNormal(float3 p) {\n float2 e = float2(1e-2, 0);\n \n float3 n = sceneSDF(p).x - float3(\n sceneSDF(p - e.xyy).x,\n sceneSDF(p - e.yxy).x,\n sceneSDF(p - e.yyx).x\n );\n \n return normalize(n);\n }\n float4 generated_shader(float3 CameraPosition, float3 RayDirection, out float metallic, out float roughness, out float3 normal) {\n float3 ro = CameraPosition;\n float3 rd = RayDirection;\n float2 dist = RayMarch(ro, rd);\n\t\tfloat3 p = ro+dist.x*rd;\n\t\tfloat4 pc = tofloat4(p.xzy/Scale, dist.y);\n\t\tfloat alpha = (dist < MAX_DIST) ? 1.0 : 0.0;\n$begin_generate hlsl,rename_buffers,unreal\n float4 albedo = tofloat4($albedo(pc), alpha);\n metallic = $metallic(pc).x;\n roughness = $roughness(pc).x;\n$end_generate\n normal = GetNormal(p.xzy);\n return albedo;\n }\n};\nFunctions f;\nfloat4 albedo = f.generated_shader(CameraPosition, RayDirection, metallic, roughness, normal);\nreturn albedo;\n", + "type": "template" + }, + { + "file_name": "$(file_prefix)_texture_$(buffer_index).png", + "type": "buffers" + } + ] + } + }, + "global": "", + "inputs": [ + { + "default": "vec2(0.0)", + "function": true, + "label": "Distance", + "name": "distance", + "type": "sdf3dc" + }, + { + "default": "vec3(1.0)", + "function": true, + "label": "Albedo", + "name": "albedo", + "type": "tex3d" + }, + { + "default": "vec3(0.0)", + "function": true, + "label": "Metallic", + "name": "metallic", + "type": "tex3d" + }, + { + "default": "vec3(1.0)", + "function": true, + "label": "Roughness", + "name": "roughness", + "type": "tex3d" + } + ], + "instance": "", + "name": "Raymarching Material", + "outputs": [ + + ], + "parameters": [ + + ], + "preview_shader": "shader_type spatial;\n\nvarying float elapsed_time;\n\nvarying vec3 world_camera;\nvarying vec3 world_position;\n\nconst int MAX_STEPS = 100;\nconst float MAX_DIST = 100.0;\nconst float SURF_DIST = 1e-3;\n\n$definitions\n\nvec2 GetDist(vec3 p) {\n\tfloat _seed_variation_ = 0.0;\n\t\n$begin_generate\n\tvec2 d = $distance(p);\n$end_generate\n\n\treturn d;\n}\n\nvec2 RayMarch(vec3 ro, vec3 rd) {\n\tfloat dO = 0.0;\n\tfloat color = 0.0;\n\tvec2 dS;\n\t\n\tfor (int i = 0; i < MAX_STEPS; i++)\n\t{\n\t\tvec3 p = ro + dO * rd;\n\t\tdS = GetDist(p);\n\t\tdO += dS.x;\n\t\t\n\t\tif (dS.x < SURF_DIST || dO > MAX_DIST) {\n\t\t\tcolor = dS.y;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn vec2(dO, color);\n}\n\nvec3 GetNormal(vec3 p) {\n\tvec2 e = vec2(1e-2, 0);\n\t\n\tvec3 n = GetDist(p).x - vec3(\n\t\tGetDist(p - e.xyy).x,\n\t\tGetDist(p - e.yxy).x,\n\t\tGetDist(p - e.yyx).x\n\t);\n\t\n\treturn normalize(n);\n}\n\nvoid vertex() {\n\telapsed_time = TIME;\n\tworld_position = VERTEX;\n\tworld_camera = (inverse(MODELVIEW_MATRIX) * vec4(0, 0, 0, 1)).xyz; //object space\n\t//world_camera = ( CAMERA_MATRIX * vec4(0, 0, 0, 1)).xyz; //uncomment this to raymarch in world space\n}\n\nvoid fragment() {\n\tfloat _seed_variation_ = 0.0;\n\t\n\tvec3 ro = world_camera;\n\tvec3 rd = normalize(world_position - ro);\n\t\n\tvec2 rm = RayMarch(ro, rd);\n\tfloat d = rm.x;\n\n\tif (d >= MAX_DIST)\n\t\tdiscard;\n\telse\n\t{\n\t\tvec3 p = ro + rd * d;\n$begin_generate\n\t\tALBEDO = $albedo(vec4(p, rm.y));\n\t\tROUGHNESS = $roughness(vec4(p, rm.y)).x;\n\t\tMETALLIC = $metallic(vec4(p, rm.y)).x;\n$end_generate\n\t\tNORMAL = (INV_CAMERA_MATRIX*WORLD_MATRIX*vec4(GetNormal(p), 0.0)).xyz;\n\t}\n}\n" + }, + "type": "material_export" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/material_unlit.mmg b/game/addons/mat_maker_gd/material_maker_nodes/material_unlit.mmg new file mode 100644 index 00000000..e19e1c36 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/material_unlit.mmg @@ -0,0 +1,119 @@ +{ + "export": { + + }, + "name": "material_unlit", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "blend": 0 + }, + "shader_model": { + "code": "", + "custom": "", + "exports": { + "Godot": { + "export_extension": "tres", + "files": [ + { + "file_name": "$(path_prefix).tres", + "template": "[gd_resource type=\"ShaderMaterial\" load_steps=2 format=2]\n[ext_resource path=\"$(file_prefix).shader\" type=\"Shader\" id=1]\n$begin_buffers\n[ext_resource path=\"res://$(file_prefix)_texture_$(buffer_index).png\" type=\"Texture\" id=$(expr:$(buffer_index)+1)]\n$end_buffers\n[resource]\nshader = ExtResource( 1 )\n$begin_buffers\nshader_param/texture_$(buffer_index) = ExtResource( $(expr:$(buffer_index)+1) )\n$end_buffers\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader", + "template": "shader_type spatial;\n$begin_generate\nrender_mode unshaded, blend_$blend;\n$end_generate\n\nuniform vec3 uv1_scale = vec3(1.0, 1.0, 1.0);\nuniform vec3 uv1_offset = vec3(0.0, 0.0, 0.0);\nuniform float variation = 0.0;\n\nvarying float elapsed_time;\nvoid vertex() {\n\telapsed_time = TIME;\n\tUV = UV*uv1_scale.xy+uv1_offset.xy;\n}\n\n$definitions float_uniform_to_const,rename_buffers\n\nvoid fragment() {\n\tfloat _seed_variation_ = variation;\n\tvec2 uv = fract(UV);\n$begin_generate rename_buffers\n\tvec4 color_tex = $color_tex(uv);\n\tcolor_tex = mix(pow((color_tex + vec4(0.055)) * (1.0 / (1.0 + 0.055)),vec4(2.4)),color_tex * (1.0 / 12.92),lessThan(color_tex,vec4(0.04045)));\n\tALBEDO = color_tex.rgb;\n\tALPHA = color_tex.a;\n$end_generate\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + } + ] + }, + "Unity": { + "export_extension": "mat", + "files": [ + { + "file_name": "$(path_prefix).shader", + "template": "Shader \"Unlit/NewUnlitShader\"\n{\n Properties\n {\n }\n SubShader\n {\n Tags { \"RenderType\"=\"Opaque\" }\n LOD 100\n Pass\n {\n \tBlend One One\n CGPROGRAM\n #pragma vertex vert\n #pragma fragment frag\n // make fog work\n #pragma multi_compile_fog\n #include \"UnityCG.cginc\"\n struct appdata\n {\n float4 vertex : POSITION;\n float2 uv : TEXCOORD0;\n };\n struct v2f\n {\n float2 uv : TEXCOORD0;\n UNITY_FOG_COORDS(1)\n float4 vertex : SV_POSITION;\n };\n$definitions hlsl,rename_buffers,unity\n\t\t\n\t\t\tv2f vert (appdata v) {\n\t\t\t\tv2f o;\n\t\t\t\to.vertex = UnityObjectToClipPos(v.vertex);\n\t\t\t\to.uv = v.uv;\n\t\t\t\tUNITY_TRANSFER_FOG(o,o.vertex);\n\t\t\t\treturn o;\n\t\t\t}\n\t\t\tfixed4 frag (v2f i) : SV_Target {\n\t\t\t\tfloat2 uv = i.uv;\n$begin_generate hlsl,rename_buffers,unity\n // sample the generated texture\n fixed4 col = $color_tex(uv);\n$end_generate\n // apply fog\n UNITY_APPLY_FOG(i.fogCoord, col);\n return col;\n }\n ENDCG\n }\n }\n}\n", + "type": "template" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png", + "type": "buffers" + }, + { + "file_name": "$(path_prefix)_texture_$(buffer_index).png.meta", + "template": "fileFormatVersion: 2\nguid: $uid(tex_$(buffer_index))\nTextureImporter:\n internalIDToNameTable: []\n externalObjects: {}\n serializedVersion: 11\n mipmaps:\n mipMapMode: 0\n enableMipMap: 1\n sRGBTexture: 1\n linearTexture: 0\n fadeOut: 0\n borderMipMap: 0\n mipMapsPreserveCoverage: 0\n alphaTestReferenceValue: 0.5\n mipMapFadeDistanceStart: 1\n mipMapFadeDistanceEnd: 3\n bumpmap:\n convertToNormalMap: 0\n externalNormalMap: 0\n heightScale: 0.25\n normalMapFilter: 0\n isReadable: 0\n streamingMipmaps: 0\n streamingMipmapsPriority: 0\n vTOnly: 0\n grayScaleToAlpha: 0\n generateCubemap: 6\n cubemapConvolution: 0\n seamlessCubemap: 0\n textureFormat: 1\n maxTextureSize: 2048\n textureSettings:\n serializedVersion: 2\n filterMode: -1\n aniso: -1\n mipBias: -100\n wrapU: -1\n wrapV: -1\n wrapW: -1\n nPOTScale: 1\n lightmap: 0\n compressionQuality: 50\n spriteMode: 0\n spriteExtrude: 1\n spriteMeshType: 1\n alignment: 0\n spritePivot: {x: 0.5, y: 0.5}\n spritePixelsToUnits: 100\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\n spriteGenerateFallbackPhysicsShape: 1\n alphaUsage: 1\n alphaIsTransparency: 0\n spriteTessellationDetail: -1\n textureType: 0\n textureShape: 1\n singleChannelComponent: 0\n flipbookRows: 1\n flipbookColumns: 1\n maxTextureSizeSet: 0\n compressionQualitySet: 0\n textureFormatSet: 0\n ignorePngGamma: 0\n applyGammaDecoding: 0\n platformSettings:\n - serializedVersion: 3\n buildTarget: DefaultTexturePlatform\n maxTextureSize: 2048\n resizeAlgorithm: 0\n textureFormat: -1\n textureCompression: 1\n compressionQuality: 50\n crunchedCompression: 0\n allowsAlphaSplitting: 0\n overridden: 0\n androidETC2FallbackOverride: 0\n forceMaximumCompressionQuality_BC6H_BC7: 0\n spriteSheet:\n serializedVersion: 2\n sprites: []\n outline: []\n physicsShape: []\n bones: []\n spriteID: \n internalID: 0\n vertices: []\n indices: \n edges: []\n weights: []\n secondaryTextures: []\n spritePackingTag: \n pSDRemoveMatte: 0\n pSDShowRemoveMatteOption: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "buffer_templates" + }, + { + "file_name": "$(path_prefix).mat", + "template": "%YAML 1.1\n%TAG !u! tag:unity3d.com,2011:\n--- !u!21 &2100000\nMaterial:\n serializedVersion: 6\n m_ObjectHideFlags: 0\n m_CorrespondingSourceObject: {fileID: 0}\n m_PrefabInstance: {fileID: 0}\n m_PrefabAsset: {fileID: 0}\n m_Name: test2\n m_Shader: {fileID: 4800000, guid: $uid(shader), type: 3}\n m_ShaderKeywords: \n m_LightmapFlags: 4\n m_EnableInstancingVariants: 0\n m_DoubleSidedGI: 0\n m_CustomRenderQueue: -1\n stringTagMap: {}\n disabledShaderPasses: []\n m_SavedProperties:\n serializedVersion: 3\n m_TexEnvs:\n - _MainTex:\n m_Texture: {fileID: 2800000, guid: 6c5d2d4e94384751a0ce7d6619e0d49a, type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$begin_buffers\n - texture_$(buffer_index):\n m_Texture: {fileID: 2800000, guid: $uid(tex_$(buffer_index)), type: 3}\n m_Scale: {x: 1, y: 1}\n m_Offset: {x: 0, y: 0}\n$end_buffers\n m_BuildTextureStacks: []\n", + "type": "template" + }, + { + "file_name": "$(path_prefix).shader.meta", + "template": "fileFormatVersion: 2\nguid: $uid(shader)\nShaderImporter:\n externalObjects: {}\n defaultTextures: []\n nonModifiableTextures: []\n preprocessorOverride: 0\n userData: \n assetBundleName: \n assetBundleVariant: \n", + "type": "template" + } + ] + }, + "Unreal": { + "export_extension": "mm2ue", + "files": [ + { + "file_name": "$(path_prefix).mm2ue", + "template": "/*\nInstructions to setup this material:\n- copy material_unlit.uasset and open the copy\n$begin_buffers\n- create a TextureObject for $(file_prefix)_texture_$(buffer_index).png in the graph\n and a new input for texture_$(buffer_index) in the custom node, and connect them\n$end_buffers\n- copy the shader code below and paste it into the Custom node\n*/\nstruct Functions {\n$definitions hlsl,rename_buffers,unreal\n\tfixed4 generated_shader(float2 uv) {\n$begin_generate hlsl,rename_buffers,unreal\n // sample the generated texture\n return $color_tex(uv);\n$end_generate\n }\n};\nFunctions f;\nreturn f.generated_shader(TexCoords);\n", + "type": "template" + } + ] + } + }, + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "name": "color_tex", + "type": "rgba" + } + ], + "instance": "", + "name": "Dynamic Unlit Material", + "outputs": [ + + ], + "parameters": [ + { + "default": 0, + "label": "Blend", + "name": "blend", + "type": "enum", + "values": [ + { + "name": "Add", + "value": "add" + }, + { + "name": "Mix", + "value": "mix" + }, + { + "name": "Mul", + "value": "mul" + }, + { + "name": "Sub", + "value": "sub" + } + ] + } + ], + "preview_shader": "shader_type spatial;\n$begin_generate\nrender_mode unshaded, blend_$blend;\n$end_generate\n\nuniform vec3 uv1_scale = vec3(1.0, 1.0, 1.0);\nuniform vec3 uv1_offset = vec3(0.0, 0.0, 0.0);\nuniform float variation = 0.0;\n\nvarying float elapsed_time;\n\nvoid vertex() {\n\telapsed_time = TIME;\n\tUV = UV*uv1_scale.xy+uv1_offset.xy;\n}\n\n$definitions\n\nvoid fragment() {\n\tfloat _seed_variation_ = variation;\n\tvec2 uv = fract(UV);\n$begin_generate\n\tvec4 color_tex = $color_tex(uv);\n\tcolor_tex = mix(pow((color_tex + vec4(0.055)) * (1.0 / (1.0 + 0.055)),vec4(2.4)),color_tex * (1.0 / 12.92),lessThan(color_tex,vec4(0.04045)));\n\tALBEDO = color_tex.rgb;\n\tALPHA = color_tex.a;\n$end_generate\n\n}\n" + }, + "type": "material_export" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/math.mmg b/game/addons/mat_maker_gd/material_maker_nodes/math.mmg new file mode 100644 index 00000000..8e22e1f8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/math.mmg @@ -0,0 +1,172 @@ +{ + "name": "math", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "clamp": false, + "default_in1": 0, + "default_in2": 0, + "op": 0 + }, + "shader_model": { + "code": "float $(name_uv)_clamp_false = $op;\nfloat $(name_uv)_clamp_true = clamp($(name_uv)_clamp_false, 0.0, 1.0);\n", + "global": "", + "inputs": [ + { + "default": "$default_in1", + "label": "2:A", + "longdesc": "The A operand", + "name": "in1", + "shortdesc": "A", + "type": "f" + }, + { + "default": "$default_in2", + "label": "B", + "longdesc": "The B operand", + "name": "in2", + "shortdesc": "B", + "type": "f" + } + ], + "instance": "", + "longdesc": "Performs a math operation using its inputs or parameter values", + "name": "Math", + "outputs": [ + { + "f": "$(name_uv)_clamp_$clamp", + "longdesc": "Shows a greyscale image of the result", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 19, + "label": "", + "longdesc": "The operation to be performed", + "name": "op", + "shortdesc": "Operation", + "type": "enum", + "values": [ + { + "name": "A+B", + "value": "$in1($uv)+$in2($uv)" + }, + { + "name": "A-B", + "value": "$in1($uv)-$in2($uv)" + }, + { + "name": "A*B", + "value": "$in1($uv)*$in2($uv)" + }, + { + "name": "A/B", + "value": "$in1($uv)/$in2($uv)" + }, + { + "name": "log(A)", + "value": "log($in1($uv))" + }, + { + "name": "log2(A)", + "value": "log2($in1($uv))" + }, + { + "name": "pow(A, B)", + "value": "pow($in1($uv),$in2($uv))" + }, + { + "name": "abs(A)", + "value": "abs($in1($uv))" + }, + { + "name": "round(A)", + "value": "round($in1($uv))" + }, + { + "name": "floor(A)", + "value": "floor($in1($uv))" + }, + { + "name": "ceil(A)", + "value": "ceil($in1($uv))" + }, + { + "name": "trunc(A)", + "value": "trunc($in1($uv))" + }, + { + "name": "fract(A)", + "value": "fract($in1($uv))" + }, + { + "name": "min(A, B)", + "value": "min($in1($uv),$in2($uv))" + }, + { + "name": "max(A, B)", + "value": "max($in1($uv),$in2($uv))" + }, + { + "name": "A= 1.0) {\n\t\t\tbreak;\n\t\t} else if (dS.x < 0.0001) {\n\t\t\tc = dS.y;\n\t\t\tbreak;\n\t\t}\n }\n \n return vec2(dO, c);\n}\n\nvec3 normal_$name(vec3 p) {\n\tif (p.z <= 0.0) {\n\t\treturn vec3(0.0, 0.0, 1.0);\n\t}\n\n\tfloat d = $sdf(p).x;\n float e = .001;\n \n vec3 n = d - vec3(\n $sdf(p-vec3(e, 0.0, 0.0)).x,\n $sdf(p-vec3(0.0, e, 0.0)).x,\n $sdf(p-vec3(0.0, 0.0, e)).x);\n \n return vec3(-1.0, -1.0, -1.0)*normalize(n);\n}\n\n", + "longdesc": "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.", + "name": "Render", + "outputs": [ + { + "f": "1.0-$(name_uv)_d.x", + "longdesc": "The generated height map", + "shortdesc": "HeightMap", + "type": "f" + }, + { + "longdesc": "The generated normal map", + "rgb": "vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d.x))", + "shortdesc": "NormalMap", + "type": "rgb" + }, + { + "f": "$(name_uv)_d.y", + "longdesc": "The generated color index map", + "shortdesc": "ColorMap", + "type": "f" + } + ], + "parameters": [ + + ], + "shortdesc": "Render" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/raymarching_preview.mmg b/game/addons/mat_maker_gd/material_maker_nodes/raymarching_preview.mmg new file mode 100644 index 00000000..7dbe9a86 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/raymarching_preview.mmg @@ -0,0 +1,35 @@ +{ + "name": "raymarching_preview", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "name": "sdf", + "type": "sdf3d" + } + ], + "instance": "float calcdist_$name(vec3 p) {\n return min($sdf(p), p.z);\n}\n\nfloat raymarch_$name(vec3 ro, vec3 rd) {\n\tfloat d=0.0;\n\tfor (int i = 0; i < 50; i++) {\n\t\tvec3 p = ro + rd*d;\n\t\tfloat dstep = calcdist_$name(p);\n\t\td += dstep;\n\t\tif (dstep < 0.0001) break;\n\t}\n\treturn d;\n}\n\nvec3 normal_$name(vec3 p) {\n\tfloat d = calcdist_$name(p);\n\tfloat e = .0001;\n\tvec3 n = d - vec3(calcdist_$name(p-vec3(e, 0.0, 0.0)), calcdist_$name(p-vec3(0.0, e, 0.0)), calcdist_$name(p-vec3(0.0, 0.0, e)));\n\treturn normalize(n);\n}\n\nvec3 render_$name(vec2 uv) {\n\tvec3 p = vec3(uv, 2.0-raymarch_$name(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));\n\tvec3 n = normal_$name(p);\n\tvec3 l = vec3(5.0, 5.0, 10.0);\n\tvec3 ld = normalize(l-p);\n\tfloat o = step(p.z, 0.001);\n\tfloat shadow = 1.0-0.75*step(raymarch_$name(l, -ld), length(l-p)-0.01);\n\tfloat light = 0.3+0.7*dot(n, ld)*shadow;\n\treturn vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light;\n}\n", + "name": "Preview", + "outputs": [ + { + "rgb": "render_$name($uv-vec2(0.5))", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/refract.mmg b/game/addons/mat_maker_gd/material_maker_nodes/refract.mmg new file mode 100644 index 00000000..4592ab93 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/refract.mmg @@ -0,0 +1,60 @@ +{ + "name": "refract", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "refract": 1.2 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be transformed", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "max(1.0-2.0*length($uv-vec2(0.5)), 0.0)", + "function": true, + "label": "", + "longdesc": "The magnifying glass shape", + "name": "s", + "shortdesc": "Shape", + "type": "f" + } + ], + "instance": "vec2 $(name)_refract(vec2 uv, float refract) {\n\tvec2 eps = vec2(0.001, 0.0);\n\tvec3 n = normalize(vec3($s(uv+eps)-$s(uv-eps), $s(uv+eps.yx)-$s(uv-eps.yx), -10.0*eps.x));\n\tfloat h = $s(uv);\n vec3 i = vec3(0.0, 0.0, -1.0);\n float mu = 1.0/refract;\n \n float dot_n_i = dot(n, i);\n vec3 t = sqrt(max(0.0, 1.0-mu*mu*(1.0-dot_n_i*dot_n_i)))*n+mu*(i-dot_n_i*n);\n \n\treturn uv+h*t.xy/t.z;\n}", + "longdesc": "Magnifying glass effect", + "name": "Refract", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$in($(name)_refract($uv, $refract))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 1, + "label": "", + "longdesc": "The maximum scaling factor for the magnifying glass", + "max": 2, + "min": 0, + "name": "refract", + "shortdesc": "Scale", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Magnify" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/remap.mmg b/game/addons/mat_maker_gd/material_maker_nodes/remap.mmg new file mode 100644 index 00000000..780eee33 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/remap.mmg @@ -0,0 +1,77 @@ +{ + "name": "remap", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "max": 1, + "min": -1, + "step": 0 + }, + "shader_model": { + "code": "float $(name_uv)_x = $in($uv)*($max-$min);", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The greyscale input map", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Remaps a greyscale image for use as an input map for Advanced Tiler nodes", + "name": "Remap", + "outputs": [ + { + "f": "$min+$(name_uv)_x-mod($(name_uv)_x, max($step, 0.00000001))", + "longdesc": "The remapped image map", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Min", + "longdesc": "The value generated for black areas of the input", + "max": 10, + "min": -10, + "name": "min", + "shortdesc": "Min", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Max", + "longdesc": "The value generated for white areas of the input", + "max": 10, + "min": -10, + "name": "max", + "shortdesc": "Max", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Step", + "longdesc": "The step between generated values", + "max": 1, + "min": 0, + "name": "step", + "shortdesc": "Step", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Remap" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/repeat.mmg b/game/addons/mat_maker_gd/material_maker_nodes/repeat.mmg new file mode 100644 index 00000000..ad38db12 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/repeat.mmg @@ -0,0 +1,39 @@ +{ + "name": "repeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be transformed", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Translates, rotates and scales its input", + "name": "Repeat", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$i(fract($uv))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/rotate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/rotate.mmg new file mode 100644 index 00000000..6dda441a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/rotate.mmg @@ -0,0 +1,77 @@ +{ + "name": "rotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "rotate": 0 + }, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Rotates its input", + "name": "Rotate", + "outputs": [ + { + "longdesc": "Shows the rotated image", + "rgba": "$i(rotate($uv, vec2(0.5+$cx, 0.5+$cy), $rotate*0.01745329251))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "Center X:", + "longdesc": "The position of the rotation center", + "max": 1, + "min": -1, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.005, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y:", + "longdesc": "The position of the rotation center", + "max": 1, + "min": -1, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.005, + "type": "float" + }, + { + "control": "Radius1.a", + "default": 0, + "label": "Rotate:", + "longdesc": "The angle of the rotation", + "max": 720, + "min": -720, + "name": "rotate", + "shortdesc": "Angle", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Rotate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/runes.mmg b/game/addons/mat_maker_gd/material_maker_nodes/runes.mmg new file mode 100644 index 00000000..a6599bc4 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/runes.mmg @@ -0,0 +1,60 @@ +{ + "name": "runes", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "columns": 4, + "rows": 4 + }, + "shader_model": { + "code": "", + "global": "float ThickLine(vec2 uv, vec2 posA, vec2 posB, float radiusInv)\n{\n\treturn clamp(1.1-20.0*sdLine(uv, posA, posB).x, 0.0, 1.0);\n}\n\n// makes a rune in the 0..1 uv space. Seed is which rune to draw.\n// passes back gray in x and derivates for lighting in yz\nfloat Rune(vec2 uv, float s) {\n\tfloat finalLine = 0.0;\n\tvec2 seed = floor(uv)-rand2(vec2(s));\n\tuv = fract(uv);\n\tfor (int i = 0; i < 4; i++)\t// number of strokes\n\t{\n\t\tvec2 posA = rand2(floor(seed+0.5));\n\t\tvec2 posB = rand2(floor(seed+1.5));\n\t\tseed += 2.0;\n\t\t// expand the range and mod it to get a nicely distributed random number - hopefully. :)\n\t\tposA = fract(posA * 128.0);\n\t\tposB = fract(posB * 128.0);\n\t\t// each rune touches the edge of its box on all 4 sides\n\t\tif (i == 0) posA.y = 0.0;\n\t\tif (i == 1) posA.x = 0.999;\n\t\tif (i == 2) posA.x = 0.0;\n\t\tif (i == 3) posA.y = 0.999;\n\t\t// snap the random line endpoints to a grid 2x3\n\t\tvec2 snaps = vec2(2.0, 3.0);\n\t\tposA = (floor(posA * snaps) + 0.5) / snaps;\t// + 0.5 to center it in a grid cell\n\t\tposB = (floor(posB * snaps) + 0.5) / snaps;\n\t\t//if (distance(posA, posB) < 0.0001) continue;\t// eliminate dots.\n\t\t// Dots (degenerate lines) are not cross-GPU safe without adding 0.001 - divide by 0 error.\n\t\tfinalLine = max(finalLine, ThickLine(uv, posA, posB + 0.001, 20.0));\n\t}\n\treturn finalLine;\n}\n\n\n", + "includes": [ + "sdline" + ], + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a grid filled with random runes", + "name": "Runes", + "outputs": [ + { + "f": "Rune(vec2($columns, $rows)*$uv, float($seed))", + "longdesc": "A greyscale image showing random runes.", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Size X", + "longdesc": "The number of columns of the grid", + "max": 32, + "min": 2, + "name": "columns", + "shortdesc": "Size.x", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Size Y", + "longdesc": "The number of rows of the grid", + "max": 32, + "min": 2, + "name": "rows", + "shortdesc": "Size.y", + "step": 1, + "type": "float" + } + ], + "shortdesc": "Simple runes" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/scale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/scale.mmg new file mode 100644 index 00000000..351d4151 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/scale.mmg @@ -0,0 +1,90 @@ +{ + "name": "scale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "scale_x": 1, + "scale_y": 1 + }, + "shader_model": { + "code": "", + "global": "vec2 scale(vec2 uv, vec2 center, vec2 scale) {\n\tuv -= center;\n\tuv /= scale;\n\tuv += center;\n return uv;\n}", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Scales its input", + "name": "Scale", + "outputs": [ + { + "longdesc": "Shows the scaled image", + "rgba": "$i(scale($uv, vec2(0.5+$cx, 0.5+$cy), vec2($scale_x, $scale_y)))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "Center X:", + "longdesc": "The position of the scale center", + "max": 1, + "min": -1, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.005, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y:", + "longdesc": "The poisition of the scale center", + "max": 1, + "min": -1, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.x", + "default": 1, + "label": "Scale X:", + "longdesc": "The scale amount along the X axis", + "max": 50, + "min": 0, + "name": "scale_x", + "shortdesc": "Scale.x", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.y", + "default": 1, + "label": "Scale Y:", + "longdesc": "The scale amount along the Y axis", + "max": 50, + "min": 0, + "name": "scale_y", + "shortdesc": "Scale.y", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Scale" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/scratches.mmg b/game/addons/mat_maker_gd/material_maker_nodes/scratches.mmg new file mode 100644 index 00000000..747d697e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/scratches.mmg @@ -0,0 +1,108 @@ +{ + "name": "scratches", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "angle": 0, + "layers": 5, + "length": 0.25, + "randomness": 0.3, + "waviness": 0.3, + "width": 0.4 + }, + "shader_model": { + "code": "", + "longdesc": "Draws white scratches on a black background", + "global": "float scratch(vec2 uv, vec2 size, float waviness, float angle, float randomness, vec2 seed) {\n\tfloat subdivide = floor(1.0/size.x);\n\tfloat cut = size.x*subdivide;\n\tuv *= subdivide;\n\tvec2 r1 = rand2(floor(uv)+seed);\n\tvec2 r2 = rand2(r1);\n\tuv = fract(uv);\n\tvec2 border = 10.0*min(fract(uv), 1.0-fract(uv));\n\tuv = 2.0*uv-vec2(1.0);\n\tfloat a = 6.28318530718*(angle+(r1.x-0.5)*randomness);\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\tuv = vec2(c*uv.x+s*uv.y, s*uv.x-c*uv.y);\n\tuv.y += 2.0*r1.y-1.0;\n\tuv.y += 0.5*waviness*cos(2.0*uv.x+6.28318530718*r2.y);\n\tuv.x /= cut;\n\tuv.y /= subdivide*size.y;\n\treturn min(border.x, border.y)*(1.0-uv.x*uv.x)*max(0.0, 1.0-1000.0*uv.y*uv.y);\n}\n\nfloat scratches(vec2 uv, int layers, vec2 size, float waviness, float angle, float randomness, vec2 seed) {\n\tfloat v = 0.0;\n\tfor (int i = 0; i < layers; ++i) {\n\t\tseed = rand2(seed);\n\t\tv = max(v, scratch(fract(uv+seed), size, waviness, angle/360.0, randomness, seed));\n\t}\n\treturn v;\n}\n", + "inputs": [ + + ], + "instance": "", + "name": "Scratches", + "outputs": [ + { + "f": "scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0))", + "longdesc": "Shows white scratches on a black background", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.25, + "label": "Length", + "longdesc": "The length of scratches (the shorter the scratches,the more they will be)", + "max": 1, + "min": 0.1, + "name": "length", + "shortdesc": "Length", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Width", + "longdesc": "The width of scratches", + "max": 1, + "min": 0.1, + "name": "width", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Layers", + "longdesc": "The number of scratches layers", + "max": 10, + "min": 1, + "name": "layers", + "shortdesc": "Layers", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Waviness", + "longdesc": "The waviness of scratches", + "max": 1, + "min": 0, + "name": "waviness", + "shortdesc": "Waviness", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Angle", + "longdesc": "The average angle of the scratches (0 generates horizontal scratches)", + "max": 180, + "min": -180, + "name": "angle", + "shortdesc": "Angle", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Randomness", + "longdesc": "The randomness of the scratches angles", + "max": 1, + "min": 0, + "name": "randomness", + "shortdesc": "Randomness", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sd_mask_to_sdf.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sd_mask_to_sdf.mmg new file mode 100644 index 00000000..ce94f4a8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sd_mask_to_sdf.mmg @@ -0,0 +1,1146 @@ +{ + "connections": [ + { + "from": "6520", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "edge_detect", + "from_port": 0, + "to": "1823", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "6520", + "to_port": 1 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "tones_step", + "to_port": 0 + }, + { + "from": "tones_step", + "from_port": 0, + "to": "edge_detect", + "to_port": 0 + }, + { + "from": "1823", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 0 + }, + { + "from": "2434_8", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 1 + }, + { + "from": "iterate_buffer", + "from_port": 0, + "to": "6520", + "to_port": 0 + }, + { + "from": "24282_2", + "from_port": 0, + "to": "2434_8", + "to_port": 0 + }, + { + "from": "iterate_buffer", + "from_port": 1, + "to": "24282_2", + "to_port": 0 + } + ], + "label": "Mask to SDF", + "longdesc": "", + "name": "sd_mask_to_sdf", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "iterate_buffer", + "node_position": { + "x": 76.700005, + "y": -249.817047 + }, + "parameters": { + "filter": false, + "iterations": 30, + "mipmap": false, + "size": 10 + }, + "seed_value": 29168, + "type": "iterate_buffer" + }, + { + "name": "2434_8", + "node_position": { + "x": 91.099991, + "y": -9.031479 + }, + "parameters": { + "distance": 0, + "size": 10 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(-1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec3 $(name)_jump_flood(vec2 uv, float size) {\n\tivec2 int_uv = ivec2(uv * size);\n\tfloat best_distance = 9999.9;\n\tvec2 best_coord;\n\tfloat iter = $in(uv).b;\n\titer += 0.01;\n\tfloat step_width = size / 4.0 / (iter * 100.0);\n\t\n\tfor (int x = -1; x <= 1; x++) {\n\t\tfor (int y = -1; y <= 1; y++) {\n\t\t\tivec2 offsetUV = int_uv + ivec2(x, y) * int(step_width);\n\t\t\tvec2 float_uv = vec2(offsetUV) / size;\n\t\t\tvec2 offset_pos = $in(float_uv).rg;\n\t\t\t\n\t\t\tif (offset_pos.x != 0.0 && offset_pos.y != 0.0) {\n\t\t\t\tvec2 diff = offset_pos - uv;\n\t\t\t\t//float dist = dot(diff, diff);\n\t\t\t\t$distance\n\t\t\t\tif (dist < best_distance) {\n\t\t\t\t\tbest_distance = dist;\n\t\t\t\t\tbest_coord = offset_pos;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn vec3(best_coord, iter);\n}", + "name": "Jump Flood", + "outputs": [ + { + "rgb": "$(name)_jump_flood($uv, $size)", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 10, + "first": 0, + "label": "", + "last": 13, + "name": "size", + "type": "size" + }, + { + "default": 0, + "label": "", + "name": "distance", + "type": "enum", + "values": [ + { + "name": "Euclidean", + "value": "float dist = dot(diff, diff);" + }, + { + "name": "Manhattan", + "value": "float dist = abs(diff.x) + abs(diff.y);" + }, + { + "name": "Chebyshev", + "value": "float dist = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);" + } + ] + } + ] + }, + "type": "shader" + }, + { + "name": "1823", + "node_position": { + "x": -269.899872, + "y": -18.741766 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "", + "name": "Mask to UV Mask", + "outputs": [ + { + "rgb": "$in($uv) < .5 ? vec3(0.0) : vec3($uv, 0.0)", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "edge_detect", + "node_position": { + "x": -286.951447, + "y": -137.078964 + }, + "parameters": { + "size": 10, + "threshold": 0.4, + "width": 1 + }, + "type": "edge_detect" + }, + { + "name": "6520", + "node_position": { + "x": 364.156525, + "y": -261.873169 + }, + "parameters": { + "distance": 0, + "tiled": false + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + }, + { + "default": "0.0", + "function": true, + "label": "", + "name": "mask", + "type": "f" + } + ], + "instance": "float $(name)_distance(vec2 uv, bool tiled) {\n\tif (tiled) {\n\t\tuv = fract(uv);\n\t}\n\tvec2 custom_uv = $in(uv).xy;\n\tvec2 diff = custom_uv != vec2(0.0) ? custom_uv - uv : vec2(1.0);\n\t$distance\n\tif (!tiled) {\n\t\tuv = clamp(uv, 0.0, 1.0);\n\t}\n\treturn $mask(uv) < 0.5 ? distance : -distance;\n}", + "name": "Calculate Distance", + "outputs": [ + { + "sdf2d": "$(name)_distance($uv, $tiled)", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": false, + "label": "Tiled", + "name": "tiled", + "type": "boolean" + }, + { + "default": 0, + "label": "", + "name": "distance", + "type": "enum", + "values": [ + { + "name": "Euclidean", + "value": "float distance = length(diff);" + }, + { + "name": "Manhattan", + "value": "float distance = abs(diff.x) + abs(diff.y);" + }, + { + "name": "Chebyshev", + "value": "float distance = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);" + } + ] + } + ] + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -735.85144, + "y": -352.006775 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The greyscale mask to be converted", + "name": "mask", + "shortdesc": "Mask", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 646.256348, + "y": -263.285461 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The genrated distance field", + "name": "sdf", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -47.67952, + "y": -541.979187 + }, + "parameters": { + "param0": 10, + "param1": 30, + "param2": false, + "param3": 0 + }, + "type": "remote", + "widgets": [ + { + "label": "Size", + "linked_widgets": [ + { + "node": "iterate_buffer", + "widget": "size" + }, + { + "node": "2434_8", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + }, + { + "node": "edge_detect", + "widget": "size" + } + ], + "longdesc": "The resolution used for the operation", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Iterations", + "linked_widgets": [ + { + "node": "iterate_buffer", + "widget": "iterations" + } + ], + "longdesc": "The number of iterations the jump flood algorithm performs to calculate the distances", + "name": "param1", + "shortdesc": "Iterations", + "type": "linked_control" + }, + { + "label": "Tiled", + "linked_widgets": [ + { + "node": "24282_2", + "widget": "tiled" + }, + { + "node": "6520", + "widget": "tiled" + } + ], + "longdesc": "Controls whether the resulting ditance field will be tiled. Useful for patterns that extend over the texture bounds", + "name": "param2", + "shortdesc": "Tiled", + "type": "linked_control" + }, + { + "label": "Distance", + "linked_widgets": [ + { + "node": "2434_8", + "widget": "distance" + }, + { + "node": "6520", + "widget": "distance" + } + ], + "name": "param3", + "shortdesc": "Distance function", + "type": "linked_control" + } + ] + }, + { + "name": "buffer_2", + "node_position": { + "x": -297.702789, + "y": -348.41391 + }, + "parameters": { + "size": 10 + }, + "type": "buffer", + "version": 1 + }, + { + "name": "tones_step", + "node_position": { + "x": -294.947968, + "y": -258.84549 + }, + "parameters": { + "invert": false, + "value": 0.5, + "width": 0 + }, + "type": "tones_step" + }, + { + "name": "24282_2", + "node_position": { + "x": 114.391708, + "y": -90.765732 + }, + "parameters": { + "tiled": false + }, + "shader_model": { + "code": "vec3 $(name_uv)_in = $in(fract($uv));\nvec3 $(name_uv)_tiled = $(name_uv)_in.xy != vec2(0.0) ? $(name_uv)_in + vec3(floor($uv), 0.0) : $(name_uv)_in;", + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "", + "name": "Tiling", + "outputs": [ + { + "rgb": "$tiled ? $(name_uv)_tiled : $(name_uv)_in", + "type": "rgb" + } + ], + "parameters": [ + { + "default": false, + "label": "Tiled", + "name": "tiled", + "type": "boolean" + } + ] + }, + "type": "shader" + }, + { + "connections": [ + { + "from": "edge_detect", + "from_port": 0, + "to": "1823", + "to_port": 0 + }, + { + "from": "tones_step", + "from_port": 0, + "to": "edge_detect", + "to_port": 0 + }, + { + "from": "1823", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 0 + }, + { + "from": "2434_8", + "from_port": 0, + "to": "iterate_buffer", + "to_port": 1 + }, + { + "from": "iterate_buffer", + "from_port": 0, + "to": "6520", + "to_port": 0 + }, + { + "from": "24282_2", + "from_port": 0, + "to": "2434_8", + "to_port": 0 + }, + { + "from": "iterate_buffer", + "from_port": 1, + "to": "24282_2", + "to_port": 0 + }, + { + "from": "iterate_buffer", + "from_port": 0, + "to": "2153", + "to_port": 1 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "tones_step", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "2153", + "to_port": 0 + }, + { + "from": "2153", + "from_port": 0, + "to": "11582", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "11582", + "to_port": 2 + }, + { + "from": "11582", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "8064", + "from_port": 0, + "to": "2153", + "to_port": 2 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "8064", + "to_port": 0 + }, + { + "from": "8064", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "6520", + "to_port": 1 + }, + { + "from": "6520", + "from_port": 0, + "to": "11582", + "to_port": 0 + } + ], + "label": "Dilate 2", + "longdesc": "", + "name": "graph_3", + "node_position": { + "x": 515.555786, + "y": -545.049744 + }, + "nodes": [ + { + "name": "iterate_buffer", + "node_position": { + "x": 64.900002, + "y": -259.215881 + }, + "parameters": { + "filter": false, + "iterations": 30, + "mipmap": false, + "size": 9 + }, + "seed_value": 29168, + "type": "iterate_buffer" + }, + { + "name": "2434_8", + "node_position": { + "x": 102.099998, + "y": 15.367363 + }, + "parameters": { + "distance": 0, + "size": 9 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(-1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec3 $(name)_jump_flood(vec2 uv, float size) {\n\tivec2 int_uv = ivec2(uv * size);\n\tfloat best_distance = 9999.9;\n\tvec2 best_coord;\n\tfloat iter = $in(uv).b;\n\titer += 0.01;\n\tfloat step_width = size / 4.0 / (iter * 100.0);\n\t\n\tfor (int x = -1; x <= 1; x++) {\n\t\tfor (int y = -1; y <= 1; y++) {\n\t\t\tivec2 offsetUV = int_uv + ivec2(x, y) * int(step_width);\n\t\t\tvec2 float_uv = vec2(offsetUV) / size;\n\t\t\tvec2 offset_pos = $in(float_uv).rg;\n\t\t\t\n\t\t\tif (offset_pos.x != 0.0 && offset_pos.y != 0.0) {\n\t\t\t\tvec2 diff = offset_pos - uv;\n\t\t\t\t//float dist = dot(diff, diff);\n\t\t\t\t//float dist = abs(diff.x) + abs(diff.y);\n\t\t\t\t//float dist = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);\n\t\t\t\t$distance\n\t\t\t\tif (dist < best_distance) {\n\t\t\t\t\tbest_distance = dist;\n\t\t\t\t\tbest_coord = offset_pos;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn vec3(best_coord, iter);\n}", + "name": "Jump Flood", + "outputs": [ + { + "rgb": "$(name)_jump_flood($uv, $size)", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 10, + "first": 0, + "label": "", + "last": 13, + "name": "size", + "type": "size" + }, + { + "default": 2, + "label": "", + "name": "distance", + "type": "enum", + "values": [ + { + "name": "Euclidean", + "value": "float dist = dot(diff, diff);" + }, + { + "name": "Manhattan", + "value": "float dist = abs(diff.x) + abs(diff.y);" + }, + { + "name": "Chebyshev", + "value": "float dist = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);" + } + ] + } + ] + }, + "type": "shader" + }, + { + "name": "1823", + "node_position": { + "x": -269.899872, + "y": -17.741766 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "1.0", + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "", + "name": "Mask to UV Mask", + "outputs": [ + { + "rgb": "$in($uv) < .5 ? vec3(0.0) : vec3($uv, 0.0)", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "edge_detect", + "node_position": { + "x": -286.951447, + "y": -137.078964 + }, + "parameters": { + "size": 9, + "threshold": 0.4, + "width": 1 + }, + "type": "edge_detect" + }, + { + "name": "6520", + "node_position": { + "x": 347.356567, + "y": -346.449127 + }, + "parameters": { + "distance": 0, + "length": 0.1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + }, + { + "default": "0.0", + "function": true, + "label": "", + "name": "mask", + "type": "f" + } + ], + "instance": "float $(name)_distance(vec2 uv, float length) {\n\tvec2 custom_uv = $in(fract(uv)).xy;\n\tvec2 diff = custom_uv != vec2(0.0) ? custom_uv - fract(uv) : vec2(1.0);\n\t//float distance = length(diff);\n\t//float distance = abs(diff.x) + abs(diff.y);\n\t//float distance = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);\n\t$distance\n\tif (length >= 0.0) {\n\t\treturn $mask(uv) < 0.5 ? clamp(1.0 - (distance / length), 0.0, 1.0) : 1.0;\n\t} else {\n\t\treturn $mask(uv) > 0.5 ? clamp((distance / -length), 0.0, 1.0) : 0.0;\n\t}\n}", + "name": "Calculate Distance", + "outputs": [ + { + "f": "$(name)_distance($uv, $length)", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.1, + "label": "Length", + "max": 1, + "min": -1, + "name": "length", + "step": 0.01, + "type": "float" + }, + { + "default": 2, + "label": "", + "name": "distance", + "type": "enum", + "values": [ + { + "name": "Euclidean", + "value": "float distance = length(diff);" + }, + { + "name": "Manhattan", + "value": "float distance = abs(diff.x) + abs(diff.y);" + }, + { + "name": "Chebyshev", + "value": "float distance = abs(diff.x) > abs(diff.y) ? abs(diff.x) : abs(diff.y);" + } + ] + } + ] + }, + "type": "shader" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -793.451477, + "y": -236.812195 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The greyscale mask to be converted", + "name": "mask", + "shortdesc": "Mask", + "type": "f" + }, + { + "group_size": 0, + "longdesc": "", + "name": "source", + "shortdesc": "Source", + "type": "rgb" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 885.056335, + "y": -247.896317 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the dilated image", + "name": "out", + "shortdesc": "Output", + "type": "rgb" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": 61.520477, + "y": -639.339172 + }, + "parameters": { + "param0": 9, + "param1": 0.1, + "param2": 0, + "param3": 0, + "param4": 30 + }, + "type": "remote", + "widgets": [ + { + "label": "", + "linked_widgets": [ + { + "node": "iterate_buffer", + "widget": "size" + }, + { + "node": "2434_8", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + }, + { + "node": "edge_detect", + "widget": "size" + } + ], + "longdesc": "The resolution of the input images", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "", + "linked_widgets": [ + { + "node": "6520", + "widget": "length" + } + ], + "longdesc": "The length of the dilate effect", + "name": "param1", + "shortdesc": "Length", + "type": "linked_control" + }, + { + "label": "", + "linked_widgets": [ + { + "node": "11582", + "widget": "fill" + } + ], + "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": "2434_8", + "widget": "distance" + }, + { + "node": "6520", + "widget": "distance" + } + ], + "name": "param3", + "shortdesc": "Distance Function", + "type": "linked_control" + }, + { + "label": "", + "linked_widgets": [ + { + "node": "iterate_buffer", + "widget": "iterations" + } + ], + "longdesc": "The number of iterations the jump flood algorithm performs to calculate the distances", + "name": "param4", + "shortdesc": "Iterations", + "type": "linked_control" + } + ] + }, + { + "name": "buffer_2", + "node_position": { + "x": -294.502808, + "y": -340.816589 + }, + "parameters": { + "size": 9 + }, + "type": "buffer", + "version": 1 + }, + { + "name": "tones_step", + "node_position": { + "x": -285.347992, + "y": -253.248215 + }, + "parameters": { + "invert": false, + "value": 0.5, + "width": 0 + }, + "type": "tones_step" + }, + { + "name": "24282_2", + "node_position": { + "x": 109.591705, + "y": -88.567284 + }, + "parameters": { + "tiled": true + }, + "shader_model": { + "code": "vec3 $(name_uv)_in = $in(fract($uv));\nvec3 $(name_uv)_tiled = $(name_uv)_in.xy != vec2(0.0) ? $(name_uv)_in + vec3(floor($uv), 0.0) : $(name_uv)_in;", + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "", + "name": "Tiling", + "outputs": [ + { + "rgb": "$tiled ? $(name_uv)_tiled : $(name_uv)_in", + "type": "rgb" + } + ], + "parameters": [ + { + "default": false, + "label": "Tiled", + "name": "tiled", + "type": "boolean" + } + ] + }, + "type": "shader" + }, + { + "name": "2153", + "node_position": { + "x": 368.85202, + "y": -157.100906 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(1.0)", + "label": "Source", + "name": "source", + "type": "rgb" + }, + { + "default": "$uv", + "label": "Custom UV", + "name": "custom_uv", + "type": "rgb" + }, + { + "default": "0.0", + "label": "Mask", + "name": "mask", + "type": "f" + } + ], + "instance": "", + "name": "Dilate UV", + "outputs": [ + { + "rgb": "$mask($uv) < 0.5 ? $source($custom_uv($uv).xy) : $source($uv)", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + }, + { + "name": "11582", + "node_position": { + "x": 609.343445, + "y": -239.746399 + }, + "parameters": { + "fill": 0 + }, + "shader_model": { + "code": "float $(name_uv)_dist = $distance($uv);\nvec3 $(name_uv)_color = mix($source(fract($uv)), $fill_raw(fract($uv)), float( $(name_uv)_dist != 0.0 ) );\nvec3 $(name_uv)_mix = mix($(name_uv)_color * $(name_uv)_dist, $(name_uv)_color, $fill);", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "Distance", + "name": "distance", + "type": "f" + }, + { + "default": "vec3(1.0)", + "function": true, + "label": "Fill Raw", + "name": "fill_raw", + "type": "rgb" + }, + { + "default": "vec3(1.0)", + "function": true, + "label": "Source", + "name": "source", + "type": "rgb" + } + ], + "instance": "", + "name": "Dilate Combine", + "outputs": [ + { + "rgb": "$(name_uv)_mix", + "type": "rgb" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Fill", + "max": 1, + "min": 0, + "name": "fill", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "8064", + "node_position": { + "x": -282.533325, + "y": -433.011169 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "", + "name": "Default Value", + "outputs": [ + { + "rgb": "$in($uv)", + "type": "rgb" + } + ], + "parameters": [ + + ] + }, + "type": "shader" + } + ], + "parameters": { + "param0": 9, + "param1": 0.1, + "param2": 0, + "param3": 0, + "param4": 30 + }, + "shortdesc": "", + "type": "graph" + } + ], + "parameters": { + "param0": 10, + "param1": 30, + "param2": false, + "param3": 0 + }, + "shortdesc": "", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdannularshape.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdannularshape.mmg new file mode 100644 index 00000000..527fa92e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdannularshape.mmg @@ -0,0 +1,64 @@ +{ + "name": "sdannularshape", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.1, + "ripples": 1 + }, + "shader_model": { + "code": "", + "global": "float sdRipples(float d, float w, int r) {\n\tfor (int i = 0; i < r; ++i) {\n\t\td = abs(d)-w;\n\t}\n\treturn d;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Creates an annular shape from a shape described as a signed distance function", + "name": "sdAnnularShape", + "outputs": [ + { + "longdesc": "The generated layered shape", + "sdf2d": "sdRipples($in($uv), $r, int($ripples))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Width", + "longdesc": "The width of each generated ripple", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Ripples", + "longdesc": "The number of generated ripples", + "max": 16, + "min": 0, + "name": "ripples", + "shortdesc": "Ripples", + "step": 1, + "type": "float" + } + ], + "shortdesc": "sdAnnularShape" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdarc.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdarc.mmg new file mode 100644 index 00000000..e82e476c --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdarc.mmg @@ -0,0 +1,83 @@ +{ + "name": "sdarc", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a1": 30, + "a2": 150, + "r1": 0.3, + "r2": 0.1 + }, + "shader_model": { + "code": "", + "global": "float sdArc(vec2 p, float a1, float a2, float ra, float rb) {\n\tfloat amid = 0.5*(a1+a2)+1.6+3.14*step(a1, a2);\n\tfloat alength = 0.5*(a1-a2)-1.6+3.14*step(a1, a2);\n\tvec2 sca = vec2(cos(amid), sin(amid));\n\tvec2 scb = vec2(cos(alength), sin(alength));\n p *= mat2(vec2(sca.x,sca.y),vec2(-sca.y,sca.x));\n p.x = abs(p.x);\n float k = (scb.y*p.x>scb.x*p.y) ? dot(p.xy,scb) : length(p.xy);\n return sqrt( dot(p,p) + ra*ra - 2.0*ra*k ) - rb;\n}\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "An arc as a signed distance function", + "name": "sdArc", + "outputs": [ + { + "longdesc": "The arc as a signed distance function", + "sdf2d": "sdArc($uv-vec2(0.5), mod($a1, 360.0)*0.01745329251, mod($a2, 360.0)*0.01745329251, $r1, $r2)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Angle1.a", + "default": 0, + "label": "Angle 1", + "longdesc": "The first angle of the arc", + "max": 180, + "min": -180, + "name": "a1", + "shortdesc": "Angle1", + "step": 1, + "type": "float" + }, + { + "control": "Angle2.a", + "default": 0, + "label": "Angle 2", + "longdesc": "The second angle of the arc", + "max": 180, + "min": -180, + "name": "a2", + "shortdesc": "Angle2", + "step": 1, + "type": "float" + }, + { + "control": "Radius1.r", + "default": 0.5, + "label": "Radius", + "longdesc": "The radius of the arc", + "max": 1, + "min": 0, + "name": "r1", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "Radius11.r", + "default": 0.1, + "label": "Width", + "longdesc": "The width of the shape around the arc", + "max": 1, + "min": 0, + "name": "r2", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdArc" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdboolean.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdboolean.mmg new file mode 100644 index 00000000..093a2a64 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdboolean.mmg @@ -0,0 +1,69 @@ +{ + "name": "sdboolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "op": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf2d" + }, + { + "default": "0.0", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Performs a boolean operation (union, intersection or difference) between two shapes", + "name": "sdBoolean", + "outputs": [ + { + "longdesc": "The shape generated by the boolean operation", + "sdf2d": "$op $in1($uv), $in2($uv))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 2, + "label": "", + "longdesc": "The operation performed by this node", + "name": "op", + "shortdesc": "Operation", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "min(" + }, + { + "name": "Subtraction", + "value": "max(-" + }, + { + "name": "Intersection", + "value": "max(" + } + ] + } + ], + "shortdesc": "sdBoolean" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdbox.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdbox.mmg new file mode 100644 index 00000000..b7db8d52 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdbox.mmg @@ -0,0 +1,83 @@ +{ + "name": "sdbox", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "h": 0.2, + "w": 0.3 + }, + "shader_model": { + "code": "vec2 $(name_uv)_d = abs($uv-vec2($cx+0.5, $cy+0.5))-vec2($w, $h);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "A rectangle described as a signed distance function", + "name": "sdBox", + "outputs": [ + { + "longdesc": "The generated signed distance function", + "sdf2d": "length(max($(name_uv)_d,vec2(0)))+min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Rect1.x", + "default": 0.5, + "label": "Width", + "longdesc": "The width of the box", + "max": 1, + "min": 0, + "name": "w", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.y", + "default": 1, + "label": "Height", + "longdesc": "The height of the box", + "max": 1, + "min": 0, + "name": "h", + "shortdesc": "Height", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.x", + "default": 0, + "label": "Center X", + "longdesc": "The position of the center of the box on the X axis", + "max": 1, + "min": -1, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y", + "longdesc": "The position of the center of the box on the Y axis", + "max": 1, + "min": -1, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdBox" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdcircle.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdcircle.mmg new file mode 100644 index 00000000..8f73a196 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdcircle.mmg @@ -0,0 +1,70 @@ +{ + "name": "sdcircle", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "r": 0.4 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "A circle described as a signed distance function", + "name": "sdCircle", + "outputs": [ + { + "longdesc": "The generated signed distance function", + "sdf2d": "length($uv-vec2($cx+0.5, $cy+0.5))-$r", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Radius1.r", + "default": 0.5, + "label": "Radius", + "longdesc": "The radius of the circle", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.x", + "default": 0, + "label": "Center X", + "longdesc": "The position of the center on the X axis", + "max": 1, + "min": -1, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y", + "longdesc": "The position of the center on the Y axis", + "max": 1, + "min": -1, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdCircle" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdcirclerepeat.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdcirclerepeat.mmg new file mode 100644 index 00000000..fd288b95 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdcirclerepeat.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdcirclerepeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "c": 6 + }, + "shader_model": { + "code": "", + "global": "vec2 circle_repeat_transform_2d(vec2 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec2 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Repeats its input shape around a circle", + "name": "Circle Repeat", + "outputs": [ + { + "longdesc": "The shape generated by the repeat operation", + "sdf2d": "$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "", + "longdesc": "The number of repetitions of the input shape around the circle", + "max": 32, + "min": 1, + "name": "c", + "shortdesc": "Count", + "step": 1, + "type": "float" + } + ], + "shortdesc": "Circle Repeat" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdelongation.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdelongation.mmg new file mode 100644 index 00000000..adc95c5f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdelongation.mmg @@ -0,0 +1,62 @@ +{ + "name": "sdelongation", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "bevel": 0, + "cx": 0, + "cy": 0, + "h": 0.08, + "k": 0.15, + "op": 0, + "r": 0.08, + "w": 0.28, + "x": 0, + "y": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "name": "in", + "type": "sdf2d" + } + ], + "instance": "", + "name": "sdElongation", + "outputs": [ + { + "sdf2d": "$in($uv-clamp($uv-vec2(0.5), -vec2($x, $y), vec2($x, $y)))", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Rect1.x", + "default": 0, + "label": "X", + "max": 1, + "min": 0, + "name": "x", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.y", + "default": 0, + "label": "Y", + "max": 1, + "min": 0, + "name": "y", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_angle.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_angle.mmg new file mode 100644 index 00000000..bbddc95a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_angle.mmg @@ -0,0 +1,72 @@ +{ + "name": "sdf3d_angle", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "angle": 135, + "axis": 2 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "vec3 $(name_uv)_uv = $uv.$axis;\nfloat $(name_uv)_rotated = rotate3d($(name_uv)_uv, vec3(($angle-180.0)*0.01745329251, 0.0, 0.0)).y;\nfloat $(name_uv)_d1 = max($(name_uv)_uv.y, $(name_uv)_rotated);\nfloat $(name_uv)_d2 = min($(name_uv)_uv.y, $(name_uv)_rotated);\nfloat $(name_uv)_d = (mod($angle, 360.0) < 180.0) ? $(name_uv)_d1 : $(name_uv)_d2;", + "global": "", + "includes": [ + "sdf3d_rotate" + ], + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates an angle formed by 2 planes that can be used to cut other shapes", + "name": "Angle", + "outputs": [ + { + "longdesc": "Shows the angle", + "sdf3d": "$(name_uv)_d", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "The axis of the angle", + "name": "axis", + "shortdesc": "Axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "xyz" + }, + { + "name": "Y", + "value": "yzx" + }, + { + "name": "Z", + "value": "zxy" + } + ] + }, + { + "control": "None", + "default": 180, + "label": "", + "longdesc": "The angle of the shape", + "max": 360, + "min": 0, + "name": "angle", + "shortdesc": "Angle", + "step": 0.1, + "type": "float" + } + ], + "shortdesc": "Angle" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_boolean.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_boolean.mmg new file mode 100644 index 00000000..16212f27 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_boolean.mmg @@ -0,0 +1,70 @@ +{ + "name": "sdf3d_boolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "op": 0 + }, + "seed_value": 60292, + "shader_model": { + "code": "", + "global": "vec2 sdf3dc_union(vec2 a, vec2 b) {\n\treturn vec2(min(a.x, b.x), mix(b.y, a.y, step(a.x, b.x)));\n}\nvec2 sdf3dc_sub(vec2 a, vec2 b) {\n\treturn vec2(max(-a.x, b.x), a.y);\n}\nvec2 sdf3dc_inter(vec2 a, vec2 b) {\n\treturn vec2(max(a.x, b.x), mix(a.y, b.y, step(a.x, b.x)));\n}\n", + "inputs": [ + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf3dc" + }, + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Performs a boolean operation (union, intersection or difference) between two shapes", + "name": "Boolean", + "outputs": [ + { + "longdesc": "The shape generated by the boolean operation", + "sdf3dc": "$op($in1($uv), $in2($uv))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "default": 2, + "label": "", + "longdesc": "The operation performed by this node", + "name": "op", + "shortdesc": "Operation", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "sdf3dc_union" + }, + { + "name": "Subtraction", + "value": "sdf3dc_sub" + }, + { + "name": "Intersection", + "value": "sdf3dc_inter" + } + ] + } + ], + "shortdesc": "Boolean" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_box.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_box.mmg new file mode 100644 index 00000000..5669f44d --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_box.mmg @@ -0,0 +1,83 @@ +{ + "name": "sdf3d_box", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.01, + "sx": 0.3, + "sy": 0.25, + "sz": 0.25 + }, + "shader_model": { + "code": "vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a rounded box as a signed distance function", + "name": "Box", + "outputs": [ + { + "longdesc": "Shows the rounded box", + "sdf3d": "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", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "control": "Rect1.x", + "default": 0.5, + "label": "Size X", + "longdesc": "The size of the box along the X axis", + "max": 1, + "min": 0, + "name": "sx", + "shortdesc": "Size.x", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.y", + "default": 0.5, + "label": "Size Y", + "longdesc": "The size of the box along the 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": "The size of the box along the Z axis", + "max": 1, + "min": 0, + "name": "sz", + "shortdesc": "Size.z", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Radius", + "longdesc": "The radius of the rounded box", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Box" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule.mmg new file mode 100644 index 00000000..4b038ffb --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule.mmg @@ -0,0 +1,119 @@ +{ + "name": "sdf3d_capsule", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "axis": 1, + "l": 0.3, + "profile": { + "points": [ + { + "ls": 0, + "rs": 0, + "x": 0, + "y": 1 + }, + { + "ls": 0, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + }, + "r": 0.2 + }, + "shader_model": { + "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a capsule as a signed distance functioni", + "name": "Capsule", + "outputs": [ + { + "longdesc": "Shows the capsule", + "sdf3d": "length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 1, + "label": "Axis", + "longdesc": "The axis of the capsule", + "name": "axis", + "shortdesc": "Axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "x" + }, + { + "name": "Y", + "value": "y" + }, + { + "name": "Z", + "value": "z" + } + ] + }, + { + "control": "Rect1.y", + "default": 0.25, + "label": "Length", + "longdesc": "The length of the capsule", + "max": 1, + "min": 0, + "name": "l", + "shortdesc": "Length", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.x", + "default": 0.2, + "label": "Radius", + "longdesc": "The radius of the capsule", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "default": { + "points": [ + { + "ls": 0, + "rs": 0, + "x": 0, + "y": 1 + }, + { + "ls": 0, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + }, + "label": "Profile", + "name": "profile", + "type": "curve" + } + ], + "shortdesc": "capsule" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule2.mmg new file mode 100644 index 00000000..ec63d57c --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_capsule2.mmg @@ -0,0 +1,89 @@ +{ + "name": "sdf3d_capsule2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "axis": 1, + "l": 0.3, + "r": 0.2 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "vec3 $(name_uv)_p = $uv;\n$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);\n", + "global": "", + "inputs": [ + { + "default": "1.0", + "label": "3:", + "longdesc": "An input gradient (generated, for example by a Tonality node) that defines a profile for the shape", + "name": "profile", + "shortdesc": "Profile", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates a capsule as a signed distance functioni", + "name": "Capsule", + "outputs": [ + { + "longdesc": "Shows the capsule", + "sdf3d": "length($(name_uv)_p)-$r*$profile(vec2(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0), 0.5))", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 1, + "label": "Axis", + "longdesc": "The axis of the capsule", + "name": "axis", + "shortdesc": "Axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "x" + }, + { + "name": "Y", + "value": "y" + }, + { + "name": "Z", + "value": "z" + } + ] + }, + { + "control": "Rect1.y", + "default": 0.25, + "label": "Length", + "longdesc": "The length of the capsule", + "max": 1, + "min": 0, + "name": "l", + "shortdesc": "Length", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.x", + "default": 0.2, + "label": "Radius", + "longdesc": "The radius of the capsule", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "capsule" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_circle_repeat.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_circle_repeat.mmg new file mode 100644 index 00000000..f7b4be6e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_circle_repeat.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_circle_repeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "c": 5 + }, + "shader_model": { + "code": "", + "global": "vec3 circle_repeat_transform(vec3 p, float count) {\n\tfloat r = 6.28/count;\n\tfloat pa = atan(p.x, p.y);\n\tfloat a = mod(pa+0.5*r, r)-0.5*r;\n\tvec3 rv;\n\tfloat c = cos(a-pa);\n\tfloat s = sin(a-pa);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "vec2(100, 0.0)", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Repeats its input shape around a circle", + "name": "Circle Repeat", + "outputs": [ + { + "longdesc": "The shape generated by the repeat operation", + "sdf3dc": "$in(circle_repeat_transform($uv, $c))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "", + "longdesc": "The number of repetitions of the input shape around the circle", + "max": 32, + "min": 1, + "name": "c", + "shortdesc": "Count", + "step": 1, + "type": "float" + } + ], + "shortdesc": "Circle Repeat" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_color.mmg new file mode 100644 index 00000000..b754ea2a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_color.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "c": 0.5 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input 3D object", + "name": "in", + "shortdesc": "Input", + "type": "sdf3d" + } + ], + "instance": "", + "longdesc": "Assigns a color index to a 3D object", + "name": "Color", + "outputs": [ + { + "longdesc": "The colored 3D object", + "sdf3dc": "vec2($in($uv), $c)", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The color index to be assigned", + "max": 1, + "min": 0, + "name": "c", + "shortdesc": "Color", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Color" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cone.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cone.mmg new file mode 100644 index 00000000..b52f73b5 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cone.mmg @@ -0,0 +1,71 @@ +{ + "name": "sdf3d_cone", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 30, + "axis": 2 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "name": "Cone", + "outputs": [ + { + "sdf3d": "dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 5, + "label": "Axis", + "name": "axis", + "type": "enum", + "values": [ + { + "name": "+X", + "value": "length($uv.yz),-$uv.x" + }, + { + "name": "-X", + "value": "length($uv.yz),$uv.x" + }, + { + "name": "+Y", + "value": "length($uv.xz),$uv.y" + }, + { + "name": "-Y", + "value": "length($uv.xz),-$uv.y" + }, + { + "name": "+Z", + "value": "length($uv.xy),-$uv.z" + }, + { + "name": "-Z", + "value": "length($uv.xy),$uv.z" + } + ] + }, + { + "control": "None", + "default": 30, + "label": "Angle", + "max": 90, + "min": 0, + "name": "a", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cylinder.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cylinder.mmg new file mode 100644 index 00000000..4f664991 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_cylinder.mmg @@ -0,0 +1,80 @@ +{ + "name": "sdf3d_cylinder", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "axis": 1, + "l": 0.25, + "r": 0.25 + }, + "shader_model": { + "code": "vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a cylinder as a signed distance function", + "name": "Cylinder", + "outputs": [ + { + "longdesc": "Shows the cylinder", + "sdf3d": "min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0) + length(max($(name_uv)_d,0.0))", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 1, + "label": "Axis", + "longdesc": "The axis of the cylinder", + "name": "axis", + "shortdesc": "Axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "length($uv.yz),$uv.x" + }, + { + "name": "Y", + "value": "length($uv.xz),$uv.y" + }, + { + "name": "Z", + "value": "length($uv.xy),$uv.z" + } + ] + }, + { + "control": "Rect1.y", + "default": 0.5, + "label": "Length", + "longdesc": "The length of the cylinder", + "max": 1, + "min": 0, + "name": "l", + "shortdesc": "Length", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.x", + "default": 0.2, + "label": "Radius", + "longdesc": "The radius of the cylinder", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Cylinder" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_elongation.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_elongation.mmg new file mode 100644 index 00000000..b1f87916 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_elongation.mmg @@ -0,0 +1,77 @@ +{ + "name": "sdf3d_elongation", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "x": 0.2, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec2(100, 0.0)", + "label": "", + "longdesc": "The input object to be elongated", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Elongates its input", + "name": "Elongation", + "outputs": [ + { + "longdesc": "The shape generated by the operation", + "sdf3dc": "$in($uv-clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "X", + "longdesc": "The elongation along the X axis", + "max": 1, + "min": 0, + "name": "x", + "shortdesc": "Length.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Y", + "longdesc": "The elongation along the Y axis", + "max": 1, + "min": 0, + "name": "y", + "shortdesc": "Length.y", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Z", + "longdesc": "The elongation along the Z axis", + "max": 1, + "min": 0, + "name": "z", + "shortdesc": "Length.z", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Elongation" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_extrusion.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_extrusion.mmg new file mode 100644 index 00000000..75d37aee --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_extrusion.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_extrusion", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "d": 0.3 + }, + "shader_model": { + "code": "vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);\n", + "global": "", + "inputs": [ + { + "default": "100.0", + "label": "", + "longdesc": "The input 2D shape as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Extrudes its 2D input shape along the Y axis", + "name": "Extrusion", + "outputs": [ + { + "longdesc": "The extruded shape", + "sdf3d": "min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.25, + "label": "", + "longdesc": "The length of the extrusion operation", + "max": 1, + "min": 0, + "name": "d", + "shortdesc": "Length", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Extrusion" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_morph.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_morph.mmg new file mode 100644 index 00000000..9fdd4c6b --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_morph.mmg @@ -0,0 +1,59 @@ +{ + "name": "sdf3d_morph", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0.5 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "10.0", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf3d" + }, + { + "default": "10.0", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf3d" + } + ], + "instance": "", + "longdesc": "Morphs between 2 input shapes", + "name": "Morph", + "outputs": [ + { + "longdesc": "The generated hybrid shape", + "sdf3d": "mix($in1($uv), $in2($uv), $amount)", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "", + "longdesc": "The amount of the second input in the result", + "max": 1, + "min": 0, + "name": "amount", + "shortdesc": "Amount", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Morph" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_plane.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_plane.mmg new file mode 100644 index 00000000..9dc474ab --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_plane.mmg @@ -0,0 +1,56 @@ +{ + "name": "sdf3d_plane", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "axis": 0 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a plane that can be used to cut other shapes", + "name": "Plane", + "outputs": [ + { + "longdesc": "Shows the plane", + "sdf3d": "$uv.$axis", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 2, + "label": "", + "longdesc": "The axis of the plane", + "name": "axis", + "shortdesc": "Axis", + "type": "enum", + "values": [ + { + "name": "X", + "value": "x" + }, + { + "name": "Y", + "value": "y" + }, + { + "name": "Z", + "value": "z" + } + ] + } + ], + "shortdesc": "Plane" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_repeat.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_repeat.mmg new file mode 100644 index 00000000..972ad9df --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_repeat.mmg @@ -0,0 +1,77 @@ +{ + "name": "sdf3d_repeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.3, + "rx": 3, + "ry": 3 + }, + "shader_model": { + "code": "", + "global": "vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {\n\tvec3 a = (rand3(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;\n\tp = mod(p+0.5*r,r)-0.5*r;\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "vec2(100, 0.0)", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Repeats its input shape on a grid.\nThis node does not support overlapping between instances.", + "name": "Repeat", + "outputs": [ + { + "longdesc": "The shape generated by the repeat operation", + "sdf3dc": "$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "X", + "longdesc": "The number of columns in the grid", + "max": 32, + "min": 1, + "name": "rx", + "shortdesc": "Columns", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Y", + "longdesc": "The number of lines in the grid", + "max": 32, + "min": 1, + "name": "ry", + "shortdesc": "Lines", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "R", + "longdesc": "The amount of random rotation on each instance of the input shape", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Rotation", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Repeat" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_revolution.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_revolution.mmg new file mode 100644 index 00000000..048fd2f8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_revolution.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_revolution", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "d": 0.25 + }, + "shader_model": { + "code": "vec2 $(name_uv)_q = vec2(length($uv.xy)-$d+0.5, $uv.z+0.5);\n", + "global": "", + "inputs": [ + { + "default": "10.0", + "label": "", + "longdesc": "The input shape", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Revolves its input 2D shape around the Z axis", + "name": "Revolution", + "outputs": [ + { + "longdesc": "The generated 3D object", + "sdf3d": "$in($(name_uv)_q)", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.25, + "label": "", + "longdesc": "The offset applied to the input shape during the revolution operation", + "max": 1, + "min": 0, + "name": "d", + "shortdesc": "Offset", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Revolution" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rotate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rotate.mmg new file mode 100644 index 00000000..c7c3bd95 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rotate.mmg @@ -0,0 +1,77 @@ +{ + "name": "sdf3d_rotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "ax": 0, + "ay": 0, + "az": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 rotate3d(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The input object as signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Rotates its input 3D object described as a signed distance function.", + "name": "Rotate", + "outputs": [ + { + "longdesc": "The rotated object", + "sdf3dc": "$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "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" + } + ], + "shortdesc": "Rotate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rounded.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rounded.mmg new file mode 100644 index 00000000..f2921977 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_rounded.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_rounded", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.15 + }, + "shader_model": { + "code": "vec2 $(name_uv)_v = $in($uv);", + "global": "", + "inputs": [ + { + "default": "vec2(100, 0.0)", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Dilates an input shape into a rounded shape", + "name": "Rounded", + "outputs": [ + { + "longdesc": "The shape generated by the operation", + "sdf3dc": "vec2($(name_uv)_v.x-$r, $(name_uv)_v.y)", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The length of the dilate operation", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "RoundedShape" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_scale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_scale.mmg new file mode 100644 index 00000000..f5be160a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_scale.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdf3d_scale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "s": 1 + }, + "shader_model": { + "code": "vec2 $(name_uv)_in = $in(($uv)/$s);", + "global": "", + "inputs": [ + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The input object as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Scales its input 3D object described as a signed distance function.", + "name": "Scale", + "outputs": [ + { + "longdesc": "The scaled object", + "sdf3dc": "vec2($(name_uv)_in.x*$s, $(name_uv)_in.y)", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "Scale1.x", + "default": 1, + "label": "", + "longdesc": "The scale factor", + "max": 5, + "min": 0, + "name": "s", + "shortdesc": "Scale", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Scale" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_smoothboolean.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_smoothboolean.mmg new file mode 100644 index 00000000..e10cbbc5 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_smoothboolean.mmg @@ -0,0 +1,82 @@ +{ + "name": "sdf3d_smoothboolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "k": 0.15, + "op": 0 + }, + "shader_model": { + "code": "", + "global": "vec2 sdf3d_smooth_union(vec2 d1, vec2 d2, float k) {\n float h = clamp(0.5+0.5*(d2.x-d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, d1.x, h)-k*h*(1.0-h), mix(d2.y, d1.y, step(d1.x, d2.x)));\n}\n\nvec2 sdf3d_smooth_subtraction(vec2 d1, vec2 d2, float k ) {\n float h = clamp(0.5-0.5*(d2.x+d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);\n}\n\nvec2 sdf3d_smooth_intersection(vec2 d1, vec2 d2, float k ) {\n float h = clamp(0.5-0.5*(d2.x-d1.x)/k, 0.0, 1.0);\n return vec2(mix(d2.x, d1.x, h)+k*h*(1.0-h), mix(d1.y, d2.y, step(d1.x, d2.x)));\n}\n", + "inputs": [ + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf3dc" + }, + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Performs a smooth boolean operation (union, intersection or difference) between two shapes", + "name": "SmoothBoolean", + "outputs": [ + { + "longdesc": "The shape generated by the boolean operation", + "sdf3dc": "sdf3d_smooth_$op($in1($uv), $in2($uv), $k)", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "default": 2, + "label": "", + "longdesc": "The operation performed by this node", + "name": "op", + "shortdesc": "Operation", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "union" + }, + { + "name": "Subtraction", + "value": "subtraction" + }, + { + "name": "Intersection", + "value": "intersection" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The smoothness of the boolean operation", + "max": 1, + "min": 0, + "name": "k", + "shortdesc": "Smoothness", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "SmoothBoolean" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_sphere.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_sphere.mmg new file mode 100644 index 00000000..03203180 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_sphere.mmg @@ -0,0 +1,44 @@ +{ + "name": "sdf3d_sphere", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.4 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a sphere as a signed distance function", + "name": "Sphere", + "outputs": [ + { + "longdesc": "Shows the sphere", + "sdf3d": "length($uv)-$r", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "control": "Radius1.r", + "default": 0.5, + "label": "", + "longdesc": "The radius of the sphere", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Sphere" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_torus.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_torus.mmg new file mode 100644 index 00000000..deb4ecd9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_torus.mmg @@ -0,0 +1,80 @@ +{ + "name": "sdf3d_torus", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "R": 0.3, + "axis": 2, + "r": 0.15 + }, + "shader_model": { + "code": "vec2 $(name_uv)_q = vec2($axis);\n", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a torus as a signed distance function", + "name": "Torus", + "outputs": [ + { + "longdesc": "Shows the torus", + "sdf3d": "length($(name_uv)_q)-$r", + "shortdesc": "Output", + "type": "sdf3d" + } + ], + "parameters": [ + { + "default": 0, + "label": "Axis", + "longdesc": "The axis of the torus", + "name": "axis", + "shortdesc": "Torus", + "type": "enum", + "values": [ + { + "name": "X", + "value": "length($uv.yz)-$R,$uv.x" + }, + { + "name": "Y", + "value": "length($uv.zx)-$R,$uv.y" + }, + { + "name": "Z", + "value": "length($uv.xy)-$R,$uv.z" + } + ] + }, + { + "control": "Radius1.r", + "default": 0.5, + "label": "R", + "longdesc": "The major radius of the torus", + "max": 1, + "min": 0, + "name": "R", + "shortdesc": "Radius1", + "step": 0.01, + "type": "float" + }, + { + "control": "Radius11.r", + "default": 0.1, + "label": "r", + "longdesc": "The minor radius of the torus", + "max": 0.5, + "min": 0, + "name": "r", + "shortdesc": "Radius2", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Torus" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_translate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_translate.mmg new file mode 100644 index 00000000..826d6423 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdf3d_translate.mmg @@ -0,0 +1,77 @@ +{ + "name": "sdf3d_translate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "x": 0, + "y": 0, + "z": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec2(100.0, 0.0)", + "label": "", + "longdesc": "The input object as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Translates its input 3D object described as a signed distance function.", + "name": "Translate", + "outputs": [ + { + "longdesc": "The translated object", + "sdf3dc": "$in($uv-vec3($x, $y, $z))", + "shortdesc": "Output", + "type": "sdf3dc" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "X", + "longdesc": "The translation along the X axis", + "max": 1, + "min": -1, + "name": "x", + "shortdesc": "Translate.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Y", + "longdesc": "The translation along the Y axis", + "max": 1, + "min": -1, + "name": "y", + "shortdesc": "Translate.y", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Z", + "longdesc": "The translation along the Z axis", + "max": 1, + "min": -1, + "name": "z", + "shortdesc": "Translate.z", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Translate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdline.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdline.mmg new file mode 100644 index 00000000..eab624c2 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdline.mmg @@ -0,0 +1,135 @@ +{ + "name": "sdline", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "ax": -0.3, + "ay": -0.3, + "bx": 0.3, + "by": 0.3, + "profile": { + "points": [ + { + "ls": 0, + "rs": 0, + "x": 0, + "y": 1 + }, + { + "ls": 0, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + }, + "r": 0.1 + }, + "shader_model": { + "code": "vec2 $(name_uv)_sdl = sdLine($uv, vec2($ax+0.5, $ay+0.5), vec2($bx+0.5, $by+0.5));", + "global": "vec2 sdLine(vec2 p, vec2 a, vec2 b) {\n vec2 pa = p-a, ba = b-a;\n float h = clamp(dot(pa,ba)/dot(ba,ba), 0.0, 1.0);\n return vec2(length(pa-ba*h), h);\n}\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "A line or a capsule shape described as a signed distance function", + "name": "sdLine", + "outputs": [ + { + "longdesc": "The shape as signed distance function", + "sdf2d": "$(name_uv)_sdl.x-$r*$profile($(name_uv)_sdl.y)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "A X", + "longdesc": "The position on the X axis of the first point of the line", + "max": 1, + "min": -1, + "name": "ax", + "shortdesc": "A.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "A Y", + "longdesc": "The position on the Y axis of the first point of the line", + "max": 1, + "min": -1, + "name": "ay", + "shortdesc": "A.y", + "step": 0.01, + "type": "float" + }, + { + "control": "P2.x", + "default": 1, + "label": "B X", + "longdesc": "The position on the X axis of the second point of the line", + "max": 1, + "min": -1, + "name": "bx", + "shortdesc": "B.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P2.y", + "default": 1, + "label": "B Y", + "longdesc": "The position on the Y axis of the second point of the line", + "max": 1, + "min": -1, + "name": "by", + "shortdesc": "B.y", + "step": 0.01, + "type": "float" + }, + { + "control": "Radius1.r", + "default": 0, + "label": "Width", + "longdesc": "The width of the capsule shape around the line", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "default": { + "points": [ + { + "ls": 0, + "rs": 0, + "x": 0, + "y": 1 + }, + { + "ls": 0, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + }, + "label": "Profile", + "name": "profile", + "type": "curve" + } + ], + "shortdesc": "sdLine" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdmorph.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdmorph.mmg new file mode 100644 index 00000000..d2cf417f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdmorph.mmg @@ -0,0 +1,60 @@ +{ + "name": "sdmorph", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0.5 + }, + "seed_value": 41515, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf2d" + }, + { + "default": "0.0", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Morphs between 2 input shapes", + "name": "sdMorph", + "outputs": [ + { + "longdesc": "The generated hybrid shape", + "sdf2d": "mix($in1($uv), $in2($uv), $amount)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "", + "longdesc": "The amount of the second input in the result", + "max": 1, + "min": 0, + "name": "amount", + "shortdesc": "Amount", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdMorph" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdngon.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdngon.mmg new file mode 100644 index 00000000..af22d982 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdngon.mmg @@ -0,0 +1,102 @@ +{ + "name": "sdngon", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "n": 5, + "r": 0.4, + "rot": 0 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "float sdNgon(vec2 p, float r, float n) {\n\tfloat PI = 3.1415926535;\n\tp = circle_repeat_transform_2d(p, n);\n\tvec2 d = abs(p)-vec2(r*tan(3.14159265359/n), r);\n\treturn p.y < r ? p.y-r : length(max(d,vec2(0)))+min(max(d.x,d.y),0.0);\n}", + "includes": [ + "sdrotate", + "sdcirclerepeat" + ], + "inputs": [ + + ], + "instance": "", + "longdesc": "An n-gon described as a signed distance function", + "name": "sdNgon", + "outputs": [ + { + "longdesc": "The n-gon as a signed distance function", + "sdf2d": "sdNgon(sdf2d_rotate($uv-vec2($cx, $cy), $rot*0.01745329251-1.57079632679)-vec2(0.5), $r, $n)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 3, + "label": "N", + "longdesc": "The number of sides of the n-gon", + "max": 12, + "min": 3, + "name": "n", + "shortdesc": "N", + "step": 1, + "type": "float" + }, + { + "control": "Radius1.r", + "default": 0.5, + "label": "Radius", + "longdesc": "The radius of the n-gon", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + }, + { + "control": "Radius1.a", + "default": 0, + "label": "Rotation", + "longdesc": "The rotation of the n-gon", + "max": 180, + "min": -180, + "name": "rot", + "shortdesc": "Rotation", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.x", + "default": 0, + "label": "Center X", + "longdesc": "The position of the center on the X axis", + "max": 0.5, + "min": -0.5, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y", + "longdesc": "The position of the center on the Y axis", + "max": 0.5, + "min": -0.5, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdNgon" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdpolygon.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdpolygon.mmg new file mode 100644 index 00000000..9a948b60 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdpolygon.mmg @@ -0,0 +1,72 @@ +{ + "name": "sdpolygon", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "polygon": { + "points": [ + { + "x": 0.2, + "y": 0.2 + }, + { + "x": 0.4, + "y": 0.7 + }, + { + "x": 0.7, + "y": 0.4 + } + ], + "type": "Polygon" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "float sdPolygon_$(name)(vec2 p) {\n\tvec2 v[] = $polygon;\n\tint l = v.length();\n float d = dot(p-v[0],p-v[0]);\n float s = 1.0;\n\tint j = l-1;\n for(int i=0; i=v[i].y,p.ye.y*w.x);\n if( all(c) || all(not(c)) ) s*=-1.0;\n\t\tj=i;\n }\n return s*sqrt(d);\n}\n", + "longdesc": "A polygon as a signed distance function", + "name": "sdPolygon", + "outputs": [ + { + "longdesc": "The polygon as a signed distance function", + "sdf2d": "sdPolygon_$(name)($uv)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": { + "points": [ + { + "x": 0.2, + "y": 0.2 + }, + { + "x": 0.4, + "y": 0.7 + }, + { + "x": 0.7, + "y": 0.4 + } + ], + "type": "Polygon" + }, + "label": "", + "longdesc": "The polygon to be drawn", + "name": "polygon", + "shortdesc": "Polygon", + "type": "polygon" + } + ], + "shortdesc": "sdPolygon" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdrepeat.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdrepeat.mmg new file mode 100644 index 00000000..0721e1a8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdrepeat.mmg @@ -0,0 +1,77 @@ +{ + "name": "sdrepeat", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.5, + "rx": 3, + "ry": 3 + }, + "shader_model": { + "code": "", + "global": "vec2 repeat_2d(vec2 p, vec2 r, float seed, float randomness) {\n\tp -= vec2(0.5);\n\tfloat a = (rand(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;\n\tp = mod(p+0.5*r,r)-0.5*r;\n\tvec2 rv;\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\treturn rv+vec2(0.5);\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Repeats its input shape on a grid.\nThis node does not support overlapping between instances.", + "name": "Repeat", + "outputs": [ + { + "longdesc": "The shape generated by the repeat operation", + "sdf2d": "$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "X", + "longdesc": "The number of columns in the grid", + "max": 32, + "min": 1, + "name": "rx", + "shortdesc": "Columns", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Y", + "longdesc": "The number of lines in the grid", + "max": 32, + "min": 1, + "name": "ry", + "shortdesc": "Lines", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "R", + "longdesc": "The amount of random rotation on each instance of the input shape", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Rotation", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdRepeat" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdrhombus.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdrhombus.mmg new file mode 100644 index 00000000..21480dd2 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdrhombus.mmg @@ -0,0 +1,83 @@ +{ + "name": "sdrhombus", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0, + "cy": 0, + "h": 0.2, + "w": 0.3 + }, + "shader_model": { + "code": "", + "global": "float sdr_ndot(vec2 a, vec2 b) { return a.x*b.x - a.y*b.y; }\nfloat sdRhombus(in vec2 p, in vec2 b) {\n vec2 q = abs(p);\n float h = clamp((-2.0*sdr_ndot(q,b)+sdr_ndot(b,b))/dot(b,b),-1.0,1.0);\n float d = length( q - 0.5*b*vec2(1.0-h,1.0+h) );\n return d * sign( q.x*b.y + q.y*b.x - b.x*b.y );\n}", + "inputs": [ + + ], + "instance": "", + "longdesc": "A rhombus described as a signed distance function", + "name": "sdRhombus", + "outputs": [ + { + "longdesc": "The rhombus as a signed distance function", + "sdf2d": "sdRhombus($uv-vec2($cx+0.5, $cy+0.5), vec2($w, $h))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Rect1.x", + "default": 0.5, + "label": "Width", + "longdesc": "The width of the rhombus", + "max": 1, + "min": 0, + "name": "w", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "control": "Rect1.y", + "default": 1, + "label": "Height", + "longdesc": "The height of the rhombus", + "max": 1, + "min": 0, + "name": "h", + "shortdesc": "Height", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.x", + "default": 0, + "label": "Center X", + "longdesc": "The position of the center on the X axis", + "max": 1, + "min": -1, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Center Y", + "longdesc": "The position of the center on the Y axis", + "max": 1, + "min": -1, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdRhombus" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdrotate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdrotate.mmg new file mode 100644 index 00000000..43ac6eba --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdrotate.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdrotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0 + }, + "shader_model": { + "code": "", + "global": "vec2 sdf2d_rotate(vec2 uv, float a) {\n\tvec2 rv;\n\tfloat c = cos(a);\n\tfloat s = sin(a);\n\tuv -= vec2(0.5);\n\trv.x = uv.x*c+uv.y*s;\n\trv.y = -uv.x*s+uv.y*c;\n\treturn rv+vec2(0.5);\n}\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Rotates its input shape described as a signed distance function", + "name": "Rotate", + "outputs": [ + { + "longdesc": "The rotated shape", + "sdf2d": "$in(sdf2d_rotate($uv, $a*0.01745329251))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Radius1.a", + "default": 0, + "label": "", + "longdesc": "The rotation angle", + "max": 180, + "min": -180, + "name": "a", + "shortdesc": "Angle", + "step": 1, + "type": "float" + } + ], + "shortdesc": "sdRotate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdroundedshape.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdroundedshape.mmg new file mode 100644 index 00000000..762b54dd --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdroundedshape.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdroundedshape", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "r": 0.2 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Dilates an input shape into a rounded shape", + "name": "sdRoundedShape", + "outputs": [ + { + "longdesc": "The shape generated by the operation", + "sdf2d": "$in($uv)-$r", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The length of the dilate operation", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdRoundedShape" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdscale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdscale.mmg new file mode 100644 index 00000000..2f8d96d8 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdscale.mmg @@ -0,0 +1,51 @@ +{ + "name": "sdscale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "s": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Scales its input shape described as a signed distance function", + "name": "Scale", + "outputs": [ + { + "longdesc": "The generated scaled shape", + "sdf2d": "$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "Scale1.x", + "default": 1, + "label": "", + "longdesc": "The scale of the transform", + "max": 5, + "min": 0, + "name": "s", + "shortdesc": "Scale", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdScale" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdshow.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdshow.mmg new file mode 100644 index 00000000..641e8a83 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdshow.mmg @@ -0,0 +1,64 @@ +{ + "name": "sdshow", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "base": 0, + "bevel": 0.1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Creates a greyscale image from a shape described as a 2D Signed Distance Function", + "name": "sdShow", + "outputs": [ + { + "f": "clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)", + "longdesc": "Shows the shape as a greyscale image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0, + "label": "Bevel", + "longdesc": "The width of the gradient at the edges of the shape", + "max": 1, + "min": 0, + "name": "bevel", + "shortdesc": "Bevel", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Base", + "longdesc": "The base value of the output", + "max": 1, + "min": 0, + "name": "base", + "shortdesc": "Base", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdShow" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdsmoothboolean.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdsmoothboolean.mmg new file mode 100644 index 00000000..08d58d2f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdsmoothboolean.mmg @@ -0,0 +1,82 @@ +{ + "name": "sdsmoothboolean", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "k": 0.15, + "op": 0 + }, + "shader_model": { + "code": "", + "global": "float sdSmoothUnion( float d1, float d2, float k ) {\n float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) - k*h*(1.0-h); }\n\nfloat sdSmoothSubtraction( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2+d1)/k, 0.0, 1.0 );\n return mix( d2, -d1, h ) + k*h*(1.0-h); }\n\nfloat sdSmoothIntersection( float d1, float d2, float k ) {\n float h = clamp( 0.5 - 0.5*(d2-d1)/k, 0.0, 1.0 );\n return mix( d2, d1, h ) + k*h*(1.0-h); }\n", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The first shape, defined as a signed distance function", + "name": "in1", + "shortdesc": "Input1", + "type": "sdf2d" + }, + { + "default": "0.0", + "label": "", + "longdesc": "The second shape, defined as a signed distance function", + "name": "in2", + "shortdesc": "Input2", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Performs a smooth boolean operation (union, intersection or difference) between two shapes", + "name": "sdSmoothBoolean", + "outputs": [ + { + "longdesc": "The shape generated by the boolean operation", + "sdf2d": "sdSmooth$op($in1($uv), $in2($uv), $k)", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "The operation performed by this node", + "name": "op", + "shortdesc": "Operation", + "type": "enum", + "values": [ + { + "name": "Union", + "value": "Union" + }, + { + "name": "Subtraction", + "value": "Subtraction" + }, + { + "name": "Intersection", + "value": "Intersection" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The smoothness of the boolean operation", + "max": 1, + "min": 0, + "name": "k", + "shortdesc": "Smoothness", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdSmoothBoolean" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sdtranslate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sdtranslate.mmg new file mode 100644 index 00000000..f03d5e5b --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sdtranslate.mmg @@ -0,0 +1,64 @@ +{ + "name": "sdtranslate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "x": 0, + "y": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "label": "", + "longdesc": "The input shape, defined as a signed distance function", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Translates its input shape described as signed distance function", + "name": "Translate", + "outputs": [ + { + "longdesc": "The translated shape", + "sdf2d": "$in($uv-vec2($x, $y))", + "shortdesc": "Output", + "type": "sdf2d" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "X", + "longdesc": "The translation along the X axis", + "max": 1, + "min": -1, + "name": "x", + "shortdesc": "Translate.x", + "step": 0.01, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Y", + "longdesc": "The translation along the Y axis", + "max": 1, + "min": -1, + "name": "y", + "shortdesc": "Translate.y", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "sdTranslate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/shape.mmg b/game/addons/mat_maker_gd/material_maker_nodes/shape.mmg new file mode 100644 index 00000000..14d9a018 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/shape.mmg @@ -0,0 +1,115 @@ +{ + "name": "shape", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "edge": 0.1, + "radius": 0.85, + "shape": 1, + "sides": 6 + }, + "shader_model": { + "code": "", + "global": "float shape_circle(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float distance = length(uv);\n return clamp((1.0-distance/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_polygon(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y)+3.14159265359;\n float slice = 6.28318530718/sides;\n return clamp((1.0-(cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = atan(uv.x, uv.y);\n float slice = 6.28318530718/sides;\n 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);\n}\n\nfloat shape_curved_star(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = max(edge, 1.0e-8);\n float angle = 2.0*(atan(uv.x, uv.y)+3.14159265359);\n float slice = 6.28318530718/sides;\n return clamp((1.0-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv)/size)/edge, 0.0, 1.0);\n}\n\nfloat shape_rays(vec2 uv, float sides, float size, float edge) {\n uv = 2.0*uv-1.0;\n\tedge = 0.5*max(edge, 1.0e-8)*size;\n\tfloat slice = 6.28318530718/sides;\n float angle = mod(atan(uv.x, uv.y)+3.14159265359, slice)/slice;\n return clamp(min((size-angle)/edge, angle/edge), 0.0, 1.0);\n}\n\n", + "inputs": [ + { + "default": "1.0", + "label": "3:", + "longdesc": "An input map that affects the shape size", + "name": "radius_map", + "shortdesc": "Size map", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An input map that affects the edge width", + "name": "edge_map", + "shortdesc": "Edge map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Draws a white shape on a black background", + "name": "Shape", + "outputs": [ + { + "f": "shape_$(shape)($(uv), $(sides), $(radius)*$radius_map($uv), $(edge)*$edge_map($uv))", + "longdesc": "Shows a white shape on a black background", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "The type of shape drawn by this node", + "name": "shape", + "shortdesc": "Shape", + "type": "enum", + "values": [ + { + "name": "Circle", + "value": "circle" + }, + { + "name": "Polygon", + "value": "polygon" + }, + { + "name": "Star", + "value": "star" + }, + { + "name": "Curved star", + "value": "curved_star" + }, + { + "name": "Rays", + "value": "rays" + } + ] + }, + { + "control": "None", + "default": 3, + "label": "", + "longdesc": "The number of sides of the generated shape (unused for Circle)", + "max": 32, + "min": 2, + "name": "sides", + "shortdesc": "Sides count", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "", + "longdesc": "The size of the generated shape", + "max": 1, + "min": 0, + "name": "radius", + "shortdesc": "Shape size", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.2, + "label": "", + "longdesc": "The edge width of the generated shape", + "max": 1, + "min": 0, + "name": "edge", + "shortdesc": "Edge width", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sharpen.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sharpen.mmg new file mode 100644 index 00000000..f32413e2 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sharpen.mmg @@ -0,0 +1,50 @@ +{ + "name": "sharpen", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 6 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgb" + } + ], + "instance": "vec3 $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(1.0/$size, 0.0);\n\tvec3 rv = 5.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\treturn rv;\n}", + "longdesc": "Sharpens it input image", + "name": "Sharpen", + "outputs": [ + { + "longdesc": "Shows the generated sharpened image", + "rgb": "$(name)_fct($uv)", + "shortdesc": "Output", + "type": "rgb" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "longdesc": "The resolution of the input image", + "name": "size", + "shortdesc": "Size", + "type": "size" + } + ], + "shortdesc": "Sharpen" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/shear.mmg b/game/addons/mat_maker_gd/material_maker_nodes/shear.mmg new file mode 100644 index 00000000..c80f5b8c --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/shear.mmg @@ -0,0 +1,83 @@ +{ + "name": "shear", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0, + "center": 0, + "direction": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Performs a shear stress transform on its input", + "name": "Shear", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$in($uv+$amount*($uv.yx-vec2($center))*vec2($direction))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 1, + "label": "", + "longdesc": "The direction of the shear transform (horizontal or vertical)", + "name": "direction", + "shortdesc": "Direction", + "type": "enum", + "values": [ + { + "name": "Horizontal", + "value": "1.0, 0.0" + }, + { + "name": "Vertical", + "value": "0.0, 1.0" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The amount of the transform", + "max": 1, + "min": -1, + "name": "amount", + "shortdesc": "Amount", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The position of the shear center", + "max": 1, + "min": 0, + "name": "center", + "shortdesc": "Center", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Shear" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sine_wave.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sine_wave.mmg new file mode 100644 index 00000000..df5f99f9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sine_wave.mmg @@ -0,0 +1,70 @@ +{ + "name": "sine_wave", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amplitude": 0.25, + "frequency": 4, + "phase": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Draws a greyscale sine wave pattern", + "name": "Sine Wave", + "outputs": [ + { + "f": "1.0-abs(2.0*($uv.y-0.5)-$amplitude*sin(($frequency*$uv.x+$phase)*6.28318530718))", + "longdesc": "Shows a greyscale image of a sine wave", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "Amplitude", + "longdesc": "The amplitude of the sine wave function", + "max": 1, + "min": 0, + "name": "amplitude", + "shortdesc": "Amplitude", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Frequency", + "longdesc": "The frequency of the sine wave function (i.e. the number of oscillations shown in the generated image).", + "max": 16, + "min": 0, + "name": "frequency", + "shortdesc": "Frequency", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Phase", + "longdesc": "The phase of the sine wave function", + "max": 1, + "min": 0, + "name": "phase", + "shortdesc": "Phase", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Sine wave pattern" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/skew.mmg b/game/addons/mat_maker_gd/material_maker_nodes/skew.mmg new file mode 100644 index 00000000..b73f6120 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/skew.mmg @@ -0,0 +1,61 @@ +{ + "name": "skew", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": -0.175, + "amout": 0, + "direction": 0, + "offset": 0.730769 + }, + "shader_model": { + "global": "vec2 uvskew_h(vec2 uv, float amount) {\n\treturn vec2(uv.x+amount*(uv.y-0.5), uv.y);\n}\nvec2 uvskew_v(vec2 uv, float amount) {\n\treturn vec2(uv.x, uv.y+amount*(uv.x-0.5));\n}", + "inputs": [ + { + "default": "vec4($uv, 0, 1)", + "label": "", + "name": "i", + "type": "rgba" + } + ], + "instance": "", + "name": "Skew", + "outputs": [ + { + "rgba": "$i(uvskew_$direction($uv, $amount))", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "name": "direction", + "type": "enum", + "values": [ + { + "name": "Horizontal", + "value": "h" + }, + { + "name": "Vertical", + "value": "v" + } + ] + }, + { + "default": 0, + "label": "", + "max": 3, + "min": -3, + "name": "amount", + "step": 0.005, + "type": "float", + "widget": "spinbox" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/slope_blur.mmg b/game/addons/mat_maker_gd/material_maker_nodes/slope_blur.mmg new file mode 100644 index 00000000..1a35d461 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/slope_blur.mmg @@ -0,0 +1,230 @@ +{ + "connections": [ + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "edge_detect_3_3_2", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "edge_detect_3_3_2", + "to_port": 1 + }, + { + "from": "edge_detect_3_3_2", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Slope Blur", + "longdesc": "Applys a blur effect on its input, following slopes of an input height map", + "name": "slope_blur", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer", + "node_position": { + "x": -395.25, + "y": -274.75 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -462.666626, + "y": -397.666656 + }, + "parameters": { + "param0": 10, + "param1": 30 + }, + "type": "remote", + "widgets": [ + { + "label": "Grid size:", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "edge_detect_3_3_2", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + } + ], + "longdesc": "The resolution of the input image", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Sigma", + "linked_widgets": [ + { + "node": "edge_detect_3_3_2", + "widget": "sigma" + } + ], + "longdesc": "The strength of the blur filter", + "name": "param1", + "shortdesc": "Sigma", + "type": "linked_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -872.666626, + "y": -243.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + }, + { + "group_size": 0, + "longdesc": "A height map whose slopes control the strength and direction of the blur filter", + "name": "heightmap", + "shortdesc": "Height map", + "type": "f" + } + ], + "seed_value": 91624, + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -45.452393, + "y": -195.392853 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the generated blurred image", + "name": "port0", + "shortdesc": "Output", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "edge_detect_3_3_2", + "node_position": { + "x": -401.725464, + "y": -199.178955 + }, + "parameters": { + "sigma": 30, + "size": 10 + }, + "seed_value": -47470, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgba" + }, + { + "default": "1.0", + "function": true, + "label": "", + "name": "heightmap", + "type": "f" + } + ], + "instance": "vec4 $(name)_fct(vec2 uv) {\n\tfloat dx = 1.0/$size;\n float v = $heightmap(uv);\n\tvec2 slope = vec2($heightmap(uv+vec2(dx, 0.0))-v, $heightmap(uv+vec2(0.0, dx))-v);\n\tfloat slope_strength = length(slope)*$size;\n vec2 norm_slope = (slope_strength == 0.0) ? vec2(0.0, 1.0) : normalize(slope);\n vec2 e = dx*norm_slope;\n\tvec4 rv = vec4(0.0);\n\tfloat sum = 0.0;\n\tfloat sigma = max($sigma*slope_strength, 0.0001);\n\tfor (float i = 0.0; i <= 50.0; i += 1.0) {\n\t\tfloat coef = exp(-0.5*(pow(i/sigma, 2.0)))/(6.28318530718*sigma*sigma);\n\t\trv += $in(uv+i*e)*coef;\n\t\tsum += coef;\n\t}\n\treturn rv/sum;\n}", + "name": "Slope Blur", + "outputs": [ + { + "rgba": "$(name)_fct($uv)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 9, + "first": 4, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 0.5, + "label": "Sigma", + "max": 50, + "min": 0, + "name": "sigma", + "step": 0.1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "buffer_2", + "node_position": { + "x": -392.952209, + "y": -115.576294 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + } + ], + "parameters": { + "param0": 10, + "param1": 30 + }, + "shortdesc": "Slope blur", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature.mmg b/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature.mmg new file mode 100644 index 00000000..7aaa32fb --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature.mmg @@ -0,0 +1,880 @@ +{ + "connections": [ + { + "from": "blend", + "from_port": 0, + "to": "blend_2", + "to_port": 1 + }, + { + "from": "blend_2", + "from_port": 0, + "to": "blend_3", + "to_port": 1 + }, + { + "from": "blend_3", + "from_port": 0, + "to": "blend_4", + "to_port": 1 + }, + { + "from": "blend_4", + "from_port": 0, + "to": "invert", + "to_port": 0 + }, + { + "from": "invert", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "normal_map", + "to_port": 0 + }, + { + "from": "598_3", + "from_port": 0, + "to": "fast_blur", + "to_port": 0 + }, + { + "from": "fast_blur", + "from_port": 0, + "to": "blend_4", + "to_port": 0 + }, + { + "from": "598_2", + "from_port": 0, + "to": "fast_blur_2", + "to_port": 0 + }, + { + "from": "fast_blur_2", + "from_port": 0, + "to": "blend_3", + "to_port": 0 + }, + { + "from": "598_4", + "from_port": 0, + "to": "fast_blur_3", + "to_port": 0 + }, + { + "from": "fast_blur_3", + "from_port": 0, + "to": "blend_2", + "to_port": 0 + }, + { + "from": "598_5", + "from_port": 0, + "to": "fast_blur_4", + "to_port": 0 + }, + { + "from": "fast_blur_4", + "from_port": 0, + "to": "blend", + "to_port": 0 + }, + { + "from": "598_6", + "from_port": 0, + "to": "fast_blur_5", + "to_port": 0 + }, + { + "from": "fast_blur_5", + "from_port": 0, + "to": "blend", + "to_port": 1 + }, + { + "from": "normal_map", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "598_3", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "598_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "598_4", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "598_5", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "598_6", + "to_port": 0 + } + ], + "label": "Smooth Curvature", + "longdesc": "Creates a smooth curvature map from a height map", + "name": "smooth_curvature", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "normal_map", + "node_position": { + "x": -684.409058, + "y": 680 + }, + "parameters": { + "param0": 11, + "param1": 1, + "param2": 0, + "param4": 1 + }, + "type": "normal_map" + }, + { + "name": "blend", + "node_position": { + "x": 510.361206, + "y": 903.779297 + }, + "parameters": { + "amount": 1, + "blend_type": 4 + }, + "type": "blend" + }, + { + "name": "blend_2", + "node_position": { + "x": 510.179382, + "y": 803.915527 + }, + "parameters": { + "amount": 1, + "blend_type": 4 + }, + "type": "blend" + }, + { + "name": "blend_3", + "node_position": { + "x": 509.270233, + "y": 702.279175 + }, + "parameters": { + "amount": 1, + "blend_type": 4 + }, + "type": "blend" + }, + { + "name": "blend_4", + "node_position": { + "x": 509.542999, + "y": 600.279175 + }, + "parameters": { + "amount": 1, + "blend_type": 4 + }, + "type": "blend" + }, + { + "name": "invert", + "node_position": { + "x": 754.354553, + "y": 603.172791 + }, + "parameters": { + + }, + "type": "invert" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -1097.162842, + "y": 678.835876 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input height map", + "name": "port0", + "shortdesc": "Height map", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 908.046326, + "y": 596.806824 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The generated curvature map", + "name": "port0", + "shortdesc": "Output", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -121.992188, + "y": 350.266235 + }, + "parameters": { + "param0": 11, + "param2": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Size", + "linked_widgets": [ + { + "node": "normal_map", + "widget": "param0" + }, + { + "node": "598_3", + "widget": "size" + }, + { + "node": "fast_blur", + "widget": "param0" + }, + { + "node": "598_2", + "widget": "size" + }, + { + "node": "fast_blur_2", + "widget": "param0" + }, + { + "node": "598_4", + "widget": "size" + }, + { + "node": "fast_blur_3", + "widget": "param0" + }, + { + "node": "fast_blur_4", + "widget": "param0" + }, + { + "node": "598_5", + "widget": "size" + }, + { + "node": "fast_blur_5", + "widget": "param0" + }, + { + "node": "598_6", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + } + ], + "longdesc": "The buffer size for the filter", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Intensity", + "linked_widgets": [ + { + "node": "normal_map", + "widget": "param1" + } + ], + "longdesc": "The contrast of the generated highlights", + "name": "param2", + "shortdesc": "Intensity", + "type": "linked_control" + } + ] + }, + { + "name": "598_3", + "node_position": { + "x": -94.135475, + "y": 510.526459 + }, + "parameters": { + "amount": 1, + "size": 11, + "width": 1 + }, + "shader_model": { + "code": "vec2 $(name_uv)_emboss = $(name)_fct($uv);", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec2 $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tvec2 rv = vec2(0.0);\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy)).xy*cos(vec2(atan(dy, dx))-vec2(0.0, 0.5)*3.14159265359)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Curvature", + "outputs": [ + { + "f": "0.5*($(name_uv)_emboss.x+$(name_uv)_emboss.y)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "598_2", + "node_position": { + "x": -100.207932, + "y": 638.757874 + }, + "parameters": { + "amount": 1, + "size": 11, + "width": 2 + }, + "shader_model": { + "code": "vec2 $(name_uv)_emboss = $(name)_fct($uv);", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec2 $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tvec2 rv = vec2(0.0);\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy)).xy*cos(vec2(atan(dy, dx))-vec2(0.0, 0.5)*3.14159265359)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Curvature", + "outputs": [ + { + "f": "0.5*($(name_uv)_emboss.x+$(name_uv)_emboss.y)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "598_4", + "node_position": { + "x": -97.532082, + "y": 755.803345 + }, + "parameters": { + "amount": 1, + "size": 11, + "width": 4 + }, + "shader_model": { + "code": "vec2 $(name_uv)_emboss = $(name)_fct($uv);", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec2 $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tvec2 rv = vec2(0.0);\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy)).xy*cos(vec2(atan(dy, dx))-vec2(0.0, 0.5)*3.14159265359)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Curvature", + "outputs": [ + { + "f": "0.5*($(name_uv)_emboss.x+$(name_uv)_emboss.y)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "598_5", + "node_position": { + "x": -95.713867, + "y": 877.621521 + }, + "parameters": { + "amount": 1, + "size": 11, + "width": 8 + }, + "shader_model": { + "code": "vec2 $(name_uv)_emboss = $(name)_fct($uv);", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec2 $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tvec2 rv = vec2(0.0);\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy)).xy*cos(vec2(atan(dy, dx))-vec2(0.0, 0.5)*3.14159265359)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Curvature", + "outputs": [ + { + "f": "0.5*($(name_uv)_emboss.x+$(name_uv)_emboss.y)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "name": "598_6", + "node_position": { + "x": -92.077492, + "y": 992.848633 + }, + "parameters": { + "amount": 1, + "size": 11, + "width": 16 + }, + "shader_model": { + "code": "vec2 $(name_uv)_emboss = $(name)_fct($uv);", + "global": "", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "name": "in", + "type": "rgb" + } + ], + "instance": "vec2 $(name)_fct(vec2 uv) {\n\tfloat pixels = max(1.0, $width);\n\tfloat e = 1.0/$size;\n\tvec2 rv = vec2(0.0);\n\tfor (float dx = -pixels; dx <= pixels; dx += 1.0) {\n\t\tfor (float dy = -pixels; dy <= pixels; dy += 1.0) {\n\t\t\tif (abs(dx) > 0.5 || abs(dy) > 0.5) {\n\t\t\t\trv += $in(uv+e*vec2(dx, dy)).xy*cos(vec2(atan(dy, dx))-vec2(0.0, 0.5)*3.14159265359)/length(vec2(dx, dy));\n\t\t\t}\n\t\t}\n\t}\n\treturn $amount*rv/pixels+0.5;\n}", + "name": "Curvature", + "outputs": [ + { + "f": "0.5*($(name_uv)_emboss.x+$(name_uv)_emboss.y)", + "type": "f" + } + ], + "parameters": [ + { + "default": 9, + "first": 6, + "label": "Size", + "last": 12, + "name": "size", + "type": "size" + }, + { + "control": "None", + "default": 1, + "label": "Amount", + "max": 10, + "min": 0, + "name": "amount", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "max": 5, + "min": 1, + "name": "width", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" + }, + { + "connections": [ + { + "from": "buffer_2", + "from_port": 0, + "to": "fast_blur_shader", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "fast_blur_shader", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + } + ], + "label": "Fast Blur", + "longdesc": "", + "name": "fast_blur", + "node_position": { + "x": 167.483093, + "y": 509.757843 + }, + "nodes": [ + { + "name": "fast_blur_shader", + "node_position": { + "x": -168, + "y": 120 + }, + "parameters": { + "quality": 1, + "sigma": 2 + }, + "type": "fast_blur_shader" + }, + { + "name": "buffer_2", + "node_position": { + "x": -187, + "y": 61.5 + }, + "parameters": { + "size": 11 + }, + "type": "buffer", + "version": 1 + }, + { + "name": "gen_inputs", + "node_position": { + "x": -602, + "y": 91.75 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "name": "port0", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 88, + "y": 61.75 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "name": "port0", + "type": "rgba" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -254.5, + "y": -122.5 + }, + "parameters": { + "param0": 11, + "param1": 2, + "param2": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Resolution", + "linked_widgets": [ + { + "node": "buffer_2", + "widget": "size" + } + ], + "name": "param0", + "type": "linked_control" + }, + { + "label": "Sigma", + "linked_widgets": [ + { + "node": "fast_blur_shader", + "widget": "sigma" + } + ], + "name": "param1", + "type": "linked_control" + }, + { + "label": "Quality", + "linked_widgets": [ + { + "node": "fast_blur_shader", + "widget": "quality" + } + ], + "name": "param2", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "param0": 11, + "param1": 2, + "param2": 1 + }, + "shortdesc": "", + "type": "graph" + }, + { + "name": "fast_blur_2", + "node_position": { + "x": 167.156082, + "y": 638.560974 + }, + "parameters": { + "param0": 11, + "param1": 5, + "param2": 1 + }, + "type": "fast_blur" + }, + { + "name": "fast_blur_3", + "node_position": { + "x": 171.701691, + "y": 756.742798 + }, + "parameters": { + "param0": 11, + "param1": 8, + "param2": 1 + }, + "type": "fast_blur" + }, + { + "name": "fast_blur_4", + "node_position": { + "x": 167.377045, + "y": 877.651917 + }, + "parameters": { + "param0": 11, + "param1": 16, + "param2": 1 + }, + "type": "fast_blur" + }, + { + "name": "fast_blur_5", + "node_position": { + "x": 170.104279, + "y": 992.197327 + }, + "parameters": { + "param0": 11, + "param1": 34, + "param2": 1 + }, + "type": "fast_blur" + }, + { + "name": "buffer_2", + "node_position": { + "x": -426.44928, + "y": 678.75 + }, + "parameters": { + "filter": false, + "mipmap": false, + "size": 11 + }, + "type": "buffer", + "version": 2 + } + ], + "parameters": { + "param0": 11, + "param2": 1 + }, + "shortdesc": "Smooth Curvature", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature2.mmg new file mode 100644 index 00000000..71314606 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/smooth_curvature2.mmg @@ -0,0 +1,475 @@ +{ + "connections": [ + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer", + "to_port": 0 + }, + { + "from": "buffer", + "from_port": 0, + "to": "switch", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "switch", + "to_port": 0 + }, + { + "from": "598", + "from_port": 0, + "to": "buffer_2", + "to_port": 0 + }, + { + "from": "buffer_2", + "from_port": 0, + "to": "switch_2", + "to_port": 1 + }, + { + "from": "598", + "from_port": 0, + "to": "switch_2", + "to_port": 0 + }, + { + "from": "switch_2", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "switch", + "from_port": 0, + "to": "598", + "to_port": 0 + } + ], + "label": "Smooth Curvature 2", + "longdesc": "", + "name": "smooth_curvature2", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer", + "node_position": { + "x": 300.603302, + "y": -549.522034 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + }, + { + "name": "598", + "node_position": { + "x": 286.999847, + "y": -359.903259 + }, + "parameters": { + "quality": 4, + "radius": 1, + "strength": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.5", + "function": true, + "label": "", + "name": "in", + "type": "f" + } + ], + "instance": "float $(name)_curve( vec2 p, vec2 o ){\n\tfloat a = $in(p+o);\n\tfloat b = $in(p-o);\n\tfloat c = $in(p+o*vec2(1.0,-1.0));\n\tfloat d = $in(p-o*vec2(1.0,-1.0));\n\treturn -a - b - c - d;\n}\n\nfloat $(name)_curvature_map(vec2 p, float r, float q){\n\tfloat s = r/q;\n\tfloat H = $in(p)*4.0;\n\tfloat v = 0.0;\n\tvec2 o;\n\tfor( o.x = 0.0; o.x < q; o.x++ ){\n\t\tfor( o.y = 0.0; o.y < q; o.y++ ){\n\t\t\tfloat c = $(name)_curve(p, o*s);\n\t\t\tv += (H + c) * ((r-length(o*s)) / r);\n\t\t}\n\t}\n\treturn v/(q*q);\n}\n\nfloat $(name)_curvature(vec2 uv, float quality, float strength, float radius) {\n\tfloat c = $(name)_curvature_map(uv, 0.050 * radius, quality)*strength / radius;\n\treturn 0.5 + c;\n}", + "name": "Smooth Curvature", + "outputs": [ + { + "f": "$(name)_curvature($uv, $quality, $strength, $radius)", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "Quality", + "longdesc": "How many times the input is sampled to generate the curvature map", + "max": 16, + "min": 2, + "name": "quality", + "shortdesc": "Quality", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Strength", + "longdesc": "The intensity of the curvature map", + "max": 2, + "min": 0, + "name": "strength", + "shortdesc": "Strength", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Radius", + "longdesc": "The radius of the smoothing of the curvature effect", + "max": 2, + "min": 0, + "name": "radius", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Smooth Curvature" + }, + "type": "shader" + }, + { + "name": "gen_parameters", + "node_position": { + "x": 242.146149, + "y": -788.088806 + }, + "parameters": { + "param0": 10, + "param1": 4, + "param2": 1, + "param3": 1, + "param4": 1 + }, + "type": "remote", + "widgets": [ + { + "label": "Size", + "linked_widgets": [ + { + "node": "buffer", + "widget": "size" + }, + { + "node": "buffer_2", + "widget": "size" + } + ], + "longdesc": "The resolution of the curvature map if buffer is used", + "name": "param0", + "shortdesc": "Size", + "type": "linked_control" + }, + { + "label": "Quality", + "linked_widgets": [ + { + "node": "598", + "widget": "quality" + } + ], + "longdesc": "How many times the input is sampled to generate the curvature map", + "name": "param1", + "shortdesc": "Quality", + "type": "linked_control" + }, + { + "label": "Strength", + "linked_widgets": [ + { + "node": "598", + "widget": "strength" + } + ], + "longdesc": "The intensity of the curvature map", + "name": "param2", + "shortdesc": "Strength", + "type": "linked_control" + }, + { + "label": "Radius", + "linked_widgets": [ + { + "node": "598", + "widget": "radius" + } + ], + "longdesc": "The radius of the smoothing of the curvature effect", + "name": "param3", + "shortdesc": "Radius", + "type": "linked_control" + }, + { + "configurations": { + "False": [ + { + "node": "switch", + "value": 0, + "widget": "source" + }, + { + "node": "switch_2", + "value": 0, + "widget": "source" + } + ], + "True": [ + { + "node": "switch", + "value": 1, + "widget": "source" + }, + { + "node": "switch_2", + "value": 1, + "widget": "source" + } + ] + }, + "label": "Buffer", + "linked_widgets": [ + { + "node": "switch", + "widget": "source" + }, + { + "node": "switch_2", + "widget": "source" + } + ], + "longdesc": "When set, a buffer is used to sample the input before the normal map filter", + "name": "param4", + "shortdesc": "Buffer", + "type": "config_control" + } + ] + }, + { + "name": "gen_inputs", + "node_position": { + "x": -135.453888, + "y": -518.927429 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "The input height map", + "name": "Heightmap", + "shortdesc": "Input", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": 586.203247, + "y": -534.919678 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "longdesc": "Shows the generated curvature map", + "name": "Curvature", + "shortdesc": "Output", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "switch", + "node_position": { + "x": 310.739746, + "y": -451.658417 + }, + "parameters": { + "choices": 2, + "outputs": 1, + "source": 1 + }, + "type": "switch" + }, + { + "name": "buffer_2", + "node_position": { + "x": 293.839874, + "y": -225.201691 + }, + "parameters": { + "lod": 0, + "size": 10 + }, + "type": "buffer" + }, + { + "name": "switch_2", + "node_position": { + "x": 312.239838, + "y": -129.465912 + }, + "parameters": { + "choices": 2, + "outputs": 1, + "source": 1 + }, + "type": "switch" + }, + { + "name": "blend", + "node_position": { + "x": 802.064697, + "y": -277.727295 + }, + "parameters": { + "amount": 0.5, + "blend_type": 0 + }, + "shader_model": { + "code": "vec4 $(name_uv)_s1 = $s1($uv);\nvec4 $(name_uv)_s2 = $s2($uv);\nfloat $(name_uv)_a = $amount*$a($uv);\n", + "global": "vec3 blend_normal(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend_dissolve(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\tif (rand(uv) < opacity) {\n\t\treturn c1;\n\t} else {\n\t\treturn c2;\n\t}\n}\n\nvec3 blend_multiply(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend_screen(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend_overlay(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend_overlay_f(c1.x, c2.x), blend_overlay_f(c1.y, c2.y), blend_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend_hard_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend_overlay(uv, c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend_soft_light_f(float c1, float c2) {\n\treturn (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}\n\nvec3 blend_soft_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend_soft_light_f(c1.x, c2.x), blend_soft_light_f(c1.y, c2.y), blend_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend_burn(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend_burn_f(c1.x, c2.x), blend_burn_f(c1.y, c2.y), blend_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nfloat blend_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend_dodge(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*vec3(blend_dodge_f(c1.x, c2.x), blend_dodge_f(c1.y, c2.y), blend_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n}\n\nvec3 blend_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n", + "inputs": [ + { + "default": "vec4(round($uv.x) , 1.0, 1.0, 1.0)", + "label": "Source1", + "longdesc": "The foreground input", + "name": "s1", + "shortdesc": "Foreground", + "type": "rgba" + }, + { + "default": "vec4(1.0, $uv.y, 1.0, 1.0)", + "label": "Source2", + "longdesc": "The background input", + "name": "s2", + "shortdesc": "Background", + "type": "rgba" + }, + { + "default": "1.0", + "label": "Opacity", + "longdesc": "The optional opacity mask", + "name": "a", + "shortdesc": "Mask", + "type": "f" + } + ], + "instance": "", + "longdesc": "Blends its input, using an optional mask", + "name": "Blend", + "outputs": [ + { + "longdesc": "Shows the result of the blend operation", + "rgba": "vec4(blend_$blend_type($uv, $(name_uv)_s1.rgb, $(name_uv)_s2.rgb, $(name_uv)_a*$(name_uv)_s1.a), min(1.0, $(name_uv)_s2.a+$(name_uv)_a*$(name_uv)_s1.a))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "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": "Dissolve", + "value": "dissolve" + }, + { + "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.01, + "type": "float" + } + ], + "shortdesc": "Blend" + }, + "type": "shader" + } + ], + "parameters": { + "param0": 10, + "param1": 4, + "param2": 1, + "param3": 1, + "param4": 1 + }, + "shortdesc": "Smooth Curvature", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/sphere.mmg b/game/addons/mat_maker_gd/material_maker_nodes/sphere.mmg new file mode 100644 index 00000000..8371e2da --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/sphere.mmg @@ -0,0 +1,68 @@ +{ + "name": "sphere", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "cx": 0.5, + "cy": 0.5, + "r": 0.5 + }, + "shader_model": { + "code": "", + "global": "float sphere(vec2 uv, vec2 c, float r) {\n\tuv -= c;\n\tuv /= r;\n\treturn 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv)));\n}\n", + "inputs": [ + + ], + "instance": "", + "name": "Sphere", + "outputs": [ + { + "f": "sphere($uv, vec2($cx, $cy), $r)", + "longdesc": "A heightmap of the specified sphere", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "Center X", + "longdesc": "Position of the center along the X axis", + "max": 1, + "min": 0, + "name": "cx", + "shortdesc": "Center.x", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Center Y", + "longdesc": "Position of the center along the Y axis", + "max": 1, + "min": 0, + "name": "cy", + "shortdesc": "Center.y", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Radius", + "longdesc": "Radius of the sphere", + "max": 1, + "min": 0, + "name": "r", + "shortdesc": "Radius", + "step": 0.01, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/splatter.mmg b/game/addons/mat_maker_gd/material_maker_nodes/splatter.mmg new file mode 100644 index 00000000..fe3742a9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/splatter.mmg @@ -0,0 +1,162 @@ +{ + "name": "splatter", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 25, + "rotate": 0, + "scale": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "value": 0 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rch = splatter_$(name)($uv, int($count), vec2(float($seed)));", + "global": "", + "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" + } + ], + "instance": "vec4 splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tfloat c = 0.0;\n\tvec3 rc = vec3(0.0);\n\tvec3 rc1;\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\trc1 = rand3(seed);\n\t\tfloat mask = $mask(fract(seed+vec2(0.5)));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = fract(uv - seed)-vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\tpv += vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tvec2 clamped_pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\tif (pv.x != clamped_pv.x || pv.y != clamped_pv.y) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t$select_inputs\n\t\t\tfloat c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask*(1.0-$value*seed.x);\n\t\t\tc = max(c, c1);\n\t\t\trc = mix(rc, rc1, step(c, c1));\n\t\t}\n\t}\n\treturn vec4(rc, c);\n}\n", + "longdesc": "Spreads several occurences of an input image randomly.", + "name": "Splatter", + "outputs": [ + { + "f": "$(name_uv)_rch.a", + "longdesc": "Shows the generated pattern", + "shortdesc": "Output", + "type": "f" + }, + { + "longdesc": "Shows a random color for each instance of the input image", + "rgb": "$(name_uv)_rch.rgb", + "shortdesc": "Instance map", + "type": "rgb" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "longdesc": "The number of occurences of the input image", + "max": 100, + "min": 1, + "name": "count", + "shortdesc": "Count", + "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": 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" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Value", + "longdesc": "The random greyscale value applied to each image instance", + "max": 1, + "min": 0, + "name": "value", + "shortdesc": "RndValue", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Variations", + "longdesc": "Check to splat variations of the input", + "name": "variations", + "shortdesc": "Variations", + "type": "boolean" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/splatter_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/splatter_color.mmg new file mode 100644 index 00000000..77525b32 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/splatter_color.mmg @@ -0,0 +1,156 @@ +{ + "name": "splatter_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 25, + "opacity": 0, + "rotate": 0, + "scale": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(0.0, 0.0, 0.0, 0.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" + } + ], + "instance": "vec4 splatter_$(name)(vec2 uv, int count, vec2 seed) {\n\tvec4 c = vec4(0.0);\n\tfor (int i = 0; i < count; ++i) {\n\t\tseed = rand2(seed);\n\t\tfloat mask = $mask(fract(seed+vec2(0.5)));\n\t\tif (mask > 0.01) {\n\t\t\tvec2 pv = fract(uv - seed)-vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\tfloat ca = cos(angle);\n\t\t\tfloat sa = sin(angle);\n\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\tpv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\tpv += vec2(0.5);\n\t\t\tseed = rand2(seed);\n\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t$select_inputs\n\t\t\tvec4 n = $in.variation(pv, $variations ? seed.x : 0.0);\n\t\t\tfloat na = n.a*mask*(1.0-$opacity*seed.x);\n\t\t\tfloat a = (1.0-c.a)*(1.0*na);\n\t\t\tc = mix(c, n, na);\n\t\t}\n\t}\n\treturn c;\n}\n", + "longdesc": "Spreads several occurences of an input image randomly.", + "name": "Color Splatter", + "outputs": [ + { + "longdesc": "Shows the generated pattern", + "rgba": "splatter_$(name)($uv, int($count), vec2(float($seed)))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 10, + "label": "Count", + "longdesc": "The number of occurences of the input image", + "max": 100, + "min": 1, + "name": "count", + "shortdesc": "Count", + "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": 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" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Opacity", + "longdesc": "The random opacity applied to each image instance", + "max": 1, + "min": 0, + "name": "opacity", + "shortdesc": "RndOpacity", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Variations", + "longdesc": "Check to splat variations of the input", + "name": "variations", + "shortdesc": "Variations", + "type": "boolean" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/supersample.mmg b/game/addons/mat_maker_gd/material_maker_nodes/supersample.mmg new file mode 100644 index 00000000..9c16bbc4 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/supersample.mmg @@ -0,0 +1,76 @@ +{ + "name": "supersample", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "count": 2, + "size": 9, + "width": 1 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0, 1.0, 1.0, 1.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "vec4 supersample_$(name)(vec2 uv, float size, int count, float width) {\n\tvec4 rv = vec4(0.0);\n\tvec2 step_size = vec2(width)/size/float(count);\n\tuv -= vec2(0.5)/size;\n\tfor (int x = 0; x < count; ++x) {\n\t\tfor (int y = 0; y < count; ++y) {\n\t\t\trv += $in(uv+(vec2(float(x), float(y))+vec2(0.5))*step_size);\n\t\t}\n\t}\n\treturn rv/float(count*count);\n}", + "longdesc": "A filter that samples sub-pixel details to make them visible", + "name": "Supersample", + "outputs": [ + { + "longdesc": "Shows the supersampled image. Due to the performance cost of this node, it is recommended to connect a buffer directly to this output.", + "rgba": "supersample_$(name)($uv, $size, int($count), $width)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 10, + "first": 4, + "label": "Size", + "last": 12, + "longdesc": "The resolution of the output", + "name": "size", + "shortdesc": "Size", + "type": "size" + }, + { + "control": "None", + "default": 2, + "label": "Count", + "longdesc": "The number of samples on each axis. High values will badly impact performances.", + "max": 5, + "min": 2, + "name": "count", + "shortdesc": "Count", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "longdesc": "The width of the sampled area. Setting this value higher than 1 will sample neighbouring pixels and antialias the result.", + "max": 2, + "min": 1, + "name": "width", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Supersample" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/swap_channels.mmg b/game/addons/mat_maker_gd/material_maker_nodes/swap_channels.mmg new file mode 100644 index 00000000..0f750f6a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/swap_channels.mmg @@ -0,0 +1,242 @@ +{ + "name": "swap_channels", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "out_a": 8, + "out_b": 6, + "out_g": 4, + "out_r": 2 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "longdesc": "The input RGBA image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Swaps the channels of its RGBA input", + "name": "Swap channels", + "outputs": [ + { + "longdesc": "The output RGBA image", + "rgba": "vec4($out_r,$out_g,$out_b,$out_a)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 2, + "label": "R", + "longdesc": "The input channel to be assigned to the Red channel", + "name": "out_r", + "shortdesc": "Red", + "type": "enum", + "values": [ + { + "name": "0", + "value": "0.0" + }, + { + "name": "1", + "value": "1.0" + }, + { + "name": "R", + "value": "$in($uv).r" + }, + { + "name": "-R", + "value": "1.0-$in($uv).r" + }, + { + "name": "G", + "value": "$in($uv).g" + }, + { + "name": "-G", + "value": "1.0-$in($uv).g" + }, + { + "name": "B", + "value": "$in($uv).b" + }, + { + "name": "-B", + "value": "1.0-$in($uv).b" + }, + { + "name": "A", + "value": "$in($uv).a" + }, + { + "name": "-A", + "value": "1.0-$in($uv).a" + } + ] + }, + { + "default": 4, + "label": "G", + "longdesc": "The input channel to be assigned to the Green channel", + "name": "out_g", + "shortdesc": "Green", + "type": "enum", + "values": [ + { + "name": "0", + "value": "0.0" + }, + { + "name": "1", + "value": "1.0" + }, + { + "name": "R", + "value": "$in($uv).r" + }, + { + "name": "-R", + "value": "1.0-$in($uv).r" + }, + { + "name": "G", + "value": "$in($uv).g" + }, + { + "name": "-G", + "value": "1.0-$in($uv).g" + }, + { + "name": "B", + "value": "$in($uv).b" + }, + { + "name": "-B", + "value": "1.0-$in($uv).b" + }, + { + "name": "A", + "value": "$in($uv).a" + }, + { + "name": "-A", + "value": "1.0-$in($uv).a" + } + ] + }, + { + "default": 6, + "label": "B", + "longdesc": "The input channel to be assigned to the Blue channel", + "name": "out_b", + "shortdesc": "Blue", + "type": "enum", + "values": [ + { + "name": "0", + "value": "0.0" + }, + { + "name": "1", + "value": "1.0" + }, + { + "name": "R", + "value": "$in($uv).r" + }, + { + "name": "-R", + "value": "1.0-$in($uv).r" + }, + { + "name": "G", + "value": "$in($uv).g" + }, + { + "name": "-G", + "value": "1.0-$in($uv).g" + }, + { + "name": "B", + "value": "$in($uv).b" + }, + { + "name": "-B", + "value": "1.0-$in($uv).b" + }, + { + "name": "A", + "value": "$in($uv).a" + }, + { + "name": "-A", + "value": "1.0-$in($uv).a" + } + ] + }, + { + "default": 8, + "label": "A", + "longdesc": "The input channel to be assigned to the Alpha channel", + "name": "out_a", + "shortdesc": "Alpha", + "type": "enum", + "values": [ + { + "name": "0", + "value": "0.0" + }, + { + "name": "1", + "value": "1.0" + }, + { + "name": "R", + "value": "$in($uv).r" + }, + { + "name": "-R", + "value": "1.0-$in($uv).r" + }, + { + "name": "G", + "value": "$in($uv).g" + }, + { + "name": "-G", + "value": "1.0-$in($uv).g" + }, + { + "name": "B", + "value": "$in($uv).b" + }, + { + "name": "-B", + "value": "1.0-$in($uv).b" + }, + { + "name": "A", + "value": "$in($uv).a" + }, + { + "name": "-A", + "value": "1.0-$in($uv).a" + } + ] + } + ], + "shortdesc": "Swap channels" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply.mmg new file mode 100644 index 00000000..47984458 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply.mmg @@ -0,0 +1,56 @@ +{ + "name": "tex3d_apply", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "Applies 3D textures to a rendered 3D signed distance function scene.", + "name": "TEX3D Apply", + "outputs": [ + { + "longdesc": "The textured 3D scene", + "rgb": "$t(vec4($uv, $z($uv), $c($uv)))", + "shortdesc": "Output", + "type": "rgb" + } + ], + "parameters": [ + + ], + "shortdesc": "Tex3D Apply" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply_invuvmap.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply_invuvmap.mmg new file mode 100644 index 00000000..f9521ce7 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_apply_invuvmap.mmg @@ -0,0 +1,48 @@ +{ + "name": "tex3d_apply_invuvmap", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "This node applies a 3D texture to an object using its inverse UV map.", + "name": "TEX3D Apply", + "outputs": [ + { + "longdesc": "The generated texture", + "rgb": "$t(vec4($map($uv), 0.0))", + "shortdesc": "Output", + "type": "rgb" + } + ], + "parameters": [ + + ], + "shortdesc": "TEX3D Apply" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_blend.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_blend.mmg new file mode 100644 index 00000000..dd8b5517 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_blend.mmg @@ -0,0 +1,122 @@ +{ + "name": "tex3d_blend", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0.5, + "blend_type": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (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}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_lighten(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_darken(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_difference(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n", + "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" + } + ], + "instance": "", + "longdesc": "Blends its 3D texture inputs, using an optional mask", + "name": "TEX3D Blend", + "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" + } + ], + "shortdesc": "Tex3D Blend" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_colorize.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_colorize.mmg new file mode 100644 index 00000000..ab6b7e63 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_colorize.mmg @@ -0,0 +1,85 @@ +{ + "name": "tex3d_colorize", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "g": { + "interpolation": 1, + "points": [ + { + "a": 1, + "b": 1, + "g": 0, + "pos": 0, + "r": 0 + }, + { + "a": 1, + "b": 0, + "g": 0.46875, + "pos": 1, + "r": 1 + } + ], + "type": "Gradient" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3($uv.x+0.5)", + "label": "", + "longdesc": "The input greyscale 3D texture", + "name": "in", + "shortdesc": "Input", + "type": "tex3d" + } + ], + "instance": "", + "longdesc": "Remaps a greyscale 3D texture to a custom gradient", + "name": "TEX3D Colorize", + "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" + } + ], + "shortdesc": "Tex3D Colorize" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_distort.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_distort.mmg new file mode 100644 index 00000000..7bf96c40 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_distort.mmg @@ -0,0 +1,59 @@ +{ + "name": "tex3d_distort", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "Distort": 0.3 + }, + "shader_model": { + "code": "", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "Distorts its input 3D texture using another 3D texture", + "name": "TEX3D Distort", + "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" + } + ], + "shortdesc": "Tex3D Distort" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_fbm.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_fbm.mmg new file mode 100644 index 00000000..07f2ab43 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_fbm.mmg @@ -0,0 +1,119 @@ +{ + "name": "tex3d_fbm", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "iterations": 1, + "noise": 0, + "persistence": 0.5, + "scale_x": 8, + "scale_y": 8, + "scale_z": 8 + }, + "shader_model": { + "code": "", + "global": "float rand31(vec3 p) {\n\treturn fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123);\n}\nvec3 rand33(vec3 p){\n\tp = vec3( dot(p,vec3(127.1,311.7, 74.7)),\n\t\t\t dot(p,vec3(269.5,183.3,246.1)),\n\t\t\t dot(p,vec3(113.5,271.9,124.6)));\n\n\treturn -1.0 + 2.0*fract(sin(p)*43758.5453123);\n}\n\nfloat tex3d_fbm_value(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\tvec3 f = fract(coord);\n\tfloat p000 = rand31(mod(o, size));\n\tfloat p001 = rand31(mod(o + vec3(0.0, 0.0, 1.0), size));\n\tfloat p010 = rand31(mod(o + vec3(0.0, 1.0, 0.0), size));\n\tfloat p011 = rand31(mod(o + vec3(0.0, 1.0, 1.0), size));\n\tfloat p100 = rand31(mod(o + vec3(1.0, 0.0, 0.0), size));\n\tfloat p101 = rand31(mod(o + vec3(1.0, 0.0, 1.0), size));\n\tfloat p110 = rand31(mod(o + vec3(1.0, 1.0, 0.0), size));\n\tfloat p111 = rand31(mod(o + vec3(1.0, 1.0, 1.0), size));\n\tvec3 t = f * f * (3.0 - 2.0 * f);\n\treturn 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}\n\nfloat tex3d_fbm_perlin(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\tvec3 f = fract(coord);\n\tvec3 v000 = normalize(rand33(mod(o, size))-vec3(0.5));\n\tvec3 v001 = normalize(rand33(mod(o + vec3(0.0, 0.0, 1.0), size))-vec3(0.5));\n\tvec3 v010 = normalize(rand33(mod(o + vec3(0.0, 1.0, 0.0), size))-vec3(0.5));\n\tvec3 v011 = normalize(rand33(mod(o + vec3(0.0, 1.0, 1.0), size))-vec3(0.5));\n\tvec3 v100 = normalize(rand33(mod(o + vec3(1.0, 0.0, 0.0), size))-vec3(0.5));\n\tvec3 v101 = normalize(rand33(mod(o + vec3(1.0, 0.0, 1.0), size))-vec3(0.5));\n\tvec3 v110 = normalize(rand33(mod(o + vec3(1.0, 1.0, 0.0), size))-vec3(0.5));\n\tvec3 v111 = normalize(rand33(mod(o + vec3(1.0, 1.0, 1.0), size))-vec3(0.5));\n\tfloat p000 = dot(v000, f);\n\tfloat p001 = dot(v001, f - vec3(0.0, 0.0, 1.0));\n\tfloat p010 = dot(v010, f - vec3(0.0, 1.0, 0.0));\n\tfloat p011 = dot(v011, f - vec3(0.0, 1.0, 1.0));\n\tfloat p100 = dot(v100, f - vec3(1.0, 0.0, 0.0));\n\tfloat p101 = dot(v101, f - vec3(1.0, 0.0, 1.0));\n\tfloat p110 = dot(v110, f - vec3(1.0, 1.0, 0.0));\n\tfloat p111 = dot(v111, f - vec3(1.0, 1.0, 1.0));\n\tvec3 t = f * f * (3.0 - 2.0 * f);\n\treturn 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);\n}\n\nfloat tex3d_fbm_cellular(vec3 coord, vec3 size, float seed) {\n\tvec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\tvec3 f = fract(coord);\n\tfloat min_dist = 3.0;\n\tfor (float x = -1.0; x <= 1.0; x++) {\n\t\tfor (float y = -1.0; y <= 1.0; y++) {\n\t\t\tfor (float z = -1.0; z <= 1.0; z++) {\n\t\t\t\tvec3 node = 0.4*rand33(mod(o + vec3(x, y, z), size)) + vec3(x, y, z);\n\t\t\t\tfloat dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y + (f - node).z * (f - node).z);\n\t\t\t\tmin_dist = min(min_dist, dist);\n\t\t\t}\n\t\t}\n\t}\n\treturn min_dist;\n}\n", + "inputs": [ + + ], + "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", + "longdesc": "Generates a 3D noise made of several octaves of a simple noise", + "name": "TEX3D FBM", + "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" + } + ], + "shortdesc": "Tex3D FBM" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_from2d.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_from2d.mmg new file mode 100644 index 00000000..7e3f6098 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_from2d.mmg @@ -0,0 +1,40 @@ +{ + "name": "tex3d_from2d", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec3(0.5)", + "label": "", + "longdesc": "The input 2D texture", + "name": "in", + "shortdesc": "Input", + "type": "rgb" + } + ], + "instance": "", + "longdesc": "Creates a 3D texture from a 2D texture", + "name": "TEX3D From2D", + "outputs": [ + { + "longdesc": "The generated 3D texture", + "shortdesc": "Output", + "tex3d": "$in($uv.xy+vec2(0.5))", + "type": "tex3d" + } + ], + "parameters": [ + + ], + "shortdesc": "Tex3D From 2D" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_pattern.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_pattern.mmg new file mode 100644 index 00000000..eb22e846 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_pattern.mmg @@ -0,0 +1,210 @@ +{ + "name": "tex3d_pattern", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "mix": 4, + "x_scale": 2, + "x_wave": 2, + "y_scale": 2, + "y_wave": 2, + "z_scale": 2, + "z_wave": 2 + }, + "shader_model": { + "code": "", + "global": "float wave3d_constant(float x) {\n\treturn 1.0;\n}\n\nfloat wave3d_sine(float x) {\n\treturn 0.5-0.5*cos(3.14159265359*2.0*x);\n}\n\nfloat wave3d_triangle(float x) {\n\tx = fract(x);\n\treturn min(2.0*x, 2.0-2.0*x);\n}\n\nfloat wave3d_sawtooth(float x) {\n\treturn fract(x);\n}\n\nfloat wave3d_square(float x) {\n\treturn (fract(x) < 0.5) ? 0.0 : 1.0;\n}\n\nfloat wave3d_bounce(float x) {\n\tx = 2.0*(fract(x)-0.5);\n\treturn sqrt(1.0-x*x);\n}\n\nfloat mix3d_mul(float x, float y, float z) {\n\treturn x*y*z;\n}\n\nfloat mix3d_add(float x, float y, float z) {\n\treturn min(x+y+z, 1.0);\n}\n\nfloat mix3d_max(float x, float y, float z) {\n\treturn max(max(x, y), z);\n}\n\nfloat mix3d_min(float x, float y, float z) {\n\treturn min(min(x, y), z);\n}\n\nfloat mix3d_xor(float x, float y, float z) {\n\tfloat xy = min(x+y, 2.0-x-y);\n\treturn min(xy+z, 2.0-xy-z);\n}\n\nfloat mix3d_pow(float x, float y, float z) {\n\treturn pow(pow(x, y), z);\n}", + "inputs": [ + + ], + "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}", + "longdesc": "A greyscale 3D texture that combines patterns along all 3 axes", + "name": "TEX3D Pattern", + "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" + } + ], + "shortdesc": "Tex3D Pattern" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_rotate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_rotate.mmg new file mode 100644 index 00000000..2ba116e5 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_rotate.mmg @@ -0,0 +1,77 @@ +{ + "name": "tex3d_rotate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "ax": 0, + "ay": 0, + "az": 0 + }, + "shader_model": { + "code": "", + "global": "vec3 tex3d_rotate(vec3 p, vec3 a) {\n\tvec3 rv;\n\tfloat c;\n\tfloat s;\n\tc = cos(a.x);\n\ts = sin(a.x);\n\trv.x = p.x;\n\trv.y = p.y*c+p.z*s;\n\trv.z = -p.y*s+p.z*c;\n\tc = cos(a.y);\n\ts = sin(a.y);\n\tp.x = rv.x*c+rv.z*s;\n\tp.y = rv.y;\n\tp.z = -rv.x*s+rv.z*c;\n\tc = cos(a.z);\n\ts = sin(a.z);\n\trv.x = p.x*c+p.y*s;\n\trv.y = -p.x*s+p.y*c;\n\trv.z = p.z;\n\treturn rv;\n}\n", + "inputs": [ + { + "default": "vec3(1.0)", + "label": "", + "longdesc": "The input 3D texture", + "name": "in", + "shortdesc": "Input", + "type": "tex3d" + } + ], + "instance": "", + "longdesc": "Rotates a 3D texture", + "name": "TEX3D Rotate", + "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" + } + ], + "shortdesc": "Tex3D Rotate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select.mmg new file mode 100644 index 00000000..d573b554 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select.mmg @@ -0,0 +1,72 @@ +{ + "name": "tex3d_select", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "t": 0.01, + "v": 1 + }, + "shader_model": { + "code": "float $(name_uv)_d = ($uv.w-$v)/$t;", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "Selects a 3D texture for a given color index. This can be used to map several textures into a single 3D scene.", + "name": "TEX3D Select", + "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" + } + ], + "shortdesc": "Tex3D Select" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select_shape.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select_shape.mmg new file mode 100644 index 00000000..a90a2e6e --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tex3d_select_shape.mmg @@ -0,0 +1,69 @@ +{ + "name": "tex3d_select_shape", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "d": 0 + }, + "seed": 0, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "Selects a 3D texture inside, and another outside a shape. This can be used to map several textures into a single 3D scene.", + "name": "TEX3D Shape Select", + "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" + } + ], + "shortdesc": "Tex3D Shape Select" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tile2x2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tile2x2.mmg new file mode 100644 index 00000000..eeaaad82 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tile2x2.mmg @@ -0,0 +1,64 @@ +{ + "name": "tile2x2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "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" + } + ], + "instance": "", + "longdesc": "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.\nAtlases are used by remapping nodes such as CustomUV, Tiler and Splatter.", + "name": "Tile2x2", + "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" + } + ], + "parameters": [ + + ], + "shortdesc": "Tile2x2" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tile2x2_variations.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tile2x2_variations.mmg new file mode 100644 index 00000000..ccbc5b3c --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tile2x2_variations.mmg @@ -0,0 +1,41 @@ +{ + "name": "tile2x2_variations", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "longdesc": "The first input", + "name": "in", + "shortdesc": "Input1", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "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.\nAtlases are used by remapping nodes such as CustomUV, Tiler and Splatter.", + "name": "Tile2x2 Variations", + "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" + } + ], + "parameters": [ + + ], + "shortdesc": "Tile2x2" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tiler.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tiler.mmg new file mode 100644 index 00000000..d734a604 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tiler.mmg @@ -0,0 +1,213 @@ +{ + "name": "tiler", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "fixed_offset": 0, + "offset": 1, + "overlap": 1, + "rotate": 180, + "scale": 0.5, + "scale_x": 0.5, + "scale_y": 0.5, + "select_inputs": 0, + "tx": 20, + "ty": 20, + "value": 2 + }, + "shader_model": { + "code": "vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)));", + "global": "", + "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" + } + ], + "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed) {\n\tfloat c = 0.0;\n\tvec3 rc = vec3(0.0);\n\tvec3 rc1;\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\tvec2 seed = rand2(pos+_seed);\n\t\t\trc1 = rand3(seed);\n\t\t\tpos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\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\tseed = rand2(seed);\n\t\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $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 *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tseed = rand2(seed);\n\t\t\t\tvec2 clamped_pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\t\tif (pv.x != clamped_pv.x || pv.y != clamped_pv.y) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t$select_inputs\n\t\t\t\tfloat c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask*(1.0-$value*seed.x);\n\t\t\t\tc = max(c, c1);\n\t\t\t\trc = mix(rc, rc1, step(c, c1));\n\t\t\t}\n\t\t}\n\t}\n\treturn vec4(rc, c);\n}", + "longdesc": "Tiles several occurences of an input image while adding randomness.", + "name": "Tiler", + "outputs": [ + { + "f": "$(name_uv)_rch.a", + "longdesc": "Shows the generated pattern", + "shortdesc": "Output", + "type": "f" + }, + { + "longdesc": "Shows a random color for each instance of the input image", + "rgb": "$(name_uv)_rch.rgb", + "shortdesc": "Instance map", + "type": "rgb" + } + ], + "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": 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" + }, + { + "control": "None", + "default": 0.5, + "label": "Fixed Offset", + "longdesc": "The relative offset of odd rows", + "max": 1, + "min": 0, + "name": "fixed_offset", + "shortdesc": "FixedOffset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Offset", + "max": 1, + "min": 0, + "name": "offset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Value", + "longdesc": "The random greyscale value applied to each image instance", + "max": 1, + "min": 0, + "name": "value", + "shortdesc": "RndValue", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Variations", + "longdesc": "Check to tile variations of the input", + "name": "variations", + "shortdesc": "Variations", + "type": "boolean" + } + ], + "shortdesc": "Tiler" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced.mmg new file mode 100644 index 00000000..0c4fef88 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced.mmg @@ -0,0 +1,259 @@ +{ + "name": "tiler_advanced", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "overlap": 1, + "rotate": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "translate_x": 0, + "translate_y": 0, + "tx": 4, + "ty": 4, + "variations": false + }, + "seed": 0.488938, + "seed_locked": false, + "shader_model": { + "code": "vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed));", + "global": "", + "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}", + "longdesc": "Tiles several occurences of an input image while adding randomness.", + "name": "Advanced Tiler", + "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" + } + ], + "shortdesc": "Tiler" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced_color.mmg new file mode 100644 index 00000000..4590f575 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tiler_advanced_color.mmg @@ -0,0 +1,256 @@ +{ + "name": "tiler_advanced_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "overlap": 1, + "rotate": 0, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "translate_x": 0, + "translate_y": 0, + "tx": 4, + "ty": 4 + }, + "shader_model": { + "code": "vec2 $(name_uv)_mapuv;\nvec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed), $(name_uv)_mapuv);", + "global": "", + "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", + "longdesc": "Tiles several occurences of an input image while adding randomness.", + "name": "Advanced Tiler Color", + "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" + } + ], + "shortdesc": "Tiler" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tiler_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tiler_color.mmg new file mode 100644 index 00000000..bf73952a --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tiler_color.mmg @@ -0,0 +1,213 @@ +{ + "name": "tiler_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "fixed_offset": 0.5, + "offset": 0.25, + "opacity": 0, + "overlap": 1, + "rotate": 45, + "scale": 0.2, + "scale_x": 1, + "scale_y": 1, + "select_inputs": 0, + "tx": 4, + "ty": 4 + }, + "shader_model": { + "code": "vec3 $(name_uv)_random_color;\nvec4 $(name_uv)_tiled_output = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)), $(name_uv)_random_color);", + "global": "", + "inputs": [ + { + "default": "0.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" + } + ], + "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed, out vec3 random_color) {\n\tvec4 c = vec4(0.0);\n\tvec3 rc = vec3(0.0);\n\tvec3 rc1;\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\tvec2 seed = rand2(pos+_seed);\n\t\t\trc1 = rand3(seed);\n\t\t\tpos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\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\tseed = rand2(seed);\n\t\t\t\tfloat angle = (seed.x * 2.0 - 1.0) * $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 *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\tpv /= vec2($scale_x, $scale_y);\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tpv = clamp(pv, vec2(0.0), vec2(1.0));\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\tseed = rand2(seed);\n\t\t\t\tfloat na = n.a*mask*(1.0-$opacity*seed.x);\n\t\t\t\tfloat a = (1.0-c.a)*(1.0*na);\n\t\t\t\tc = mix(c, n, na);\n\t\t\t\trc = mix(rc, rc1, n.a);\n\t\t\t}\n\t\t}\n\t}\n\trandom_color = rc;\n\treturn c;\n}\n", + "longdesc": "Tiles several occurences of an input image while adding randomness.", + "name": "Color Tiler", + "outputs": [ + { + "longdesc": "Shows the generated pattern", + "rgba": "$(name_uv)_tiled_output", + "shortdesc": "Output", + "type": "rgba" + }, + { + "longdesc": "Shows a random color for each instance of the input image", + "rgb": "$(name_uv)_random_color", + "shortdesc": "Instance Map", + "type": "rgb" + } + ], + "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": 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" + }, + { + "control": "None", + "default": 0.5, + "label": "Fixed Offset", + "longdesc": "The relative offset of odd rows", + "max": 1, + "min": 0, + "name": "fixed_offset", + "shortdesc": "FixedOffset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Offset", + "max": 1, + "min": 0, + "name": "offset", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Rotate", + "longdesc": "The random rotation applied to each image instance", + "max": 180, + "min": 0, + "name": "rotate", + "shortdesc": "RndRotate", + "step": 0.1, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Rnd Scale", + "longdesc": "The random scale applied to each image instance", + "max": 1, + "min": 0, + "name": "scale", + "shortdesc": "RndScale", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Rnd Opacity", + "longdesc": "The random opacity applied to each image instance", + "max": 1, + "min": 0, + "name": "opacity", + "shortdesc": "RndOpacity", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Variations", + "longdesc": "Check to tile variations of the input", + "name": "variations", + "shortdesc": "Variations", + "type": "boolean" + } + ], + "shortdesc": "Color Tiler" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tonality.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tonality.mmg new file mode 100644 index 00000000..f605f491 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tonality.mmg @@ -0,0 +1,79 @@ +{ + "name": "tonality", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "curve": { + "points": [ + { + "ls": 0, + "rs": 1, + "x": 0, + "y": 0 + }, + { + "ls": 1, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "$uv.x", + "label": "", + "longdesc": "The input greyscale image", + "name": "input", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Remaps a greyscale image tonality using a curve", + "name": "Tonality", + "outputs": [ + { + "f": "$curve($input($uv))", + "longdesc": "The remapped greyscale image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": { + "points": [ + { + "ls": 0, + "rs": 1, + "x": 0, + "y": 0 + }, + { + "ls": 1, + "rs": 0, + "x": 1, + "y": 1 + } + ], + "type": "Curve" + }, + "label": "", + "longdesc": "The tonality curve to which the input is remapped", + "name": "curve", + "shortdesc": "Curve", + "type": "curve" + } + ], + "shortdesc": "Tonality" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tones.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tones.mmg new file mode 100644 index 00000000..be161f0c --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tones.mmg @@ -0,0 +1,122 @@ +{ + "name": "levels", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "in_max": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "in_mid": { + "a": 0.5, + "b": 0.5, + "g": 0.5, + "r": 0.5, + "type": "Color" + }, + "in_min": { + "a": 0, + "b": 0, + "g": 0, + "r": 0, + "type": "Color" + }, + "out_max": { + "a": 1, + "b": 1, + "g": 1, + "r": 1, + "type": "Color" + }, + "out_min": { + "a": 0, + "b": 0, + "g": 0, + "r": 0, + "type": "Color" + } + }, + "shader_model": { + "code": "", + "global": "vec4 adjust_levels(vec4 input, vec4 in_min, vec4 in_mid, vec4 in_max, vec4 out_min, vec4 out_max) {\n\tinput = clamp((input-in_min)/(in_max-in_min), 0.0, 1.0);\n\tin_mid = (in_mid-in_min)/(in_max-in_min);\n\tvec4 dark = step(in_mid, input);\n\tinput = 0.5*mix(input/(in_mid), 1.0+(input-in_mid)/(1.0-in_mid), dark);\n\treturn out_min+input*(out_max-out_min);\n}\n", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "name": "input", + "type": "rgba" + } + ], + "instance": "", + "name": "Levels", + "outputs": [ + { + "rgba": "adjust_levels($input($uv), $in_min, $in_mid, $in_max, $out_min, $out_max)", + "type": "rgba" + } + ], + "parameters": [ + { + "default": { + "a": 0, + "b": 0, + "g": 0, + "r": 0 + }, + "label": "", + "name": "in_min", + "type": "color" + }, + { + "default": { + "a": 0.498039, + "b": 0.498039, + "g": 0.498039, + "r": 0.498039 + }, + "label": "", + "name": "in_mid", + "type": "color" + }, + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "", + "name": "in_max", + "type": "color" + }, + { + "default": { + "a": 1, + "b": 0, + "g": 0, + "r": 0 + }, + "label": "", + "name": "out_min", + "type": "color" + }, + { + "default": { + "a": 1, + "b": 1, + "g": 1, + "r": 1 + }, + "label": "", + "name": "out_max", + "type": "color" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tones_map.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tones_map.mmg new file mode 100644 index 00000000..952fc85d --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tones_map.mmg @@ -0,0 +1,90 @@ +{ + "name": "tones_map", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "in_max": 1, + "in_min": 0, + "out_max": 1, + "out_min": 0 + }, + "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": "Maps linearly an input tones interval to an output tones interval.", + "name": "Tones map", + "outputs": [ + { + "longdesc": "Shows the generated remapped image", + "rgba": "vec4(vec3($out_min)+($in($uv).rgb-vec3($in_min))*vec3(($out_max-$out_min)/($in_max-$in_min)), $in($uv).a)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "Input min", + "longdesc": "The minimum value of the input interval", + "max": 1, + "min": 0, + "name": "in_min", + "shortdesc": "InputMin", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Input max", + "longdesc": "The maximum value of the input interval", + "max": 1, + "min": 0, + "name": "in_max", + "shortdesc": "InputMax", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Output min", + "longdesc": "The minimum value of the output interval", + "max": 1, + "min": 0, + "name": "out_min", + "shortdesc": "OutputMin", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Output max", + "longdesc": "The maximum value of the output interval", + "max": 1, + "min": 0, + "name": "out_max", + "shortdesc": "OutputMax", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Tones map" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tones_range.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tones_range.mmg new file mode 100644 index 00000000..eba25413 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tones_range.mmg @@ -0,0 +1,86 @@ +{ + "name": "tones_range", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "contrast": 0.5, + "invert": false, + "value": 0.5, + "width": 0.25 + }, + "shader_model": { + "code": "float $(name_uv)_step = clamp(($in($uv) - ($value))/max(0.0001, $width)+0.5, 0.0, 1.0);\nfloat $(name_uv)_false = clamp((min($(name_uv)_step, 1.0-$(name_uv)_step) * 2.0) / (1.0 - $contrast), 0.0, 1.0);\nfloat $(name_uv)_true = 1.0-$(name_uv)_false;", + "global": "", + "inputs": [ + { + "default": "($uv.x + $uv.y) / 2.0", + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Outputs the tone range around a specified value,", + "name": "Tones Range", + "outputs": [ + { + "f": "$(name_uv)_$invert", + "longdesc": "Shows the generated high contrast image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "Value", + "longdesc": "The center value of the selection", + "max": 1, + "min": 0, + "name": "value", + "shortdesc": "Value", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.25, + "label": "Width", + "longdesc": "The width (in tones space) of the selection area", + "max": 1, + "min": 0, + "name": "width", + "shortdesc": "Width", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.5, + "label": "Contrast", + "longdesc": "Adjusts the falloff of the output", + "max": 1, + "min": 0, + "name": "contrast", + "shortdesc": "Contrast", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Invert", + "longdesc": "Invert the generated image if set", + "name": "invert", + "shortdesc": "Invert", + "type": "boolean" + } + ], + "shortdesc": "Tones Range" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/tones_step.mmg b/game/addons/mat_maker_gd/material_maker_nodes/tones_step.mmg new file mode 100644 index 00000000..af4c0497 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/tones_step.mmg @@ -0,0 +1,73 @@ +{ + "name": "tones_step", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "invert": false, + "value": 0.5, + "width": 0.1 + }, + "shader_model": { + "code": "vec3 $(name_uv)_false = clamp(($in($uv).rgb-vec3($value))/max(0.0001, $width)+vec3(0.5), vec3(0.0), vec3(1.0));\nvec3 $(name_uv)_true = vec3(1.0)-$(name_uv)_false;", + "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": "Emphasizes dark and light tones around a specified value", + "name": "Tones step", + "outputs": [ + { + "longdesc": "Shows the generated high contrast image", + "rgba": "vec4($(name_uv)_$invert, $in($uv).a)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 0.5, + "label": "Value", + "longdesc": "The value of the input that separate dark and light zones of the result", + "max": 1, + "min": 0, + "name": "value", + "shortdesc": "Value", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Width", + "longdesc": "The width (in tones space) of the transition area", + "max": 1, + "min": 0, + "name": "width", + "shortdesc": "width", + "step": 0.01, + "type": "float" + }, + { + "default": false, + "label": "Invert", + "longdesc": "Invert the generated image if set", + "name": "invert", + "shortdesc": "Invert", + "type": "boolean" + } + ], + "shortdesc": "Tones step" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/transform.mmg b/game/addons/mat_maker_gd/material_maker_nodes/transform.mmg new file mode 100644 index 00000000..cf2ef72b --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/transform.mmg @@ -0,0 +1,151 @@ +{ + "name": "transform", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "repeat": false, + "rotate": 0, + "scale_x": 1, + "scale_y": 1, + "translate_x": 0, + "translate_y": 0 + }, + "shader_model": { + "code": "", + "longdesc": "Translates, rotates and scales its input", + "global": "vec2 transform(vec2 uv, vec2 translate, float rotate, vec2 scale, bool repeat) {\n \tvec2 rv;\n\tuv -= translate;\n\tuv -= vec2(0.5);\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv /= scale;\n\trv += vec2(0.5);\n if (repeat) {\n\t\treturn fract(rv);\n\t} else {\n\t\treturn clamp(rv, vec2(0.0), vec2(1.0));\n\t}\t\n}", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be transformed", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for translation along the X axis", + "name": "tx", + "shortdesc": "TranslateMap.x", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for translation along the Y axis", + "name": "ty", + "shortdesc": "TranslateMap.y", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for rotation", + "name": "r", + "shortdesc": "RotateMap", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for scaling along the X axis", + "name": "sx", + "shortdesc": "ScaleMap.x", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for scaling along the Y axis", + "name": "sy", + "shortdesc": "ScaleMap.y", + "type": "f" + } + ], + "instance": "", + "name": "Transform", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$i(transform($uv, vec2($translate_x*(2.0*$tx($uv)-1.0), $translate_y*(2.0*$ty($uv)-1.0)), $rotate*0.01745329251*(2.0*$r($uv)-1.0), vec2($scale_x*(2.0*$sx($uv)-1.0), $scale_y*(2.0*$sy($uv)-1.0)), $repeat))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "2:Translate X:", + "longdesc": "The translation along the X axis", + "max": 1, + "min": -1, + "name": "translate_x", + "shortdesc": "Translate.x", + "step": 0.005, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Translate Y:", + "longdesc": "The translation along the Y axis", + "max": 1, + "min": -1, + "name": "translate_y", + "shortdesc": "Translate.y", + "step": 0.005, + "type": "float" + }, + { + "control": "Radius1.a", + "default": 0, + "label": "Rotate:", + "longdesc": "The rotation angle", + "max": 720, + "min": -720, + "name": "rotate", + "shortdesc": "Rotate", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.x", + "default": 1, + "label": "Scale X:", + "longdesc": "The scaling factor along the X axis", + "max": 50, + "min": 0, + "name": "scale_x", + "shortdesc": "Scale.x", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.y", + "default": 1, + "label": "Scale Y:", + "longdesc": "The scaling factor along the Y axis", + "max": 50, + "min": 0, + "name": "scale_y", + "shortdesc": "Scale.y", + "step": 0.005, + "type": "float" + }, + { + "default": false, + "label": "Repeat:", + "longdesc": "Repeat the input if checked, clamps otherwise", + "name": "repeat", + "shortdesc": "Repeat", + "type": "boolean" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/transform2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/transform2.mmg new file mode 100644 index 00000000..e9188662 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/transform2.mmg @@ -0,0 +1,165 @@ +{ + "name": "transform2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "mode": 0, + "rotate": 0, + "scale_x": 1, + "scale_y": 1, + "translate_x": 0, + "translate_y": 0 + }, + "shader_model": { + "code": "", + "longdesc": "Translates, rotates and scales its input", + "global": "vec2 transform2_clamp(vec2 uv) {\n\treturn clamp(uv, vec2(0.0), vec2(1.0));\n}\n\nvec2 transform2(vec2 uv, vec2 translate, float rotate, vec2 scale) {\n \tvec2 rv;\n\tuv -= translate;\n\tuv -= vec2(0.5);\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv /= scale;\n\trv += vec2(0.5);\n\treturn rv;\t\n}", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image to be transformed", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for translation along the X axis", + "name": "tx", + "shortdesc": "TranslateMap.x", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for translation along the Y axis", + "name": "ty", + "shortdesc": "TranslateMap.y", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for rotation", + "name": "r", + "shortdesc": "RotateMap", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for scaling along the X axis", + "name": "sx", + "shortdesc": "ScaleMap.x", + "type": "f" + }, + { + "default": "1.0", + "label": "", + "longdesc": "An optional map for scaling along the Y axis", + "name": "sy", + "shortdesc": "ScaleMap.y", + "type": "f" + } + ], + "instance": "", + "name": "Transform", + "outputs": [ + { + "longdesc": "Shows the transformed image", + "rgba": "$i($mode(transform2($uv, vec2($translate_x*(2.0*$tx($uv)-1.0), $translate_y*(2.0*$ty($uv)-1.0)), $rotate*0.01745329251*(2.0*$r($uv)-1.0), vec2($scale_x*(2.0*$sx($uv)-1.0), $scale_y*(2.0*$sy($uv)-1.0)))))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "2:Translate X:", + "longdesc": "The translation along the X axis", + "max": 1, + "min": -1, + "name": "translate_x", + "shortdesc": "Translate.x", + "step": 0.005, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Translate Y:", + "longdesc": "The translation along the Y axis", + "max": 1, + "min": -1, + "name": "translate_y", + "shortdesc": "Translate.y", + "step": 0.005, + "type": "float" + }, + { + "control": "Radius1.a", + "default": 0, + "label": "Rotate:", + "longdesc": "The rotation angle", + "max": 720, + "min": -720, + "name": "rotate", + "shortdesc": "Rotate", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.x", + "default": 1, + "label": "Scale X:", + "longdesc": "The scaling factor along the X axis", + "max": 50, + "min": 0, + "name": "scale_x", + "shortdesc": "Scale.x", + "step": 0.005, + "type": "float" + }, + { + "control": "Scale1.y", + "default": 1, + "label": "Scale Y:", + "longdesc": "The scaling factor along the Y axis", + "max": 50, + "min": 0, + "name": "scale_y", + "shortdesc": "Scale.y", + "step": 0.005, + "type": "float" + }, + { + "default": 0, + "label": "Mode", + "longdesc": "Defines the behavior beyond the limits or the input image:\n- Clamp stretches the edges\n- Repeat tiles the input\n- Extend shows parts of the input that are beyond the edges", + "name": "mode", + "shortdesc": "Mode", + "type": "enum", + "values": [ + { + "name": "Clamp", + "value": "transform2_clamp" + }, + { + "name": "Repeat", + "value": "fract" + }, + { + "name": "Extend", + "value": "" + } + ] + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/translate.mmg b/game/addons/mat_maker_gd/material_maker_nodes/translate.mmg new file mode 100644 index 00000000..4c612c4f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/translate.mmg @@ -0,0 +1,64 @@ +{ + "name": "translate", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "translate_x": 0, + "translate_y": 0 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "vec4($uv, 0.0, 1.0)", + "label": "", + "longdesc": "The input image", + "name": "i", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Translates its input", + "name": "Translate", + "outputs": [ + { + "longdesc": "Shows the translated image", + "rgba": "$i($uv-vec2($translate_x, $translate_y))", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "P1.x", + "default": 0, + "label": "Translate X:", + "longdesc": "The translation along the X axis", + "max": 1, + "min": -1, + "name": "translate_x", + "shortdesc": "Translate.x", + "step": 0.005, + "type": "float" + }, + { + "control": "P1.y", + "default": 0, + "label": "Translate Y:", + "longdesc": "The translation along the Y axis", + "max": 1, + "min": -1, + "name": "translate_y", + "shortdesc": "Translate.y", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Translate" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/truchet.mmg b/game/addons/mat_maker_gd/material_maker_nodes/truchet.mmg new file mode 100644 index 00000000..33f42681 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/truchet.mmg @@ -0,0 +1,63 @@ +{ + "name": "truchet", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "shape": 0, + "size": 4 + }, + "shader_model": { + "code": "", + "global": "float truchet1(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv)-vec2(0.5);\n return 1.0-abs(abs((2.0*step(rand(i+seed), 0.5)-1.0)*f.x+f.y)-0.5);\n}\n\nfloat truchet2(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n float random = step(rand(i+seed), 0.5);\n f.x *= 2.0*random-1.0;\n f.x += 1.0-random;\n return 1.0-min(abs(length(f)-0.5), abs(length(1.0-f)-0.5));\n}\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates a truchet pattern", + "name": "Truchet", + "outputs": [ + { + "f": "truchet$shape($uv*$size, vec2(float($seed)))", + "longdesc": "Shows a greyscale image of the truchet pattern.", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "Shape", + "longdesc": "The base shape of each tile of the truchet pattern", + "name": "shape", + "shortdesc": "Shape", + "type": "enum", + "values": [ + { + "name": "Line", + "value": "1" + }, + { + "name": "Circle", + "value": "2" + } + ] + }, + { + "control": "None", + "default": 4, + "label": "Size", + "longdesc": "The number of rows and columns of the truchet pattern", + "max": 64, + "min": 2, + "name": "size", + "shortdesc": "Size", + "step": 1, + "type": "float" + } + ], + "shortdesc": "Truchet pattern" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/truchet_generic.mmg b/game/addons/mat_maker_gd/material_maker_nodes/truchet_generic.mmg new file mode 100644 index 00000000..c529ea83 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/truchet_generic.mmg @@ -0,0 +1,43 @@ +{ + "name": "truchet_generic", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "size": 6 + }, + "shader_model": { + "code": "", + "global": "vec2 truchet_generic_uv(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n\tvec2 invert = step(rand2(seed+i), vec2(0.5));\n return f*(vec2(1.0)-invert)+(vec2(1.0)-f)*invert;\n}\n", + "inputs": [ + { + "default": "vec4(1.0)", + "label": "", + "name": "in", + "type": "rgba" + } + ], + "instance": "", + "name": "Generic Truchet", + "outputs": [ + { + "rgba": "$in(truchet_generic_uv($uv*$size, vec2(float($seed))))", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "Size", + "max": 64, + "min": 2, + "name": "size", + "step": 1, + "type": "float" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/uniform.mmg b/game/addons/mat_maker_gd/material_maker_nodes/uniform.mmg new file mode 100644 index 00000000..b7730ffb --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/uniform.mmg @@ -0,0 +1,50 @@ +{ + "name": "uniform", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "color": { + "a": 1, + "b": 1, + "g": 0.415686, + "r": 0, + "type": "Color" + } + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Draws a uniform image", + "name": "Uniform", + "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" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/uniform_greyscale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/uniform_greyscale.mmg new file mode 100644 index 00000000..0d006d0d --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/uniform_greyscale.mmg @@ -0,0 +1,43 @@ +{ + "name": "uniform_greyscale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "color": 0.5 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + + ], + "instance": "", + "longdesc": "Draws a uniform greyscale image", + "name": "Greyscale Uniform", + "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" + } + ] + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/unity.mat.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/unity.mat.tmpl new file mode 100644 index 00000000..0b45a4dd --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/unity.mat.tmpl @@ -0,0 +1,97 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: test + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords:$(expr:" _METALLICGLOSSMAP" if $(connected:roughness_tex) or $(connected:metallic_tex) else "")$(expr:" _NORMALMAP" if $(connected:normal_tex) else "")$(expr:" _PARALLAXMAP" if $(connected:depth_tex) else "") + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: +$if $(connected:normal_tex) + m_Texture: {fileID: 2800000, guid: $(uid:2), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: +$if $(connected:albedo_tex) + m_Texture: {fileID: 2800000, guid: $(uid:0), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: +$if $(connected:roughness_tex) or $(connected:metallic_tex) + m_Texture: {fileID: 2800000, guid: $(uid:1), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: +$if $(connected:ao_tex) + m_Texture: {fileID: 2800000, guid: $(uid:4), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: +$if $(connected:depth_tex) + m_Texture: {fileID: 2800000, guid: $(uid:3), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/game/addons/mat_maker_gd/material_maker_nodes/unity.png.meta.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/unity.png.meta.tmpl new file mode 100644 index 00000000..7321aa3d --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/unity.png.meta.tmpl @@ -0,0 +1,91 @@ +fileFormatVersion: 2 +guid: $(file_param:uid) +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 10 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: $(file_param:srgb) + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: $(file_param:normal) + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/addons/mat_maker_gd/material_maker_nodes/unity_hdrp.mat.tmpl b/game/addons/mat_maker_gd/material_maker_nodes/unity_hdrp.mat.tmpl new file mode 100644 index 00000000..f0d872df --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/unity_hdrp.mat.tmpl @@ -0,0 +1,288 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: test + m_Shader: {fileID: 4800000, guid: 6e4ae4064600d784cac1e41a9e6f2e59, type: 3} + m_ShaderKeywords: _NORMALMAP_TANGENT_SPACE$(expr:" _NORMALMAP" if $(connected:normal_tex) else "")$(expr:" _HEIGHTMAP _PIXEL_DISPLACEMENT _PIXEL_DISPLACEMENT_LOCK_OBJECT_SCALE _DISPLACEMENT_LOCK_TILING_SCALE" if $(connected:depth_tex) else "")$(expr:" _MASKMAP" if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex) else "")$(expr:" _EMISSIVE_COLOR_MAP" if $(connected:emission_tex) else "") + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: + - DistortionVectors + - MOTIONVECTORS + - TransparentDepthPrepass + - TransparentDepthPostpass + - TransparentBackface + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _AnisotropyMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BaseColorMap: +$if $(connected:albedo_tex) + m_Texture: {fileID: 2800000, guid: $(uid:0), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BentNormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _CoatMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DistortionVectorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissiveColorMap: +$if $(connected:emission_tex) + m_Texture: {fileID: 2800000, guid: $(uid:4), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _HeightMap: +$if $(connected:depth_tex) + m_Texture: {fileID: 2800000, guid: $(uid:3), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _IridescenceThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: +$if $(connected:albedo_tex) + m_Texture: {fileID: 2800000, guid: $(uid:0), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MaskMap: +$if $(connected:ao_tex) or $(connected:roughness_tex) or $(connected:metallic_tex) + m_Texture: {fileID: 2800000, guid: $(uid:1), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMap: +$if $(connected:normal_tex) + m_Texture: {fileID: 2800000, guid: $(uid:2), type: 3} +$else + m_Texture: {fileID: 0} +$fi + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _NormalMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SpecularColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _SubsurfaceMaskMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TangentMapOS: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ThicknessMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _TransmittanceColorMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _AORemapMax: 1 + - _AORemapMin: 0 + - _ATDistance: 1 + - _AddPrecomputedVelocity: 0 + - _AlbedoAffectEmissive: 0 + - _AlphaCutoff: 0.5 + - _AlphaCutoffEnable: 0 + - _AlphaCutoffPostpass: 0.5 + - _AlphaCutoffPrepass: 0.5 + - _AlphaCutoffShadow: 0.5 + - _AlphaDstBlend: 0 + - _AlphaSrcBlend: 1 + - _Anisotropy: 0 + - _BlendMode: 0 + - _CoatMask: 0 + - _CullMode: 2 + - _CullModeForward: 2 + - _Cutoff: 0.5 + - _DepthOffsetEnable: 0 + - _DetailAlbedoScale: 1 + - _DetailNormalScale: 1 + - _DetailSmoothnessScale: 1 + - _DiffusionProfile: 0 + - _DiffusionProfileHash: 0 + - _DisplacementLockObjectScale: 1 + - _DisplacementLockTilingScale: 1 +$if $(connected:depth_tex) + - _DisplacementMode: 2 +$else + - _DisplacementMode: 0 +$fi + - _DistortionBlendMode: 0 + - _DistortionBlurBlendMode: 0 + - _DistortionBlurDstBlend: 1 + - _DistortionBlurRemapMax: 1 + - _DistortionBlurRemapMin: 0 + - _DistortionBlurScale: 1 + - _DistortionBlurSrcBlend: 1 + - _DistortionDepthTest: 1 + - _DistortionDstBlend: 1 + - _DistortionEnable: 0 + - _DistortionScale: 1 + - _DistortionSrcBlend: 1 + - _DistortionVectorBias: -1 + - _DistortionVectorScale: 2 + - _DoubleSidedEnable: 0 + - _DoubleSidedNormalMode: 1 + - _DstBlend: 0 + - _EmissiveColorMode: 1 + - _EmissiveExposureWeight: 1 + - _EmissiveIntensity: 1 + - _EmissiveIntensityUnit: 0 + - _EnableBlendModePreserveSpecularLighting: 1 + - _EnableFogOnTransparent: 1 + - _EnableGeometricSpecularAA: 0 + - _EnergyConservingSpecularColor: 1 + - _HeightAmplitude: $(expr:0.08*$(param:depth_scale)) + - _HeightCenter: 1 + - _HeightMapParametrization: 0 + - _HeightMax: 1 + - _HeightMin: -1 + - _HeightOffset: 0 + - _HeightPoMAmplitude: $(expr:8*$(param:depth_scale)) + - _HeightTessAmplitude: 2 + - _HeightTessCenter: 0.5 + - _InvTilingScale: 1 + - _Ior: 1.5 + - _IridescenceMask: 1 + - _IridescenceThickness: 1 + - _LinkDetailsWithBase: 1 + - _MaterialID: 1 + - _Metallic: $(param:metallic) + - _NormalMapSpace: 0 + - _NormalScale: $(param:normal) + - _PPDLodThreshold: 5 + - _PPDMaxSamples: 15 + - _PPDMinSamples: 5 + - _PPDPrimitiveLength: 1 + - _PPDPrimitiveWidth: 1 + - _ReceivesSSR: 1 + - _RefractionModel: 0 + - _SSRefractionProjectionModel: 0 + - _Smoothness: 1 + - _SmoothnessRemapMax: 1 + - _SmoothnessRemapMin: $(expr:1-$(param:roughness)) + - _SpecularAAScreenSpaceVariance: 0.1 + - _SpecularAAThreshold: 0.2 + - _SpecularOcclusionMode: 1 + - _SrcBlend: 1 + - _StencilRef: 0 + - _StencilRefDepth: 8 + - _StencilRefDistortionVec: 4 + - _StencilRefGBuffer: 10 + - _StencilRefMV: 40 + - _StencilWriteMask: 6 + - _StencilWriteMaskDepth: 8 + - _StencilWriteMaskDistortionVec: 4 + - _StencilWriteMaskGBuffer: 14 + - _StencilWriteMaskMV: 40 + - _SubsurfaceMask: 1 + - _SupportDecals: 1 + - _SurfaceType: 0 + - _TexWorldScale: 1 + - _TexWorldScaleEmissive: 1 + - _Thickness: 1 + - _TransmissionEnable: 1 + - _TransparentBackfaceEnable: 0 + - _TransparentCullMode: 2 + - _TransparentDepthPostpassEnable: 0 + - _TransparentDepthPrepassEnable: 0 + - _TransparentSortPriority: 0 + - _TransparentWritingMotionVec: 0 + - _TransparentZWrite: 0 + - _UVBase: 0 + - _UVDetail: 0 + - _UVEmissive: 0 + - _UseEmissiveIntensity: 0 + - _UseShadowThreshold: 0 + - _ZTestDepthEqualForOpaque: 3 + - _ZTestGBuffer: 4 + - _ZTestModeDistortion: 4 + - _ZTestTransparent: 4 + - _ZWrite: 1 + m_Colors: + - _BaseColor: {r: 1, g: 1, b: 1, a: 1} + - _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0} + - _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0} + - _EmissionColor: {r: 1, g: 1, b: 1, a: 1} + - _EmissiveColor: {r: 0, g: 0, b: 0, a: 1} + - _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1} + - _InvPrimScale: {r: 1, g: 1, b: 0, a: 0} + - _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _SpecularColor: {r: 1, g: 1, b: 1, a: 1} + - _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0} + - _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1} + - _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMask: {r: 1, g: 0, b: 0, a: 0} + - _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0} +--- !u!114 &8466335806480081788 +MonoBehaviour: + m_ObjectHideFlags: 11 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3} + m_Name: + m_EditorClassIdentifier: + version: 2 diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_color.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_color.mmg new file mode 100644 index 00000000..f60644f7 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_color.mmg @@ -0,0 +1,65 @@ +{ + "name": "variations_color", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec3(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgb" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "rgb": "$in.variation($uv, $seed)", + "shortdesc": "Output1", + "type": "rgb" + }, + { + "longdesc": "Shows a variation of the input", + "rgb": "$in.variation($uv, $seed+0.1)", + "shortdesc": "Output2", + "type": "rgb" + }, + { + "longdesc": "Shows a variation of the input", + "rgb": "$in.variation($uv, $seed+0.2)", + "shortdesc": "Output3", + "type": "rgb" + }, + { + "longdesc": "Shows a variation of the input", + "rgb": "$in.variation($uv, $seed+0.3)", + "shortdesc": "Output4", + "type": "rgb" + }, + { + "longdesc": "Shows a variation of the input", + "rgb": "$in.variation($uv, $seed+0.4)", + "shortdesc": "Output5", + "type": "rgb" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_greyscale.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_greyscale.mmg new file mode 100644 index 00000000..e5eeec8f --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_greyscale.mmg @@ -0,0 +1,65 @@ +{ + "name": "variations_greyscale", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "f": "$in.variation($uv, $seed)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output1", + "type": "f" + }, + { + "f": "$in.variation($uv, $seed+0.1)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output2", + "type": "f" + }, + { + "f": "$in.variation($uv, $seed+0.2)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output3", + "type": "f" + }, + { + "f": "$in.variation($uv, $seed+0.3)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output4", + "type": "f" + }, + { + "f": "$in.variation($uv, $seed+0.4)", + "longdesc": "Shows a variation of the input", + "shortdesc": "Output5", + "type": "f" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_rgba.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_rgba.mmg new file mode 100644 index 00000000..05946dc9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_rgba.mmg @@ -0,0 +1,65 @@ +{ + "name": "variations_rgba", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "rgba": "$in.variation($uv, $seed)", + "shortdesc": "Output1", + "type": "rgba" + }, + { + "longdesc": "Shows a variation of the input", + "rgba": "$in.variation($uv, $seed+0.1)", + "shortdesc": "Output2", + "type": "rgba" + }, + { + "longdesc": "Shows a variation of the input", + "rgba": "$in.variation($uv, $seed+0.2)", + "shortdesc": "Output3", + "type": "rgba" + }, + { + "longdesc": "Shows a variation of the input", + "rgba": "$in.variation($uv, $seed+0.3)", + "shortdesc": "Output4", + "type": "rgba" + }, + { + "longdesc": "Shows a variation of the input", + "rgba": "$in.variation($uv, $seed+0.4)", + "shortdesc": "Output5", + "type": "rgba" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf2d.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf2d.mmg new file mode 100644 index 00000000..84cf68a1 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf2d.mmg @@ -0,0 +1,67 @@ +{ + "name": "variations_sdf2d", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "seed": 0.660085, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "sdf2d" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "sdf2d": "$in.variation($uv, $seed)", + "shortdesc": "Output1", + "type": "sdf2d" + }, + { + "longdesc": "Shows a variation of the input", + "sdf2d": "$in.variation($uv, $seed+0.1)", + "shortdesc": "Output2", + "type": "sdf2d" + }, + { + "longdesc": "Shows a variation of the input", + "sdf2d": "$in.variation($uv, $seed+0.2)", + "shortdesc": "Output3", + "type": "sdf2d" + }, + { + "longdesc": "Shows a variation of the input", + "sdf2d": "$in.variation($uv, $seed+0.3)", + "shortdesc": "Output4", + "type": "sdf2d" + }, + { + "longdesc": "Shows a variation of the input", + "sdf2d": "$in.variation($uv, $seed+0.4)", + "shortdesc": "Output5", + "type": "sdf2d" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf3dc.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf3dc.mmg new file mode 100644 index 00000000..30f940fd --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_sdf3dc.mmg @@ -0,0 +1,67 @@ +{ + "name": "variations_sdf3dc", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "seed": 0.846412, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "sdf3dc" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "sdf3dc": "$in.variation($uv, $seed)", + "shortdesc": "Output1", + "type": "sdf3dc" + }, + { + "longdesc": "Shows a variation of the input", + "sdf3dc": "$in.variation($uv, $seed+0.1)", + "shortdesc": "Output2", + "type": "sdf3dc" + }, + { + "longdesc": "Shows a variation of the input", + "sdf3dc": "$in.variation($uv, $seed+0.2)", + "shortdesc": "Output3", + "type": "sdf3dc" + }, + { + "longdesc": "Shows a variation of the input", + "sdf3dc": "$in.variation($uv, $seed+0.3)", + "shortdesc": "Output4", + "type": "sdf3dc" + }, + { + "longdesc": "Shows a variation of the input", + "sdf3dc": "$in.variation($uv, $seed+0.4)", + "shortdesc": "Output5", + "type": "sdf3dc" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/variations_tex3d.mmg b/game/addons/mat_maker_gd/material_maker_nodes/variations_tex3d.mmg new file mode 100644 index 00000000..a1482428 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/variations_tex3d.mmg @@ -0,0 +1,67 @@ +{ + "name": "variations_tex3d", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + + }, + "seed": 0.660085, + "seed_locked": false, + "shader_model": { + "code": "", + "global": "vec2 rotate(vec2 uv, vec2 center, float rotate) {\n \tvec2 rv;\n\tuv -= center;\n\trv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;\n\trv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;\n\trv += center;\n return rv;\t\n}", + "inputs": [ + { + "default": "vec4(0.0)", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "tex3d" + } + ], + "instance": "", + "longdesc": "Generates variations for its input", + "name": "Variations", + "outputs": [ + { + "longdesc": "Shows a variation of the input", + "shortdesc": "Output1", + "tex3d": "$in.variation($uv, $seed)", + "type": "tex3d" + }, + { + "longdesc": "Shows a variation of the input", + "shortdesc": "Output2", + "tex3d": "$in.variation($uv, $seed+0.1)", + "type": "tex3d" + }, + { + "longdesc": "Shows a variation of the input", + "shortdesc": "Output3", + "tex3d": "$in.variation($uv, $seed+0.2)", + "type": "tex3d" + }, + { + "longdesc": "Shows a variation of the input", + "shortdesc": "Output4", + "tex3d": "$in.variation($uv, $seed+0.3)", + "type": "tex3d" + }, + { + "longdesc": "Shows a variation of the input", + "shortdesc": "Output5", + "tex3d": "$in.variation($uv, $seed+0.4)", + "type": "tex3d" + } + ], + "parameters": [ + + ], + "shortdesc": "Variations" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/voronoi.mmg b/game/addons/mat_maker_gd/material_maker_nodes/voronoi.mmg new file mode 100644 index 00000000..c369c7d9 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/voronoi.mmg @@ -0,0 +1,127 @@ +{ + "name": "voronoi", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "intensity": 1, + "randomness": 0.85, + "scale_x": 4, + "scale_y": 5, + "stretch_x": 1, + "stretch_y": 1 + }, + "shader_model": { + "code": "vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);", + "global": "// Based on https://www.shadertoy.com/view/ldl3W8\n// The MIT License\n// Copyright © 2013 Inigo Quilez\nvec3 iq_voronoi(vec2 x, vec2 size, vec2 stretch, float randomness, vec2 seed) {\n vec2 n = floor(x);\n vec2 f = fract(x);\n\n\tvec2 mg, mr, mc;\n float md = 8.0;\n for (int j=-1; j<=1; j++)\n for (int i=-1; i<=1; i++) {\n vec2 g = vec2(float(i),float(j));\n\t\tvec2 o = randomness*rand2(seed + mod(n + g + size, size));\n\t\tvec2 c = g + o;\n vec2 r = c - f;\n\t\tvec2 rr = r*stretch;\n float d = dot(rr,rr);\n\n if (d0.00001)\n \t\tmd = min(md, dot(0.5*(mr+r)*stretch, normalize((r-mr)*stretch)));\n }\n\n return vec3(md, mc+n);\n}\n\nvec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, float seed) {\n uv *= size;\n\tvec3 v = iq_voronoi(uv, size, stretch, randomness, rand2(vec2(seed, 1.0-seed)));\n\treturn vec4(v.yz, intensity*length((uv-v.yz)*stretch), v.x);\n}\n", + "inputs": [ + + ], + "instance": "", + "longdesc": "Generates several images from a tileable voronoi noise", + "name": "Voronoi", + "outputs": [ + { + "f": "$(name_uv)_xyzw.z", + "longdesc": "A greyscale pattern based on the distance to cell centers", + "shortdesc": "Nodes", + "type": "f" + }, + { + "f": "$(name_uv)_xyzw.w", + "longdesc": "A greyscale pattern based on the distance to borders", + "shortdesc": "Borders", + "type": "f" + }, + { + "longdesc": "A color pattern that assigns a random color to each cell", + "rgb": "rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)))", + "shortdesc": "Random color", + "type": "rgb" + }, + { + "longdesc": "An output that should be plugged into a Fill companion node", + "rgba": "vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))", + "shortdesc": "Fill", + "type": "rgba" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "Scale X", + "longdesc": "The scale 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 along the Y axis", + "max": 32, + "min": 1, + "name": "scale_y", + "shortdesc": "Scale.y", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Stretch X", + "longdesc": "The stretch factor along the X axis", + "max": 1, + "min": 0.01, + "name": "stretch_x", + "shortdesc": "Stretch.x", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Stretch Y", + "longdesc": "The stretch factor along the Y axis", + "max": 1, + "min": 0.01, + "name": "stretch_y", + "shortdesc": "Stretch.y", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0.75, + "label": "Intensity", + "longdesc": "A value factor for greyscale outputs", + "max": 1, + "min": 0, + "name": "intensity", + "shortdesc": "Intensity", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Randomness", + "longdesc": "The randomness of cell centers positions", + "max": 1, + "min": 0, + "name": "randomness", + "shortdesc": "Randomness", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Voronoi Noise" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/warp.mmg b/game/addons/mat_maker_gd/material_maker_nodes/warp.mmg new file mode 100644 index 00000000..dea232c4 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/warp.mmg @@ -0,0 +1,92 @@ +{ + "name": "warp", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0.1, + "eps": 0.1, + "mode": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_slope = $(name)_slope($uv, $eps);\nvec2 $(name_uv)_warp = $mode;", + "global": "", + "inputs": [ + { + "default": "vec4(sin($uv.x*20.0)*0.5+0.5, sin($uv.y*20.0)*0.5+0.5, 0, 1)", + "label": "", + "longdesc": "The input image to be warped", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The height map whose slopes are used to deform the input", + "name": "d", + "shortdesc": "Height map", + "type": "f" + } + ], + "instance": "vec2 $(name)_slope(vec2 uv, float epsilon) {\n\treturn vec2($d(fract(uv+vec2(epsilon, 0.0)))-$d(fract(uv-vec2(epsilon, 0.0))), $d(fract(uv+vec2(0.0, epsilon)))-$d(fract(uv-vec2(0.0, epsilon))));\n}", + "longdesc": "Warps its input according to a heightmap", + "name": "Warp", + "outputs": [ + { + "longdesc": "Shows the warped image", + "rgba": "$in($uv+$amount*$(name_uv)_warp)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "Both warp modes extract their direction from the height map slopes:\n- Slope warp intensity only depends on the slope\n- Distance to top warp intensity depends on the slope and the distance to the top, and can be used to create mosaic-like patterns\n\nA Transform node with translate maps can produce effects similar to Slope Warp and is generally faster.", + "name": "mode", + "shortdesc": "Mode", + "type": "enum", + "values": [ + { + "name": "Slope", + "value": "$(name_uv)_slope" + }, + { + "name": "Distance to top", + "value": "$(name_uv)_slope*(1.0-$d($uv))" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The strength of the warp effect", + "max": 1, + "min": 0, + "name": "amount", + "shortdesc": "Strength", + "step": 0.005, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The offset used to measure slopes", + "max": 0.2, + "min": 0.005, + "name": "eps", + "shortdesc": "Epsilon", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Warp" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/warp2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/warp2.mmg new file mode 100644 index 00000000..97d209a6 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/warp2.mmg @@ -0,0 +1,79 @@ +{ + "name": "warp2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "amount": 0.05, + "mode": 0 + }, + "shader_model": { + "code": "vec2 $(name_uv)_slope = $(name)_slope($uv);\nvec2 $(name_uv)_warp = $mode;", + "global": "", + "inputs": [ + { + "default": "vec4(sin($uv.x*20.0)*0.5+0.5, sin($uv.y*20.0)*0.5+0.5, 0, 1)", + "label": "", + "longdesc": "The input image to be warped", + "name": "in", + "shortdesc": "Input", + "type": "rgba" + }, + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The height map whose slopes are used to deform the input", + "name": "d", + "shortdesc": "Height map", + "type": "f" + } + ], + "instance": "vec2 $(name)_slope(vec2 uv) {\n vec2 e = vec2(0.001, 0.0);\n return 0.5*vec2($d(uv+e)-$d(uv-e), $d(uv+e.yx)-$d(uv-e.yx))/e.x;\n}", + "longdesc": "Warps its input according to a heightmap", + "name": "Warp", + "outputs": [ + { + "longdesc": "Shows the warped image", + "rgba": "$in($uv+$amount*$(name_uv)_warp)", + "shortdesc": "Output", + "type": "rgba" + } + ], + "parameters": [ + { + "default": 0, + "label": "", + "longdesc": "Both warp modes extract their direction from the height map slopes:\n- Slope warp intensity only depends on the slope\n- Distance to top warp intensity depends on the slope and the distance to the top, and can be used to create mosaic-like patterns\n\nA Transform node with translate maps can produce effects similar to Slope Warp and is generally faster.", + "name": "mode", + "shortdesc": "Mode", + "type": "enum", + "values": [ + { + "name": "Slope", + "value": "$(name_uv)_slope" + }, + { + "name": "Distance to top", + "value": "$(name_uv)_slope*(1.0-$d($uv))" + } + ] + }, + { + "control": "None", + "default": 0, + "label": "", + "longdesc": "The strength of the warp effect", + "max": 1, + "min": 0, + "name": "amount", + "shortdesc": "Strength", + "step": 0.005, + "type": "float" + } + ], + "shortdesc": "Warp" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation.mmg b/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation.mmg new file mode 100644 index 00000000..936fb864 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation.mmg @@ -0,0 +1,220 @@ +{ + "connections": [ + { + "from": "warp_dilation", + "from_port": 0, + "to": "buffer_5", + "to_port": 0 + }, + { + "from": "buffer_5", + "from_port": 0, + "to": "gen_outputs", + "to_port": 0 + }, + { + "from": "gen_inputs", + "from_port": 1, + "to": "buffer_6", + "to_port": 0 + }, + { + "from": "buffer_6", + "from_port": 0, + "to": "warp_dilation", + "to_port": 1 + }, + { + "from": "gen_inputs", + "from_port": 0, + "to": "buffer_7", + "to_port": 0 + }, + { + "from": "buffer_7", + "from_port": 0, + "to": "warp_dilation", + "to_port": 0 + } + ], + "label": "Warp Dilation", + "longdesc": "", + "name": "warp_dilation", + "node_position": { + "x": 0, + "y": 0 + }, + "nodes": [ + { + "name": "buffer_5", + "node_position": { + "x": -387.923584, + "y": -38 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "buffer_6", + "node_position": { + "x": -636.189514, + "y": -90.757477 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "buffer_7", + "node_position": { + "x": -635.189514, + "y": -199.757477 + }, + "parameters": { + "lod": 0, + "size": 9 + }, + "type": "buffer" + }, + { + "name": "warp_dilation", + "node_position": { + "x": -404.125, + "y": -172.25 + }, + "parameters": { + "a": 0, + "d": 0.5, + "mode": 0, + "s": 9 + }, + "type": "warp_dilation_nobuf" + }, + { + "name": "gen_inputs", + "node_position": { + "x": -1127.189453, + "y": -144.691238 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "name": "port1", + "type": "f" + }, + { + "group_size": 0, + "name": "port0", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_outputs", + "node_position": { + "x": -70.923584, + "y": -122.691238 + }, + "parameters": { + + }, + "ports": [ + { + "group_size": 0, + "name": "port0", + "type": "f" + } + ], + "type": "ios" + }, + { + "name": "gen_parameters", + "node_position": { + "x": -463.856934, + "y": -398.757477 + }, + "parameters": { + "a": 0, + "d": 0.5, + "mode": 0, + "s": 9 + }, + "type": "remote", + "widgets": [ + { + "label": "Mode", + "linked_widgets": [ + { + "node": "warp_dilation", + "widget": "mode" + } + ], + "name": "mode", + "type": "linked_control" + }, + { + "label": "Resolution", + "linked_widgets": [ + { + "node": "warp_dilation", + "widget": "s" + }, + { + "node": "buffer_7", + "widget": "size" + }, + { + "node": "buffer_6", + "widget": "size" + }, + { + "node": "buffer_5", + "widget": "size" + } + ], + "name": "s", + "type": "linked_control" + }, + { + "label": "Distance", + "linked_widgets": [ + { + "node": "warp_dilation", + "widget": "d" + } + ], + "name": "d", + "type": "linked_control" + }, + { + "label": "Attenuation", + "linked_widgets": [ + { + "node": "warp_dilation", + "widget": "a" + } + ], + "name": "a", + "type": "linked_control" + } + ] + } + ], + "parameters": { + "a": 0, + "d": 0.5, + "mode": 0, + "s": 9 + }, + "shortdesc": "", + "type": "graph" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation_nobuf.mmg b/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation_nobuf.mmg new file mode 100644 index 00000000..eb756323 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/warp_dilation_nobuf.mmg @@ -0,0 +1,108 @@ +{ + "name": "warp_dilation", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "a": 0, + "d": 0.5, + "mode": 0, + "s": 9 + }, + "shader_model": { + "code": "", + "global": "", + "inputs": [ + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The input image", + "name": "in", + "shortdesc": "Input", + "type": "f" + }, + { + "default": "0.0", + "function": true, + "label": "", + "longdesc": "The height map whose contours or slopes are followed", + "name": "hm", + "shortdesc": "Height map", + "type": "f" + } + ], + "instance": "vec2 $(name)_slope(vec2 uv, float epsilon) {\n\tfloat dx = $hm(fract(uv+vec2(epsilon, 0.0)))-$hm(fract(uv-vec2(epsilon, 0.0)));\n\tfloat dy = $hm(fract(uv+vec2(0.0, epsilon)))-$hm(fract(uv-vec2(0.0, epsilon)));\n\treturn vec2($mode);\n}\n\nfloat $(name)_dilate(vec2 uv, vec2 slope) {\n\tfloat e = 1.0/$s;\n\tfloat v = 0.0;\n\tfor (float x = 0.0; x <= $d; x += e) {\n\t\tv = max(v, $in(fract(uv))*(1.0-x/$d*$a));\n\t\tuv += e*normalize($(name)_slope(uv, 0.0001));\n\t}\n\treturn v;\n}", + "longdesc": "Dilates its input following the contours or slope of an input heightmap", + "name": "Warp Dilation", + "outputs": [ + { + "f": "$(name)_dilate($uv, normalize($(name)_slope($uv, 0.001)))", + "longdesc": "The dilated image", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "default": 0, + "label": "Mode", + "longdesc": "The dilate mode (clockwise contour, counter clockwise contour or slope)", + "name": "mode", + "shortdesc": "Mode", + "type": "enum", + "values": [ + { + "name": "Contour (cw)", + "value": "-dy,dx" + }, + { + "name": "Contour (ccw)", + "value": "dy, -dx" + }, + { + "name": "Slope", + "value": "dx,dy" + } + ] + }, + { + "default": 9, + "first": 6, + "label": "Resolution", + "last": 12, + "longdesc": "The resolution at which the contours or slopes are followed (higher values will be more precise but rendering time will be higher)", + "name": "s", + "shortdesc": "Resolution", + "type": "size" + }, + { + "control": "None", + "default": 0.1, + "label": "Distance", + "longdesc": "The distance along which the contours or slopes are followed", + "max": 0.5, + "min": 0, + "name": "d", + "shortdesc": "Distance", + "step": 0.01, + "type": "float" + }, + { + "control": "None", + "default": 0, + "label": "Attenuation", + "longdesc": "The attenuation applied along the path", + "max": 1, + "min": 0, + "name": "a", + "shortdesc": "Attenuation", + "step": 0.01, + "type": "float" + } + ], + "shortdesc": "Warp Dilation" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/weave.mmg b/game/addons/mat_maker_gd/material_maker_nodes/weave.mmg new file mode 100644 index 00000000..ddfb0940 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/weave.mmg @@ -0,0 +1,77 @@ +{ + "name": "weave", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "columns": 4, + "rows": 4, + "width": 0.9 + }, + "shader_model": { + "code": "", + "global": "float weave(vec2 uv, vec2 count, float width) {\n uv *= count;\n\tfloat c = (sin(3.1415926*(uv.x+floor(uv.y)))*0.5+0.5)*step(abs(fract(uv.y)-0.5), width*0.5);\n\tc = max(c, (sin(3.1415926*(1.0+uv.y+floor(uv.x)))*0.5+0.5)*step(abs(fract(uv.x)-0.5), width*0.5));\n\treturn c;\n}", + "inputs": [ + { + "default": "1.0", + "label": "3:", + "longdesc": "An input map that affects the width parameter", + "name": "width_map", + "shortdesc": "Width map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates a simple weave pattern", + "name": "Weave", + "outputs": [ + { + "f": "weave($uv, vec2($columns, $rows), $width*$width_map($uv))", + "longdesc": "Shows the generated greyscale weave pattern.", + "shortdesc": "Output", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "Size X", + "longdesc": "The number of columns of the pattern", + "max": 32, + "min": 2, + "name": "columns", + "shortdesc": "Size.x", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Size Y", + "longdesc": "The number of rows of the pattern", + "max": 32, + "min": 2, + "name": "rows", + "shortdesc": "Size.y", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.8, + "label": "Width", + "longdesc": "The width of each row/column", + "max": 1, + "min": 0, + "name": "width", + "shortdesc": "Width", + "step": 0.05, + "type": "float" + } + ], + "shortdesc": "Weave pattern" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/material_maker_nodes/weave2.mmg b/game/addons/mat_maker_gd/material_maker_nodes/weave2.mmg new file mode 100644 index 00000000..35f07c86 --- /dev/null +++ b/game/addons/mat_maker_gd/material_maker_nodes/weave2.mmg @@ -0,0 +1,113 @@ +{ + "name": "weave2", + "node_position": { + "x": 0, + "y": 0 + }, + "parameters": { + "columns": 4, + "rows": 4, + "stitch": 1, + "width_x": 0.9, + "width_y": 0.9 + }, + "shader_model": { + "code": "vec3 $(name_uv) = weave($uv, vec2($columns, $rows), $stitch, $width_x*$width_map($uv), $width_y*$width_map($uv));", + "global": "vec3 weave(vec2 uv, vec2 count, float stitch, float width_x, float width_y) {\n uv *= stitch;\n\tuv *= count;\n\tfloat c1 = (sin( 3.1415926 / stitch * (uv.x + floor(uv.y) - (stitch - 1.0))) * 0.25 + 0.75 ) *step(abs(fract(uv.y)-0.5), width_x*0.5);\n\tfloat c2 = (sin(3.1415926 / stitch * (1.0+uv.y+floor(uv.x) ))* 0.25 + 0.75 )*step(abs(fract(uv.x)-0.5), width_y*0.5);\n\treturn vec3(max(c1, c2), 1.0-step(c1, c2), 1.0-step(c2, c1));\n}", + "inputs": [ + { + "default": "1.0", + "label": "3:", + "longdesc": "An input map that affects the width parameter", + "name": "width_map", + "shortdesc": "Width map", + "type": "f" + } + ], + "instance": "", + "longdesc": "Generates a simple weave pattern", + "name": "Weave", + "outputs": [ + { + "f": "$(name_uv).x", + "longdesc": "Shows the generated greyscale weave pattern.", + "shortdesc": "Output", + "type": "f" + }, + { + "f": "$(name_uv).y", + "longdesc": "Mask for horizontal stripes", + "shortdesc": "Horizontal mask", + "type": "f" + }, + { + "f": "$(name_uv).z", + "longdesc": "Mask for vertical stripes", + "shortdesc": "Vertical mask", + "type": "f" + } + ], + "parameters": [ + { + "control": "None", + "default": 4, + "label": "Size X", + "longdesc": "The number of columns of the pattern", + "max": 32, + "min": 2, + "name": "columns", + "shortdesc": "Size.x", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 4, + "label": "Size Y", + "longdesc": "The number of rows of the pattern", + "max": 32, + "min": 2, + "name": "rows", + "shortdesc": "Size.y", + "step": 1, + "type": "float" + }, + { + "control": "None", + "default": 0.8, + "label": "Width X", + "longdesc": "The width of each row/column", + "max": 1, + "min": 0, + "name": "width_x", + "shortdesc": "Width", + "step": 0.05, + "type": "float" + }, + { + "control": "None", + "default": 0.8, + "label": "Width Y", + "max": 1, + "min": 0, + "name": "width_y", + "step": 0.05, + "type": "float" + }, + { + "control": "None", + "default": 1, + "label": "Stitch", + "longdesc": "The length of each stitch", + "max": 10, + "min": 0, + "name": "stitch", + "shortdesc": "Stitch", + "step": 1, + "type": "float" + } + ], + "shortdesc": "Weave pattern" + }, + "type": "shader" +} \ No newline at end of file diff --git a/game/addons/mat_maker_gd/noise/noise.gd b/game/addons/mat_maker_gd/noise/noise.gd new file mode 100644 index 00000000..33a3d4d3 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise.gd @@ -0,0 +1,232 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o7136_amplitude = 0.500000000; +var p_o7136_frequency = 2.000000000; +var p_o7136_phase = 0.000000000; + +func sinewave(uv : Vector2) -> Color: + + var f : float = 1.0- abs(2.0 * (uv.y-0.5) - p_o7136_amplitude * sin((p_o7136_frequency* uv.x + p_o7136_phase) * 6.28318530718)); + + return Color(f, f, f, 1) + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/noise.tscn b/game/addons/mat_maker_gd/noise/noise.tscn new file mode 100644 index 00000000..61c247c0 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_sine_wave.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/noise_FBM.gd b/game/addons/mat_maker_gd/noise/noise_FBM.gd new file mode 100644 index 00000000..1093cb53 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_FBM.gd @@ -0,0 +1,569 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + +# var col : Color = fbmval(v) +# var col : Color = perlin(v) +# var col : Color = cellular(v) +# var col : Color = cellular2(v) +# var col : Color = cellular3(v) +# var col : Color = cellular4(v) +# var col : Color = cellular5(v) + var col : Color = cellular6(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o33355 = 26177; +var p_o33355_scale_x = 2.000000000; +var p_o33355_scale_y = 2.000000000; +var p_o33355_iterations = 5.000000000; +var p_o33355_persistence = 0.500000000; + +func fbmval(uv : Vector2) -> Color: + var f : float = o33355_fbm(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func perlin(uv : Vector2) -> Color: + var f : float = o33355_perlin(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular(uv : Vector2) -> Color: + var f : float = o33355_cellular(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular2(uv : Vector2) -> Color: + var f : float = o33355_cellular2(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular3(uv : Vector2) -> Color: + var f : float = o33355_cellular3(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular4(uv : Vector2) -> Color: + var f : float = o33355_cellular4(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular5(uv : Vector2) -> Color: + var f : float = o33355_cellular5(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func cellular6(uv : Vector2) -> Color: + var f : float = o33355_cellular6(((uv)), Vector2(p_o33355_scale_x, p_o33355_scale_y), int(p_o33355_iterations), p_o33355_persistence, float(seed_o33355)); + + return Color(f, f, f, 1) + +func o33355_fbm(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_value(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_perlin(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_perlin(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular2(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular2(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular3(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular3(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular4(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular4(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular5(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular5(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func o33355_cellular6(coord : Vector2, size : Vector2, octaves : int, persistence : float, pseed : float) -> float: + var normalize_factor : float = 0.0; + var value : float = 0.0; + var scale : float = 1.0; + + for i in range(octaves):# (int i = 0; i < octaves; i++) { + value += fbm_cellular6(coord*size, size, pseed) * scale; + normalize_factor += scale; + size *= 2.0; + scale *= persistence; + + return value / normalize_factor; + +func fbm_value(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = fractv2(coord); + var p00 : float = rand(modv2(o, size)); + var p01 : float = rand(modv2(o + Vector2(0.0, 1.0), size)); + var p10 : float = rand(modv2(o + Vector2(1.0, 0.0), size)); + var p11 : float = rand(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); + +func fbm_perlin(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = fractv2(coord); + var a00 : float = rand(modv2(o, size)) * 6.28318530718; + var a01 : float = rand(modv2(o + Vector2(0.0, 1.0), size)) * 6.28318530718; + var a10 : float = rand(modv2(o + Vector2(1.0, 0.0), size)) * 6.28318530718; + var a11 : float = rand(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); + + +func fbm_cellular(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + +func fbm_cellular2(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + +func fbm_cellular3(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + +func fbm_cellular4(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + +func fbm_cellular5(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + + + +func fbm_cellular6(coord : Vector2, size : Vector2, pseed : float) -> float: + var o : Vector2 = floorv2(coord) + rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size; + var f : Vector2 = 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 = rand2(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; + + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/noise_FBM.tscn b/game/addons/mat_maker_gd/noise/noise_FBM.tscn new file mode 100644 index 00000000..44df5787 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_FBM.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/noise_FBM.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/noise_color.gd b/game/addons/mat_maker_gd/noise/noise_color.gd new file mode 100644 index 00000000..306acfd8 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_color.gd @@ -0,0 +1,264 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = nc(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + + +func nc(uv : Vector2) -> Color: + var v : Vector3 = color_dots(((uv)), 1.0/512.000000000, seed_o26210); + + return Color(v.x, v.y, v.z, 1) + + +var seed_o26210 = 7313; + +func color_dots(uv : Vector2, size : float, pseed : int) -> Vector3: + var seed2 : Vector2 = rand2(Vector2(float(pseed), 1.0 - float(pseed))); + uv /= size; + var point_pos : Vector2 = floorv2(uv) + Vector2(0.5, 0.5); + return rand3(seed2 + point_pos); + + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/noise_color.tscn b/game/addons/mat_maker_gd/noise/noise_color.tscn new file mode 100644 index 00000000..988640ce --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_color.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/noise_color.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/noise_voronoi.gd b/game/addons/mat_maker_gd/noise/noise_voronoi.gd new file mode 100644 index 00000000..7196453d --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_voronoi.gd @@ -0,0 +1,310 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + +# var col : Color = voron_1(v) +# var col : Color = voron_2(v) + var col : Color = voron_3(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + + +func voron_1(uv : Vector2) -> Color: + var c : Color = voronoi(((uv)), Vector2(p_o8689_scale_x, p_o8689_scale_y), Vector2(p_o8689_stretch_y, p_o8689_stretch_x), p_o8689_intensity, p_o8689_randomness, seed_o8689); + + return Color(c.b, c.b, c.b, 1) + +func voron_2(uv : Vector2) -> Color: + var c : Color = voronoi(((uv)), Vector2(p_o8689_scale_x, p_o8689_scale_y), Vector2(p_o8689_stretch_y, p_o8689_stretch_x), p_o8689_intensity, p_o8689_randomness, seed_o8689); + + return Color(c.a, c.a, c.a, 1) + +func voron_3(uv : Vector2) -> Color: + var c : Color = voronoi(((uv)), Vector2(p_o8689_scale_x, p_o8689_scale_y), Vector2(p_o8689_stretch_y, p_o8689_stretch_x), p_o8689_intensity, p_o8689_randomness, seed_o8689); + + var vv : Vector2 = Vector2(c.r, c.g) + + var v : Vector3 = rand3(fractv2(vv)); + + return Color(v.x, v.y, v.z, 1) + + +var seed_o8689 = 11667; +var p_o8689_scale_x = 4.000000000; +var p_o8689_scale_y = 4.000000000; +var p_o8689_stretch_x = 1.000000000; +var p_o8689_stretch_y = 1.000000000; +var p_o8689_intensity = 1.000000000; +var p_o8689_randomness = 0.750000000; + + +func voronoi(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color: + var seed2 : Vector2 = 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 = 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 * rand2(seed2 + 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); + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/noise_voronoi.tscn b/game/addons/mat_maker_gd/noise/noise_voronoi.tscn new file mode 100644 index 00000000..133dc992 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/noise_voronoi.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/noise_voronoi.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/perlin.gd b/game/addons/mat_maker_gd/noise/perlin.gd new file mode 100644 index 00000000..f18bd7ec --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin.gd @@ -0,0 +1,266 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o12297 = -26656; +var p_o12297_scale_x = 4.000000000; +var p_o12297_scale_y = 4.000000000; +var p_o12297_iterations = 3.000000000; +var p_o12297_persistence = 0.500000000; + +func sinewave(uv : Vector2) -> Color: + + var f : float = perlin(((uv)), Vector2(p_o12297_scale_x, p_o12297_scale_y), int(p_o12297_iterations), p_o12297_persistence, seed_o12297); + + return Color(f, f, f, 1) + +func perlin(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> float: + var seed2 : Vector2 = 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 = floorv2(uv * size); + var f0 : float = rand(seed2 + modv2(xy, size)); + var f1 : float = rand(seed2 + modv2(xy + Vector2(1.0, 0.0), size)); + var f2 : float = rand(seed2 + modv2(xy + Vector2(0.0, 1.0), size)); + var f3 : float = rand(seed2 + modv2(xy + Vector2(1.0, 1.0), size)); + + var mixval : Vector2 = smoothstepv2(0.0, 1.0, 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; + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/perlin.tscn b/game/addons/mat_maker_gd/noise/perlin.tscn new file mode 100644 index 00000000..d7f10fe6 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/perlin.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/perlin_color.gd b/game/addons/mat_maker_gd/noise/perlin_color.gd new file mode 100644 index 00000000..d581e008 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_color.gd @@ -0,0 +1,266 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o28198 = 53932; +var p_o28198_scale_x = 4.000000000; +var p_o28198_scale_y = 4.000000000; +var p_o28198_iterations = 3.000000000; +var p_o28198_persistence = 0.500000000; + +func sinewave(uv : Vector2) -> Color: + + var f : Vector3 = perlin_color(((uv)), Vector2(p_o28198_scale_x, p_o28198_scale_y), int(p_o28198_iterations), p_o28198_persistence, seed_o28198); + + return Color(f.x, f.y, f.z, 1) + +func perlin_color(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Vector3: + var seed2 : Vector2 = 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 = floorv2(uv * size); + + var f0 : Vector3 = rand3(seed2 + modv2(xy, size)); + var f1 : Vector3 = rand3(seed2 + modv2(xy + Vector2(1.0, 0.0), size)); + var f2 : Vector3 = rand3(seed2 + modv2(xy + Vector2(0.0, 1.0), size)); + var f3 : Vector3 = rand3(seed2 + modv2(xy + Vector2(1.0, 1.0), size)); + + var mixval : Vector2 = smoothstepv2(0.0, 1.0, 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; + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/perlin_color.tscn b/game/addons/mat_maker_gd/noise/perlin_color.tscn new file mode 100644 index 00000000..351b87cc --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_color.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/perlin_color.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/perlin_warp1.gd b/game/addons/mat_maker_gd/noise/perlin_warp1.gd new file mode 100644 index 00000000..3010aa26 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_warp1.gd @@ -0,0 +1,293 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o41835_translate_x = 0.500000000; +var p_o41835_translate_y = 0.500000000; +var p_o41835_rotate = 0.000000000; +var p_o41835_scale_x = 1.000000000; +var p_o41835_scale_y = 1.000000000; +var seed_o41836 = 31052; +var p_o41836_scale_x = 4.000000000; +var p_o41836_scale_y = 4.000000000; +var p_o41836_iterations = 3.000000000; +var p_o41836_persistence = 0.500000000; + +func sinewave(uv : Vector2) -> Color: + var f : float = perlin((((uv))), Vector2(p_o41836_scale_x, p_o41836_scale_y), int(p_o41836_iterations), p_o41836_persistence, seed_o41836); + var ff : float = perlin((transform(((uv)), Vector2(p_o41835_translate_x*(2.0*f-1.0), p_o41835_translate_y*(2.0*f-1.0)), p_o41835_rotate*0.01745329251*(2.0*1.0-1.0), Vector2(p_o41835_scale_x*(2.0*1.0-1.0), p_o41835_scale_y*(2.0*1.0-1.0)), true)), Vector2(p_o41836_scale_x, p_o41836_scale_y), int(p_o41836_iterations), p_o41836_persistence, seed_o41836); + + return Color(ff, ff, ff, 1) + + +func perlin(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> float: + var seed2 : Vector2 = 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 = floorv2(uv * size); + var f0 : float = rand(seed2 + modv2(xy, size)); + var f1 : float = rand(seed2 + modv2(xy + Vector2(1.0, 0.0), size)); + var f2 : float = rand(seed2 + modv2(xy + Vector2(0.0, 1.0), size)); + var f3 : float = rand(seed2 + modv2(xy + Vector2(1.0, 1.0), size)); + + var mixval : Vector2 = smoothstepv2(0.0, 1.0, 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; + + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/perlin_warp1.tscn b/game/addons/mat_maker_gd/noise/perlin_warp1.tscn new file mode 100644 index 00000000..59eb58a6 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_warp1.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/perlin_warp1.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/noise/perlin_warp2.gd b/game/addons/mat_maker_gd/noise/perlin_warp2.gd new file mode 100644 index 00000000..65a62159 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_warp2.gd @@ -0,0 +1,303 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o56044_translate_x = 0.500000000; +var p_o56044_translate_y = 0.500000000; +var p_o56044_rotate = 0.000000000; +var p_o56044_scale_x = 1.000000000; +var p_o56044_scale_y = 1.000000000; +var p_o56039_translate_x = 0.500000000; +var p_o56039_translate_y = 0.500000000; +var p_o56039_rotate = 0.000000000; +var p_o56039_scale_x = 1.000000000; +var p_o56039_scale_y = 1.000000000; +var seed_o56040 = 26697; +var p_o56040_scale_x = 4.000000000; +var p_o56040_scale_y = 4.000000000; +var p_o56040_iterations = 3.000000000; +var p_o56040_persistence = 0.500000000; + +func sinewave(uv : Vector2) -> Color: + var f = perlin(((((uv)))), Vector2(p_o56040_scale_x, p_o56040_scale_y), int(p_o56040_iterations), p_o56040_persistence, seed_o56040); + var ff : float = perlin((transform((((uv))), Vector2(p_o56039_translate_x*(2.0*f-1.0), p_o56039_translate_y*(2.0*f-1.0)), p_o56039_rotate*0.01745329251*(2.0*1.0-1.0), Vector2(p_o56039_scale_x*(2.0*1.0-1.0), p_o56039_scale_y*(2.0*1.0-1.0)), true)), Vector2(p_o56040_scale_x, p_o56040_scale_y), int(p_o56040_iterations), p_o56040_persistence, seed_o56040); + + var o56039_0_1_rgba : Vector3 = Vector3(ff, ff, ff) + + var tf : Vector2 = transform(uv, Vector2(p_o56044_translate_x * (2.0 * (o56039_0_1_rgba.dot(Vector3(1, 1, 1) / 3.0) - 1.0)), p_o56044_translate_y*(2.0*( o56039_0_1_rgba.dot(Vector3(1, 1, 1) /3.0)-1.0))), p_o56044_rotate*0.01745329251*(2.0*1.0-1.0), Vector2(p_o56044_scale_x*(2.0*1.0-1.0), p_o56044_scale_y*(2.0*1.0-1.0)), true) + + var fff : float = perlin(tf, Vector2(p_o56040_scale_x, p_o56040_scale_y), int(p_o56040_iterations), p_o56040_persistence, seed_o56040); + + return Color(fff, fff, fff, 1) + + +func perlin(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> float: + var seed2 : Vector2 = 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 = floorv2(uv * size); + var f0 : float = rand(seed2 + modv2(xy, size)); + var f1 : float = rand(seed2 + modv2(xy + Vector2(1.0, 0.0), size)); + var f2 : float = rand(seed2 + modv2(xy + Vector2(0.0, 1.0), size)); + var f3 : float = rand(seed2 + modv2(xy + Vector2(1.0, 1.0), size)); + + var mixval : Vector2 = smoothstepv2(0.0, 1.0, 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; + +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)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +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 + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/noise/perlin_warp2.tscn b/game/addons/mat_maker_gd/noise/perlin_warp2.tscn new file mode 100644 index 00000000..4b73eaa3 --- /dev/null +++ b/game/addons/mat_maker_gd/noise/perlin_warp2.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/noise/perlin_warp2.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/TextureRectBricks.gd b/game/addons/mat_maker_gd/pattern/TextureRectBricks.gd new file mode 100644 index 00000000..591a4a3e --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/TextureRectBricks.gd @@ -0,0 +1,479 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + pass + + +#float o39644_0_2_f : float = o39644_0.x +var seed_o39644 : int = 15005 +var p_o39644_repeat : float = 1.000000000 +var p_o39644_rows : float = 6.000000000 +var p_o39644_columns : float = 3.000000000 +var p_o39644_row_offset : float = 0.500000000 +var p_o39644_mortar: float = 0.100000000 +var p_o39644_bevel : float = 0.100000000 +var p_o39644_round : float= 0.000000000 +var p_o39644_corner : float = 0.420000000 + + +var p_o3335_albedo_color_r : float = 1.000000000 +var p_o3335_albedo_color_g : float = 1.000000000 +var p_o3335_albedo_color_b : float = 1.000000000 +var p_o3335_albedo_color_a : float = 1.000000000 +var p_o3335_metallic : float = 1.000000000 +var p_o3335_roughness : float = 1.000000000 +var p_o3335_emission_energy : float = 1.000000000 +var p_o3335_normal : float = 1.000000000 +var p_o3335_ao : float = 1.000000000 +var p_o3335_depth_scale : float = 0.500000000 +var p_o3335_sss : float = 0.000000000 + + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var vb : Vector3 = brick_uv(v, bmin, bmax, pseed) +## var col : Color = Color(vb.x, vb.y, vb.z, 1) +# +# var col : Color = brick(v, bmin, bmax, 0.2, 0.2, 0.2) +# var cc : Color = Color(vb.x, vb.y, vb.z, 1) +# image.set_pixel(x, y, cc) + + #Running Bond +# var brect : Color = bricks_rb(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset); + + #RunningBond2 +# var brect : Color = bricks_rb2(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset); + + #HerringBone +# var brect : Color = bricks_hb(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset); + + #BasketWeave +# var brect : Color = bricks_bw(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset); + + #SpanishBond + var brect : Color = bricks_sb(v, Vector2(p_o39644_columns, p_o39644_rows), p_o39644_repeat, p_o39644_row_offset); + + + # 1, 2 + var fcolor : Color = brick(v, Vector2(brect.r, brect.g), Vector2(brect.b, brect.a), p_o39644_mortar*1.0, p_o39644_round*1.0, max(0.001, p_o39644_bevel*1.0)); + +# image.set_pixel(x, y, brect) +# image.set_pixel(x, y, fcolor) +# image.set_pixel(x, y, Color(fcolor.r, fcolor.g, fcolor.b, 1)) + + #1 + var rr : float = fcolor.r; + image.set_pixel(x, y, Color(rr,rr, rr, 1)) +# +# # 3 +# var yy : float = fcolor.g; +# image.set_pixel(x, y, Color(yy,yy, yy, 1)) +# +# # 4 +# var zz : float = fcolor.b; +# image.set_pixel(x, y, Color(zz,zz, zz, 1)) + + # 5 +# var c : Vector3 = brick_uv(v, Vector2(brect.r, brect.g), Vector2(brect.b, brect.a), float(seed_o39644)) +# image.set_pixel(x, y, Color(c.x, c.y, c.z, 1)) + + # 6 +# var c : Vector3 = brick_corner_uv(v, Vector2(brect.r, brect.g), Vector2(brect.b, brect.a), p_o39644_mortar*1.0, p_o39644_corner, float(seed_o39644)); +# image.set_pixel(x, y, Color(c.x, c.y, c.z, 1)) + + + # 7 +# var f : float = 0.5*(sign(brect.b-brect.r-brect.a+brect.g)+1.0); +# image.set_pixel(x, y, Color(f, f, f, 1)) + + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func brick_corner_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, corner : float, pseed : float) -> Vector3: + var center : Vector2 = 0.5 * (bmin + bmax) + var size : Vector2 = bmax - bmin + var max_size : float = max(size.x, size.y) + var min_size : float = min(size.x, size.y) + mortar *= min_size + corner *= min_size + + var r : Vector3 = Vector3() + + r.x = clamp(((0.5 * size.x - mortar) - abs(uv.x - center.x)) / corner, 0, 1) + r.y = clamp(((0.5 * size.y - mortar) - abs(uv.y - center.y)) / corner, 0, 1) + r.z = rand(fract(center) + Vector2(pseed, pseed)) + + return r + +# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed))); + + +func brick(uv : Vector2, bmin : Vector2, bmax : Vector2, mortar : float, pround : float, bevel : float) -> Color: + var color : float + var size : Vector2 = bmax - bmin + + var min_size : float = min(size.x, size.y) + mortar *= min_size + bevel *= min_size + pround *= min_size + + var center : Vector2 = 0.5 * (bmin + bmax) + var d : Vector2 = Vector2() + + d.x = abs(uv.x - center.x) - 0.5 * (size.x) + (pround + mortar) + d.y = abs(uv.y - center.y) - 0.5 * (size.y) + (pround + mortar) + + color = Vector2(max(d.x, 0), max(d.y, 0)).length() + min(max(d.x, d.y), 0.0) - pround + + color = clamp(-color / bevel, 0.0, 1.0) + +# var tiled_brick_pos : Vector2 = Vector2(bmin.x - 1.0 * floor(bmin.x / 1.0), bmin.y - 1.0 * floor(bmin.y / 1.0)) + + var tiled_brick_pos_x : float = bmin.x - 1.0 * floor(bmin.x / 1.0) + var tiled_brick_pos_y : float = bmin.y - 1.0 * floor(bmin.y / 1.0) + + #vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0)); + + return Color(color, center.x, center.y, tiled_brick_pos_x + 7.0 * tiled_brick_pos_y) + +func brick_uv(uv : Vector2, bmin : Vector2, bmax : Vector2, pseed : float) -> Vector3: + var center : Vector2 = 0.5 * (bmin + bmax) + var size : Vector2 = bmax - bmin + var max_size : float = max(size.x, size.y) + + var x : float = 0.5+ (uv.x - center.x) / max_size + var y : float = 0.5+ (uv.y - center.y) /max_size + + return Vector3(x, y, rand(fract(center) + Vector2(pseed, pseed))) + +func bricks_rb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color: + count *= repeat + + var x_offset : float = offset * step(0.5, fractf(uv.y * count.y * 0.5)) + + var bmin : Vector2 + bmin.x = floor(uv.x * count.x - x_offset) + bmin.y = floor(uv.y * count.y) + + bmin.x += x_offset; + bmin /= count + var bmc : Vector2 = bmin + Vector2(1.0, 1.0) / count + + return Color(bmin.x, bmin.y, bmc.x, bmc.y) + +func bricks_rb2(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color: + count *= repeat + + var x_offset : float = offset * step(0.5, fractf(uv.y * count.y * 0.5)) + count.x = count.x * (1.0+step(0.5, fractf(uv.y * count.y * 0.5))) + var bmin : Vector2 = Vector2() + + bmin.x = floor(uv.x * count.x - x_offset) + bmin.y = floor(uv.y * count.y) + + bmin.x += x_offset + bmin /= count + + var b : Vector2 = bmin + Vector2(1, 1) / count + + return Color(bmin.x, bmin.y, b.x, b.y) + +func bricks_hb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color: + var pc : float = count.x + count.y + var c : float = pc * repeat + + var corner : Vector2 = Vector2(floor(uv.x * c), floor(uv.y * c)) + var cdiff : float = modf(corner.x - corner.y, pc) + + if (cdiff < count.x): + var col : Color = Color() + + col.r = (corner.x - cdiff) / c + col.g = corner.y / c + + col.b = (corner.x - cdiff + count.x) / c + col.a = (corner.y + 1.0) / c + + return col + else: + var col : Color = Color() + + col.r = corner.x / c + col.g = (corner.y - (pc - cdiff - 1.0)) / c + + col.b = (corner.x + 1.0) / c + col.a = (corner.y - (pc - cdiff - 1.0) + count.y) / c + + return col + +func bricks_bw(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color: + var c : Vector2 = 2.0 * count * repeat + var mc : float = max(c.x, c.y) + var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y)) + var corner2 : Vector2 = Vector2(count.x * floor(repeat* 2.0 * uv.x), count.y * floor(repeat * 2.0 * uv.y)) + + var tmp : Vector2 = Vector2(floor(repeat * 2.0 * uv.x), floor(repeat * 2.0 * uv.y)) + var cdiff : float = modf(tmp.dot(Vector2(1, 1)), 2.0) + + var corner : Vector2 + var size : Vector2 + + if cdiff == 0: + corner = Vector2(corner1.x, corner2.y) + size = Vector2(1.0, count.y) + else: + corner = Vector2(corner2.x, corner1.y) + size = Vector2(count.x, 1.0) + + return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y) + +func bricks_sb(uv : Vector2, count : Vector2, repeat : float, offset : float) -> Color: + var c : Vector2 = (count + Vector2(1, 1)) * repeat + var mc : float = max(c.x, c.y) + var corner1 : Vector2 = Vector2(floor(uv.x * c.x), floor(uv.y * c.y)) + var corner2 : Vector2 = (count + Vector2(1, 1)) * Vector2(floor(repeat * uv.x), floor(repeat * uv.y)) + var rcorner : Vector2 = corner1 - corner2 + + var corner : Vector2 + var size : Vector2 + + if (rcorner.x == 0.0 && rcorner.y < count.y): + corner = corner2 + size = Vector2(1.0, count.y) + elif (rcorner.y == 0.0): + corner = corner2 + Vector2(1.0, 0.0) + size = Vector2(count.x, 1.0) + elif (rcorner.x == count.x): + corner = corner2 + Vector2(count.x, 1.0) + size = Vector2(1.0, count.y) + elif (rcorner.y == count.y): + corner = corner2 + Vector2(0.0, count.y) + size = Vector2(count.x, 1.0) + else: + corner = corner2 + Vector2(1, 1) + size = Vector2(count.x-1.0, count.y-1.0) + + return Color(corner.x / c.x, corner.y / c.y, (corner.x + size.x) / c.x, (corner.y + size.y) / c.y) + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + +# +#vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset); +#vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv))); +# +#vec4 brick(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float round, float bevel) { +# float color; +# vec2 size = bmax - bmin; +# float min_size = min(size.x, size.y); +# mortar *= min_size; +# bevel *= min_size; +# round *= min_size; +# vec2 center = 0.5*(bmin+bmax); +# +# vec2 d = abs(uv-center)-0.5*(size)+vec2(round+mortar); +# color = length(max(d,vec2(0))) + min(max(d.x,d.y),0.0)-round; +# color = clamp(-color/bevel, 0.0, 1.0); +# vec2 tiled_brick_pos = mod(bmin, vec2(1.0, 1.0)); +# +# return vec4(color, center, tiled_brick_pos.x+7.0*tiled_brick_pos.y); +#} +# +#vec3 brick_uv(vec2 uv, vec2 bmin, vec2 bmax, float seed) { +# vec2 center = 0.5*(bmin + bmax); +# vec2 size = bmax - bmin; +# float max_size = max(size.x, size.y); +# +# return vec3(0.5+(uv-center)/max_size, rand(fract(center)+vec2(seed))); +#} +# +#vec3 brick_corner_uv(vec2 uv, vec2 bmin, vec2 bmax, float mortar, float corner, float seed) { +# vec2 center = 0.5*(bmin + bmax); +# vec2 size = bmax - bmin; +# float max_size = max(size.x, size.y); +# float min_size = min(size.x, size.y); +# mortar *= min_size;\n\tcorner *= min_size; +# +# return vec3(clamp((0.5*size-vec2(mortar)-abs(uv-center))/corner, vec2(0.0), vec2(1.0)), rand(fract(center)+vec2(seed))); +#} +# +#vec4 bricks_rb(vec2 uv, vec2 count, float repeat, float offset) { +# count *= repeat; +# float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5)); +# vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y)); +# bmin.x += x_offset;\n\tbmin /= count; +# +# return vec4(bmin, bmin+vec2(1.0)/count); +#} +# +#vec4 bricks_rb2(vec2 uv, vec2 count, float repeat, float offset) { +# count *= repeat; +# +# float x_offset = offset*step(0.5, fract(uv.y*count.y*0.5)); +# count.x = count.x*(1.0+step(0.5, fract(uv.y*count.y*0.5))); +# vec2 bmin = floor(vec2(uv.x*count.x-x_offset, uv.y*count.y)); +# +# bmin.x += x_offset; +# bmin /= count; +# return vec4(bmin, bmin+vec2(1.0)/count); +#} +# +#vec4 bricks_hb(vec2 uv, vec2 count, float repeat, float offset) { +# float pc = count.x+count.y; +# float c = pc*repeat; +# vec2 corner = floor(uv*c); +# float cdiff = mod(corner.x-corner.y, pc); +# +# if (cdiff < count.x) { +# return vec4((corner-vec2(cdiff, 0.0))/c, (corner-vec2(cdiff, 0.0)+vec2(count.x, 1.0))/c); +# } else { +# return vec4((corner-vec2(0.0, pc-cdiff-1.0))/c, (corner-vec2(0.0, pc-cdiff-1.0)+vec2(1.0, count.y))/c); +# } +#} +# +#vec4 bricks_bw(vec2 uv, vec2 count, float repeat, float offset) { +# vec2 c = 2.0*count*repeat; +# float mc = max(c.x, c.y); +# vec2 corner1 = floor(uv*c); +# vec2 corner2 = count*floor(repeat*2.0*uv); +# float cdiff = mod(dot(floor(repeat*2.0*uv), vec2(1.0)), 2.0); +# vec2 corner; +# vec2 size; +# +# if (cdiff == 0.0) { +# corner = vec2(corner1.x, corner2.y); +# size = vec2(1.0, count.y); +# } else { +# corner = vec2(corner2.x, corner1.y); +# size = vec2(count.x, 1.0); +# } +# +# return vec4(corner/c, (corner+size)/c); +#} +# +#vec4 bricks_sb(vec2 uv, vec2 count, float repeat, float offset) { +# vec2 c = (count+vec2(1.0))*repeat; +# float mc = max(c.x, c.y); +# vec2 corner1 = floor(uv*c); +# vec2 corner2 = (count+vec2(1.0))*floor(repeat*uv); +# vec2 rcorner = corner1 - corner2; +# +# vec2 corner; +# vec2 size; +# +# if (rcorner.x == 0.0 && rcorner.y < count.y) { +# corner = corner2; +# size = vec2(1.0, count.y); +# } else if (rcorner.y == 0.0) { +# corner = corner2+vec2(1.0, 0.0); +# size = vec2(count.x, 1.0); +# } else if (rcorner.x == count.x) { +# corner = corner2+vec2(count.x, 1.0); +# size = vec2(1.0, count.y); +# } else if (rcorner.y == count.y) { +# corner = corner2+vec2(0.0, count.y); +# size = vec2(count.x, 1.0); +# } else { +# corner = corner2+vec2(1.0); +# size = vec2(count.x-1.0, count.y-1.0); +# } +# +# return vec4(corner/c, (corner+size)/c); +#} + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/TextureRectBricks.tscn b/game/addons/mat_maker_gd/pattern/TextureRectBricks.tscn new file mode 100644 index 00000000..4558c447 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/TextureRectBricks.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/TextureRectBricks.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} +bmin = Vector2( 0.12, 0.282 ) +bmax = Vector2( 1.082, 1.112 ) diff --git a/game/addons/mat_maker_gd/pattern/pattern_beehive.gd b/game/addons/mat_maker_gd/pattern/pattern_beehive.gd new file mode 100644 index 00000000..d8a83a0f --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_beehive.gd @@ -0,0 +1,284 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = beehive_1_col(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o80035 = 15184; +var p_o80035_sx = 4.000000000; +var p_o80035_sy = 4.000000000; + +func beehive_1_col(uv : Vector2) -> Color: + var o80035_0_uv : Vector2 = ((uv)) * Vector2(p_o80035_sx, p_o80035_sy * 1.73205080757); + var center : Color = beehive_center(o80035_0_uv); + + var f : float = 1.0 - 2.0 * beehive_dist(Vector2(center.r, center.g)); + + return Color(f, f, f, 1) + +func beehive_2_col(uv : Vector2) -> Color: + var o80035_0_uv : Vector2 = ((uv)) * Vector2(p_o80035_sx, p_o80035_sy * 1.73205080757); + var center : Color = beehive_center(o80035_0_uv); + + var f : float = 1.0 - 2.0 * beehive_dist(Vector2(center.r, center.g)); + + var v : Vector3 = rand3(fractv2(Vector2(center.b, center.a) / Vector2(p_o80035_sx, p_o80035_sy)) + Vector2(float(seed_o80035),float(seed_o80035))); + + return Color(v.x, v.y, v.z, 1) + +func beehive_3_col(uv : Vector2) -> Color: + var o80035_0_uv : Vector2 = ((uv)) * Vector2(p_o80035_sx, p_o80035_sy * 1.73205080757); + var center : Color = beehive_center(o80035_0_uv); + + #var f : float = 1.0 - 2.0 * beehive_dist(Vector2(center.r, center.g)); + + var v1 : Vector2 = Vector2(0.5, 0.5) + Vector2(center.r, center.g) + var ff : float = rand(fractv2(Vector2(center.b, center.a) / Vector2(p_o80035_sx, p_o80035_sy)) + Vector2(float(seed_o80035), float(seed_o80035))) + + var c : Color = Color(v1.x, v1.y, ff, ff); + + return c + + +func beehive_dist(p : Vector2) -> float: + var s : Vector2 = Vector2(1.0, 1.73205080757); + + p = absv2(p); + + return max(p.dot(s*.5), p.x); + +func beehive_center(p : Vector2) -> Color: + var s : Vector2 = Vector2(1.0, 1.73205080757); + + var hC : Color = Color(p.x, p.y, p.x - 0.5, p.y - 1) / Color(s.x, s.y, s.x, s.y); + + hC = floorc(Color(p.x, p.y, p.x - 0.5, p.y - 1) / Color(s.x, s.y, s.x, s.y)) + Color(0.5, 0.5, 0.5, 0.5); + + var v1 : Vector2 = Vector2(p.x - hC.r * s.x, p.y - hC.g * s.y) + var v2 : Vector2 = Vector2(p.x - (hC.b + 0.5) * s.x, p.y - (hC.a + 0.5) * s.y) + + var h : Color = Color(v1.x, v1.y, v2.x, v2.y); + + if Vector2(h.r, h.g).dot(Vector2(h.r, h.g)) < Vector2(h.b, h.a).dot(Vector2(h.b, h.a)): + return Color(h.r, h.g, hC.r, hC.g) + else: + return Color(h.b, h.a, hC.b + 9.73, hC.a + 9.73) + + #return dot(h.xy, h.xy) < dot(h.zw, h.zw) ? Color(h.xy, hC.xy) : Color(h.zw, hC.zw + 9.73); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_beehive.tscn b/game/addons/mat_maker_gd/pattern/pattern_beehive.tscn new file mode 100644 index 00000000..3f7a7b05 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_beehive.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_beehive.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_generic.gd b/game/addons/mat_maker_gd/pattern/pattern_generic.gd new file mode 100644 index 00000000..b5acc62d --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_generic.gd @@ -0,0 +1,309 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + +enum CombinerAxisType { + SINE, + TRIANGLE, + SQUARE, + SAWTOOTH, + CONSTANT, + BOUNCE +} + +enum CombinerType { + MULTIPLY, + ADD, + MAX, + MIN, + XOR, + POW +} + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = Color(f, f, f, 1) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +#var p_o7009_x_scale = 4.000000000; +#var p_o7009_y_scale = 4.000000000; + + +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 = wave_sine(x_scale * uv.x) + elif catx == CombinerAxisType.TRIANGLE: + x = wave_triangle(x_scale * uv.x) + elif catx == CombinerAxisType.SQUARE: + x = wave_square(x_scale * uv.x) + elif catx == CombinerAxisType.SAWTOOTH: + x = wave_sawtooth(x_scale * uv.x) + elif catx == CombinerAxisType.CONSTANT: + x = wave_constant(x_scale * uv.x) + elif catx == CombinerAxisType.BOUNCE: + x = wave_bounce(x_scale * uv.x) + + if caty == CombinerAxisType.SINE: + y = wave_sine(y_scale * uv.y) + elif caty == CombinerAxisType.TRIANGLE: + y = wave_triangle(y_scale * uv.y) + elif caty == CombinerAxisType.SQUARE: + y = wave_square(y_scale * uv.y) + elif caty == CombinerAxisType.SAWTOOTH: + y = wave_sawtooth(y_scale * uv.y) + elif caty == CombinerAxisType.CONSTANT: + y = wave_constant(y_scale * uv.y) + elif caty == CombinerAxisType.BOUNCE: + y = wave_bounce(y_scale * uv.y) + + if ct == CombinerType.MULTIPLY: + return mix_mul(x, y) + elif ct == CombinerType.ADD: + return mix_add(x, y); + elif ct == CombinerType.MAX: + return mix_max(x, y); + elif ct == CombinerType.MIN: + return mix_min(x, y); + elif ct == CombinerType.XOR: + return mix_xor(x, y); + elif ct == CombinerType.POW: + return mix_pow(x, y); + + return 0.0 + +func wave_constant(x : float) -> float: + return 1.0; + +func wave_sine(x : float) -> float: + return 0.5-0.5*cos(3.14159265359*2.0*x); + +func wave_triangle(x : float) -> float: + x = fractf(x); + return min(2.0*x, 2.0-2.0*x); + +func wave_sawtooth(x : float) -> float: + return fractf(x); + +func wave_square(x : float) -> float: + if (fractf(x) < 0.5): + return 0.0 + else: + return 1.0 + +func wave_bounce(x : float) -> float: + x = 2.0*(fractf(x)-0.5); + return sqrt(1.0-x*x); + +func mix_mul(x : float, y : float) -> float: + return x*y; + +func mix_add(x : float, y : float) -> float: + return min(x+y, 1.0); + +func mix_max(x : float, y : float) -> float: + return max(x, y); + +func mix_min(x : float, y : float) -> float: + return min(x, y); + +func mix_xor(x : float, y : float) -> float: + return min(x+y, 2.0-x-y); + +func mix_pow(x : float, y : float) -> float: + return pow(x, y); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_generic.tscn b/game/addons/mat_maker_gd/pattern/pattern_generic.tscn new file mode 100644 index 00000000..7195c3de --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_generic.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_generic.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_iching.gd b/game/addons/mat_maker_gd/pattern/pattern_iching.gd new file mode 100644 index 00000000..7094c656 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_iching.gd @@ -0,0 +1,226 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = runecol(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o57193 = 16936; +var p_o57193_columns = 2.000000000; +var p_o57193_rows = 2.000000000; + +func runecol(uv : Vector2) -> Color: + var f : float = IChing(Vector2(p_o57193_columns, p_o57193_rows)*((uv)), float(seed_o57193)); + + return Color(f, f, f, 1) + +func IChing(uv : Vector2, pseed : float) -> float: + var value : int = int(32.0 * rand(floorv2(uv) + Vector2(pseed, pseed))); + var base : float = step(0.5, fract(fract(uv.y)*6.5))*step(0.04, fract(uv.y+0.02)) * step(0.2, fract(uv.x+0.1)); + var bit : int = int(fract(uv.y)*6.5); + + return base * step(0.1*step(float(bit & value), 0.5), fract(uv.x+0.55)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_iching.tscn b/game/addons/mat_maker_gd/pattern/pattern_iching.tscn new file mode 100644 index 00000000..fa798a33 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_iching.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_iching.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_rune.gd b/game/addons/mat_maker_gd/pattern/pattern_rune.gd new file mode 100644 index 00000000..bada1f36 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_rune.gd @@ -0,0 +1,277 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = runecol(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o49619_columns = 4.000000000; +var p_o49619_rows = 4.000000000; + +func runecol(uv : Vector2) -> Color: + var f : float = Rune(Vector2(p_o49619_columns, p_o49619_rows)*((uv))); + + return Color(f, f, f, 1) + + +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; + +# makes a rune in the 0..1 uv space. Seed is which rune to draw. +# passes back gray in x and derivates for lighting in yz +func Rune(uv : Vector2) -> float: + var finalLine : float = 0.0; + var pseed : Vector2 = floorv2(uv) - Vector2(0.41, 0.41); + + uv = fractv2(uv); + + for i in range(4):# (int i = 0; i < 4; i++): # // number of strokes + var posA : Vector2 = rand2(floorv2(pseed + Vector2(0.5, 0.5))); + var posB : Vector2 = rand2(floorv2(pseed + Vector2(1.5, 1.5))); + pseed.x += 2.0; + pseed.y += 2.0; + + # expand the range and mod it to get a nicely distributed random number - hopefully. :) + + posA = fractv2(posA * 128.0); + posB = fractv2(posB * 128.0); + + # each rune touches the edge of its box on all 4 sides + if (i == 0): + posA.y = 0.0; + + if (i == 1): + posA.x = 0.999; + + if (i == 2): + posA.x = 0.0; + + if (i == 3): + posA.y = 0.999; + + # snap the random line endpoints to a grid 2x3 + + var snaps : Vector2 = Vector2(2.0, 3.0); + + posA = (floorv2(posA * snaps) + Vector2(0.5, 0.5)) / snaps; # + 0.5 to center it in a grid cell + posB = (floorv2(posB * snaps) + Vector2(0.5, 0.5)) / snaps; + + #if (distance(posA, posB) < 0.0001) continue; // eliminate dots. + # Dots (degenerate lines) are not cross-GPU safe without adding 0.001 - divide by 0 error. + + finalLine = max(finalLine, ThickLine(uv, posA, posB + Vector2(0.001, 0.001), 20.0)); + + return finalLine; + + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_rune.tscn b/game/addons/mat_maker_gd/pattern/pattern_rune.tscn new file mode 100644 index 00000000..1cd563d4 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_rune.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_rune.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_scratches.gd b/game/addons/mat_maker_gd/pattern/pattern_scratches.gd new file mode 100644 index 00000000..c4e0b01f --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_scratches.gd @@ -0,0 +1,252 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = scratchescol(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var seed_o74963 = 31821; +var p_o74963_length = 0.250000000; +var p_o74963_width = 0.400000000; +var p_o74963_layers = 5.000000000; +var p_o74963_waviness = 0.510000000; +var p_o74963_angle = -1.000000000; +var p_o74963_randomness = 0.440000000; + +func scratchescol(uv : Vector2) -> Color: + var f : float = scratches(((uv)), int(p_o74963_layers), Vector2(p_o74963_length, p_o74963_width), p_o74963_waviness, p_o74963_angle, p_o74963_randomness, Vector2(float(seed_o74963), 0.0)); + + return Color(f, f, f, 1) + +func scratch(uv : Vector2, size : Vector2, waviness : float, angle : float, randomness : float, pseed : Vector2) -> float: + var subdivide : float = floor(1.0/size.x); + var cut : float = size.x*subdivide; + uv *= subdivide; + var r1 : Vector2 = rand2(floorv2(uv) + pseed); + var r2 : Vector2 = rand2(r1); + uv = fractv2(uv); + uv = 2.0 * uv - Vector2(1, 1); + + var a : float = 6.28*(angle+(r1.x-0.5)*randomness); + var c : float = cos(a); + var s : float = sin(a); + + uv = Vector2(c*uv.x+s*uv.y, s*uv.x-c*uv.y); + uv.y += 2.0*r1.y-1.0; + uv.y += 0.5*waviness*cos(2.0*uv.x+6.28*r2.y); + uv.x /= cut; + uv.y /= subdivide*size.y; + + return (1.0-uv.x*uv.x)*max(0.0, 1.0-1000.0*uv.y*uv.y); + +func scratches(uv : Vector2, layers : int, size : Vector2, waviness : float, angle : float, randomness : float, pseed : Vector2) -> float: + var v : float = 0.0; + + for i in range(layers):# (int i = 0; i < layers; ++i) { + v = max(v, scratch(fractv2(uv + pseed), size, waviness, angle/360.0, randomness, pseed)); + pseed = rand2(pseed); + + return v; + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_scratches.tscn b/game/addons/mat_maker_gd/pattern/pattern_scratches.tscn new file mode 100644 index 00000000..01181d85 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_scratches.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_scratches.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_sine_wave.gd b/game/addons/mat_maker_gd/pattern/pattern_sine_wave.gd new file mode 100644 index 00000000..33a3d4d3 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_sine_wave.gd @@ -0,0 +1,232 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = sinewave(v) +# var col : Color = beehive_2_col(v) +# var col : Color = beehive_3_col(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o7136_amplitude = 0.500000000; +var p_o7136_frequency = 2.000000000; +var p_o7136_phase = 0.000000000; + +func sinewave(uv : Vector2) -> Color: + + var f : float = 1.0- abs(2.0 * (uv.y-0.5) - p_o7136_amplitude * sin((p_o7136_frequency* uv.x + p_o7136_phase) * 6.28318530718)); + + return Color(f, f, f, 1) + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + +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 + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv2(v : Vector2) -> Vector2: + v.x = cos(v.x) + v.y = cos(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_sine_wave.tscn b/game/addons/mat_maker_gd/pattern/pattern_sine_wave.tscn new file mode 100644 index 00000000..61c247c0 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_sine_wave.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_sine_wave.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_truchet.gd b/game/addons/mat_maker_gd/pattern/pattern_truchet.gd new file mode 100644 index 00000000..9ae6cd4e --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_truchet.gd @@ -0,0 +1,225 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = trunchet(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + + + +var seed_o9164 = 6039; +var p_o9164_size = 4.000000000; + +func trunchet(uv : Vector2) -> Color: +# var f : float = truchet1(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164))); + var f : float = truchet2(uv * p_o9164_size, Vector2(float(seed_o9164), float(seed_o9164))); + var col : Color = Color(f, f, f, 1); + + return col + +func truchet1(uv : Vector2, pseed : Vector2) -> float: + var i : Vector2 = floorv2(uv); + var f : Vector2 = fractv2(uv) - Vector2(0.5, 0.5); + return 1.0 - abs(abs((2.0*step(rand(i+pseed), 0.5)-1.0)*f.x+f.y)-0.5); + +func truchet2(uv : Vector2, pseed : Vector2) -> float: + var i : Vector2 = floorv2(uv); + var f : Vector2 = fractv2(uv); + var random : float = step(rand(i+pseed), 0.5); + f.x *= 2.0 * random-1.0; + f.x += 1.0 - random; + return 1.0 - min(abs(f.length() - 0.5), abs((Vector2(1, 1) - f).length() - 0.5)); + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_truchet.tscn b/game/addons/mat_maker_gd/pattern/pattern_truchet.tscn new file mode 100644 index 00000000..40c1ffaf --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_truchet.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_truchet.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/pattern/pattern_weave.gd b/game/addons/mat_maker_gd/pattern/pattern_weave.gd new file mode 100644 index 00000000..c94a2f68 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_weave.gd @@ -0,0 +1,217 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var f : float = pattern(v, 4, 4, CombinerType.MULTIPLY, CombinerAxisType.SINE, CombinerAxisType.SINE) + + var col : Color = weavecol(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + + +var p_o46354_columns = 4.000000000; +var p_o46354_rows = 4.000000000; +var p_o46354_width = 1.000000000; + +func weavecol(uv : Vector2) -> Color: + var f : float = weave(uv, Vector2(p_o46354_columns, p_o46354_rows), p_o46354_width*1.0); + + return Color(f, f, f, 1) + + +func weave(uv : Vector2, count : Vector2, width : float) -> float: + uv *= count; + var c : float = (sin(3.1415926* (uv.x + floor(uv.y)))*0.5+0.5)*step(abs(fract(uv.y)-0.5), width*0.5); + c = max(c, (sin(3.1415926*(1.0+uv.y+floor(uv.x)))*0.5+0.5)*step(abs(fract(uv.x)-0.5), width*0.5)); + return c; + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fractv2(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fract(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/pattern/pattern_weave.tscn b/game/addons/mat_maker_gd/pattern/pattern_weave.tscn new file mode 100644 index 00000000..24da16b4 --- /dev/null +++ b/game/addons/mat_maker_gd/pattern/pattern_weave.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/pattern/pattern_weave.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/plugin.cfg b/game/addons/mat_maker_gd/plugin.cfg new file mode 100644 index 00000000..0431311e --- /dev/null +++ b/game/addons/mat_maker_gd/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="mat_maker_gd" +description="" +author="Relintai" +version="" +script="plugin.gd" diff --git a/game/addons/mat_maker_gd/plugin.gd b/game/addons/mat_maker_gd/plugin.gd new file mode 100644 index 00000000..49e712eb --- /dev/null +++ b/game/addons/mat_maker_gd/plugin.gd @@ -0,0 +1,10 @@ +tool +extends EditorPlugin + + +func _enter_tree(): + pass + + +func _exit_tree(): + pass diff --git a/game/addons/mat_maker_gd/sdf2d/sdf.gd b/game/addons/mat_maker_gd/sdf2d/sdf.gd new file mode 100644 index 00000000..007a2632 --- /dev/null +++ b/game/addons/mat_maker_gd/sdf2d/sdf.gd @@ -0,0 +1,287 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + pass + + +#sdshow +var p_o47009_bevel = 0.100000000; + +#circle +var p_o11635_r = 0.400000000; +var p_o11635_cx = 0.000000000; +var p_o11635_cy = 0.000000000; + +#box +var p_o48575_w = 0.300000000; +var p_o48575_h = 0.200000000; +var p_o48575_cx = 0.000000000; +var p_o48575_cy = 0.000000000; + +#line +var p_o49570_ax = -0.300000000; +var p_o49570_ay = -0.300000000; +var p_o49570_bx = 0.300000000; +var p_o49570_by = 0.300000000; +var p_o49570_r = 0.200000000; + +#rhombus +var p_o50848_w = 0.300000000; +var p_o50848_h = 0.200000000; +var p_o50848_cx = 0.000000000; +var p_o50848_cy = 0.000000000; + +#arc +var p_o51990_a1 = 0.000000000; +var p_o51990_a2 = 0.000000000; +var p_o51990_r1 = 0.300000000; +var p_o51990_r2 = 0.100000000; + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var fc : float = sdf_circle(v) +# var fc : float = sdf_box(v) +# var fc : float = sdf_line(v) +# var fc : float = sdf_rhombus(v) +# var fc : float = sdf_arc(v) + +# var fc : float = sdf_boolean_union(sdf_circle(v), sdf_box(v)) +# var fc : float = sdf_boolean_substraction(sdf_circle(v), sdf_box(v)) +# var fc : float = sdf_boolean_intersection(sdf_circle(v), sdf_box(v)) + +# var fc : float = sdf_smooth_boolean_union(sdf_circle(v), sdf_box(v), 0.15) +# var fc : float = sdf_smooth_boolean_substraction(sdf_circle(v), sdf_box(v), 0.15) +# var fc : float = sdf_smooth_boolean_intersection(sdf_circle(v), sdf_box(v), 0.15) + +# var fc : float = sdf_rounded_shape(sdf_box(v), 0.15) +# var fc : float = sdf_annular_shape(sdf_box(v), 0.15) + + var fc : float = sdf_morph(sdf_circle(v), sdf_box(v), 0.5) + + var col : Color = sdf_show(fc) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func sdf_show(val : float) -> Color: + var o47009_0_1_f : float = clamp(-val / max(p_o47009_bevel, 0.00001), 0.0, 1.0); + + return Color(o47009_0_1_f, o47009_0_1_f, o47009_0_1_f, 1) + + +func sdf_circle(uv : Vector2) -> float: + return (uv - Vector2(p_o11635_cx + 0.5, p_o11635_cy + 0.5)).length() - p_o11635_r; + + +func sdf_box(uv : Vector2) -> float: + var o48575_0_d : Vector2 = absv2(uv - Vector2(p_o48575_cx+0.5, p_o48575_cy+0.5)) - Vector2(p_o48575_w, p_o48575_h) + + return maxv2(o48575_0_d, Vector2(0, 0)).length() + min(max(o48575_0_d.x, o48575_0_d.y), 0.0) + +func sdf_line(uv : Vector2) -> float: + return sdLine(uv, Vector2(p_o49570_ax+0.5, p_o49570_ay+0.5), Vector2(p_o49570_bx+0.5, p_o49570_by+0.5)) - p_o49570_r; + +func sdLine(p : Vector2, a : Vector2, b : Vector2) -> float: + var pa : Vector2 = p - a + var ba : Vector2 = b - a + + var h : float = clamp(pa.dot(ba) / ba.dot(ba), 0.0, 1.0); + + return (pa - (ba * h)).length() + +func sdf_rhombus(uv : Vector2) -> float: + return sdRhombus(uv - Vector2(p_o50848_cx + 0.5, p_o50848_cy+0.5), Vector2(p_o50848_w, p_o50848_h)); + +func sdr_ndot(a : Vector2, b : Vector2) -> float: + return a.x * b.x - a.y * b.y; + +func sdRhombus(p : Vector2, b : Vector2) -> float: + var q : Vector2 = absv2(p); + var h : float = clamp((-2.0 * sdr_ndot(q,b) + sdr_ndot(b,b)) / b.dot(b), -1.0, 1.0); + var d : float = ( q - 0.5*b * Vector2(1.0-h, 1.0+h)).length() + return d * sign(q.x*b.y + q.y*b.x - b.x*b.y) + +func sdf_arc(uv : Vector2) -> float: + return sdArc(uv - Vector2(0.5, 0.5), modf(p_o51990_a1, 360.0) * 0.01745329251, modf(p_o51990_a2, 360.0)*0.01745329251, p_o51990_r1, p_o51990_r2); + +func sdArc(p : Vector2, a1 : float, a2 : float, ra : float, rb : float) -> float: + var amid : float = 0.5*(a1+a2)+1.6+3.14 * step(a1, a2); + var alength : float = 0.5*(a1-a2)-1.6+3.14 * step(a1, a2); + var sca : Vector2 = Vector2(cos(amid), sin(amid)); + var scb : Vector2 = Vector2(cos(alength), sin(alength)); + + #p *= Matrix(Vector2(sca.x , sca.y), Vector2(-sca.y, sca.x)); + + var pt : Vector2 = p + + p.x = pt.x * sca.x + pt.y * sca.y + p.y = pt.x * -sca.y + pt.y * sca.x + + p.x = abs(p.x); + + var k : float + + if (scb.y * p.x > scb.x * p.y): + k = p.dot(scb) + else: + k = p.length(); + + return sqrt( p.dot(p) + ra * ra - 2.0 * ra * k ) - rb; + + +func sdf_boolean_union(a : float, b : float) -> float: + return min(a, b) + +func sdf_boolean_substraction(a : float, b : float) -> float: + return max(-a, b) + +func sdf_boolean_intersection(a : float, b : float) -> float: + return max(a, b) + +func sdf_smooth_boolean_union(d1 : float, d2 : float, k : float) -> float: + var h : float = clamp( 0.5 + 0.5 * (d2 - d1) / k, 0.0, 1.0) + return lerp(d2, d1, h) - k * h * (1.0 - h) + +func sdf_smooth_boolean_substraction(d1 : float, d2 : float, k : float) -> float: + var h : float = clamp( 0.5 - 0.5 * (d2 + d1) / k, 0.0, 1.0) + return lerp(d2, -d1, h) + k * h * (1.0 - h) + +func sdf_smooth_boolean_intersection(d1 : float, d2 : float, k : float) -> float: + var h : float = clamp( 0.5 - 0.5 * (d2 - d1) / k, 0.0, 1.0) + return lerp(d2, d1, h) + k * h * (1.0 - h) + +func sdf_rounded_shape(a : float, r : float) -> float: + return a - r + +func sdf_annular_shape(a : float, r : float) -> float: + return abs(a) - r + +func sdf_morph(a : float, b : float, amount : float) -> float: + return lerp(a, b, amount) + +#Needs thought +#func sdf_translate(a : float, x : float, y : float) -> float: +# return lerp(a, b, amount) + +func sdf2d_rotate(uv : Vector2, a : float) -> Vector2: + var rv : Vector2; + var c : float = cos(a); + var s : float = sin(a); + uv -= Vector2(0.5, 0.5); + rv.x = uv.x*c+uv.y*s; + rv.y = -uv.x*s+uv.y*c; + return rv+Vector2(0.5, 0.5); + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/sdf2d/sdf.tscn b/game/addons/mat_maker_gd/sdf2d/sdf.tscn new file mode 100644 index 00000000..ea3489e1 --- /dev/null +++ b/game/addons/mat_maker_gd/sdf2d/sdf.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/sdf2d/sdf.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/sdf3d/sdf3d.gd b/game/addons/mat_maker_gd/sdf3d/sdf3d.gd new file mode 100644 index 00000000..3a532bbf --- /dev/null +++ b/game/addons/mat_maker_gd/sdf3d/sdf3d.gd @@ -0,0 +1,517 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +func _ready(): + if !Engine.editor_hint: + gen() + + +var g_r = 0.010000000; + +#box +var g_sx = 0.300000000; +var g_sy = 0.250000000; +var g_sz = 0.250000000; + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + var col : Color = raymarch(v) +# var col : Color = raymarch2(v) +# var col : Color = raymarch3(v) + + image.set_pixel(x, y, col) + + + image.unlock() + + tex.create_from_image(image) + texture = tex + +var p_o22692_r = 0.400000000; + +func sdf3d_input(p : Vector3) -> Vector2: +# return sdf3d_box(p, g_sx, g_sy, g_sz, g_r); +# return sdf3d_sphere(p); +# return sdf3d_cylinder_x(p); +# return sdf3d_cylinder_y(p); +# return sdf3d_cylinder_z(p); + +# return sdf3d_capsule_x(p); +# return sdf3d_capsule_y(p); +# return sdf3d_capsule_z(p); + +# return sdf3d_cone_px(p); +# return sdf3d_cone_nx(p); +# return sdf3d_cone_py(p); +# return sdf3d_cone_ny(p); +# return sdf3d_cone_pz(p); + +# return sdf3d_torus_x(p); +# return sdf3d_torus_y(p); +# return sdf3d_torus_z(p); + +# return sdf3dc_union(sdf3d_sphere(p),sdf3d_capsule_x(p)) ; +# return sdf3d_smooth_union(sdf3d_sphere(p),sdf3d_capsule_x(p), 0.5) + +# return sdf3d_rounded(sdf3d_sphere(p)); + +# return sdf3d_sphere(sdf3d_elongation(p)) + + return sdf3d_sphere(sdf3d_repeat(p)) + + +#vec2 o157216_0_1_sdf3dc = sdf3dc_union(vec2(o152465_0_1_sdf3d, 0.0), vec2(o153139_0_1_sdf3d, 0.0)); + +func raymarch(uv : Vector2) -> Color: + var o21422_0_d : Vector2 = sdf3d_raymarch(uv); + + var o21422_0_1_f : float = 1.0 - o21422_0_d.x; + + return Color(o21422_0_1_f, o21422_0_1_f, o21422_0_1_f, 1) + +func raymarch2(uv : Vector2) -> Color: + var o21422_0_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 - o21422_0_d.x)); + + return Color(v.x, v.y, v.z, 1) + +func raymarch3(uv : Vector2) -> Color: + var v : Vector2 = sdf3d_raymarch(uv); + + return Color(v.y, v.y, v.y, 1) + +func sdf3d_sphere(p : Vector3) -> Vector2: + var o22692_0_1_sdf3d : float = p.length() - p_o22692_r; + + return Vector2(o22692_0_1_sdf3d, 0.0); + +func sdf3d_box(p : Vector3, sx : float, sy : float, sz : float, r : float) -> Vector2: + var v : Vector3 = absv3((p)) - Vector3(sx, sy, sz); + var f : float = (maxv3(v,Vector3())).length() + min(max(v.x,max(v.y, v.z)),0.0) - r; + + return Vector2(f, 0.0); + +var p_o69351_l = 0.250000000; +var p_o69351_r = 0.250000000; + +func sdf3d_cylinder_y(p : Vector3) -> Vector2: + var o69351_0_d : Vector2 = absv2(Vector2(Vector2(p.x, p.z).length(),(p).y)) - Vector2(p_o69351_r,p_o69351_l); + var o69351_0_1_sdf3d : float = min(max(o69351_0_d.x, o69351_0_d.y),0.0) + maxv2(o69351_0_d, Vector2()).length(); + + return Vector2(o69351_0_1_sdf3d, 0.0); + +func sdf3d_cylinder_x(p : Vector3) -> Vector2: + var o69351_0_d : Vector2 = absv2(Vector2(Vector2(p.y, p.z).length(),(p).x)) - Vector2(p_o69351_r,p_o69351_l); + var o69351_0_1_sdf3d : float = min(max(o69351_0_d.x, o69351_0_d.y),0.0) + maxv2(o69351_0_d, Vector2()).length(); + + return Vector2(o69351_0_1_sdf3d, 0.0); + +func sdf3d_cylinder_z(p : Vector3) -> Vector2: + var o69351_0_d : Vector2 = absv2(Vector2(Vector2(p.x, p.y).length(),(p).z)) - Vector2(p_o69351_r,p_o69351_l); + var o69351_0_1_sdf3d : float = min(max(o69351_0_d.x, o69351_0_d.y),0.0) + maxv2(o69351_0_d, Vector2()).length(); + + return Vector2(o69351_0_1_sdf3d, 0.0); + +var p_o100081_l = 0.300000000; +var p_o100081_r = 0.200000000; + +func sdf3d_capsule_y(p : Vector3) -> Vector2: + var o100081_0_p : Vector3 = p; + o100081_0_p.y -= clamp(o100081_0_p.y, -p_o100081_l, p_o100081_l); + var o100081_0_1_sdf3d : float = o100081_0_p.length() - p_o100081_r; + + return Vector2(o100081_0_1_sdf3d, 0.0); + +func sdf3d_capsule_x(p : Vector3) -> Vector2: + var o100081_0_p : Vector3 = p; + o100081_0_p.x -= clamp(o100081_0_p.x, -p_o100081_l, p_o100081_l); + var o100081_0_1_sdf3d : float = o100081_0_p.length() - p_o100081_r; + + return Vector2(o100081_0_1_sdf3d, 0.0); + +func sdf3d_capsule_z(p : Vector3) -> Vector2: + var o100081_0_p : Vector3 = p; + o100081_0_p.z -= clamp(o100081_0_p.z, -p_o100081_l, p_o100081_l); + var o100081_0_1_sdf3d : float = o100081_0_p.length() - p_o100081_r; + + return Vector2(o100081_0_1_sdf3d, 0.0); + +var p_o118934_a = 30.000000000; + +func sdf3d_cone_px(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(), - (p).x)); + + return Vector2(f, 0.0); + +func sdf3d_cone_nx(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(),(p).x)); + + return Vector2(f, 0.0); + +func sdf3d_cone_py(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),(p).y)); + + return Vector2(f, 0.0); + +func sdf3d_cone_ny(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),-(p).y)); + + return Vector2(f, 0.0); + +func sdf3d_cone_pz(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),-(p).z)); + + return Vector2(f, 0.0); + +func sdf3d_cone_nz(p : Vector3) -> Vector2: + var f : float = Vector2(cos(p_o118934_a*0.01745329251),sin(p_o118934_a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),(p).z)); + + return Vector2(f, 0.0); + +var p_o136697_R = 0.300000000; +var p_o136697_r = 0.150000000; + +func sdf3d_torus_x(p : Vector3) -> Vector2: + var o136697_0_q : Vector2 = Vector2(Vector2(p.y, p.z).length() - p_o136697_R,(p).x); + var o136697_0_1_sdf3d : float = o136697_0_q.length() - p_o136697_r; + + return Vector2(o136697_0_1_sdf3d, 0.0); + +func sdf3d_torus_y(p : Vector3) -> Vector2: + var o136697_0_q : Vector2 = Vector2(Vector2(p.z, p.x).length() - p_o136697_R,(p).y); + var o136697_0_1_sdf3d : float = o136697_0_q.length() - p_o136697_r; + + return Vector2(o136697_0_1_sdf3d, 0.0); + +func sdf3d_torus_z(p : Vector3) -> Vector2: + var o136697_0_q : Vector2 = Vector2(Vector2(p.x, p.y).length() - p_o136697_R,(p).z); + var o136697_0_1_sdf3d : float = o136697_0_q.length() - p_o136697_r; + + return Vector2(o136697_0_1_sdf3d, 0.0); + + +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); + +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(); + +func sdf3dc_union(a : Vector2, b : Vector2) -> Vector2: + return Vector2(min(a.x, b.x), lerp(b.y, a.y, step(a.x, b.x))); + +func sdf3dc_sub(a : Vector2, b : Vector2) -> Vector2: + return Vector2(max(-a.x, b.x), a.y); + + +func sdf3dc_inter(a : Vector2, b : Vector2) -> Vector2: + return Vector2(max(a.x, b.x), lerp(a.y, b.y, step(a.x, b.x))); + + +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, step(d1.x, d2.x))); + +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); + +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, step(d1.x, d2.x))); + +var p_o885532_r = 0.250000000; + +func sdf3d_rounded(v : Vector2) -> Vector2: + return Vector2(v.x - p_o885532_r, v.y); + +var p_o900574_x = 0.200000000; +var p_o900574_y = 0.000000000; +var p_o900574_z = 0.000000000; + +func sdf3d_elongation(p : Vector3) -> Vector3: + return ((p) - clampv3((p), - absv3(Vector3(p_o900574_x, p_o900574_y, p_o900574_z)), absv3(Vector3(p_o900574_x, p_o900574_y, p_o900574_z)))) + +var seed_o910161 = -49592; +var p_o910161_rx = 3.000000000; +var p_o910161_ry = 3.000000000; +var p_o910161_r = 0.300000000; +var p_o152465_r = 0.400000000; + +func sdf3d_repeat(p : Vector3) -> Vector3: + return (repeat((p), Vector3(1.0/p_o910161_rx, 1.0/p_o910161_ry, 0.00001), float(seed_o910161), p_o910161_r)) + +#Needs work +func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float) -> Vector3: + #fix division by zero +# p.x += 0.000001 +# p.y += 0.000001 +# p.z += 0.000001 +# r.x += 0.000001 +# r.y += 0.000001 +# r.z += 0.000001 + + var pxy : Vector2 = Vector2(p.x, p.y) + var rxy : Vector2 = Vector2(r.x, r.y) + + var r3 : Vector2 = floorv2(modv2((pxy + 0.5 * rxy) / rxy, Vector2(1.0 / rxy.x, 1.0 / rxy.y)) + Vector2(pseed, pseed)) + + var rr : Vector3 = rand3(r3) + + rr.x -= 0.5 + rr.y -= 0.5 + rr.z -= 0.5 + + var a : Vector3 = (rr) * 6.28 * randomness; + + p = modv3(p + 0.5 * r, r) - 0.5*r; + var rv : Vector3; + var c : float; + var s : float; + + 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; + + +# +#vec2 o21422_input_sdf(vec3 p) { +#float o152465_0_1_sdf3d = length((circle_repeat_transform((p), p_o928780_c)))-p_o152465_r; +#vec2 o928780_0_1_sdf3dc = vec2(o152465_0_1_sdf3d, 0.0); +# +#return o928780_0_1_sdf3dc; +# +#var p_o928780_c = 5.000000000; +# +#func circle_repeat_transform(p : Vector3, r : Vector3, pseed : float, randomness : float) -> Vector3: +# 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; + + +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.y = clamp(v.z, mi.z, ma.z) + + return v + + +func floorv2(a : Vector2) -> Vector2: + var v : Vector2 = Vector2() + + v.x = floor(a.x) + v.y = floor(a.y) + + return v + +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 + +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 + +func absv2(v : Vector2) -> Vector2: + v.x = abs(v.x) + v.y = abs(v.y) + + return v + +func absv3(v : Vector3) -> Vector3: + v.x = abs(v.x) + v.y = abs(v.y) + v.y = abs(v.y) + + return v + +func cosv3(v : Vector3) -> Vector3: + v.x = cos(v.x) + v.y = cos(v.y) + v.y = cos(v.y) + + return v + +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 + + +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 + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +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 + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +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); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/sdf3d/sdf3d.tscn b/game/addons/mat_maker_gd/sdf3d/sdf3d.tscn new file mode 100644 index 00000000..81106432 --- /dev/null +++ b/game/addons/mat_maker_gd/sdf3d/sdf3d.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/sdf3d/sdf3d.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.gd b/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.gd new file mode 100644 index 00000000..f9ec35f0 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.gd @@ -0,0 +1,178 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +#class TGEntry: +# var pos : float +# var r : float +# var g : float +# var b : float +# var a : float + +var p_o95415_repeat = 1.000000000; + +var p_o95415_gradient_0_pos = 0.000000000; +var p_o95415_gradient_0_r = 0.000000000; +var p_o95415_gradient_0_g = 0.000000000; +var p_o95415_gradient_0_b = 0.000000000; +var p_o95415_gradient_0_a = 1.000000000; +var p_o95415_gradient_1_pos = 0.490909091; +var p_o95415_gradient_1_r = 1.000000000; +var p_o95415_gradient_1_g = 0.000000000; +var p_o95415_gradient_1_b = 0.000000000; +var p_o95415_gradient_1_a = 1.000000000; +var p_o95415_gradient_2_pos = 1.000000000; +var p_o95415_gradient_2_r = 1.000000000; +var p_o95415_gradient_2_g = 1.000000000; +var p_o95415_gradient_2_b = 1.000000000; +var p_o95415_gradient_2_a = 1.000000000; + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + + #branchless fix for division by zero + v.y += 0.000001 + +# var col : Color = gradient_type_1(fractf(p_o95415_repeat * 0.15915494309 * atan((v.x - 0.5) / (v.y - 0.5)))); +# var col : Color = gradient_type_2(fractf(p_o95415_repeat * 0.15915494309 * atan((v.x - 0.5) / (v.y - 0.5)))); +# var col : Color = gradient_type_3(fractf(p_o95415_repeat * 0.15915494309 * atan((v.x - 0.5) / (v.y - 0.5)))); + var col : Color = gradient_type_4(fractf(p_o95415_repeat * 0.15915494309 * atan((v.x - 0.5) / v.y - 0.5))); + + image.set_pixel(x, y, col) + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func gradient_type_1(x : float) -> Color: + if (x < 0.5*(p_o95415_gradient_0_pos+p_o95415_gradient_1_pos)): + return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a); + elif (x < 0.5*(p_o95415_gradient_1_pos+p_o95415_gradient_2_pos)): + return Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a); + + return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a); + +func gradient_type_2(x : float) -> Color: + if (x < p_o95415_gradient_0_pos): + return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a); + elif (x < p_o95415_gradient_1_pos): + return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), ((x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos))); + elif (x < p_o95415_gradient_2_pos): + return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), ((x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos))); + + return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a); + + +func gradient_type_3(x : float) -> Color: + if (x < p_o95415_gradient_0_pos): + return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a); + elif (x < p_o95415_gradient_1_pos): + return lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos))); + if (x < p_o95415_gradient_2_pos): + return lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos))); + + return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a); + +func gradient_type_4(x : float) -> Color: + if (x < p_o95415_gradient_0_pos): + return Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a); + elif (x < p_o95415_gradient_1_pos): + return lerp(lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), 1.0-0.5*(x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)); + elif (x < p_o95415_gradient_2_pos): + return lerp(lerp(Color(p_o95415_gradient_0_r,p_o95415_gradient_0_g,p_o95415_gradient_0_b,p_o95415_gradient_0_a), Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), (x-p_o95415_gradient_0_pos)/(p_o95415_gradient_1_pos-p_o95415_gradient_0_pos)), lerp(Color(p_o95415_gradient_1_r,p_o95415_gradient_1_g,p_o95415_gradient_1_b,p_o95415_gradient_1_a), Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a), (x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)), 0.5+0.5*(x-p_o95415_gradient_1_pos)/(p_o95415_gradient_2_pos-p_o95415_gradient_1_pos)); + + return Color(p_o95415_gradient_2_r,p_o95415_gradient_2_g,p_o95415_gradient_2_b,p_o95415_gradient_2_a); + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.tscn b/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.tscn new file mode 100644 index 00000000..07697a19 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectCirtularGradient.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/simple/TextureRectCirtularGradient.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/simple/TextureRectCurve.gd b/game/addons/mat_maker_gd/simple/TextureRectCurve.gd new file mode 100644 index 00000000..060dad49 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectCurve.gd @@ -0,0 +1,208 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +var p_o147388_ax = -0.349999994; +var p_o147388_ay = -0.200000000; +var p_o147388_bx = 0.000000000; +var p_o147388_by = 0.500000000; +var p_o147388_cx = 0.350000000; +var p_o147388_cy = -0.200000000; +var p_o147388_width = 0.050000000; +var p_o147388_repeat = 1.000000000; + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var c : float = shape_circle(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_polygon(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_curved_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) + + var o147388_0_bezier : Vector2 = sdBezier(v, Vector2(p_o147388_ax+0.5, p_o147388_ay+0.5), Vector2(p_o147388_bx+0.5, p_o147388_by+0.5), Vector2(p_o147388_cx+0.5, p_o147388_cy+0.5)); + var o147388_0_uv : Vector2 = Vector2(o147388_0_bezier.x, o147388_0_bezier.y/p_o147388_width+0.5); + + var uvt : Vector2 = absv(o147388_0_uv - Vector2(0.5, 0.5)) + + uvt.x = step(0.5, uvt.x); + uvt.y = step(0.5, uvt.y); + + o147388_0_uv = lerp(Vector2(fractf(p_o147388_repeat * o147388_0_uv.x), o147388_0_uv.y), Vector2(0, 0), max(uvt.x, uvt.y)); + + var f : float = step(abs(((o147388_0_uv)).y-0.5), 0.4999) + var c : Color = Color(f, f, f, 1.0); + + + image.set_pixel(x, y, c) + + image.unlock() + + tex.create_from_image(image) + texture = tex + +# signed distance to a quadratic bezier +func sdBezier(pos : Vector2, A : Vector2, B : Vector2, C : Vector2) -> Vector2: + var a : Vector2 = B - A; + var b : Vector2 = A - 2.0*B + C; + var c : Vector2 = a * 2.0; + var d : Vector2 = A - pos; + + var kk : float = 1.0 / b.dot(b); + var kx : float = kk * a.dot(b); + var ky : float = kk * (2.0* a.dot(a) + d.dot(b)) / 3.0; + var kz : float = kk * d.dot(a); + + var res : float = 0.0; + var sgn : float = 0.0; + + var p : float = ky - kx * kx; + var p3 : float = p*p*p; + var q : float = kx*(2.0*kx*kx - 3.0*ky) + kz; + var h : float = q*q + 4.0*p3; + var rvx : float; + + if(h >= 0.0):# // 1 root + h = sqrt(h); + + var x : Vector2 = Vector2(h,-h); + x.x -= q + x.y -= q + x.x /= 2.0 + x.y /= 2.0 + + var uv : Vector2 = Vector2() + + uv.x = sign(x.x) * pow(abs(x.x), 1); + uv.x = sign(x.y) * pow(abs(x.y), 3); + + rvx = uv.x+uv.y-kx; + var t : float = clamp(rvx, 0.0, 1.0); + var q2 : Vector2 = d+(c+b*t)*t; + res = q2.dot(q2); + + var tmp2 : Vector2 = c + tmp2.x += 2 + tmp2.y += 2 + + tmp2 *= b*t + + sgn = tmp2.cross(q2) + else: # // 3 roots + var z : float = sqrt(-p); + var v : float = acos(q/(p*z*2.0))/3.0; + var m : float = cos(v); + var n : float = sin(v)*1.732050808; + +# var t : Vector3 = clamp(Vector3(m+m,-n-m,n-m)*z-kx, 0.0, 1.0); +# +# +# var qx : Vector2 = d+(c+b*t.x)*t.x; +# var dx : float = dot(qx, qx) +# sx = cross2(c+2.0*b*t.x,qx); +# var qy : Vector2 = d+(c+b*t.y)*t.y; +# var dy : float = dot(qy, qy) +# sy = cross2(c+2.0*b*t.y,qy); +# if dx float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/simple/TextureRectCurve.tscn b/game/addons/mat_maker_gd/simple/TextureRectCurve.tscn new file mode 100644 index 00000000..7b4b5898 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectCurve.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/simple/TextureRectCurve.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/simple/TextureRectGradient.gd b/game/addons/mat_maker_gd/simple/TextureRectGradient.gd new file mode 100644 index 00000000..22c20b6a --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectGradient.gd @@ -0,0 +1,185 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +#class TGEntry: +# var pos : float +# var r : float +# var g : float +# var b : float +# var a : float + +var p_o28405_repeat : float = 1.000000000; +var p_o28405_rotate : float = 0.000000000; + +var p_o71406_repeat = 1.000000000; +var p_o71406_rotate = 0.000000000; +var p_o71406_gradient_0_pos = 0.000000000; +var p_o71406_gradient_0_r = 0.000000000; +var p_o71406_gradient_0_g = 0.000000000; +var p_o71406_gradient_0_b = 0.000000000; +var p_o71406_gradient_0_a = 1.000000000; +var p_o71406_gradient_1_pos = 0.509090909; +var p_o71406_gradient_1_r = 0.843750000; +var p_o71406_gradient_1_g = 0.003295898; +var p_o71406_gradient_1_b = 0.003295898; +var p_o71406_gradient_1_a = 1.000000000; +var p_o71406_gradient_2_pos = 1.000000000; +var p_o71406_gradient_2_r = 1.000000000; +var p_o71406_gradient_2_g = 1.000000000; +var p_o71406_gradient_2_b = 1.000000000; +var p_o71406_gradient_2_a = 1.000000000; + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237); +# var col : Color = gradient_type_1(fractf(rr * p_o71406_repeat)); + +# var rr : float = 0.5 + (cos(p_o28405_rotate*0.01745329251)*(v.x-0.5)+sin(p_o28405_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o28405_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237) +# var col : Color = gradient_type_2(fractf(rr * p_o71406_repeat)) + +# var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237); +# var col : Color = gradient_type_3(fractf(rr * p_o71406_repeat)) + + var rr : float = 0.5+(cos(p_o71406_rotate*0.01745329251)*(v.x-0.5)+sin(p_o71406_rotate*0.01745329251)*(v.y-0.5))/(cos(abs(modf(p_o71406_rotate, 90.0)-45.0)*0.01745329251)*1.41421356237); + var col : Color = gradient_type_4(fractf(rr * p_o71406_repeat)); + + image.set_pixel(x, y, col) + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func gradient_type_1(x : float) -> Color: + if (x < 0.5*(p_o71406_gradient_0_pos+p_o71406_gradient_1_pos)): + return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a); + elif (x < 0.5*(p_o71406_gradient_1_pos+p_o71406_gradient_2_pos)): + return Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a); + + return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a); + +func gradient_type_2(x : float) -> Color: + if (x < p_o71406_gradient_0_pos): + return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a); + elif (x < p_o71406_gradient_1_pos): + return lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), ((x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos))); + elif (x < p_o71406_gradient_2_pos): + return lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), ((x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos))); + + return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a); + +func gradient_type_3(x : float) -> Color: + if (x < p_o71406_gradient_0_pos): + return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a); + elif (x < p_o71406_gradient_1_pos): + return lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos))); + elif (x < p_o71406_gradient_2_pos): + return lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos))); + + return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a); + + +func gradient_type_4(x : float) -> Color: + if (x < p_o71406_gradient_0_pos): + return Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a); + elif (x < p_o71406_gradient_1_pos): + return lerp(lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), (x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)), lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), (x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)), 1.0-0.5*(x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)); + elif (x < p_o71406_gradient_2_pos): + return lerp(lerp(Color(p_o71406_gradient_0_r,p_o71406_gradient_0_g,p_o71406_gradient_0_b,p_o71406_gradient_0_a), Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), (x-p_o71406_gradient_0_pos)/(p_o71406_gradient_1_pos-p_o71406_gradient_0_pos)), lerp(Color(p_o71406_gradient_1_r,p_o71406_gradient_1_g,p_o71406_gradient_1_b,p_o71406_gradient_1_a), Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a), (x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)), 0.5+0.5*(x-p_o71406_gradient_1_pos)/(p_o71406_gradient_2_pos-p_o71406_gradient_1_pos)); + + return Color(p_o71406_gradient_2_r,p_o71406_gradient_2_g,p_o71406_gradient_2_b,p_o71406_gradient_2_a); + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/simple/TextureRectGradient.tscn b/game/addons/mat_maker_gd/simple/TextureRectGradient.tscn new file mode 100644 index 00000000..74753dc6 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectGradient.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/simple/TextureRectGradient.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.gd b/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.gd new file mode 100644 index 00000000..2346cd04 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.gd @@ -0,0 +1,184 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + +class TGEntry: + var pos : float + var r : float + var g : float + var b : float + var a : float + +var p_o28405_repeat : float = 1.000000000; +var p_o28405_rotate : float = 0.000000000; + + + +var p_o24141_gradient_0_pos = 0.000000000; +var p_o24141_gradient_0_r = 0.000000000; +var p_o24141_gradient_0_g = 0.000000000; +var p_o24141_gradient_0_b = 0.000000000; +var p_o24141_gradient_0_a = 1.000000000; +var p_o24141_gradient_1_pos = 0.554545455; +var p_o24141_gradient_1_r = 0.769531250; +var p_o24141_gradient_1_g = 0.318634033; +var p_o24141_gradient_1_b = 0.318634033; +var p_o24141_gradient_1_a = 1.000000000; +var p_o24141_gradient_2_pos = 1.000000000; +var p_o24141_gradient_2_r = 1.000000000; +var p_o24141_gradient_2_g = 1.000000000; +var p_o24141_gradient_2_b = 1.000000000; +var p_o24141_gradient_2_a = 1.000000000; + + + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# vec4 o24141_0_1_rgba = o24141_gradient_gradient_fct(fract(p_o24141_repeat*1.41421356237*length(fract(((uv)))-vec2(0.5, 0.5)))); +# vec3 o3335_0_1_rgb = ((o24141_0_1_rgba).rgb); +# + +# var col : Color = radial_gradient_type_1(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length())) +# var col : Color = radial_gradient_type_2(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length())) +# var col : Color = radial_gradient_type_3(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length())) + var col : Color = radial_gradient_type_4(fractf(p_o28405_repeat*1.41421356237* (fract(v)- Vector2(0.5, 0.5)).length())) + + image.set_pixel(x, y, col) + + image.unlock() + + tex.create_from_image(image) + texture = tex + +func radial_gradient_type_1(x : float) -> Color: + if (x < 0.5*(p_o24141_gradient_0_pos+p_o24141_gradient_1_pos)): + return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a); + elif (x < 0.5*(p_o24141_gradient_1_pos+p_o24141_gradient_2_pos)): + return Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a); + + return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a); + + +func radial_gradient_type_2(x : float) -> Color: + if (x < p_o24141_gradient_0_pos): + return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a); + elif (x < p_o24141_gradient_1_pos): + return lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), ((x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos))); + elif (x < p_o24141_gradient_2_pos): + return lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), ((x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos))); + + return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a); + +func radial_gradient_type_3(x : float) -> Color: + if (x < p_o24141_gradient_0_pos): + return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a); + elif (x < p_o24141_gradient_1_pos): + return lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), 0.5-0.5*cos(3.14159265359*(x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos))); + elif (x < p_o24141_gradient_2_pos): + return lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), 0.5-0.5*cos(3.14159265359*(x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos))); + + return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a); + +func radial_gradient_type_4(x : float) -> Color: + if (x < p_o24141_gradient_0_pos): + return Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a); + elif (x < p_o24141_gradient_1_pos): + return lerp(lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), (x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)), lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), (x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)), 1.0-0.5*(x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)); + elif (x < p_o24141_gradient_2_pos): + return lerp(lerp(Color(p_o24141_gradient_0_r,p_o24141_gradient_0_g,p_o24141_gradient_0_b,p_o24141_gradient_0_a), Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), (x-p_o24141_gradient_0_pos)/(p_o24141_gradient_1_pos-p_o24141_gradient_0_pos)), lerp(Color(p_o24141_gradient_1_r,p_o24141_gradient_1_g,p_o24141_gradient_1_b,p_o24141_gradient_1_a), Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a), (x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)), 0.5+0.5*(x-p_o24141_gradient_1_pos)/(p_o24141_gradient_2_pos-p_o24141_gradient_1_pos)); + + return Color(p_o24141_gradient_2_r,p_o24141_gradient_2_g,p_o24141_gradient_2_b,p_o24141_gradient_2_a); + + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.tscn b/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.tscn new file mode 100644 index 00000000..6e94fbdc --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectRadialGradient.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/simple/TextureRectRadialGradient.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/game/addons/mat_maker_gd/simple/TextureRectShape.gd b/game/addons/mat_maker_gd/simple/TextureRectShape.gd new file mode 100644 index 00000000..bbedc378 --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectShape.gd @@ -0,0 +1,197 @@ +tool +extends TextureRect + +var image : Image +var tex : ImageTexture + +export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) +export(Vector2) var bmax : Vector2 = Vector2(1, 1) + +export(bool) var refresh setget reff,reffg + + +var p_o3704_albedo_color_r : float = 1.000000000; +var p_o3704_albedo_color_g : float = 1.000000000; +var p_o3704_albedo_color_b : float = 1.000000000; +var p_o3704_albedo_color_a : float = 1.000000000; +var p_o3704_metallic : float = 1.000000000; +var p_o3704_roughness : float = 1.000000000; +var p_o3704_emission_energy : float = 1.000000000; +var p_o3704_normal : float = 1.000000000; +var p_o3704_ao : float = 1.000000000; +var p_o3704_depth_scale : float = 0.500000000; +var p_o3704_sss : float = 0.000000000; + +var p_o69054_sides : float = 6.000000000; +var p_o69054_radius : float = 0.845361000; +var p_o69054_edge : float = 0.051546000; + +func gen() -> void: + if !image: + image = Image.new() + image.create(300, 300, false, Image.FORMAT_RGBA8) + + if !tex: + tex = ImageTexture.new() + +# var bmin : Vector2 = Vector2(0.1, 0.1) +# var bmax : Vector2 = Vector2(1, 1) + + image.lock() + + var w : float = image.get_width() + var h : float = image.get_width() + + var pseed : float = randf() + randi() + + for x in range(image.get_width()): + for y in range(image.get_height()): + var v : Vector2 = Vector2(x / w, y / h) + +# var c : float = shape_circle(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_polygon(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) +# var c : float = shape_curved_star(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) + var c : float = shape_rays(v, p_o69054_sides, p_o69054_radius * 1.0, p_o69054_edge * 1.0) + + image.set_pixel(x, y, Color(c, c, c, 1)) + + image.unlock() + + tex.create_from_image(image) + texture = tex + + +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) + +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) + +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 * step(0.5 * slice, modf(angle, slice))) * slice - angle) * uv.length()) / (edge * size), 0.0, 1.0); + +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); + + +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 = modf(atan(uv.y / uv.x) + 3.14159265359, slice) / slice + + return clamp(min((size - angle) / edge, angle / edge), 0.0, 1.0); + +func modf(x : float, y : float) -> float: + return x - y * floor(x / y) + +func fract(v : Vector2) -> Vector2: + v.x = v.x - floor(v.x) + v.y = v.y - floor(v.y) + + return v + +func fractf(f : float) -> float: + return f - floor(f) + +func rand(x : Vector2) -> float: + return fractf(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453); + +func step(edge : float, x : float) -> float: + if x < edge: + return 0.0 + else: + return 1.0 + +#common ----- + +#float rand(vec2 x) { +# return fract(cos(dot(x, vec2(13.9898, 8.141))) * 43758.5453); +#} +# +#vec2 rand2(vec2 x) { +# return fract(cos(vec2(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)))) * 43758.5453); +#} +# +#vec3 rand3(vec2 x) { +# return fract(cos(vec3(dot(x, vec2(13.9898, 8.141)), +# dot(x, vec2(3.4562, 17.398)), +# dot(x, vec2(13.254, 5.867)))) * 43758.5453); +#} +# +#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); +#} + + +#end common + + +func reffg(): + return false + +func reff(bb): + if bb: + gen() + diff --git a/game/addons/mat_maker_gd/simple/TextureRectShape.tscn b/game/addons/mat_maker_gd/simple/TextureRectShape.tscn new file mode 100644 index 00000000..234e21ad --- /dev/null +++ b/game/addons/mat_maker_gd/simple/TextureRectShape.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/mat_maker_gd/simple/TextureRectShape.gd" type="Script" id=1] + +[node name="TextureRect" type="TextureRect"] +margin_right = 300.0 +margin_bottom = 300.0 +expand = true +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +}