mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Removed old blur node
This commit is contained in:
parent
8b9084f72b
commit
c7c1e61597
@ -1,81 +0,0 @@
|
|||||||
tool
|
|
||||||
extends "res://addons/material_maker/node_base.gd"
|
|
||||||
|
|
||||||
var input_shader = ""
|
|
||||||
var saved_texture
|
|
||||||
|
|
||||||
const DIRECTION_H = 1
|
|
||||||
const DIRECTION_V = 2
|
|
||||||
const DIRECTIONS = [
|
|
||||||
{ name="Both", mask=DIRECTION_H|DIRECTION_V },
|
|
||||||
{ name="X", mask=DIRECTION_H },
|
|
||||||
{ name="Y", mask=DIRECTION_V }
|
|
||||||
]
|
|
||||||
|
|
||||||
func _ready() -> void:
|
|
||||||
# init size widget
|
|
||||||
$HBoxContainer1/size.clear()
|
|
||||||
for i in range(7):
|
|
||||||
$HBoxContainer1/size.add_item(str(int(pow(2, 5+i))), i)
|
|
||||||
$HBoxContainer1/size.selected = 5
|
|
||||||
# init direction widget
|
|
||||||
$HBoxContainer2/direction.clear()
|
|
||||||
for d in DIRECTIONS:
|
|
||||||
$HBoxContainer2/direction.add_item(d.name)
|
|
||||||
$HBoxContainer2/direction.selected = 0
|
|
||||||
initialize_properties([ $HBoxContainer1/size, $HBoxContainer2/direction, $HBoxContainer3/sigma ])
|
|
||||||
saved_texture = ImageTexture.new()
|
|
||||||
|
|
||||||
func get_gaussian_blur_shader(horizontal) -> String:
|
|
||||||
var convolution = { x=0, y=0, kernel=[], epsilon=1.0/pow(2, 5+parameters.size) }
|
|
||||||
var kernel_size = 50
|
|
||||||
if horizontal:
|
|
||||||
convolution.x = kernel_size
|
|
||||||
else:
|
|
||||||
convolution.y = kernel_size
|
|
||||||
convolution.kernel.resize(2*kernel_size+1)
|
|
||||||
var sum = 0
|
|
||||||
for x in range(-kernel_size, kernel_size+1):
|
|
||||||
var coef = exp(-0.5*(pow((x)/parameters.sigma, 2.0))) / (2.0*PI*parameters.sigma*parameters.sigma)
|
|
||||||
convolution.kernel[x+kernel_size] = coef
|
|
||||||
sum += coef
|
|
||||||
for x in range(-kernel_size, kernel_size+1):
|
|
||||||
convolution.kernel[x+kernel_size] /= sum
|
|
||||||
return get_convolution_shader(convolution)
|
|
||||||
|
|
||||||
func _rerender() -> void:
|
|
||||||
if DIRECTIONS[parameters.direction].mask & DIRECTION_H != 0:
|
|
||||||
get_parent().renderer.precalculate_shader(input_shader, get_source().get_textures(), int(pow(2, 5+parameters.size)), saved_texture, self, "pass_1", [])
|
|
||||||
else:
|
|
||||||
get_parent().renderer.precalculate_shader(input_shader, get_source().get_textures(), int(pow(2, 5+parameters.size)), saved_texture, self, "pass_2", [])
|
|
||||||
|
|
||||||
func pass_1() -> void:
|
|
||||||
if DIRECTIONS[parameters.direction].mask & DIRECTION_V != 0:
|
|
||||||
get_parent().renderer.precalculate_shader(get_gaussian_blur_shader(true), { input=saved_texture }, int(pow(2, 5+parameters.size)), saved_texture, self, "pass_2", [])
|
|
||||||
else:
|
|
||||||
get_parent().renderer.precalculate_shader(get_gaussian_blur_shader(true), { input=saved_texture }, int(pow(2, 5+parameters.size)), saved_texture, self, "rerender_targets", [])
|
|
||||||
|
|
||||||
func pass_2() -> void:
|
|
||||||
get_parent().renderer.precalculate_shader(get_gaussian_blur_shader(false), { input=saved_texture }, int(pow(2, 5+parameters.size)), saved_texture, self, "rerender_targets", [])
|
|
||||||
|
|
||||||
func get_textures() -> Dictionary:
|
|
||||||
var list = {}
|
|
||||||
list[name] = saved_texture
|
|
||||||
return list
|
|
||||||
|
|
||||||
func _get_shader_code(uv, slot = 0) -> Dictionary:
|
|
||||||
var rv = { defs="", code="" }
|
|
||||||
var src = get_source()
|
|
||||||
if src == null:
|
|
||||||
return rv
|
|
||||||
input_shader = get_parent().renderer.generate_shader(src.get_shader_code_with_globals("UV"))
|
|
||||||
_rerender()
|
|
||||||
if generated_variants.empty():
|
|
||||||
rv.defs = "uniform sampler2D "+name+"_tex;\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)+"_rgb = texture("+name+"_tex, "+uv+").rgb;\n"
|
|
||||||
rv.rgb = name+"_"+str(variant_index)+"_rgb"
|
|
||||||
return rv
|
|
@ -1,260 +0,0 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
|
||||||
|
|
||||||
[ext_resource path="res://addons/material_maker/nodes/blur/blur.gd" type="Script" id=1]
|
|
||||||
|
|
||||||
|
|
||||||
[sub_resource type="Theme" id=1]
|
|
||||||
|
|
||||||
|
|
||||||
[node name="Blur" type="GraphNode" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 1.0
|
|
||||||
margin_top = 1.0
|
|
||||||
margin_right = 175.0
|
|
||||||
margin_bottom = 96.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 1
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 1
|
|
||||||
size_flags_vertical = 1
|
|
||||||
theme = SubResource( 1 )
|
|
||||||
title = "Blur"
|
|
||||||
offset = Vector2( 0, 0 )
|
|
||||||
show_close = true
|
|
||||||
resizable = false
|
|
||||||
selected = false
|
|
||||||
comment = false
|
|
||||||
overlay = 0
|
|
||||||
slot/0/left_enabled = true
|
|
||||||
slot/0/left_type = 0
|
|
||||||
slot/0/left_color = Color( 0.5, 0.5, 1, 1 )
|
|
||||||
slot/0/right_enabled = true
|
|
||||||
slot/0/right_type = 0
|
|
||||||
slot/0/right_color = Color( 0.5, 0.5, 1, 1 )
|
|
||||||
slot/1/left_enabled = false
|
|
||||||
slot/1/left_type = 0
|
|
||||||
slot/1/left_color = Color( 1, 1, 1, 1 )
|
|
||||||
slot/1/right_enabled = false
|
|
||||||
slot/1/right_type = 0
|
|
||||||
slot/1/right_color = Color( 1, 1, 1, 1 )
|
|
||||||
slot/2/left_enabled = false
|
|
||||||
slot/2/left_type = 0
|
|
||||||
slot/2/left_color = Color( 1, 1, 1, 1 )
|
|
||||||
slot/2/right_enabled = false
|
|
||||||
slot/2/right_type = 0
|
|
||||||
slot/2/right_color = Color( 1, 1, 1, 1 )
|
|
||||||
script = ExtResource( 1 )
|
|
||||||
_sections_unfolded = [ "Anchor", "Margin", "Size Flags", "Theme", "slot" ]
|
|
||||||
|
|
||||||
[node name="HBoxContainer1" type="HBoxContainer" parent="." index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 16.0
|
|
||||||
margin_top = 24.0
|
|
||||||
margin_right = 158.0
|
|
||||||
margin_bottom = 44.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 1
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 1
|
|
||||||
alignment = 0
|
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="HBoxContainer1" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_top = 3.0
|
|
||||||
margin_right = 63.0
|
|
||||||
margin_bottom = 17.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 2
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 4
|
|
||||||
text = "Grid size:"
|
|
||||||
percent_visible = 1.0
|
|
||||||
lines_skipped = 0
|
|
||||||
max_lines_visible = -1
|
|
||||||
_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="size" type="OptionButton" parent="HBoxContainer1" index="1"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 67.0
|
|
||||||
margin_right = 142.0
|
|
||||||
margin_bottom = 20.0
|
|
||||||
rect_min_size = Vector2( 75, 0 )
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 11
|
|
||||||
size_flags_vertical = 1
|
|
||||||
toggle_mode = false
|
|
||||||
action_mode = 0
|
|
||||||
enabled_focus_mode = 2
|
|
||||||
shortcut = null
|
|
||||||
group = null
|
|
||||||
text = "1024"
|
|
||||||
flat = false
|
|
||||||
align = 0
|
|
||||||
items = [ "32", null, false, 0, null, "64", null, false, 1, null, "128", null, false, 2, null, "256", null, false, 3, null, "512", null, false, 4, null, "1024", null, false, 5, null, "2048", null, false, 6, null ]
|
|
||||||
selected = 5
|
|
||||||
_sections_unfolded = [ "Anchor", "Caret", "Placeholder", "Rect", "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="HBoxContainer2" type="HBoxContainer" parent="." index="1"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 16.0
|
|
||||||
margin_top = 44.0
|
|
||||||
margin_right = 158.0
|
|
||||||
margin_bottom = 64.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 1
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 1
|
|
||||||
alignment = 0
|
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="HBoxContainer2" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_top = 3.0
|
|
||||||
margin_right = 63.0
|
|
||||||
margin_bottom = 17.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 2
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 4
|
|
||||||
text = "Direction:"
|
|
||||||
percent_visible = 1.0
|
|
||||||
lines_skipped = 0
|
|
||||||
max_lines_visible = -1
|
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="direction" type="OptionButton" parent="HBoxContainer2" index="1"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 67.0
|
|
||||||
margin_right = 142.0
|
|
||||||
margin_bottom = 20.0
|
|
||||||
rect_min_size = Vector2( 75, 0 )
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
focus_mode = 2
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 11
|
|
||||||
size_flags_vertical = 1
|
|
||||||
toggle_mode = false
|
|
||||||
action_mode = 0
|
|
||||||
enabled_focus_mode = 2
|
|
||||||
shortcut = null
|
|
||||||
group = null
|
|
||||||
text = "Both"
|
|
||||||
flat = false
|
|
||||||
align = 0
|
|
||||||
items = [ "Both", null, false, -1, null, "X", null, false, -1, null, "Y", null, false, -1, null ]
|
|
||||||
selected = 0
|
|
||||||
_sections_unfolded = [ "Caret", "Placeholder", "Rect", "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="HBoxContainer3" type="HBoxContainer" parent="." index="2"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 16.0
|
|
||||||
margin_top = 65.0
|
|
||||||
margin_right = 158.0
|
|
||||||
margin_bottom = 89.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 1
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 1
|
|
||||||
alignment = 0
|
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="HBoxContainer3" index="0"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_top = 5.0
|
|
||||||
margin_right = 63.0
|
|
||||||
margin_bottom = 19.0
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 2
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 3
|
|
||||||
size_flags_vertical = 4
|
|
||||||
text = "Sigma:"
|
|
||||||
percent_visible = 1.0
|
|
||||||
lines_skipped = 0
|
|
||||||
max_lines_visible = -1
|
|
||||||
_sections_unfolded = [ "Size Flags" ]
|
|
||||||
|
|
||||||
[node name="sigma" type="SpinBox" parent="HBoxContainer3" index="1"]
|
|
||||||
|
|
||||||
anchor_left = 0.0
|
|
||||||
anchor_top = 0.0
|
|
||||||
anchor_right = 0.0
|
|
||||||
anchor_bottom = 0.0
|
|
||||||
margin_left = 67.0
|
|
||||||
margin_right = 142.0
|
|
||||||
margin_bottom = 24.0
|
|
||||||
rect_min_size = Vector2( 75, 0 )
|
|
||||||
rect_pivot_offset = Vector2( 0, 0 )
|
|
||||||
rect_clip_content = false
|
|
||||||
mouse_filter = 0
|
|
||||||
mouse_default_cursor_shape = 0
|
|
||||||
size_flags_horizontal = 11
|
|
||||||
size_flags_vertical = 1
|
|
||||||
min_value = 0.05
|
|
||||||
max_value = 50.0
|
|
||||||
step = 0.1
|
|
||||||
page = 0.0
|
|
||||||
value = 1.0
|
|
||||||
exp_edit = false
|
|
||||||
rounded = false
|
|
||||||
editable = true
|
|
||||||
prefix = ""
|
|
||||||
suffix = ""
|
|
||||||
_sections_unfolded = [ "Caret", "Placeholder", "Rect", "Size Flags" ]
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user