From bdd12744fe340152cef5bf88de9e2d183bff1790 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sun, 19 Jul 2015 01:48:46 -0300 Subject: Select and move multiple nodes at once --- scene/resources/default_theme/default_theme.cpp | 2 ++ scene/resources/default_theme/graph_node_selected.png | Bin 0 -> 738 bytes scene/resources/default_theme/theme_data.h | 5 +++++ 3 files changed, 7 insertions(+) create mode 100644 scene/resources/default_theme/graph_node_selected.png (limited to 'scene/resources') diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 9a9048e3e5..667dfd4632 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -558,9 +558,11 @@ void make_default_theme() { // GraphNode Ref graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5); + Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5); //graphsb->set_expand_margin_size(MARGIN_LEFT,10); //graphsb->set_expand_margin_size(MARGIN_RIGHT,10); t->set_stylebox("frame","GraphNode", graphsb ); + t->set_stylebox("selectedframe","GraphNode", graphsbselected ); t->set_constant("separation","GraphNode", 1 ); t->set_icon("port","GraphNode", make_icon( graph_port_png ) ); t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) ); diff --git a/scene/resources/default_theme/graph_node_selected.png b/scene/resources/default_theme/graph_node_selected.png new file mode 100644 index 0000000000..06a9db4409 Binary files /dev/null and b/scene/resources/default_theme/graph_node_selected.png differ diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 03d851e749..a00651a0b3 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -114,6 +114,11 @@ static const unsigned char graph_node_close_png[]={ }; +static const unsigned char graph_node_selected_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x40,0x8,0x6,0x0,0x0,0x0,0x13,0x7d,0xf7,0x96,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x7,0x12,0x1,0xc,0x6,0x23,0x98,0xc7,0x50,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x2,0x46,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0x97,0xcd,0x6a,0x13,0x51,0x14,0xc7,0x7f,0xe7,0xce,0x34,0x49,0xd,0xa6,0xb1,0x2a,0xe2,0x7,0x74,0xa1,0x6e,0x4,0x85,0xe2,0x3,0xb8,0x72,0x21,0xba,0x16,0x5c,0xb9,0x16,0x4,0x7d,0x84,0x3e,0x82,0x82,0xe0,0xda,0x95,0x2f,0x60,0x71,0xe1,0xca,0x7,0xd0,0x82,0xa5,0x6e,0xd4,0x45,0xc1,0x8f,0x4a,0x6c,0x9a,0x46,0x62,0x66,0xa6,0x73,0xef,0x71,0xe1,0x4c,0x92,0x99,0x4c,0x93,0x36,0xdd,0xc9,0xfc,0x37,0x77,0x3e,0xee,0xfd,0xdd,0x73,0xfe,0xf7,0xc,0xcc,0x11,0x86,0x12,0xc0,0x0,0x5e,0x32,0xa,0x59,0x29,0xe0,0x0,0x9b,0x8c,0xca,0xc8,0x24,0x3,0x1c,0x3,0x16,0x81,0xd3,0x40,0x3,0x98,0xcb,0x1,0xf6,0x80,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33,0x1a,0x3f,0xae,0xbf,0xf0,0x27,0xf6,0x42,0xf6,0xf5,0xfd,0xae,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + static const unsigned char graph_port_png[]={ 0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0xa,0x0,0x0,0x0,0xa,0x8,0x6,0x0,0x0,0x0,0x8d,0x32,0xcf,0xbd,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0x0,0x0,0x0,0x0,0x0,0xf9,0x43,0xbb,0x7f,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xde,0xc,0x14,0x17,0x20,0x3,0xeb,0x8f,0x3a,0xdb,0x0,0x0,0x0,0x19,0x74,0x45,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x57,0x81,0xe,0x17,0x0,0x0,0x1,0x65,0x49,0x44,0x41,0x54,0x18,0xd3,0x4d,0xd0,0x4f,0x6b,0xda,0x70,0x1c,0x7,0xe0,0xcf,0x37,0x7f,0x7e,0x49,0x66,0xd2,0x64,0x61,0x5,0x61,0x76,0x47,0xf1,0xa4,0x2d,0xdb,0x75,0x5,0x11,0x84,0xb0,0x5e,0xeb,0xd9,0xeb,0xf4,0x6d,0xec,0x2d,0xf8,0x26,0xb6,0x77,0xe0,0x45,0xba,0xa3,0x6c,0xa0,0x3b,0xad,0x39,0xb6,0x36,0x8,0x1b,0x4b,0x32,0xd2,0xc6,0x6c,0x9a,0x4f,0x4f,0x85,0x3e,0x2f,0xe1,0x11,0x0,0x20,0x29,0xd3,0xe9,0xd4,0xda,0x6e,0xb7,0x23,0xdf,0xf7,0xbb,0x0,0x90,0xe7,0xf9,0x8f,0x66,0xb3,0xf9,0x79,0x36,0x9b,0x55,0x22,0x42,0x83,0xa4,0x44,0x51,0xf4,0xea,0xe2,0xe2,0xc3,0xf7,0xf1,0x78,0xdc,0xa,0x82,0x40,0x8,0x20,0xcf,0x32,0x2e,0x97,0xcb,0x4f,0x51,0x14,0xbd,0x25,0xf9,0x5b,0x26,0x93,0x89,0xdd,0xe9,0x74,0xe2,0xf7,0xe7,0xe7,0x27,0x59,0xfa,0x87,0x65,0xb9,0x13,0x0,0xb0,0x1d,0x9b,0xe1,0xcb,0x50,0xbe,0x5e,0x5d,0xdd,0xfe,0xbc,0xbe,0x6e,0x6b,0x49,0x92,0x8c,0x4e,0x7b,0xa7,0xad,0xbf,0x79,0x4e,0xd3,0x54,0x12,0x86,0x21,0xc2,0x30,0x84,0x32,0x95,0xe4,0x79,0xc6,0xde,0xd9,0x59,0x2b,0x49,0xee,0x46,0x86,0xeb,0xba,0x5d,0xfb,0x85,0x23,0x87,0xfd,0x1e,0xb6,0xed,0x40,0xd7,0x35,0x0,0x40,0x7d,0x38,0xa0,0xdc,0xed,0x44,0x37,0x74,0xb8,0xae,0xd7,0x35,0x48,0x62,0xff,0xff,0x1f,0xfc,0x20,0x80,0xae,0xe9,0x78,0x42,0x0,0xca,0xb2,0x90,0x65,0x19,0x58,0xd7,0xd0,0x8a,0xa2,0x58,0xa7,0x69,0x56,0x6b,0xa2,0x51,0x29,0x5,0xcb,0x52,0xb0,0x94,0x5,0x4b,0x29,0x88,0x8,0xd3,0x34,0xad,0x8b,0xfb,0x62,0xad,0xf,0x6,0x83,0xb8,0xaa,0xaa,0xb1,0xe7,0x79,0xbe,0x77,0x74,0x44,0xb7,0xe1,0x89,0x69,0x1a,0x28,0xcb,0x92,0x9b,0xcd,0x46,0x56,0xab,0xd5,0x86,0xe4,0x47,0x21,0x29,0xc3,0xe1,0xf0,0xb8,0xdf,0xef,0x7f,0x6b,0xb7,0xdb,0xaf,0x1b,0x8d,0x86,0x46,0x10,0xf,0xf7,0xf,0x75,0x1c,0xc7,0x77,0x8b,0xc5,0xe2,0xdd,0x7c,0x3e,0xff,0x25,0xcf,0xc3,0x6f,0x6e,0x6f,0x2e,0x1d,0xdb,0xe9,0x9,0x80,0xb2,0x2a,0xd7,0x27,0xad,0x37,0x5f,0x9e,0xc2,0x1f,0x1,0x3a,0xe6,0xa5,0x7b,0xef,0xf2,0xf3,0xcd,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 }; -- cgit v1.2.3 From 2a43778793ba67c7edb7d96ab30c4c2a8c145c70 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Mon, 20 Jul 2015 22:15:06 -0300 Subject: Fix tab indent --- scene/resources/default_theme/default_theme.cpp | 90 ++++++++++++------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'scene/resources') diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 667dfd4632..58ba5fba25 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -31,7 +31,7 @@ static TexCacheMap *tex_cache; template static Ref make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) { - + Ref texture; @@ -56,17 +56,17 @@ static Ref make_stylebox(T p_src,float p_left, float p_top, flo style->set_default_margin( MARGIN_BOTTOM, p_margin_botton ); style->set_default_margin( MARGIN_TOP, p_margin_top ); style->set_draw_center(p_draw_center); - + return style; } template static Ref make_icon(T p_src) { - - + + Ref texture( memnew( ImageTexture ) ); texture->create_from_image( Image(p_src),ImageTexture::FLAG_FILTER ); - + return texture; } @@ -75,7 +75,7 @@ static Ref make_font(int p_height,int p_ascent, int p_valign, int p_charco Ref font( memnew( Font ) ); font->add_texture( p_texture ); - + for (int i=0;i make_font(int p_height,int p_ascent, int p_valign, int p_charco font->add_char( chr, 0, frect, align,advance ); - + } - + font->set_height( p_height ); font->set_ascent( p_ascent ); @@ -152,12 +152,12 @@ static Ref make_font2(int p_height,int p_ascent, int p_charcount, const in static Ref make_empty_stylebox(float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1) { Ref style( memnew( StyleBoxEmpty) ); - + style->set_default_margin( MARGIN_LEFT, p_margin_left ); style->set_default_margin( MARGIN_RIGHT, p_margin_right ); style->set_default_margin( MARGIN_BOTTOM, p_margin_botton ); style->set_default_margin( MARGIN_TOP, p_margin_top ); - + return style; } @@ -300,49 +300,49 @@ void make_default_theme() { t->set_constant("hseparation","MenuButton", 0 ); - // CheckBox + // CheckBox - Ref cbx_empty = memnew( StyleBoxEmpty ); - cbx_empty->set_default_margin(MARGIN_LEFT,22); - cbx_empty->set_default_margin(MARGIN_RIGHT,4); - cbx_empty->set_default_margin(MARGIN_TOP,4); - cbx_empty->set_default_margin(MARGIN_BOTTOM,5); - Ref cbx_focus = focus; - cbx_focus->set_default_margin(MARGIN_LEFT,4); - cbx_focus->set_default_margin(MARGIN_RIGHT,22); - cbx_focus->set_default_margin(MARGIN_TOP,4); - cbx_focus->set_default_margin(MARGIN_BOTTOM,5); + Ref cbx_empty = memnew( StyleBoxEmpty ); + cbx_empty->set_default_margin(MARGIN_LEFT,22); + cbx_empty->set_default_margin(MARGIN_RIGHT,4); + cbx_empty->set_default_margin(MARGIN_TOP,4); + cbx_empty->set_default_margin(MARGIN_BOTTOM,5); + Ref cbx_focus = focus; + cbx_focus->set_default_margin(MARGIN_LEFT,4); + cbx_focus->set_default_margin(MARGIN_RIGHT,22); + cbx_focus->set_default_margin(MARGIN_TOP,4); + cbx_focus->set_default_margin(MARGIN_BOTTOM,5); - t->set_stylebox("normal","CheckBox", cbx_empty ); - t->set_stylebox("pressed","CheckBox", cbx_empty ); - t->set_stylebox("disabled","CheckBox", cbx_empty ); - t->set_stylebox("hover","CheckBox", cbx_empty ); - t->set_stylebox("focus","CheckBox", cbx_focus ); + t->set_stylebox("normal","CheckBox", cbx_empty ); + t->set_stylebox("pressed","CheckBox", cbx_empty ); + t->set_stylebox("disabled","CheckBox", cbx_empty ); + t->set_stylebox("hover","CheckBox", cbx_empty ); + t->set_stylebox("focus","CheckBox", cbx_focus ); - t->set_icon("checked", "CheckBox", make_icon(checked_png)); - t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png)); - t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png)); - t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png)); + t->set_icon("checked", "CheckBox", make_icon(checked_png)); + t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png)); + t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png)); + t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png)); - t->set_font("font","CheckBox", default_font ); + t->set_font("font","CheckBox", default_font ); - t->set_color("font_color","CheckBox", control_font_color ); - t->set_color("font_color_pressed","CheckBox", control_font_color_pressed ); - t->set_color("font_color_hover","CheckBox", control_font_color_hover ); - t->set_color("font_color_disabled","CheckBox", control_font_color_disabled ); + t->set_color("font_color","CheckBox", control_font_color ); + t->set_color("font_color_pressed","CheckBox", control_font_color_pressed ); + t->set_color("font_color_hover","CheckBox", control_font_color_hover ); + t->set_color("font_color_disabled","CheckBox", control_font_color_disabled ); - t->set_constant("hseparation","CheckBox",4); - t->set_constant("check_vadjust","CheckBox",0); + t->set_constant("hseparation","CheckBox",4); + t->set_constant("check_vadjust","CheckBox",0); // CheckButton - + Ref cb_empty = memnew( StyleBoxEmpty ); cb_empty->set_default_margin(MARGIN_LEFT,6); cb_empty->set_default_margin(MARGIN_RIGHT,70); cb_empty->set_default_margin(MARGIN_TOP,4); - cb_empty->set_default_margin(MARGIN_BOTTOM,4); + cb_empty->set_default_margin(MARGIN_BOTTOM,4); t->set_stylebox("normal","CheckButton", cb_empty ); t->set_stylebox("pressed","CheckButton", cb_empty ); @@ -366,7 +366,7 @@ void make_default_theme() { // Label - + t->set_font("font","Label", default_font ); t->set_color("font_color","Label", Color(1,1,1) ); @@ -558,11 +558,11 @@ void make_default_theme() { // GraphNode Ref graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5); - Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5); + Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5); //graphsb->set_expand_margin_size(MARGIN_LEFT,10); //graphsb->set_expand_margin_size(MARGIN_RIGHT,10); t->set_stylebox("frame","GraphNode", graphsb ); - t->set_stylebox("selectedframe","GraphNode", graphsbselected ); + t->set_stylebox("selectedframe","GraphNode", graphsbselected ); t->set_constant("separation","GraphNode", 1 ); t->set_icon("port","GraphNode", make_icon( graph_port_png ) ); t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) ); @@ -713,7 +713,7 @@ void make_default_theme() { // FileDialog - + t->set_icon("folder","FileDialog",make_icon(icon_folder_png)); t->set_color("files_disabled","FileDialog",Color(0,0,0,0.7)); @@ -877,10 +877,10 @@ void make_default_theme() { #endif void clear_default_theme() { - + Theme::set_default( Ref() ); Theme::set_default_icon( Ref< Texture >() ); - Theme::set_default_style( Ref< StyleBox >() ); + Theme::set_default_style( Ref< StyleBox >() ); Theme::set_default_font( Ref< Font >() ); } -- cgit v1.2.3 From 5ffd818fb195a6e9bea48ec03ad52a77080a8d25 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sat, 25 Jul 2015 21:16:07 -0300 Subject: Duplicate GraphNode(s) [Control+D] --- scene/resources/shader_graph.cpp | 41 ++++++++++++++++++++++++++++++++++++++++ scene/resources/shader_graph.h | 4 ++++ 2 files changed, 45 insertions(+) (limited to 'scene/resources') diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index a0766ff317..108aad3c56 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -824,6 +824,47 @@ float ShaderGraph::texture_node_get_filter_strength(ShaderType p_type,float p_id return arr[1]; } +void ShaderGraph::duplicate_nodes(ShaderType p_which, List &p_nodes) +{ + //Create new node IDs + Map duplicates = Map(); + int i=1; + for(List::Element *E=p_nodes.front();E; E=E->next()) { + while (shader[p_which].node_map.has(i)) + i++; + duplicates.insert(E->get(), i); + i++; + } + + for(List::Element *E = p_nodes.front();E; E=E->next()) { + + const Node &n=shader[p_which].node_map[E->get()]; + Node nn=n; + nn.id=duplicates.find(n.id)->get(); + nn.pos += Vector2(0,100); + for (Map::Element *C=nn.connections.front();C;C=C->next()) { + SourceSlot &c=C->get(); + if (p_nodes.find(c.id)) + c.id=duplicates.find(c.id)->get(); + } + shader[p_which].node_map[nn.id]=nn; + } + _request_update(); +} + +List ShaderGraph::generate_ids(ShaderType p_type, int count) +{ + List ids = List(); + int i=1; + while (ids.size() < count) { + while (shader[p_type].node_map.has(i)) + i++; + ids.push_back(i); + i++; + } + return ids; +} + void ShaderGraph::scalar_op_node_set_op(ShaderType p_type,float p_id,ScalarOp p_op){ diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index fd6540a747..d3a297cd6c 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -216,6 +216,10 @@ public: void texture_node_set_filter_strength(ShaderType p_which,float p_id,float p_strength); float texture_node_get_filter_strength(ShaderType p_which,float p_id) const; + void duplicate_nodes(ShaderType p_which, List &p_nodes); + + List generate_ids(ShaderType p_type, int count); + enum ScalarOp { SCALAR_OP_ADD, SCALAR_OP_SUB, -- cgit v1.2.3 From add0105c4e89e586fb3d3a9646a9ffc747d2e881 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sat, 25 Jul 2015 22:05:45 -0300 Subject: Little fix: don't create an empty undo/redo command when trying to add a second Input GraphNode --- scene/resources/shader_graph.cpp | 9 +++++++++ scene/resources/shader_graph.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'scene/resources') diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 108aad3c56..9522667698 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -142,6 +142,15 @@ ShaderGraph::GraphError ShaderGraph::get_graph_error(ShaderType p_type) const { return shader[p_type].error; } +int ShaderGraph::node_count(ShaderType p_which, int p_type) +{ + int count=0; + for (Map::Element *E=shader[p_which].node_map.front();E;E=E->next()) + if (E->get().type==p_type) + count++; + return count; +} + void ShaderGraph::_bind_methods() { ObjectTypeDB::bind_method(_MD("_update_shader"),&ShaderGraph::_update_shader); diff --git a/scene/resources/shader_graph.h b/scene/resources/shader_graph.h index d3a297cd6c..b93567538d 100644 --- a/scene/resources/shader_graph.h +++ b/scene/resources/shader_graph.h @@ -365,6 +365,8 @@ public: GraphError get_graph_error(ShaderType p_type) const; + int node_count(ShaderType p_which, int p_type); + static int get_type_input_count(NodeType p_type); static int get_type_output_count(NodeType p_type); static SlotType get_type_input_type(NodeType p_type,int p_idx); -- cgit v1.2.3 From ea448cb779c9268f6213a8e741cfc793704ca2fe Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sat, 29 Aug 2015 21:09:11 -0300 Subject: Edit default values. WARNING!!! Do not merge these changes, default values are not compiled into shaders yet! --- scene/resources/default_theme/default_theme.cpp | 8 +- .../resources/default_theme/graph_node_default.png | Bin 0 -> 289 bytes .../default_theme/graph_node_default_focus.png | Bin 0 -> 408 bytes scene/resources/default_theme/theme_data.h | 10 ++ scene/resources/shader_graph.cpp | 150 +++++++++++++++------ scene/resources/shader_graph.h | 9 +- 6 files changed, 131 insertions(+), 46 deletions(-) create mode 100644 scene/resources/default_theme/graph_node_default.png create mode 100644 scene/resources/default_theme/graph_node_default_focus.png (limited to 'scene/resources') diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 819d0a5cb9..3ee4da5974 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -556,12 +556,16 @@ void make_default_theme() { // GraphNode - Ref graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5); - Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5); + Ref graphsb = make_stylebox(graph_node_png,6,24,6,5,3,24,16,5); + Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,3,24,16,5); + Ref graphsbdefault = make_stylebox(graph_node_default_png,4,4,4,4,6,4,4,4); + Ref graphsbdeffocus = make_stylebox(graph_node_default_focus_png,4,4,4,4,6,4,4,4); //graphsb->set_expand_margin_size(MARGIN_LEFT,10); //graphsb->set_expand_margin_size(MARGIN_RIGHT,10); t->set_stylebox("frame","GraphNode", graphsb ); t->set_stylebox("selectedframe","GraphNode", graphsbselected ); + t->set_stylebox("defaultframe", "GraphNode", graphsbdefault ); + t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus ); t->set_constant("separation","GraphNode", 1 ); t->set_icon("port","GraphNode", make_icon( graph_port_png ) ); t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) ); diff --git a/scene/resources/default_theme/graph_node_default.png b/scene/resources/default_theme/graph_node_default.png new file mode 100644 index 0000000000..ea6ec52828 Binary files /dev/null and b/scene/resources/default_theme/graph_node_default.png differ diff --git a/scene/resources/default_theme/graph_node_default_focus.png b/scene/resources/default_theme/graph_node_default_focus.png new file mode 100644 index 0000000000..b7c38ae481 Binary files /dev/null and b/scene/resources/default_theme/graph_node_default_focus.png differ diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index a00651a0b3..ba818d86b2 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -114,6 +114,16 @@ static const unsigned char graph_node_close_png[]={ }; +static const unsigned char graph_node_default_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x8,0x1a,0x17,0x2e,0xd,0x4c,0xb7,0x38,0x4,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x0,0x85,0x49,0x44,0x41,0x54,0x38,0xcb,0xed,0x93,0x31,0xa,0x83,0x40,0x14,0x44,0xdf,0xba,0xa5,0x20,0x41,0x30,0x20,0x4,0xab,0x40,0x20,0x7,0xc9,0x69,0xec,0x72,0x4e,0x9b,0xa0,0x1e,0xc1,0x2a,0x42,0x10,0x82,0xbb,0xc5,0x77,0x6d,0x4c,0x11,0x48,0xe3,0xb7,0x49,0xe1,0x6b,0x6,0xa6,0x78,0xd5,0x8c,0x1,0x6e,0x80,0xe1,0x9b,0xb0,0xe4,0xaf,0xde,0x3,0x4f,0xa0,0x3,0x6,0x93,0x67,0xa7,0xc0,0xa,0x44,0x64,0x72,0x7e,0x6c,0x87,0xf7,0xab,0x4,0x1e,0x68,0x38,0x17,0x97,0x90,0xc4,0x87,0xa,0xb8,0xa2,0xe5,0x98,0xe6,0x1,0xb8,0x47,0x5a,0x81,0xb5,0x16,0xa0,0x56,0xb,0x3e,0xec,0x82,0x3f,0x10,0x4c,0x6a,0x81,0x88,0x78,0xc0,0x45,0xda,0x29,0x3b,0x3f,0x36,0x40,0xbf,0xf9,0x4c,0x66,0xeb,0x9d,0x67,0x5c,0x46,0x37,0x51,0xb6,0x55,0x6d,0xc2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + +static const unsigned char graph_node_default_focus_png[]={ +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x10,0x8,0x6,0x0,0x0,0x0,0x1f,0xf3,0xff,0x61,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x8,0x1b,0x1,0x9,0x1c,0x5c,0xd5,0x12,0x34,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x0,0xfc,0x49,0x44,0x41,0x54,0x38,0xcb,0xbd,0x93,0x41,0x4a,0x4,0x41,0xc,0x45,0x7f,0xca,0x6a,0x14,0x42,0x2f,0xc4,0x85,0x7,0xf0,0x3c,0xde,0xa2,0xbc,0x41,0xd7,0xa2,0xa1,0x60,0xea,0x60,0xae,0x5c,0xea,0x19,0xdc,0xd7,0x42,0x97,0xe5,0xc,0x12,0xeb,0xbb,0x69,0xa5,0x84,0xe9,0x41,0x1d,0xf1,0x43,0x8,0x84,0xe4,0x2d,0x92,0x1f,0xc1,0x22,0x92,0x2,0xc0,0x2d,0x81,0x2e,0x7f,0xa8,0x75,0xb9,0x89,0x8,0x1,0x40,0x48,0x5e,0x76,0xcd,0xad,0x6b,0x74,0x7b,0xea,0x6,0xe0,0x75,0x9,0x13,0x11,0xca,0x34,0x4d,0xc4,0x37,0x35,0xc,0xc3,0xf3,0x38,0x8e,0xb7,0xf3,0x3c,0xdf,0x0,0xd8,0x1,0x30,0x90,0x4,0x49,0xe4,0x9c,0x11,0x42,0x40,0x29,0x65,0x15,0x50,0x4a,0xb9,0x8,0x21,0x30,0xe7,0x7c,0x47,0x52,0x49,0x9e,0x7c,0x2,0x62,0x8c,0x30,0x33,0xa8,0xea,0x2a,0x40,0x55,0xaf,0xcc,0x4c,0x62,0x8c,0x5b,0x92,0xe7,0x24,0x7,0xd7,0x2d,0x11,0xde,0x7b,0xd4,0x5a,0x57,0x1,0xb5,0xd6,0x47,0xef,0x3d,0x49,0x9e,0x1,0xf0,0x0,0x9c,0xc3,0xef,0xe5,0xf6,0x9d,0xea,0x5f,0x1,0x38,0x16,0xd0,0xfe,0x16,0x20,0x22,0x7,0x3d,0xd0,0x7b,0x41,0x44,0xb6,0x8b,0x2b,0x9b,0xeb,0x6e,0x8c,0x94,0x12,0xcc,0x6c,0x75,0xd8,0xcc,0xc6,0x94,0xd2,0x93,0xaa,0xde,0x2f,0x76,0x6e,0x3f,0xb2,0xb2,0x88,0xec,0x54,0xf5,0x61,0xb3,0xd9,0x5c,0x3,0x78,0x1,0x60,0xc7,0x3c,0x53,0x13,0x91,0x37,0xe9,0x9d,0xd8,0xe9,0xf4,0xc0,0xe2,0xbe,0xbc,0xf3,0x3b,0x49,0xa0,0x89,0xbf,0x71,0xc6,0xcd,0x1c,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +}; + + static const unsigned char graph_node_selected_png[]={ 0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x0,0x40,0x8,0x6,0x0,0x0,0x0,0x13,0x7d,0xf7,0x96,0x0,0x0,0x0,0x6,0x62,0x4b,0x47,0x44,0x0,0xff,0x0,0xff,0x0,0xff,0xa0,0xbd,0xa7,0x93,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xdf,0x7,0x12,0x1,0xc,0x6,0x23,0x98,0xc7,0x50,0x0,0x0,0x0,0x1d,0x69,0x54,0x58,0x74,0x43,0x6f,0x6d,0x6d,0x65,0x6e,0x74,0x0,0x0,0x0,0x0,0x0,0x43,0x72,0x65,0x61,0x74,0x65,0x64,0x20,0x77,0x69,0x74,0x68,0x20,0x47,0x49,0x4d,0x50,0x64,0x2e,0x65,0x7,0x0,0x0,0x2,0x46,0x49,0x44,0x41,0x54,0x58,0xc3,0xed,0x97,0xcd,0x6a,0x13,0x51,0x14,0xc7,0x7f,0xe7,0xce,0x34,0x49,0xd,0xa6,0xb1,0x2a,0xe2,0x7,0x74,0xa1,0x6e,0x4,0x85,0xe2,0x3,0xb8,0x72,0x21,0xba,0x16,0x5c,0xb9,0x16,0x4,0x7d,0x84,0x3e,0x82,0x82,0xe0,0xda,0x95,0x2f,0x60,0x71,0xe1,0xca,0x7,0xd0,0x82,0xa5,0x6e,0xd4,0x45,0xc1,0x8f,0x4a,0x6c,0x9a,0x46,0x62,0x66,0xa6,0x73,0xef,0x71,0xe1,0x4c,0x92,0x99,0x4c,0x93,0x36,0xdd,0xc9,0xfc,0x37,0x77,0x3e,0xee,0xfd,0xdd,0x73,0xfe,0xf7,0xc,0xcc,0x11,0x86,0x12,0xc0,0x0,0x5e,0x32,0xa,0x59,0x29,0xe0,0x0,0x9b,0x8c,0xca,0xc8,0x24,0x3,0x1c,0x3,0x16,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x7e,0xda,0xf,0xee,0x93,0x85,0x26,0x29,0xc7,0x33,0x1a,0x3f,0xae,0xbf,0xf0,0x27,0xf6,0x42,0xf6,0xf5,0xfd,0xae,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 }; diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 9522667698..fbc76c5143 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -80,12 +80,15 @@ void ShaderGraph::_set_data(const Dictionary &p_data) { ERR_FAIL_COND((conns.size()%3)!=0); for(int j=0;jget().param2; Array conns; - conns.resize(E->get().connections.size()*3); + conns.resize(E->get().connections.size()*3+E->get().defaults.size()*3); int idx2=0; for(Map::Element*F=E->get().connections.front();F;F=F->next()) { @@ -123,6 +126,14 @@ Dictionary ShaderGraph::_get_data() const { conns[idx2+2]=F->get().slot; idx2+=3; } + for(Map::Element*F=E->get().defaults.front();F;F=F->next()) { + + conns[idx2+0]=SLOT_DEFAULT_VALUE; + conns[idx2+1]=F->key(); + conns[idx2+2]=F->get(); + idx2+=3; + } + data[idx+5]=conns; idx+=6; } @@ -164,6 +175,9 @@ void ShaderGraph::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_node_list","shader_type"),&ShaderGraph::_get_node_list); + ObjectTypeDB::bind_method(_MD("default_set_value","shader_type","id","param_id","value"), &ShaderGraph::default_set_value); + ObjectTypeDB::bind_method(_MD("default_get_value","shader_type","id","param_id"), &ShaderGraph::default_get_value); + ObjectTypeDB::bind_method(_MD("scalar_const_node_set_value","shader_type","id","value"),&ShaderGraph::scalar_const_node_set_value); ObjectTypeDB::bind_method(_MD("scalar_const_node_get_value","shader_type","id"),&ShaderGraph::scalar_const_node_set_value); @@ -546,7 +560,7 @@ void ShaderGraph::node_add(ShaderType p_type, NodeType p_node_type,int p_id) { case NODE_RGB_INPUT: {node.param1=_find_unique_name("Color");node.param2=Color();} break; // color uniform (assignable in material) case NODE_XFORM_INPUT: {node.param1=_find_unique_name("XForm"); node.param2=Transform();} break; // mat4 uniform (assignable in material) case NODE_TEXTURE_INPUT: {node.param1=_find_unique_name("Tex"); } break; // texture input (assignable in material) - case NODE_CUBEMAP_INPUT: {node.param1=_find_unique_name("Cube"); } break; // cubemap input (assignable in material) + case NODE_CUBEMAP_INPUT: {node.param1=_find_unique_name("Cube"); } break; // cubemap input (assignable in material) case NODE_DEFAULT_TEXTURE: {}; break; case NODE_OUTPUT: {} break; // output (shader type dependent) case NODE_COMMENT: {} break; // comment @@ -692,6 +706,18 @@ void ShaderGraph::get_node_connections(ShaderType p_type,List *p_con } } +bool ShaderGraph::is_slot_connected(ShaderGraph::ShaderType p_type, int p_dst_id, int slot_id) +{ + for(const Map::Element *E=shader[p_type].node_map.front();E;E=E->next()) { + for (const Map::Element *F=E->get().connections.front();F;F=F->next()) { + + if (p_dst_id == E->key() && slot_id==F->key()) + return true; + } + } + return false; +} + void ShaderGraph::clear(ShaderType p_type) { @@ -1005,6 +1031,33 @@ ShaderGraph::ScalarFunc ShaderGraph::scalar_func_node_get_function(ShaderType p_ return ScalarFunc(func); } +void ShaderGraph::default_set_value(ShaderGraph::ShaderType p_which, int p_id, int p_param, const Variant &p_value) +{ + ERR_FAIL_INDEX(p_which,3); + ERR_FAIL_COND(!shader[p_which].node_map.has(p_id)); + Node& n = shader[p_which].node_map[p_id]; + if(p_value.get_type()==Variant::NIL) + n.defaults.erase(n.defaults.find(p_param)); + else + n.defaults[p_param]=p_value; + + _request_update(); + +} + +Variant ShaderGraph::default_get_value(ShaderGraph::ShaderType p_which, int p_id, int p_param) +{ + ERR_FAIL_INDEX_V(p_which,3,Variant()); + ERR_FAIL_COND_V(!shader[p_which].node_map.has(p_id),Variant()); + const Node& n = shader[p_which].node_map[p_id]; + + if (!n.defaults.has(p_param)) + return Variant(); + return n.defaults[p_param]; +} + + + void ShaderGraph::vec_func_node_set_function(ShaderType p_type,int p_id,VecFunc p_func){ ERR_FAIL_INDEX(p_type,3); @@ -1030,52 +1083,52 @@ ShaderGraph::VecFunc ShaderGraph::vec_func_node_get_function(ShaderType p_type, void ShaderGraph::color_ramp_node_set_ramp(ShaderType p_type,int p_id,const DVector& p_colors, const DVector& p_offsets){ - ERR_FAIL_INDEX(p_type,3); - ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); - ERR_FAIL_COND(p_colors.size()!=p_offsets.size()); - Node& n = shader[p_type].node_map[p_id]; - n.param1=p_colors; - n.param2=p_offsets; - _request_update(); + ERR_FAIL_INDEX(p_type,3); + ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); + ERR_FAIL_COND(p_colors.size()!=p_offsets.size()); + Node& n = shader[p_type].node_map[p_id]; + n.param1=p_colors; + n.param2=p_offsets; + _request_update(); } DVector ShaderGraph::color_ramp_node_get_colors(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); - const Node& n = shader[p_type].node_map[p_id]; - return n.param1; + ERR_FAIL_INDEX_V(p_type,3,DVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + const Node& n = shader[p_type].node_map[p_id]; + return n.param1; } DVector ShaderGraph::color_ramp_node_get_offsets(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); - const Node& n = shader[p_type].node_map[p_id]; - return n.param2; + ERR_FAIL_INDEX_V(p_type,3,DVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + const Node& n = shader[p_type].node_map[p_id]; + return n.param2; } void ShaderGraph::curve_map_node_set_points(ShaderType p_type,int p_id,const DVector& p_points) { - ERR_FAIL_INDEX(p_type,3); - ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); - Node& n = shader[p_type].node_map[p_id]; - n.param1=p_points; - _request_update(); + ERR_FAIL_INDEX(p_type,3); + ERR_FAIL_COND(!shader[p_type].node_map.has(p_id)); + Node& n = shader[p_type].node_map[p_id]; + n.param1=p_points; + _request_update(); } DVector ShaderGraph::curve_map_node_get_points(ShaderType p_type,int p_id) const{ - ERR_FAIL_INDEX_V(p_type,3,DVector()); - ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); - const Node& n = shader[p_type].node_map[p_id]; - return n.param1; + ERR_FAIL_INDEX_V(p_type,3,DVector()); + ERR_FAIL_COND_V(!shader[p_type].node_map.has(p_id),DVector()); + const Node& n = shader[p_type].node_map[p_id]; + return n.param1; } @@ -1265,6 +1318,12 @@ Variant ShaderGraph::node_get_state(ShaderType p_type,int p_id) const { s["pos"]=n.pos; s["param1"]=n.param1; s["param2"]=n.param2; + Array keys; + for (Map::Element *E=n.defaults.front();E;E=E->next()) { + keys.append(E->key()); + s[E->key()]=E->get(); + } + s["default_keys"]=keys; return s; } @@ -1277,10 +1336,15 @@ void ShaderGraph::node_set_state(ShaderType p_type,int p_id,const Variant& p_sta ERR_FAIL_COND(!d.has("pos")); ERR_FAIL_COND(!d.has("param1")); ERR_FAIL_COND(!d.has("param2")); + ERR_FAIL_COND(!d.has("default_keys")); + n.pos=d["pos"]; n.param1=d["param1"]; n.param2=d["param2"]; - + Array keys = d["default_keys"]; + for(int i=0;i defaults; int id; mutable int order; // used for sorting int sort_order; @@ -318,6 +320,9 @@ public: VEC_MAX_FUNC }; + void default_set_value(ShaderType p_which,int p_id,int p_param, const Variant& p_value); + Variant default_get_value(ShaderType p_which,int p_id,int p_param); + void vec_func_node_set_function(ShaderType p_which,int p_id,VecFunc p_func); VecFunc vec_func_node_get_function(ShaderType p_which,int p_id) const; @@ -358,6 +363,8 @@ public: void get_node_connections(ShaderType p_which,List *p_connections) const; + bool is_slot_connected(ShaderType p_which,int p_dst_id,int slot_id); + void clear(ShaderType p_which); Variant node_get_state(ShaderType p_type, int p_node) const; -- cgit v1.2.3 From a19a653e2cae50f43b8de5d4ba69170c7d2fa800 Mon Sep 17 00:00:00 2001 From: Mariano Javier Suligoy Date: Sun, 30 Aug 2015 02:44:49 -0300 Subject: Compile shaders using default values. --- scene/resources/shader_graph.cpp | 87 +++++++++++++++++++++++++++++++++++----- 1 file changed, 77 insertions(+), 10 deletions(-) (limited to 'scene/resources') diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index fbc76c5143..4604c42de1 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -1849,17 +1849,17 @@ void ShaderGraph::_update_shader() { Vector inputs; int max = get_node_input_slot_count(get_mode(),ShaderType(i),n->type); for(int k=0;kconnections.has(k)) { - shader[i].error=GRAPH_ERROR_MISSING_CONNECTIONS; - failed=true; - break; + iname="nd"+itos(n->id)+"sl"+itos(k)+"def"; + } else { + iname="nd"+itos(n->connections[k].id)+"sl"+itos(n->connections[k].slot); + if (node_get_type(ShaderType(i),n->connections[k].id)==NODE_INPUT) { + inputs_used.insert(iname); + } + } - String iname="nd"+itos(n->connections[k].id)+"sl"+itos(n->connections[k].slot); inputs.push_back(iname); - if (node_get_type(ShaderType(i),n->connections[k].id)==NODE_INPUT) { - inputs_used.insert(iname); - } - } if (failed) @@ -2065,6 +2065,31 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectortype,slot)])+" "+("nd"+itos(id)+"sl"+itos(slot))) #define OUTVAR(id,slot) ("nd"+itos(id)+"sl"+itos(slot)) +#define DEF_VEC(slot)\ + if (p_inputs[slot].ends_with("def")){\ + Vector3 v = p_node->defaults[slot];\ + code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+v+");\n";\ + } +#define DEF_SCALAR(slot)\ + if (p_inputs[slot].ends_with("def")){\ + double v = p_node->defaults[slot];\ + code+=String(typestr[0])+" "+p_inputs[slot]+"="+rtos(v)+";\n";\ + } +#define DEF_COLOR(slot)\ + if (p_inputs[slot].ends_with("def")){\ + Color col = p_node->defaults[slot];\ + code+=String(typestr[1])+" "+p_inputs[slot]+"=vec3("+rtos(col.r)+","+rtos(col.g)+","+rtos(col.b)+");\n";\ + } +#define DEF_MATRIX(slot) \ + if (p_inputs[slot].ends_with("def")){\ + Transform xf = p_node->defaults[slot]; \ + code+=String(typestr[3])+" "+p_inputs[slot]+"=mat4(\n";\ + code+="\tvec4(vec3("+rtos(xf.basis.get_axis(0).x)+","+rtos(xf.basis.get_axis(0).y)+","+rtos(xf.basis.get_axis(0).z)+"),0),\n";\ + code+="\tvec4(vec3("+rtos(xf.basis.get_axis(1).x)+","+rtos(xf.basis.get_axis(1).y)+","+rtos(xf.basis.get_axis(1).z)+"),0),\n";\ + code+="\tvec4(vec3("+rtos(xf.basis.get_axis(2).x)+","+rtos(xf.basis.get_axis(2).y)+","+rtos(xf.basis.get_axis(2).z)+"),0),\n";\ + code+="\tvec4(vec3("+rtos(xf.origin.x)+","+rtos(xf.origin.y)+","+rtos(xf.origin.z)+"),1)\n";\ + code+=");\n";\ + } switch(p_node->type) { @@ -2101,9 +2126,12 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,0)+"=TIME;\n"; }break; case NODE_SCREEN_TEX: { + DEF_VEC(0); code+=OUTNAME(p_node->id,0)+"=texscreen("+p_inputs[0]+".xy);\n"; }break; case NODE_SCALAR_OP: { + DEF_SCALAR(0); + DEF_SCALAR(1); int op = p_node->param1; String optxt; switch(op) { @@ -2123,6 +2151,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; String optxt; switch(op) { @@ -2140,6 +2170,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; String optxt; switch(op) { @@ -2151,6 +2183,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; static const char*axisn[3]={"x","y","z"}; @@ -2162,7 +2196,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n"; - + print_line(OUTNAME(p_node->id,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n"); } break; case RGB_OP_DARKEN: { @@ -2233,11 +2267,15 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,0)+"="+p_inputs[0]+"*"+p_inputs[1]+";\n"; }break; case NODE_XFORM_VEC_MULT: { + DEF_MATRIX(0); + DEF_VEC(1); bool no_translation = p_node->param1; if (no_translation) { @@ -2248,6 +2286,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; if (no_translation) { code += OUTNAME(p_node->id,0)+"=("+p_inputs[1]+"*vec4("+p_inputs[0]+",0)).xyz;\n"; @@ -2256,6 +2296,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,0)+"=length("+p_inputs[0]+");\n"; }break; case NODE_DOT_PROD: { + DEF_VEC(0); + DEF_VEC(1); code += OUTNAME(p_node->id,0)+"=dot("+p_inputs[1]+","+p_inputs[0]+");\n"; }break; case NODE_VEC_TO_SCALAR: { + DEF_VEC(0); code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n"; code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n"; code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n"; }break; case NODE_SCALAR_TO_VEC: { + DEF_SCALAR(0); + DEF_SCALAR(1); + DEF_SCALAR(2); code += OUTNAME(p_node->id,0)+"=vec3("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+""+");\n"; }break; case NODE_VEC_TO_XFORM: { + DEF_VEC(0); + DEF_VEC(1); + DEF_VEC(2); + DEF_VEC(3); code += OUTNAME(p_node->id,0)+"=xform("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+","+","+p_inputs[3]+");\n"; }break; case NODE_XFORM_TO_VEC: { + DEF_MATRIX(0); code += OUTNAME(p_node->id,0)+"="+p_inputs[0]+".x;\n"; code += OUTNAME(p_node->id,1)+"="+p_inputs[0]+".y;\n"; code += OUTNAME(p_node->id,2)+"="+p_inputs[0]+".z;\n"; code += OUTNAME(p_node->id,3)+"="+p_inputs[0]+".o;\n"; }break; case NODE_SCALAR_INTERP: { + DEF_SCALAR(0); + DEF_SCALAR(1); + DEF_SCALAR(2); code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n"; }break; case NODE_VEC_INTERP: { + DEF_VEC(0); + DEF_VEC(1); + DEF_SCALAR(2); code += OUTNAME(p_node->id,0)+"=mix("+p_inputs[0]+","+p_inputs[1]+","+p_inputs[2]+");\n"; }break; case NODE_COLOR_RAMP: { + DEF_SCALAR(0); static const int color_ramp_len=512; DVector cramp; @@ -2416,6 +2477,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; float dv=p_node->param2; code +="uniform float "+name+"="+rtos(dv)+";\n"; @@ -2520,6 +2585,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; String rname="rt_read_tex"+itos(p_node->id); code +="uniform texture "+name+";"; @@ -2529,7 +2595,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; code +="uniform cubemap "+name+";"; String rname="rt_read_tex"+itos(p_node->id); @@ -2538,6 +2604,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,1)+"="+rname+".a;\n"; }break; case NODE_DEFAULT_TEXTURE: { + DEF_VEC(0); if (get_mode()==MODE_CANVAS_ITEM && p_type==SHADER_TYPE_FRAGMENT) { -- cgit v1.2.3 From 25324aa5061b07df6da877e94c8c23fbe7f34f6e Mon Sep 17 00:00:00 2001 From: MarianoGNU Date: Sat, 17 Oct 2015 15:27:36 -0300 Subject: Fix crash when using a Scalar Uniform node to GraphShader --- scene/resources/shader_graph.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scene/resources') diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp index 4604c42de1..49a1bdccb1 100644 --- a/scene/resources/shader_graph.cpp +++ b/scene/resources/shader_graph.cpp @@ -2196,7 +2196,6 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorid,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n"; - print_line(OUTNAME(p_node->id,0)+"=abs("+p_inputs[0]+"-"+p_inputs[1]+");\n"); } break; case RGB_OP_DARKEN: { @@ -2545,9 +2544,6 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vectorparam1; float dv=p_node->param2; code +="uniform float "+name+"="+rtos(dv)+";\n"; @@ -2631,4 +2627,8 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector