material-maker/addons/procedural_material/nodes/voronoi.gd
RodZill4 10ea905090 Many changes & fixes...
- shader updates are delayed by .25 seconds to avouid UI freeze
- fixed GraphNode initialization upon loading
- started obsoleting get_source_rgb and get_source_f functions
- updated colorize node to use gradient
- image node can now be loaded/saved
- removed iqnoise node
- rewrote perlin shader to support a seed parameter (seed is calculated from the node's position, so just move it to reseed)
- Added voronoi noise node
- updated code to use % formats instead of concatenating strings (should solve type problems in shaders)
- reworked the context menu (now has submenus)
- fixes in the gradient editor
2018-07-28 09:37:51 +02:00

26 lines
857 B
GDScript

tool
extends "res://addons/procedural_material/node_base.gd"
var scale_x
var scale_y
var intensity
func _ready():
set_slot(0, false, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1))
initialize_properties([ $HBoxContainer1/scale_x, $HBoxContainer2/scale_y, $HBoxContainer3/intensity ])
func _get_shader_code(uv):
var rv = { defs="", code="" }
if generated_variants.empty():
rv.defs = "vec4 "+name+"_xyzw(vec2 uv) { return voronoi(uv, vec2(%f, %f), %.9f, %d); }\n" % [ scale_x, scale_y, intensity, get_seed() ]
var variant_index = generated_variants.find(uv)
if variant_index == -1:
variant_index = generated_variants.size()
generated_variants.append(uv)
rv.code = "vec4 "+name+"_"+str(variant_index)+"_xyzw = "+name+"_xyzw("+uv+");\n"
rv.f = name+"_"+str(variant_index)+"_xyzw.z"
return rv
func _on_offset_changed():
update_shaders()