Added size parameter to emboss node

This commit is contained in:
Rodolphe Suescun 2018-08-27 19:31:00 +02:00
parent ec645a06f4
commit effa29e158
3 changed files with 129 additions and 7 deletions

View File

@ -1,6 +1,7 @@
tool
extends "res://addons/procedural_material/node_base.gd"
var size = 5
var direction = 0
var input_shader = ""
@ -24,15 +25,20 @@ const INDICES = [ 0, 1, 2, 5, 8, 7, 6, 3 ]
const COEFS = [ 1, 2, 1, 0, -1, -2, -1, 0 ]
func _ready():
$HBoxContainer1/size.clear()
for i in range(7):
$HBoxContainer1/size.add_item(str(int(pow(2, 5+i))), i)
$HBoxContainer1/size.selected = size
input_texture = ImageTexture.new()
final_texture = ImageTexture.new()
initialize_properties([ $direction ])
initialize_properties([ $HBoxContainer1/size, $HBoxContainer2/direction ])
func _rerender():
get_parent().precalculate_shader(input_shader, get_source().get_textures(), 1024, input_texture, self, "pass_1", [])
func pass_1():
var convolution = CONVOLUTION
convolution.epsilon=1.0/pow(2, 5+size)
for i in range(8):
convolution.kernel[INDICES[i]] = COEFS[(i+8-int(direction))%8]
get_parent().precalculate_shader(get_convolution_shader(convolution), {input=input_texture}, 1024, final_texture, self, "rerender_targets", [])

View File

@ -13,8 +13,8 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 1.0
margin_top = 1.0
margin_right = 124.0
margin_bottom = 54.0
margin_right = 173.0
margin_bottom = 71.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 1
@ -35,10 +35,16 @@ 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 )
script = ExtResource( 1 )
_sections_unfolded = [ "Theme", "slot", "slot/0" ]
[node name="direction" type="OptionButton" parent="." index="0"]
[node name="HBoxContainer1" type="HBoxContainer" parent="." index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -46,14 +52,123 @@ anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 16.0
margin_top = 24.0
margin_right = 107.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 = 1
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 = [ "Anchor", "Margin", "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
@ -65,6 +180,6 @@ flat = false
align = 0
items = [ "N", null, false, 0, null, "NE", null, false, 1, null, "E", null, false, 2, null, "SE", null, false, 3, null, "S", null, false, 4, null, "SW", null, false, 5, null, "W", null, false, 6, null, "NW", null, false, 7, null ]
selected = 0
_sections_unfolded = [ "Caret", "Placeholder" ]
_sections_unfolded = [ "Caret", "Placeholder", "Rect", "Size Flags" ]

1
test.ptex Normal file
View File

@ -0,0 +1 @@
{"connections":[{"from":"pattern_1","from_port":0,"to":"colorize_0","to_port":0},{"from":"perlin_0","from_port":0,"to":"transform_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"transform_0","to_port":3},{"from":"uniform_0","from_port":0,"to":"Material","to_port":2},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"transform_0","from_port":0,"to":"normal_map_0","to_port":0},{"from":"transform_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"Material","to_port":0}],"nodes":[{"iterations":7,"name":"perlin_0","node_position":{"x":-248,"y":-183.5},"persistence":0.5,"scale_x":4,"scale_y":4,"type":"perlin"},{"mix":0,"name":"pattern_1","node_position":{"x":-488,"y":6.5},"type":"pattern","x_scale":1,"x_wave":0,"y_scale":1,"y_wave":0},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}],"name":"colorize_0","node_position":{"x":-214,"y":9.5},"type":"colorize"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":387,"y":-79},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":248.577271,"y":-53.178574},"type":"uniform"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":234.577271,"y":52.821411},"type":"normal_map"},{"name":"transform_0","node_position":{"x":-8,"y":-73.5},"repeat":true,"rotate":100,"scale_x":1,"scale_y":1,"translate_x":0,"translate_y":0,"type":"transform"},{"gradient":[{"b":0,"g":0,"pos":0.3,"r":1},{"b":0,"g":1,"pos":0.409091,"r":0.96875},{"b":0,"g":0.801432,"pos":0.518182,"r":0.025045},{"b":1,"g":0.000001,"pos":0.627273,"r":0},{"b":0.708333,"g":0,"pos":0.745455,"r":0.641927}],"name":"colorize_1","node_position":{"x":213,"y":-149.5},"type":"colorize"}]}