mirror of
https://github.com/Relintai/material-maker.git
synced 2024-12-23 21:16:54 +01:00
507586cbec
Updated base node class to support several outputs. Now bricks support 2 outputs : greyscale depth map, and (random) brick color. Now Voronoi supports 3 outputs : center distance, edge distance and cell color. Updated bricks example to use brick color output.
28 lines
997 B
GDScript
28 lines
997 B
GDScript
tool
|
|
extends "res://addons/procedural_material/node_base.gd"
|
|
|
|
var rows
|
|
var columns
|
|
var row_offset
|
|
var mortar
|
|
var bevel
|
|
|
|
func _ready():
|
|
set_slot(0, false, 0, Color(0.5, 0.5, 1), true, 0, Color(0.5, 0.5, 1))
|
|
initialize_properties([ $HBoxContainer1/rows, $HBoxContainer2/columns, $HBoxContainer3/row_offset, $HBoxContainer4/mortar, $HBoxContainer5/bevel ])
|
|
|
|
func _get_shader_code(uv, slot = 0):
|
|
var rv = { defs="", code="" }
|
|
if generated_variants.empty():
|
|
rv.defs = "vec3 "+name+"_xyz(vec2 uv) { return bricks(uv, vec2("+str(columns)+", "+str(rows)+"), "+str(row_offset)+", "+str(mortar)+", "+str(max(0.001, bevel))+"); }\n"
|
|
var variant_index = generated_variants.find(uv)
|
|
if variant_index == -1:
|
|
variant_index = generated_variants.size()
|
|
generated_variants.append(uv)
|
|
rv.code = "vec3 "+name+"_"+str(variant_index)+"_xyz = "+name+"_xyz("+uv+");\n"
|
|
if slot == 0:
|
|
rv.f = name+"_"+str(variant_index)+"_xyz.x"
|
|
else:
|
|
rv.rgb = "rand3("+name+"_"+str(variant_index)+"_xyz.yz)"
|
|
return rv
|