material-maker/addons/material_maker/nodes/noise/noise.gd
RodZill4 ee0bc96f30 Added a generic node type
Updated all nodes so parameters are located in a "parameters" variable.
Started writing a generic node model whose behavior is defined in a json file. Should be able to replace all generators so far.
Wrote json files for bricks and noise nodes.
Started preparing a custom node.
2018-10-02 07:46:20 +02:00

25 lines
860 B
GDScript

tool
extends "res://addons/material_maker/node_base.gd"
func _ready():
$HBoxContainer1/size.clear()
for i in range(7):
$HBoxContainer1/size.add_item(str(int(pow(2, 5+i))), i)
$HBoxContainer1/size.selected = 4
initialize_properties([ $HBoxContainer1/size, $HBoxContainer2/density ])
func _get_shader_code(uv):
var rv = { defs="", code="" }
if generated_variants.empty():
rv.defs = "float %s_f(vec2 uv) { return dots(uv, %.9f, %.9f, %d); }\n" % [ name, 1.0/pow(2.0, 5.0+parameters.size), parameters.density, get_seed() ]
var variant_index = generated_variants.find(uv)
if variant_index == -1:
variant_index = generated_variants.size()
generated_variants.append(uv)
rv.code = "float %s_%d_f = %s_f(%s);\n" % [ name, variant_index, name, uv ]
rv.f = "%s_%d_f" % [ name, variant_index ]
return rv
func _on_offset_changed():
update_shaders()