mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
5b20a189f9
Replaced the sin node with a pattern node similar to NeoTextureEdit's FunctionPattern
28 lines
1.0 KiB
GDScript
28 lines
1.0 KiB
GDScript
tool
|
|
extends "res://addons/procedural_material/node_base.gd"
|
|
|
|
var mix = 0;
|
|
var x_wave = 0
|
|
var x_scale = 4.0
|
|
var y_wave = 0
|
|
var y_scale = 4.0
|
|
|
|
const WAVE_FCT = [ "wave_sin", "wave_saw", "wave_square" ]
|
|
const MIX_FCT = [ "mix_multiply", "mix_add", "mix_max", "mix_min", "mix_xor", "mix_pow" ]
|
|
|
|
func _ready():
|
|
set_slot(0, false, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1))
|
|
initialize_properties([ $HBoxContainer0/mix, $HBoxContainer1/x_wave, $HBoxContainer1/x_scale, $HBoxContainer2/y_wave, $HBoxContainer2/y_scale ])
|
|
|
|
func _get_shader_code(uv):
|
|
var rv = { defs="", code="" }
|
|
if generated_variants.empty():
|
|
rv.defs = "float %s_f(vec2 uv) { uv *= vec2(%.9f, %.9f); return %s(%s(uv.x), %s(uv.y)); }\n" % [ name, x_scale, y_scale, MIX_FCT[mix], WAVE_FCT[x_wave], WAVE_FCT[y_wave] ]
|
|
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 = name+"_"+str(variant_index)+"_f"
|
|
return rv
|