mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-27 23:17:14 +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.
32 lines
717 B
GDScript
32 lines
717 B
GDScript
tool
|
|
extends "res://addons/material_maker/node_base.gd"
|
|
|
|
var suffix = "suffix"
|
|
|
|
func _ready():
|
|
initialize_properties([ $resolution ])
|
|
|
|
func _get_shader_code(uv):
|
|
var rv = { defs="", code="", f="0.0" }
|
|
var src = get_source()
|
|
if src != null:
|
|
rv = src.get_shader_code(uv)
|
|
return rv
|
|
|
|
func export_textures(prefix, size = null):
|
|
var suffix = $Suffix.text
|
|
if suffix != "":
|
|
if size == null:
|
|
size = int(pow(2, 8+parameters.resolution))
|
|
get_parent().renderer.export_texture(get_source(), "%s_%s.png" % [ prefix, suffix ], size)
|
|
|
|
func serialize():
|
|
var data = .serialize()
|
|
data.suffix = $Suffix.text
|
|
return data
|
|
|
|
func deserialize(data):
|
|
if data.has("suffix"):
|
|
$Suffix.text = data.suffix
|
|
.deserialize(data)
|