material-maker/addons/material_maker/nodes/export.gd
RodZill4 2621ff4b46 Improved integration in Godot
Exporting a material will now create a SpatialMaterial. The Material graph node
now generates different textures when used as a Godot addon (metallic, roughness
and ambient occlusion are merged into a single texture).

Rendering code (that was in graph_edit and node_base scenes) is now in a single "renderer scene" attached to the main window.
2018-09-04 21:45:14 +02:00

33 lines
725 B
GDScript

tool
extends "res://addons/material_maker/node_base.gd"
var resolution = 1
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+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)