mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-18 14:07:17 +01:00
Colorize node.
This commit is contained in:
parent
e04f17dac2
commit
c634c3b882
Binary file not shown.
Before Width: | Height: | Size: 11 KiB |
@ -1,35 +0,0 @@
|
|||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="StreamTexture"
|
|
||||||
path="res://.import/new_resource-test.png-cc7641e40ff847e5aad9a8930b582cdc.stex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://addons/mat_maker_gd/new_resource-test.png"
|
|
||||||
dest_files=[ "res://.import/new_resource-test.png-cc7641e40ff847e5aad9a8930b582cdc.stex" ]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_mode=0
|
|
||||||
compress/bptc_ldr=0
|
|
||||||
compress/normal_map=0
|
|
||||||
flags/repeat=1
|
|
||||||
flags/filter=false
|
|
||||||
flags/mipmaps=false
|
|
||||||
flags/anisotropic=false
|
|
||||||
flags/srgb=2
|
|
||||||
process/fix_alpha_border=false
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/HDR_as_SRGB=false
|
|
||||||
process/invert_color=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
stream=false
|
|
||||||
size_limit=0
|
|
||||||
detect_3d=false
|
|
||||||
svg/scale=1.0
|
|
@ -1,4 +1,4 @@
|
|||||||
[gd_resource type="Resource" load_steps=31 format=2]
|
[gd_resource type="Resource" load_steps=34 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/perlin.gd" type="Script" id=2]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/perlin.gd" type="Script" id=2]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/gradient/radial_gradient.gd" type="Script" id=8]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/gradient/radial_gradient.gd" type="Script" id=8]
|
||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/uniform/uniform.gd" type="Script" id=9]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/uniform/uniform.gd" type="Script" id=9]
|
||||||
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/image.gd" type="Script" id=10]
|
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/image.gd" type="Script" id=10]
|
||||||
|
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/colorize.gd" type="Script" id=11]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=1]
|
[sub_resource type="Resource" id=1]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
@ -61,7 +62,7 @@ sides = 11
|
|||||||
radius = SubResource( 4 )
|
radius = SubResource( 4 )
|
||||||
edge = SubResource( 3 )
|
edge = SubResource( 3 )
|
||||||
|
|
||||||
[sub_resource type="Resource" id=25]
|
[sub_resource type="Resource" id=28]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
default_type = 5
|
default_type = 5
|
||||||
default_int = 0
|
default_int = 0
|
||||||
@ -72,8 +73,8 @@ 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( 100, -320 )
|
graph_position = Vector2( 300, -400 )
|
||||||
image = SubResource( 25 )
|
image = SubResource( 28 )
|
||||||
postfix = "-test"
|
postfix = "-test"
|
||||||
|
|
||||||
[sub_resource type="Resource" id=9]
|
[sub_resource type="Resource" id=9]
|
||||||
@ -176,7 +177,24 @@ graph_position = Vector2( -140, -220 )
|
|||||||
image = SubResource( 23 )
|
image = SubResource( 23 )
|
||||||
image_path = "/home/relintai/Projects/broken_seals/game/icon.png"
|
image_path = "/home/relintai/Projects/broken_seals/game/icon.png"
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=26]
|
||||||
|
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 )
|
||||||
|
input_property = SubResource( 7 )
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=27]
|
||||||
|
script = ExtResource( 11 )
|
||||||
|
graph_position = Vector2( 40, -300 )
|
||||||
|
interpolation_type = 1
|
||||||
|
points = PoolRealArray( 0, 0.171875, 1, 0, 1, 0.508474, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0.015625, 1, 1 )
|
||||||
|
image = SubResource( 26 )
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
image_size = Vector2( 128, 128 )
|
image_size = Vector2( 128, 128 )
|
||||||
nodes = [ SubResource( 1 ), SubResource( 2 ), SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ) ]
|
nodes = [ SubResource( 1 ), SubResource( 2 ), SubResource( 5 ), SubResource( 6 ), SubResource( 12 ), SubResource( 15 ), SubResource( 18 ), SubResource( 21 ), SubResource( 24 ), SubResource( 27 ) ]
|
||||||
|
@ -23,53 +23,14 @@ const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
|||||||
#colorize.mmg
|
#colorize.mmg
|
||||||
#Remaps a greyscale image to a custom gradient
|
#Remaps a greyscale image to a custom gradient
|
||||||
|
|
||||||
# "inputs": [
|
#Inputs:
|
||||||
# {
|
#input, float, $uv.x - The input greyscale image - (Image input)
|
||||||
# "default": "$uv.x",
|
|
||||||
# "label": "",
|
#Outputs:
|
||||||
# "longdesc": "The input greyscale image",
|
#output (rgba) $gradient($input($uv)) - Image output
|
||||||
# "name": "input",
|
|
||||||
# "shortdesc": "Input",
|
#Parameters:
|
||||||
# "type": "f"
|
#gradient, Gradient
|
||||||
# }
|
|
||||||
# ],
|
|
||||||
# "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"
|
|
||||||
# }
|
|
||||||
# ],
|
|
||||||
|
|
||||||
#----------------------
|
#----------------------
|
||||||
#default_color.mmg
|
#default_color.mmg
|
||||||
|
44
game/addons/mat_maker_gd/nodes/filter/colorize.gd
Normal file
44
game/addons/mat_maker_gd/nodes/filter/colorize.gd
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
tool
|
||||||
|
extends "res://addons/mat_maker_gd/nodes/bases/gradient_base.gd"
|
||||||
|
|
||||||
|
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||||
|
|
||||||
|
export(Resource) var image : Resource
|
||||||
|
|
||||||
|
func _init_properties():
|
||||||
|
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_output_property(image)
|
||||||
|
register_input_property(image)
|
||||||
|
|
||||||
|
func _register_methods(mm_graph_node) -> void:
|
||||||
|
mm_graph_node.add_slot_texture_universal(image)
|
||||||
|
mm_graph_node.add_slot_gradient()
|
||||||
|
|
||||||
|
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 = image.get_value(uv)
|
||||||
|
|
||||||
|
return get_gradient_color(c.r)
|
||||||
|
|
||||||
|
func get_gradient_color(x : float) -> Color:
|
||||||
|
if interpolation_type == 0:
|
||||||
|
return Gradients.gradient_type_1(x, points)
|
||||||
|
elif interpolation_type == 1:
|
||||||
|
return Gradients.gradient_type_2(x, points)
|
||||||
|
elif interpolation_type == 2:
|
||||||
|
return Gradients.gradient_type_3(x, points)
|
||||||
|
elif interpolation_type == 3:
|
||||||
|
return Gradients.gradient_type_4(x, points)
|
||||||
|
|
||||||
|
return Color(1, 1, 1, 1)
|
@ -31,6 +31,7 @@ export(Vector3) var default_vector3 : Vector3
|
|||||||
export(Color) var default_color : Color
|
export(Color) var default_color : Color
|
||||||
export(Image) var default_image : Image
|
export(Image) var default_image : Image
|
||||||
|
|
||||||
|
var force_override : bool = false
|
||||||
#This is not exported on purpose!
|
#This is not exported on purpose!
|
||||||
var override_image : Image
|
var override_image : Image
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ func set_default_value(val):
|
|||||||
emit_changed()
|
emit_changed()
|
||||||
|
|
||||||
func get_active_image() -> Image:
|
func get_active_image() -> Image:
|
||||||
if input_property:
|
if !force_override && input_property:
|
||||||
return input_property.get_active_image()
|
return input_property.get_active_image()
|
||||||
|
|
||||||
if override_image:
|
if override_image:
|
||||||
|
Loading…
Reference in New Issue
Block a user