mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
make_tileable node.
This commit is contained in:
parent
a5e81bc69c
commit
676de9083c
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Resource" load_steps=132 format=2]
|
||||
[gd_resource type="Resource" load_steps=136 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=2]
|
||||
@ -34,6 +34,7 @@
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/grayscale.gd" type="Script" id=32]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/blend.gd" type="Script" id=33]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/emboss.gd" type="Script" id=34]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/make_tileable.gd" type="Script" id=35]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 5 )
|
||||
@ -71,7 +72,7 @@ sides = 11
|
||||
radius = SubResource( 4 )
|
||||
edge = SubResource( 3 )
|
||||
|
||||
[sub_resource type="Resource" id=111]
|
||||
[sub_resource type="Resource" id=129]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
@ -83,7 +84,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( 300, -400 )
|
||||
image = SubResource( 111 )
|
||||
image = SubResource( 129 )
|
||||
postfix = "-test"
|
||||
|
||||
[sub_resource type="Resource" id=9]
|
||||
@ -295,7 +296,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=39]
|
||||
script = ExtResource( 12 )
|
||||
graph_position = Vector2( 400, 180 )
|
||||
graph_position = Vector2( 400, 300 )
|
||||
out_bricks_pattern = SubResource( 32 )
|
||||
out_random_color = SubResource( 37 )
|
||||
out_position_x = SubResource( 35 )
|
||||
@ -799,7 +800,7 @@ default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=115]
|
||||
script = ExtResource( 11 )
|
||||
graph_position = Vector2( 220, -20 )
|
||||
graph_position = Vector2( 300, -140 )
|
||||
interpolation_type = 1
|
||||
points = PoolRealArray( )
|
||||
image = SubResource( 114 )
|
||||
@ -877,7 +878,33 @@ angle = 20.0
|
||||
amount = 5.0
|
||||
width = 6.0
|
||||
|
||||
[sub_resource type="Resource" id=130]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=131]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 35 )
|
||||
|
||||
[sub_resource type="Resource" id=132]
|
||||
script = ExtResource( 35 )
|
||||
graph_position = Vector2( 700, 700 )
|
||||
image = SubResource( 130 )
|
||||
input = SubResource( 131 )
|
||||
width = 0.1
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ), SubResource( 82 ), SubResource( 85 ), SubResource( 88 ), SubResource( 90 ), SubResource( 92 ), SubResource( 96 ), SubResource( 100 ), SubResource( 108 ), SubResource( 110 ), SubResource( 112 ), SubResource( 113 ), SubResource( 115 ), SubResource( 120 ), SubResource( 123 ) ]
|
||||
nodes = [ SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ), SubResource( 39 ), SubResource( 42 ), SubResource( 45 ), SubResource( 49 ), SubResource( 54 ), SubResource( 58 ), SubResource( 60 ), SubResource( 63 ), SubResource( 66 ), SubResource( 69 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ), SubResource( 82 ), SubResource( 85 ), SubResource( 88 ), SubResource( 90 ), SubResource( 92 ), SubResource( 96 ), SubResource( 100 ), SubResource( 108 ), SubResource( 110 ), SubResource( 112 ), SubResource( 113 ), SubResource( 115 ), SubResource( 120 ), SubResource( 123 ), SubResource( 132 ) ]
|
||||
|
@ -1087,40 +1087,22 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#make_tileable.mmg
|
||||
#Creates a tileable version of its input image by moving different parts around to hide seams.
|
||||
|
||||
# "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",
|
||||
# "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"
|
||||
# }
|
||||
# ]
|
||||
#vec4 make_tileable_$(name)(vec2 uv, float w) {
|
||||
# vec4 a = $in(uv);
|
||||
# vec4 b = $in(fract(uv+vec2(0.5)));
|
||||
# float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
|
||||
# vec4 c = $in(fract(uv+vec2(0.25)));
|
||||
# float 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));
|
||||
# return mix(c, mix(a, b, coef_ab), coef_abc);
|
||||
#}
|
||||
|
||||
#Inputs:
|
||||
#input, rgba, default: vec4(1.0)
|
||||
#width, float, min:0, max: 1: default: 0.1, step: 0.01
|
||||
|
||||
#Outputs:
|
||||
#output (rgba)
|
||||
#make_tileable_$(name)($uv, 0.5*$w)
|
||||
|
||||
#----------------------
|
||||
#occlusion.mmg
|
||||
|
@ -20,7 +20,7 @@ func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(1)
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
78
game/addons/mat_maker_gd/nodes/filter/make_tileable.gd
Normal file
78
game/addons/mat_maker_gd/nodes/filter/make_tileable.gd
Normal file
@ -0,0 +1,78 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var width : float = 0.1
|
||||
|
||||
var size : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
size = max(material.image_size.x, material.image_size.y)
|
||||
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#make_tileable_$(name)($uv, 0.5*$w)
|
||||
return make_tileable(uv, 0.5 * width)
|
||||
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
|
||||
#----------------------
|
||||
#make_tileable.mmg
|
||||
|
||||
#vec4 make_tileable_$(name)(vec2 uv, float w) {
|
||||
# vec4 a = $in(uv);
|
||||
# vec4 b = $in(fract(uv+vec2(0.5)));
|
||||
# float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
|
||||
# vec4 c = $in(fract(uv+vec2(0.25)));
|
||||
# float 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));
|
||||
# return mix(c, mix(a, b, coef_ab), coef_abc);
|
||||
#}
|
||||
|
||||
func make_tileable(uv : Vector2, w : float) -> Color:
|
||||
var a: Color = input.get_value(uv);
|
||||
var b : Color = input.get_value(Commons.fractv2(uv + Vector2(0.5, 0.5)));
|
||||
var coef_ab : float = sin(1.57079632679 * clamp(((uv - Vector2(0.5, 0.5)).length() - 0.5 + w) / w, 0.0, 1.0));
|
||||
var c: Color = input.get_value(Commons.fractv2(uv + Vector2(0.25, 0.25)));
|
||||
var coef_abc : float = sin(1.57079632679 * clamp((min(min((uv - Vector2(0.0, 0.5)).length(), (uv - Vector2(0.5, 0.0)).length()), min((uv- Vector2(1.0, 0.5)).length(), (uv - Vector2(0.5, 1.0)).length())) - w) / w, 0.0, 1.0));
|
||||
|
||||
return lerp(c, lerp(a, b, coef_ab), coef_abc)
|
||||
|
Loading…
Reference in New Issue
Block a user