mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Color noise node.
This commit is contained in:
parent
31547bf86f
commit
7ef34acfbf
@ -351,21 +351,3 @@ static func ThickLine(uv : Vector2, posA : Vector2, posB : Vector2, radiusInv :
|
||||
var finalGray : float = clamp(1.0 - d1 * radiusInv, 0.0, 1.0);
|
||||
|
||||
return finalGray;
|
||||
|
||||
#vec3 color_dots(vec2 uv, float size, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# return rand3(seed2+point_pos);
|
||||
#}
|
||||
|
||||
static 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);
|
||||
|
||||
static func noise_color(uv : Vector2, pseed : int) -> Color:
|
||||
var v : Vector3 = color_dots(((uv)), 1.0/512.000000000, pseed);
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
@ -123,3 +123,25 @@ static func dots(uv : Vector2, size : float, density : float, pseed : float) ->
|
||||
#
|
||||
# return mix(linear, smoothed, interpolation);\n
|
||||
#}
|
||||
|
||||
#vec3 color_dots(vec2 uv, float size, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# return rand3(seed2+point_pos);
|
||||
#}
|
||||
|
||||
static func color_dots(uv : Vector2, size : float, pseed : float) -> Vector3:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
|
||||
uv /= size
|
||||
|
||||
var point_pos : Vector2 = Commons.floorv2(uv) + Vector2(0.5, 0.5)
|
||||
|
||||
return Commons.rand3(seed2 + point_pos)
|
||||
|
||||
static func noise_color(uv : Vector2, size : float, pseed : float) -> Color:
|
||||
var v : Vector3 = color_dots(uv, 1.0 / size, pseed)
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
||||
|
52
game/addons/mat_maker_gd/nodes/noise/color_noise.gd
Normal file
52
game/addons/mat_maker_gd/nodes/noise/color_noise.gd
Normal file
@ -0,0 +1,52 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Noises = preload("res://addons/mat_maker_gd/nodes/common/noises.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(int) var size : int = 8
|
||||
|
||||
#----------------------
|
||||
#color_noise.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgb) - Shows the noise pattern
|
||||
#color_dots($(uv), 1.0/$(size), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#size, float, default: 8, min: 2, max: 12, step: 1
|
||||
|
||||
|
||||
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
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_int("get_size", "set_size", "Size")#, Vector2(1, 10))
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#color_dots($(uv), 1.0/$(size), $(seed))
|
||||
return Noises.noise_color(uv, float(size), ps)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_size() -> int:
|
||||
return size
|
||||
|
||||
func set_size(val : int) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
Loading…
Reference in New Issue
Block a user