mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
26720e74e9
Updated Transform so it accepts a greyscale input per parameter. For each pixel, the parameter is multiplied by 2*v-1 (v being the value of the input's pixel) which makes it possible to affect the strength of each transform using an input image. New effects such as whirl and color guided offsets are now possible. Added Decompose node (does the opposite of combine). Used another color for inputs/outputs that expect/generate a greyscale image.
22 lines
689 B
GDScript
22 lines
689 B
GDScript
tool
|
|
extends "res://addons/procedural_material/node_base.gd"
|
|
|
|
const OUTPUTS = [ "r", "g", "b" ]
|
|
|
|
func _get_shader_code(uv, output = 0):
|
|
var rv = { defs="", code="" }
|
|
var src = get_source()
|
|
var src_code = { defs="", code="", rgb="vec3(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 += "vec3 %s_%d_rgb = %s;\n" % [ name, variant_index, src_code.rgb ]
|
|
rv.f = "%s_%d_rgb.%s" % [ name, variant_index, OUTPUTS[output] ]
|
|
return rv
|