mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
7033bf4a6e
* updated transform node (scale split into scale_x and scale_y, and added a repeat parameter) * added blend modes (burn, dodge, lighten and darken) * added a (very bad) blur node, based on generic convolution code * rewrote normal_map node using convolution code
30 lines
683 B
GDScript
30 lines
683 B
GDScript
tool
|
|
extends "res://addons/procedural_material/node_base.gd"
|
|
|
|
var sigma = 1.0
|
|
var epsilon = 0.005
|
|
|
|
func _ready():
|
|
initialize_properties([ $HBoxContainer1/sigma, $HBoxContainer2/epsilon ])
|
|
|
|
func _get_shader_code(uv):
|
|
var convolution = {
|
|
kernel=[
|
|
0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0
|
|
],
|
|
epsilon=epsilon
|
|
}
|
|
var sum = 0
|
|
for x in range(-2, 3):
|
|
for y in range(-2, 3):
|
|
var coef = exp(-0.5*(pow((x-2)/sigma, 2.0) + pow((y-2)/sigma, 2.0))) / (2.0*PI*sigma*sigma)
|
|
convolution.kernel[x+2+5*(y+2)] = coef
|
|
sum += coef
|
|
for i in range(25):
|
|
convolution.kernel[i] /= sum
|
|
return get_shader_code_convolution(convolution, uv)
|