2018-07-22 17:20:27 +02:00
|
|
|
tool
|
|
|
|
extends "res://addons/procedural_material/node_base.gd"
|
|
|
|
|
2018-08-02 06:32:08 +02:00
|
|
|
var translate_x = 0.0
|
|
|
|
var translate_y = 0.0
|
2018-07-26 00:08:34 +02:00
|
|
|
var rotate = 0.0
|
2018-08-09 22:19:27 +02:00
|
|
|
var scale_x = 1.0
|
|
|
|
var scale_y = 1.0
|
|
|
|
var repeat = true
|
2018-07-22 17:20:27 +02:00
|
|
|
|
|
|
|
func _ready():
|
|
|
|
set_slot(0, true, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1))
|
2018-08-09 22:19:27 +02:00
|
|
|
initialize_properties([ $HBoxContainer1/translate_x, $HBoxContainer2/translate_y, $HBoxContainer3/rotate, $HBoxContainer4/scale_x, $HBoxContainer5/scale_y, $repeat ])
|
2018-07-22 17:20:27 +02:00
|
|
|
|
2018-07-26 08:31:28 +02:00
|
|
|
func _get_shader_code(uv):
|
2018-07-23 22:18:43 +02:00
|
|
|
var rv = { defs="", code="" }
|
2018-07-22 17:20:27 +02:00
|
|
|
var src = get_source()
|
|
|
|
if src == null:
|
|
|
|
return rv
|
|
|
|
rv.uv = name+"_uv("+uv+")"
|
|
|
|
var src_code = src.get_shader_code(rv.uv)
|
|
|
|
if !generated:
|
2018-08-09 22:19:27 +02:00
|
|
|
rv.defs = src_code.defs+"vec2 "+name+"_uv(vec2 uv) { return %s(uv, vec2(%.9f, %.9f), %.9f, vec2(%.9f, %.9f)); }\n" % [ "transform_repeat" if repeat else "transform_norepeat", translate_x, translate_y, PI*rotate/180.0, scale_x, scale_y ]
|
2018-07-22 17:20:27 +02:00
|
|
|
generated = true
|
2018-07-23 22:18:43 +02:00
|
|
|
rv.code = src_code.code;
|
2018-07-22 23:25:05 +02:00
|
|
|
if src_code.has("f"):
|
|
|
|
rv.f = src_code.f
|
|
|
|
if src_code.has("rgb"):
|
|
|
|
rv.rgb = src_code.rgb
|
2018-07-22 17:20:27 +02:00
|
|
|
return rv
|
2018-08-09 22:19:27 +02:00
|
|
|
|
|
|
|
func deserialize(data):
|
|
|
|
if data.has("scale"):
|
|
|
|
scale_x = data.scale
|
|
|
|
scale_y = data.scale
|
|
|
|
.deserialize(data)
|