material-maker/addons/material_maker/engine/gen_ios.gd
RodZill4 ff191538f6 Added group creation and refactoring.
Moved handling of the "global" definitions of shaders into main shader generation code.
Added group creation (does not create inputs yet, and remotes should be cleaned).
updated all preview meshes (to fix problems with depth).
2019-09-29 10:07:32 +02:00

61 lines
1.3 KiB
GDScript

tool
extends MMGenBase
class_name MMGenIOs
"""
IOs just forward their inputs to their outputs and are used to specify graph interfaces
"""
var mask : int = 3
var ports : Array = []
func _ready():
if !parameters.has("size"):
parameters.size = 4
func get_type():
return "buffer"
func get_type_name():
match name:
"gen_inputs": return "Inputs"
"gen_outputs": return "Outputs"
_: return "IOs"
return "Buffer"
func get_input_defs():
var rv : Array = []
if mask != 2:
for p in ports:
rv.push_back({ name=p.name, type="rgba" })
return rv
func get_output_defs():
var rv : Array = []
if mask != 2:
for p in ports:
rv.push_back({ name=p.name, type="rgba" })
return rv
func source_changed(input_index : int):
if name == "gen_outputs":
get_parent().notify_output_change(input_index)
else:
notify_output_change(input_index)
func _get_shader_code(uv : String, output_index : int, context : MMGenContext):
if mask != 2:
var source = get_source(output_index)
if source != null:
var rv = source.generator._get_shader_code(uv, source.output_index, context)
while rv is GDScriptFunctionState:
rv = yield(rv, "completed")
return rv
return { defs="", code="", textures={} }
func _serialize(data):
data.type = "ios"
data.mask = mask
data.ports = ports
return data