mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-12-18 01:06:47 +01:00
Invert node.
This commit is contained in:
parent
77d2e64fe1
commit
713fcfb490
@ -585,24 +585,13 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
#invert.mmg
|
||||
#A filter that inverts the R, G, and B channels of its input while keeping the A channel unchanged
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(1.0, 1.0, 1.0, 1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the inverted image",
|
||||
# "rgba": "vec4(vec3(1.0)-$in($uv).rgb, $in($uv).a)",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgba)
|
||||
#vec4(vec3(1.0)-$in($uv).rgb, $in($uv).a)
|
||||
|
||||
#Inputs:
|
||||
#input, rgba, default vec4(1.0, 1.0, 1.0, 1.0)
|
||||
|
||||
#----------------------
|
||||
#normal_map.mmg
|
||||
@ -4311,7 +4300,6 @@ static func grayscale_luminosity(c : Vector3) -> float:
|
||||
static func invert(color : Color) -> Color:
|
||||
return Color(1.0 - color.r, 1.0 - color.g, 1.0 - color.b, color.a);
|
||||
|
||||
|
||||
#vec3 blend_normal(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*c1 + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
42
game/addons/mat_maker_gd/nodes/filter/invert.gd
Normal file
42
game/addons/mat_maker_gd/nodes/filter/invert.gd
Normal file
@ -0,0 +1,42 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var 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
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
return Filter.invert(c)
|
Loading…
Reference in New Issue
Block a user