mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
ee0bc96f30
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.
26 lines
693 B
GDScript
26 lines
693 B
GDScript
tool
|
|
extends "res://addons/material_maker/node_base.gd"
|
|
|
|
func _ready():
|
|
initialize_properties([ $source ])
|
|
|
|
func reset():
|
|
generated = false
|
|
generated_variants = [ [], [] ]
|
|
|
|
func _get_shader_code(uv, index = 0):
|
|
var rv = { defs="", code="" }
|
|
var src = get_source(2*parameters.source+index)
|
|
var src_code = { defs="", code="", rgb="0.0" }
|
|
if src != null:
|
|
src_code = src.get_shader_code(uv)
|
|
if generated_variants[index].empty():
|
|
rv.defs = src_code.defs;
|
|
var variant_index = generated_variants[index].find(uv)
|
|
if variant_index == -1:
|
|
variant_index = generated_variants[index].size()
|
|
generated_variants[index].append(uv)
|
|
rv.code = src_code.code
|
|
rv.rgb = src_code.rgb
|
|
return rv
|