material-maker/addons/material_maker/nodes/decompose.gd
RodZill4 1c56fc60d8 Cleanup and renaming
Moved Material Spray to another repository.
Renamed the addon directory to material_maker
2018-09-03 21:35:44 +02:00

22 lines
684 B
GDScript

tool
extends "res://addons/material_maker/node_base.gd"
const OUTPUTS = [ "r", "g", "b" ]
func _get_shader_code(uv, output = 0):
var rv = { defs="", code="" }
var src = get_source()
var src_code = { defs="", code="", rgb="vec3(0.0)" }
if src != null:
src_code = src.get_shader_code(uv)
if generated_variants.empty():
rv.defs = src_code.defs;
var variant_index = generated_variants.find(uv)
if variant_index == -1:
variant_index = generated_variants.size()
generated_variants.append(uv)
rv.code = src_code.code
rv.code += "vec3 %s_%d_rgb = %s;\n" % [ name, variant_index, src_code.rgb ]
rv.f = "%s_%d_rgb.%s" % [ name, variant_index, OUTPUTS[output] ]
return rv