material-maker/addons/procedural_material/nodes/transform.gd
Rodolphe Suescun ba016797e3 Refactoring, new noise node and blur updates
Added a noise node (paints randomly pixels in black or white).
Modified blur so direction can be selected (horizontal, verticla, or both).
Updated code to use string formats instead of conversion + concatenation.
2018-08-20 15:43:03 +02:00

37 lines
1.1 KiB
GDScript

tool
extends "res://addons/procedural_material/node_base.gd"
var translate_x = 0.0
var translate_y = 0.0
var rotate = 0.0
var scale_x = 1.0
var scale_y = 1.0
var repeat = true
func _ready():
set_slot(0, true, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1))
initialize_properties([ $HBoxContainer1/translate_x, $HBoxContainer2/translate_y, $HBoxContainer3/rotate, $HBoxContainer4/scale_x, $HBoxContainer5/scale_y, $repeat ])
func _get_shader_code(uv):
var rv = { defs="", code="" }
var src = get_source()
if src == null:
return rv
rv.uv = "%s_uv(%s)" % [ name, uv ]
var src_code = src.get_shader_code(rv.uv)
if !generated:
rv.defs = src_code.defs+"vec2 %s_uv(vec2 uv) { return %s(uv, vec2(%.9f, %.9f), %.9f, vec2(%.9f, %.9f)); }\n" % [ name, "transform_repeat" if repeat else "transform_norepeat", translate_x, translate_y, PI*rotate/180.0, scale_x, scale_y ]
generated = true
rv.code = src_code.code;
if src_code.has("f"):
rv.f = src_code.f
if src_code.has("rgb"):
rv.rgb = src_code.rgb
return rv
func deserialize(data):
if data.has("scale"):
scale_x = data.scale
scale_y = data.scale
.deserialize(data)