mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
2621ff4b46
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.
33 lines
725 B
GDScript
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)
|