mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
bf4a125386
Added initial support for alpha channel (in combine, decompose and blend nodes). Textures with alpha channels can be exported using the material node albedo input. Updated node editor with a simple editor for enumerated parameters.
22 lines
693 B
GDScript
22 lines
693 B
GDScript
tool
|
|
extends "res://addons/material_maker/node_base.gd"
|
|
|
|
const OUTPUTS = [ "r", "g", "b", "a" ]
|
|
|
|
func _get_shader_code(uv, output = 0):
|
|
var rv = { defs="", code="" }
|
|
var src = get_source()
|
|
var src_code = { defs="", code="", rgba="vec4(0.0)" }
|
|
if src != null:
|
|
src_code = src.get_shader_code(uv)
|
|
if generated_variants.empty():
|
|
rv.defs = src_code.defs;
|
|
var variant_index = generated_variants.find(uv)
|
|
if variant_index == -1:
|
|
variant_index = generated_variants.size()
|
|
generated_variants.append(uv)
|
|
rv.code = src_code.code
|
|
rv.code += "vec4 %s_%d_rgba = %s;\n" % [ name, variant_index, src_code.rgba ]
|
|
rv.f = "%s_%d_rgba.%s" % [ name, variant_index, OUTPUTS[output] ]
|
|
return rv
|