mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
blend node.
This commit is contained in:
parent
e42a25a53b
commit
2f4912c2b9
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="Resource" load_steps=116 format=2]
|
[gd_resource type="Resource" load_steps=128 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/mm_material.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=2]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/noise.gd" type="Script" id=2]
|
||||||
@ -30,6 +30,9 @@
|
|||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/curve.gd" type="Script" id=28]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/curve.gd" type="Script" id=28]
|
||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_render.gd" type="Script" id=29]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_render.gd" type="Script" id=29]
|
||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_shape_sphere.gd" type="Script" id=30]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/sdf3d/sdf3d_shape_sphere.gd" type="Script" id=30]
|
||||||
|
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/filter.gd" type="Script" id=31]
|
||||||
|
[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]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=3]
|
[sub_resource type="Resource" id=3]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
@ -67,7 +70,7 @@ sides = 11
|
|||||||
radius = SubResource( 4 )
|
radius = SubResource( 4 )
|
||||||
edge = SubResource( 3 )
|
edge = SubResource( 3 )
|
||||||
|
|
||||||
[sub_resource type="Resource" id=103]
|
[sub_resource type="Resource" id=111]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
default_type = 5
|
default_type = 5
|
||||||
default_int = 0
|
default_int = 0
|
||||||
@ -79,7 +82,7 @@ default_color = Color( 0, 0, 0, 1 )
|
|||||||
[sub_resource type="Resource" id=6]
|
[sub_resource type="Resource" id=6]
|
||||||
script = ExtResource( 6 )
|
script = ExtResource( 6 )
|
||||||
graph_position = Vector2( 300, -400 )
|
graph_position = Vector2( 300, -400 )
|
||||||
image = SubResource( 103 )
|
image = SubResource( 111 )
|
||||||
postfix = "-test"
|
postfix = "-test"
|
||||||
|
|
||||||
[sub_resource type="Resource" id=9]
|
[sub_resource type="Resource" id=9]
|
||||||
@ -770,7 +773,84 @@ graph_position = Vector2( -1040, 500 )
|
|||||||
output = SubResource( 109 )
|
output = SubResource( 109 )
|
||||||
radius = 0.5
|
radius = 0.5
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=112]
|
||||||
|
script = ExtResource( 32 )
|
||||||
|
graph_position = Vector2( 0, 0 )
|
||||||
|
bmin = Vector2( 0.1, 0.1 )
|
||||||
|
bmax = Vector2( 1, 1 )
|
||||||
|
refresh = false
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=113]
|
||||||
|
script = ExtResource( 31 )
|
||||||
|
graph_position = Vector2( 0, 0 )
|
||||||
|
bmin = Vector2( 0.1, 0.1 )
|
||||||
|
bmax = Vector2( 1, 1 )
|
||||||
|
refresh = false
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=114]
|
||||||
|
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=115]
|
||||||
|
script = ExtResource( 11 )
|
||||||
|
graph_position = Vector2( 220, -20 )
|
||||||
|
interpolation_type = 1
|
||||||
|
points = PoolRealArray( )
|
||||||
|
image = SubResource( 114 )
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=116]
|
||||||
|
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=117]
|
||||||
|
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( 1, 1, 1, 1 )
|
||||||
|
input_property = SubResource( 37 )
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=118]
|
||||||
|
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( 1, 1, 1, 1 )
|
||||||
|
input_property = SubResource( 17 )
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=119]
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
default_type = 1
|
||||||
|
default_int = 0
|
||||||
|
default_float = 0.5
|
||||||
|
default_vector2 = Vector2( 0, 0 )
|
||||||
|
default_vector3 = Vector3( 0, 0, 0 )
|
||||||
|
default_color = Color( 0, 0, 0, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=120]
|
||||||
|
script = ExtResource( 33 )
|
||||||
|
graph_position = Vector2( 720, 300 )
|
||||||
|
image = SubResource( 116 )
|
||||||
|
input1 = SubResource( 117 )
|
||||||
|
input2 = SubResource( 118 )
|
||||||
|
blend_type = 0
|
||||||
|
opacity = SubResource( 119 )
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
image_size = Vector2( 128, 128 )
|
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 ) ]
|
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 ) ]
|
||||||
|
@ -213,6 +213,19 @@ static func clampv2(v : Vector2, pmin : Vector2, pmax : Vector2) -> Vector2:
|
|||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
static func minv2(v1 : Vector2, v2 : Vector2) -> Vector2:
|
||||||
|
v1.x = min(v1.x, v2.x)
|
||||||
|
v1.y = min(v1.y, v2.y)
|
||||||
|
|
||||||
|
return v1
|
||||||
|
|
||||||
|
static func minv3(v1 : Vector3, v2 : Vector3) -> Vector3:
|
||||||
|
v1.x = min(v1.x, v2.x)
|
||||||
|
v1.y = min(v1.y, v2.y)
|
||||||
|
v1.z = min(v1.z, v2.z)
|
||||||
|
|
||||||
|
return v1
|
||||||
|
|
||||||
static func rand(x : Vector2) -> float:
|
static func rand(x : Vector2) -> float:
|
||||||
return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453);
|
return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453);
|
||||||
|
|
||||||
|
@ -498,113 +498,19 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
|||||||
#blend.mmg
|
#blend.mmg
|
||||||
#Blends its input, using an optional mask
|
#Blends its input, using an optional mask
|
||||||
|
|
||||||
# "code": "vec4 $(name_uv)_s1 = $s1($uv);\nvec4 $(name_uv)_s2 = $s2($uv);\nfloat $(name_uv)_a = $amount*$a($uv);\n",
|
#Outputs:
|
||||||
# "inputs": [
|
|
||||||
# {
|
#Output - (color)
|
||||||
# "default": "vec4($uv.x, 1.0, 1.0, 1.0)",
|
#vec4 $(name_uv)_s1 = $s1($uv);
|
||||||
# "label": "Source1",
|
#vec4 $(name_uv)_s2 = $s2($uv);
|
||||||
# "longdesc": "The foreground input",
|
#float $(name_uv)_a = $amount*$a($uv);
|
||||||
# "name": "s1",
|
#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": "Foreground",
|
|
||||||
# "type": "rgba"
|
#Inputs:
|
||||||
# },
|
#in1, color, default vec4($uv.x, 1.0, 1.0, 1.0)
|
||||||
# {
|
#in2, color, default vec4($uv.x, 1.0, 1.0, 1.0)
|
||||||
# "default": "vec4(1.0, $uv.y, 1.0, 1.0)",
|
#blend_type, enum, default: 0, Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference
|
||||||
# "label": "Source2",
|
#opactiy, float, min: 0, max: 1, default: 0.5, step: 0.01 (input float)
|
||||||
# "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"
|
|
||||||
# }
|
|
||||||
# ],
|
|
||||||
# "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"
|
|
||||||
# }
|
|
||||||
# ],
|
|
||||||
|
|
||||||
#----------------------
|
#----------------------
|
||||||
#combine.mmg
|
#combine.mmg
|
||||||
@ -4640,6 +4546,9 @@ static func invert(color : Color) -> Color:
|
|||||||
# return opacity*c1 + (1.0-opacity)*c2;\n
|
# return opacity*c1 + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_normal(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * c1 + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#vec3 blend_dissolve(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_dissolve(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# if (rand(uv) < opacity) {\n\t\t
|
# if (rand(uv) < opacity) {\n\t\t
|
||||||
# return c1;\n\t
|
# return c1;\n\t
|
||||||
@ -4648,62 +4557,122 @@ static func invert(color : Color) -> Color:
|
|||||||
# }\n
|
# }\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_dissolve(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
if (Commons.rand2(uv) < Vector2(opacity, opacity)):
|
||||||
|
return c1
|
||||||
|
else:
|
||||||
|
return c2
|
||||||
|
|
||||||
#vec3 blend_multiply(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_multiply(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*c1*c2 + (1.0-opacity)*c2;\n
|
# return opacity*c1*c2 + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_multiply(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * c1 * c2 + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#vec3 blend_screen(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_screen(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n
|
# return opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_screen(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * (Vector3(1, 1, 1) - (Vector3(1, 1, 1) - c1) * (Vector3(1, 1, 1) - c2)) + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#float blend_overlay_f(float c1, float c2) {\n\t
|
#float blend_overlay_f(float c1, float c2) {\n\t
|
||||||
# return (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n
|
# return (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_overlay_f(c1 : float, c2 : float) -> float:
|
||||||
|
if (c1 < 0.5):
|
||||||
|
return (2.0 * c1 * c2)
|
||||||
|
else:
|
||||||
|
return (1.0 - 2.0 * (1.0 - c1) * (1.0 - c2))
|
||||||
|
|
||||||
#vec3 blend_overlay(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_overlay(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return 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
|
# return 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
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_overlay(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Vector3(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
|
||||||
|
|
||||||
#vec3 blend_hard_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_hard_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*0.5*(c1*c2+blend_overlay(uv, c1, c2, 1.0)) + (1.0-opacity)*c2;\n
|
# return opacity*0.5*(c1*c2+blend_overlay(uv, c1, c2, 1.0)) + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_hard_light(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * 0.5 * (c1 * c2 + blend_overlay(uv, c1, c2, 1.0)) + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#float blend_soft_light_f(float c1, float c2) {\n\t
|
#float blend_soft_light_f(float c1, float c2) {\n\t
|
||||||
# return (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n
|
# return (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_soft_light_f(c1 : float, c2 : float) -> float:
|
||||||
|
if (c2 < 0.5):
|
||||||
|
return (2.0 * c1 * c2 + c1 * c1 * (1.0 - 2.0 * c2))
|
||||||
|
else:
|
||||||
|
return 2.0 * c1 * (1.0 - c2) + sqrt(c1) * (2.0 * c2 - 1.0)
|
||||||
|
|
||||||
#vec3 blend_soft_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_soft_light(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return 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
|
# return 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
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_soft_light(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Vector3(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
|
||||||
|
|
||||||
#float blend_burn_f(float c1, float c2) {\n\t
|
#float blend_burn_f(float c1, float c2) {\n\t
|
||||||
# return (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n
|
# return (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_burn_f(c1 : float, c2 : float) -> float:
|
||||||
|
if (c1 == 0.0):
|
||||||
|
return c1
|
||||||
|
else:
|
||||||
|
return max((1.0 - ((1.0 - c2) / c1)), 0.0)
|
||||||
|
|
||||||
#vec3 blend_burn(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_burn(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return 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;
|
# return 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;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_burn(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Vector3(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
|
||||||
|
|
||||||
#float blend_dodge_f(float c1, float c2) {\n\t
|
#float blend_dodge_f(float c1, float c2) {\n\t
|
||||||
# return (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n
|
# return (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_dodge_f(c1 : float, c2 : float) -> float:
|
||||||
|
if (c1==1.0):
|
||||||
|
return c1
|
||||||
|
else:
|
||||||
|
return min(c2 / (1.0 - c1), 1.0)
|
||||||
|
|
||||||
#vec3 blend_dodge(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_dodge(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return 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
|
# return 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
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_dodge(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Vector3(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
|
||||||
|
|
||||||
#vec3 blend_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*max(c1, c2) + (1.0-opacity)*c2;\n
|
# return opacity*max(c1, c2) + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_lighten(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Commons.maxv3(c1, c2) + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#vec3 blend_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*min(c1, c2) + (1.0-opacity)*c2;\n
|
# return opacity*min(c1, c2) + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_darken(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Commons.minv3(c1, c2) + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#vec3 blend_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
#vec3 blend_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||||
# return opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n
|
# return opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
static func blend_difference(uv : Vector2, c1 : Vector3, c2 : Vector3, opacity : float) -> Vector3:
|
||||||
|
return opacity * Commons.clampv3(c2 - c1, Vector3(), Vector3(1, 1, 1)) + (1.0 - opacity) * c2
|
||||||
|
|
||||||
#vec4 adjust_levels(vec4 input, vec4 in_min, vec4 in_mid, vec4 in_max, vec4 out_min, vec4 out_max) {\n\t
|
#vec4 adjust_levels(vec4 input, vec4 in_min, vec4 in_mid, vec4 in_max, vec4 out_min, vec4 out_max) {\n\t
|
||||||
# input = clamp((input-in_min)/(in_max-in_min), 0.0, 1.0);\n\t
|
# input = clamp((input-in_min)/(in_max-in_min), 0.0, 1.0);\n\t
|
||||||
# in_mid = (in_mid-in_min)/(in_max-in_min);\n\t
|
# in_mid = (in_mid-in_min)/(in_max-in_min);\n\t
|
||||||
@ -4715,5 +4684,3 @@ static func invert(color : Color) -> Color:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
125
game/addons/mat_maker_gd/nodes/filter/blend.gd
Normal file
125
game/addons/mat_maker_gd/nodes/filter/blend.gd
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
tool
|
||||||
|
extends MMNode
|
||||||
|
|
||||||
|
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||||
|
|
||||||
|
enum BlendType {
|
||||||
|
NORMAL = 0,
|
||||||
|
DISSOLVE,
|
||||||
|
MULTIPLY,
|
||||||
|
SCREEN,
|
||||||
|
OVERLAY,
|
||||||
|
HARD_LIGHT,
|
||||||
|
SOFT_LIGHT,
|
||||||
|
BURN,
|
||||||
|
DODGE,
|
||||||
|
LIGHTEN,
|
||||||
|
DARKEN,
|
||||||
|
DIFFRENCE
|
||||||
|
}
|
||||||
|
|
||||||
|
export(Resource) var image : Resource
|
||||||
|
export(Resource) var input1 : Resource
|
||||||
|
export(Resource) var input2 : Resource
|
||||||
|
export(int, "Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference") var blend_type : int = 0
|
||||||
|
export(Resource) var opacity : Resource
|
||||||
|
|
||||||
|
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 !input1:
|
||||||
|
input1 = MMNodeUniversalProperty.new()
|
||||||
|
input1.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||||
|
input1.set_default_value(Color(1, 1, 1, 1))
|
||||||
|
|
||||||
|
input1.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||||
|
input1.slot_name = ">>> Input1 "
|
||||||
|
|
||||||
|
if !input2:
|
||||||
|
input2 = MMNodeUniversalProperty.new()
|
||||||
|
input2.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||||
|
input2.set_default_value(Color(1, 1, 1, 1))
|
||||||
|
|
||||||
|
input2.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||||
|
input2.slot_name = ">>> Input2 "
|
||||||
|
|
||||||
|
if !opacity:
|
||||||
|
opacity = MMNodeUniversalProperty.new()
|
||||||
|
opacity.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||||
|
opacity.set_default_value(0.5)
|
||||||
|
opacity.value_range = Vector2(0, 1)
|
||||||
|
opacity.value_step = 0.01
|
||||||
|
|
||||||
|
opacity.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||||
|
opacity.slot_name = "opacity"
|
||||||
|
|
||||||
|
register_input_property(input1)
|
||||||
|
register_input_property(input2)
|
||||||
|
|
||||||
|
register_output_property(image)
|
||||||
|
register_input_property(opacity)
|
||||||
|
|
||||||
|
func _register_methods(mm_graph_node) -> void:
|
||||||
|
mm_graph_node.add_slot_texture_universal(image)
|
||||||
|
mm_graph_node.add_slot_enum("get_blend_type", "set_blend_type", "blend_type", [ "Normal", "Dissolve", "Multiply", "Screen", "Overlay", "Hard Light", "Soft Light", "Burn", "Dodge", "Lighten", "Darken", "Difference" ])
|
||||||
|
|
||||||
|
mm_graph_node.add_slot_label_universal(input1)
|
||||||
|
mm_graph_node.add_slot_label_universal(input2)
|
||||||
|
mm_graph_node.add_slot_float_universal(opacity)
|
||||||
|
|
||||||
|
func _render(material) -> void:
|
||||||
|
var img : Image = render_image(material)
|
||||||
|
|
||||||
|
image.set_value(img)
|
||||||
|
|
||||||
|
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||||
|
var b : Vector3 = Vector3()
|
||||||
|
|
||||||
|
#vec4 $(name_uv)_s1 = $s1($uv);
|
||||||
|
var s1 : Color = input1.get_value(uv)
|
||||||
|
#vec4 $(name_uv)_s2 = $s2($uv);
|
||||||
|
var s2 : Color = input2.get_value(uv)
|
||||||
|
#float $(name_uv)_a = $amount*$a($uv);
|
||||||
|
var a : float = opacity.get_default_value(uv) * opacity.get_value(uv)
|
||||||
|
|
||||||
|
#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))
|
||||||
|
|
||||||
|
#"Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference"
|
||||||
|
if blend_type == BlendType.NORMAL:
|
||||||
|
b = Filter.blend_normal(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.DISSOLVE:
|
||||||
|
b = Filter.blend_dissolve(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.MULTIPLY:
|
||||||
|
b = Filter.blend_multiply(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.SCREEN:
|
||||||
|
b = Filter.blend_screen(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.OVERLAY:
|
||||||
|
b = Filter.blend_overlay(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.HARD_LIGHT:
|
||||||
|
b = Filter.blend_hard_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.SOFT_LIGHT:
|
||||||
|
b = Filter.blend_soft_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.BURN:
|
||||||
|
b = Filter.blend_burn(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.DODGE:
|
||||||
|
b = Filter.blend_dodge(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.LIGHTEN:
|
||||||
|
b = Filter.blend_lighten(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.DARKEN:
|
||||||
|
b = Filter.blend_darken(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
elif blend_type == BlendType.DIFFRENCE:
|
||||||
|
b = Filter.blend_difference(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||||
|
|
||||||
|
return Color(b.x, b.y, b.z, min(1, s2.a + a * s1.a))
|
||||||
|
|
||||||
|
func get_blend_type() -> int:
|
||||||
|
return blend_type
|
||||||
|
|
||||||
|
func set_blend_type(val : int) -> void:
|
||||||
|
blend_type = val
|
||||||
|
|
||||||
|
set_dirty(true)
|
Loading…
Reference in New Issue
Block a user