summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/io/packet_peer.cpp30
-rw-r--r--core/io/packet_peer.h4
-rw-r--r--core/script_debugger_remote.cpp1
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp2
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h1
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp2
-rw-r--r--drivers/gles3/shaders/scene.glsl10
-rw-r--r--editor/plugins/canvas_item_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp22
-rw-r--r--editor/script_editor_debugger.cpp1
-rw-r--r--modules/gdscript/gd_parser.cpp7
-rw-r--r--modules/visual_script/visual_script.cpp8
-rw-r--r--modules/visual_script/visual_script_editor.cpp16
-rw-r--r--modules/visual_script/visual_script_nodes.cpp49
-rw-r--r--modules/visual_script/visual_script_nodes.h10
-rw-r--r--scene/3d/sprite_3d.cpp5
-rw-r--r--scene/gui/graph_edit.cpp16
-rw-r--r--scene/gui/graph_node.cpp3
-rw-r--r--scene/gui/graph_node.h4
-rw-r--r--scene/resources/material.cpp90
-rw-r--r--scene/resources/material.h16
-rw-r--r--servers/visual/shader_types.cpp1
-rw-r--r--servers/visual_server.cpp36
-rw-r--r--servers/visual_server.h3
25 files changed, 243 insertions, 100 deletions
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index a3d33593dd..40082cc481 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -139,6 +139,8 @@ void PacketPeerStream::_set_stream_peer(REF p_peer) {
void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer:StreamPeer"), &PacketPeerStream::_set_stream_peer);
+ ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
}
Error PacketPeerStream::_poll_buffer() const {
@@ -146,13 +148,13 @@ Error PacketPeerStream::_poll_buffer() const {
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
int read = 0;
- Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read);
+ Error err = peer->get_partial_data(&input_buffer[0], ring_buffer.space_left(), read);
if (err)
return err;
if (read == 0)
return OK;
- int w = ring_buffer.write(&temp_buffer[0], read);
+ int w = ring_buffer.write(&input_buffer[0], read);
ERR_FAIL_COND_V(w != read, ERR_BUG);
return OK;
@@ -198,9 +200,9 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size)
ERR_FAIL_COND_V(remaining < (int)len, ERR_UNAVAILABLE);
ring_buffer.read(lbuf, 4); //get rid of first 4 bytes
- ring_buffer.read(&temp_buffer[0], len); // read packet
+ ring_buffer.read(&input_buffer[0], len); // read packet
- *r_buffer = &temp_buffer[0];
+ *r_buffer = &input_buffer[0];
r_buffer_size = len;
return OK;
}
@@ -217,19 +219,19 @@ Error PacketPeerStream::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
return OK;
ERR_FAIL_COND_V(p_buffer_size < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_buffer_size + 4 > temp_buffer.size(), ERR_INVALID_PARAMETER);
+ ERR_FAIL_COND_V(p_buffer_size + 4 > output_buffer.size(), ERR_INVALID_PARAMETER);
- encode_uint32(p_buffer_size, &temp_buffer[0]);
- uint8_t *dst = &temp_buffer[4];
+ encode_uint32(p_buffer_size, &output_buffer[0]);
+ uint8_t *dst = &output_buffer[4];
for (int i = 0; i < p_buffer_size; i++)
dst[i] = p_buffer[i];
- return peer->put_data(&temp_buffer[0], p_buffer_size + 4);
+ return peer->put_data(&output_buffer[0], p_buffer_size + 4);
}
int PacketPeerStream::get_max_packet_size() const {
- return temp_buffer.size();
+ return output_buffer.size();
}
void PacketPeerStream::set_stream_peer(const Ref<StreamPeer> &p_peer) {
@@ -249,7 +251,12 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4));
- temp_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ input_buffer.resize(nearest_power_of_2(p_max_size + 4));
+}
+
+void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
+
+ output_buffer.resize(nearest_power_of_2(p_max_size + 4));
}
PacketPeerStream::PacketPeerStream() {
@@ -257,5 +264,6 @@ PacketPeerStream::PacketPeerStream() {
int rbsize = GLOBAL_GET("network/limits/packet_peer_stream/max_buffer_po2");
ring_buffer.resize(rbsize);
- temp_buffer.resize(1 << rbsize);
+ input_buffer.resize(1 << rbsize);
+ output_buffer.resize(1 << rbsize);
}
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 95806aa511..ed6b252d80 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -75,7 +75,8 @@ class PacketPeerStream : public PacketPeer {
mutable Ref<StreamPeer> peer;
mutable RingBuffer<uint8_t> ring_buffer;
- mutable Vector<uint8_t> temp_buffer;
+ mutable Vector<uint8_t> input_buffer;
+ mutable Vector<uint8_t> output_buffer;
Error _poll_buffer() const;
@@ -92,6 +93,7 @@ public:
void set_stream_peer(const Ref<StreamPeer> &p_peer);
void set_input_buffer_max_size(int p_max_size);
+ void set_output_buffer_max_size(int p_max_size);
PacketPeerStream();
};
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index fdde08bb32..6f12338f66 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -945,6 +945,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
tcp_client = StreamPeerTCP::create_ref();
packet_peer_stream = Ref<PacketPeerStream>(memnew(PacketPeerStream));
packet_peer_stream->set_stream_peer(tcp_client);
+ packet_peer_stream->set_output_buffer_max_size(1024 * 1024 * 8); //8mb should be way more than enough
mutex = Mutex::create();
locking = false;
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 9dd5b32f41..30a77c4b39 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -2182,7 +2182,7 @@ void RasterizerSceneGLES3::_add_geometry(RasterizerStorageGLES3::Geometry *p_geo
void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *m, bool p_shadow) {
- bool has_base_alpha = (m->shader->spatial.uses_alpha || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded);
+ bool has_base_alpha = (m->shader->spatial.uses_alpha && !m->shader->spatial.uses_alpha_scissor) || m->shader->spatial.uses_screen_texture || m->shader->spatial.unshaded;
bool has_blend_alpha = m->shader->spatial.blend_mode != RasterizerStorageGLES3::Shader::Spatial::BLEND_MODE_MIX || m->shader->spatial.ontop;
bool has_alpha = has_base_alpha || has_blend_alpha;
bool shadow = false;
@@ -2206,7 +2206,7 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
if (has_blend_alpha || (has_base_alpha && m->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS))
return; //bye
- if (!m->shader->spatial.writes_modelview_or_projection && !m->shader->spatial.uses_vertex && !m->shader->spatial.uses_discard && m->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
+ if (!m->shader->spatial.uses_alpha_scissor && !m->shader->spatial.writes_modelview_or_projection && !m->shader->spatial.uses_vertex && !m->shader->spatial.uses_discard && m->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//shader does not use discard and does not write a vertex position, use generic material
if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED)
m = storage->material_owner.getptr(default_material_twosided);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index f7ecc3b158..a8e4bc0d4b 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -1596,6 +1596,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
p_shader->spatial.depth_draw_mode = Shader::Spatial::DEPTH_DRAW_OPAQUE;
p_shader->spatial.cull_mode = Shader::Spatial::CULL_MODE_BACK;
p_shader->spatial.uses_alpha = false;
+ p_shader->spatial.uses_alpha_scissor = false;
p_shader->spatial.uses_discard = false;
p_shader->spatial.unshaded = false;
p_shader->spatial.ontop = false;
@@ -1625,6 +1626,7 @@ void RasterizerStorageGLES3::_update_shader(Shader *p_shader) const {
shaders.actions_scene.render_mode_flags["vertex_lighting"] = &p_shader->spatial.uses_vertex_lighting;
shaders.actions_scene.usage_flag_pointers["ALPHA"] = &p_shader->spatial.uses_alpha;
+ shaders.actions_scene.usage_flag_pointers["ALPHA_SCISSOR"] = &p_shader->spatial.uses_alpha_scissor;
shaders.actions_scene.usage_flag_pointers["VERTEX"] = &p_shader->spatial.uses_vertex;
shaders.actions_scene.usage_flag_pointers["SSS_STRENGTH"] = &p_shader->spatial.uses_sss;
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index b536c9841c..5a272f43fb 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -442,6 +442,7 @@ public:
int cull_mode;
bool uses_alpha;
+ bool uses_alpha_scissor;
bool unshaded;
bool ontop;
bool uses_vertex;
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index 206f270f68..c014caee8d 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -762,6 +762,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].renames["SCREEN_TEXTURE"] = "screen_texture";
actions[VS::SHADER_SPATIAL].renames["DEPTH_TEXTURE"] = "depth_buffer";
actions[VS::SHADER_SPATIAL].renames["SIDE"] = "side";
+ actions[VS::SHADER_SPATIAL].renames["ALPHA_SCISSOR"] = "alpha_scissor";
actions[VS::SHADER_SPATIAL].usage_defines["TANGENT"] = "#define ENABLE_TANGENT_INTERP\n";
actions[VS::SHADER_SPATIAL].usage_defines["BINORMAL"] = "@TANGENT";
@@ -778,6 +779,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].usage_defines["NORMALMAP_DEPTH"] = "@NORMALMAP";
actions[VS::SHADER_SPATIAL].usage_defines["COLOR"] = "#define ENABLE_COLOR_INTERP\n";
actions[VS::SHADER_SPATIAL].usage_defines["INSTANCE_CUSTOM"] = "#define ENABLE_INSTANCE_CUSTOM\n";
+ actions[VS::SHADER_SPATIAL].usage_defines["ALPHA_SCISSOR"] = "#define ALPHA_SCISSOR_USED\n";
actions[VS::SHADER_SPATIAL].usage_defines["SSS_STRENGTH"] = "#define ENABLE_SSS\n";
actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl
index efb82441f4..3f0498746b 100644
--- a/drivers/gles3/shaders/scene.glsl
+++ b/drivers/gles3/shaders/scene.glsl
@@ -1523,6 +1523,10 @@ void main() {
#endif
+#if defined(ALPHA_SCISSOR_USED)
+ float alpha_scissor = 0.5;
+#endif
+
#if defined(ENABLE_TANGENT_INTERP) || defined(ENABLE_NORMALMAP) || defined(LIGHT_USE_ANISOTROPY)
vec3 binormal = normalize(binormal_interp)*side;
vec3 tangent = normalize(tangent_interp)*side;
@@ -1571,6 +1575,12 @@ FRAGMENT_SHADER_CODE
}
+#if defined(ALPHA_SCISSOR_USED)
+ if (alpha<alpha_scissor) {
+ discard;
+ }
+#endif
+
#if defined(ENABLE_NORMALMAP)
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp
index a10a367db8..ac6d78adc2 100644
--- a/editor/plugins/canvas_item_editor_plugin.cpp
+++ b/editor/plugins/canvas_item_editor_plugin.cpp
@@ -375,6 +375,8 @@ void CanvasItemEditor::set_state(const Dictionary &p_state) {
int idx = skeleton_menu->get_item_index(SKELETON_SHOW_BONES);
skeleton_menu->set_item_checked(idx, skeleton_show_bones);
}
+
+ viewport->update();
}
void CanvasItemEditor::_add_canvas_item(CanvasItem *p_canvas_item) {
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index e7bc8a4dab..a52a875338 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -1451,6 +1451,11 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
ED_SHORTCUT("tile_map_editor/mirror_x", TTR("Mirror X"), KEY_A);
ED_SHORTCUT("tile_map_editor/mirror_y", TTR("Mirror Y"), KEY_S);
+ HBoxContainer *tool_hb1 = memnew(HBoxContainer);
+ add_child(tool_hb1);
+ HBoxContainer *tool_hb2 = memnew(HBoxContainer);
+ add_child(tool_hb2);
+
search_box = memnew(LineEdit);
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
search_box->connect("text_entered", this, "_text_entered");
@@ -1514,47 +1519,44 @@ TileMapEditor::TileMapEditor(EditorNode *p_editor) {
transp->set_tooltip(TTR("Transpose") + " (" + ED_GET_SHORTCUT("tile_map_editor/transpose")->get_as_text() + ")");
transp->set_focus_mode(FOCUS_NONE);
transp->connect("pressed", this, "_update_transform_buttons", make_binds(transp));
- toolbar->add_child(transp);
+ tool_hb1->add_child(transp);
mirror_x = memnew(ToolButton);
mirror_x->set_toggle_mode(true);
mirror_x->set_tooltip(TTR("Mirror X") + " (" + ED_GET_SHORTCUT("tile_map_editor/mirror_x")->get_as_text() + ")");
mirror_x->set_focus_mode(FOCUS_NONE);
mirror_x->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_x));
- toolbar->add_child(mirror_x);
+ tool_hb1->add_child(mirror_x);
mirror_y = memnew(ToolButton);
mirror_y->set_toggle_mode(true);
mirror_y->set_tooltip(TTR("Mirror Y") + " (" + ED_GET_SHORTCUT("tile_map_editor/mirror_y")->get_as_text() + ")");
mirror_y->set_focus_mode(FOCUS_NONE);
mirror_y->connect("pressed", this, "_update_transform_buttons", make_binds(mirror_y));
- toolbar->add_child(mirror_y);
-
- toolbar->add_child(memnew(VSeparator));
+ tool_hb1->add_child(mirror_y);
rotate_0 = memnew(ToolButton);
rotate_0->set_toggle_mode(true);
rotate_0->set_tooltip(TTR("Rotate 0 degrees"));
rotate_0->set_focus_mode(FOCUS_NONE);
rotate_0->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_0));
- toolbar->add_child(rotate_0);
+ tool_hb2->add_child(rotate_0);
rotate_90 = memnew(ToolButton);
rotate_90->set_toggle_mode(true);
rotate_90->set_tooltip(TTR("Rotate 90 degrees"));
rotate_90->set_focus_mode(FOCUS_NONE);
rotate_90->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_90));
- toolbar->add_child(rotate_90);
+ tool_hb2->add_child(rotate_90);
rotate_180 = memnew(ToolButton);
rotate_180->set_toggle_mode(true);
rotate_180->set_tooltip(TTR("Rotate 180 degrees"));
rotate_180->set_focus_mode(FOCUS_NONE);
rotate_180->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_180));
- toolbar->add_child(rotate_180);
+ tool_hb2->add_child(rotate_180);
rotate_270 = memnew(ToolButton);
rotate_270->set_toggle_mode(true);
rotate_270->set_tooltip(TTR("Rotate 270 degrees"));
rotate_270->set_focus_mode(FOCUS_NONE);
rotate_270->connect("pressed", this, "_update_transform_buttons", make_binds(rotate_270));
- toolbar->add_child(rotate_270);
- toolbar->hide();
+ tool_hb2->add_child(rotate_270);
rotate_0->set_pressed(true);
}
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index f4ed430d3d..45d2e54838 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -1595,6 +1595,7 @@ void ScriptEditorDebugger::_bind_methods() {
ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream));
+ ppeer->set_input_buffer_max_size(1024 * 1024 * 8); //8mb should be enough
editor = p_editor;
tabs = memnew(TabContainer);
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 36aa249398..9023fd4bf4 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -2369,8 +2369,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
check_block = check_block->parent_block;
}
- p_block->variables.push_back(n); //line?
- p_block->variable_lines.push_back(tokenizer->get_token_line());
+ int var_line = tokenizer->get_token_line();
//must know when the local variable is declared
LocalVarNode *lv = alloc_node<LocalVarNode>();
@@ -2400,6 +2399,10 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
c->value = Variant();
assigned = c;
}
+ //must be added later, to avoid self-referencing.
+ p_block->variables.push_back(n); //line?
+ p_block->variable_lines.push_back(var_line);
+
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = n;
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 376329715b..7a368fbace 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1058,6 +1058,10 @@ MethodInfo VisualScript::get_method_info(const StringName &p_method) const {
arg.type = func->get_argument_type(i);
mi.arguments.push_back(arg);
}
+
+ if (!func->is_sequenced()) {
+ mi.flags |= METHOD_FLAG_CONST;
+ }
}
}
@@ -1401,6 +1405,10 @@ void VisualScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
mi.arguments.push_back(arg);
}
+ if (!vsf->is_sequenced()) { //assumed constant if not sequenced
+ mi.flags |= METHOD_FLAG_CONST;
+ }
+
//vsf->Get_ for now at least it does not return..
}
}
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index a71d38f7a0..8912227692 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -869,15 +869,27 @@ void VisualScriptEditor::_member_edited() {
}
selected = new_name;
- _update_graph();
-
+ int node_id = script->get_function_node_id(name);
+ Ref<VisualScriptFunction> func;
+ if (script->has_node(name, node_id)) {
+ func = script->get_node(name, node_id);
+ }
undo_redo->create_action(TTR("Rename Function"));
undo_redo->add_do_method(script.ptr(), "rename_function", name, new_name);
undo_redo->add_undo_method(script.ptr(), "rename_function", new_name, name);
+ if (func.is_valid()) {
+
+ undo_redo->add_do_method(func.ptr(), "set_name", new_name);
+ undo_redo->add_undo_method(func.ptr(), "set_name", name);
+ }
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "_update_graph");
+ undo_redo->add_undo_method(this, "_update_graph");
undo_redo->commit_action();
+ // _update_graph();
+
return; //or crash because it will become invalid
}
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index d5d8b8fe6e..4fefa01584 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -95,6 +95,12 @@ bool VisualScriptFunction::_set(const StringName &p_name, const Variant &p_value
return true;
}
+ if (p_name == "sequenced/sequenced") {
+ sequenced = p_value;
+ ports_changed_notify();
+ return true;
+ }
+
return false;
}
@@ -133,6 +139,11 @@ bool VisualScriptFunction::_get(const StringName &p_name, Variant &r_ret) const
return true;
}
+ if (p_name == "sequenced/sequenced") {
+ r_ret = sequenced;
+ return true;
+ }
+
return false;
}
void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const {
@@ -147,6 +158,9 @@ void VisualScriptFunction::_get_property_list(List<PropertyInfo> *p_list) const
p_list->push_back(PropertyInfo(Variant::INT, "argument_" + itos(i + 1) + "/type", PROPERTY_HINT_ENUM, argt));
p_list->push_back(PropertyInfo(Variant::STRING, "argument_" + itos(i + 1) + "/name"));
}
+
+ p_list->push_back(PropertyInfo(Variant::BOOL, "sequenced/sequenced"));
+
if (!stack_less) {
p_list->push_back(PropertyInfo(Variant::INT, "stack/size", PROPERTY_HINT_RANGE, "1,100000"));
}
@@ -302,6 +316,7 @@ VisualScriptFunction::VisualScriptFunction() {
stack_size = 256;
stack_less = false;
+ sequenced = true;
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
}
@@ -314,6 +329,16 @@ bool VisualScriptFunction::is_stack_less() const {
return stack_less;
}
+void VisualScriptFunction::set_sequenced(bool p_enable) {
+
+ sequenced = p_enable;
+}
+
+bool VisualScriptFunction::is_sequenced() const {
+
+ return sequenced;
+}
+
void VisualScriptFunction::set_stack_size(int p_size) {
ERR_FAIL_COND(p_size < 1 || p_size > 100000);
@@ -1467,7 +1492,7 @@ void VisualScriptGlobalConstant::_bind_methods() {
cc += ",";
cc += GlobalConstants::get_global_constant_name(i);
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_global_constant", "get_global_constant");
}
VisualScriptGlobalConstant::VisualScriptGlobalConstant() {
@@ -1572,7 +1597,7 @@ VisualScriptNodeInstance *VisualScriptClassConstant::instance(VisualScriptInstan
void VisualScriptClassConstant::_validate_property(PropertyInfo &property) const {
- if (property.name == "constant") {
+ if (property.name == "constant/constant") {
List<String> constants;
ClassDB::get_integer_constant_list(base_type, &constants, true);
@@ -1596,7 +1621,7 @@ void VisualScriptClassConstant::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_base_type"), &VisualScriptClassConstant::get_base_type);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_type", PROPERTY_HINT_TYPE_STRING, "Object"), "set_base_type", "get_base_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_class_constant", "get_class_constant");
}
VisualScriptClassConstant::VisualScriptClassConstant() {
@@ -1701,7 +1726,7 @@ VisualScriptNodeInstance *VisualScriptBasicTypeConstant::instance(VisualScriptIn
void VisualScriptBasicTypeConstant::_validate_property(PropertyInfo &property) const {
- if (property.name == "constant") {
+ if (property.name == "constant/constant") {
List<StringName> constants;
Variant::get_numeric_constants_for_type(type, &constants);
@@ -1734,7 +1759,7 @@ void VisualScriptBasicTypeConstant::_bind_methods() {
}
ADD_PROPERTY(PropertyInfo(Variant::INT, "basic_type", PROPERTY_HINT_ENUM, argt), "set_basic_type", "get_basic_type");
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, ""), "set_basic_type_constant", "get_basic_type_constant");
}
VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() {
@@ -1855,7 +1880,7 @@ void VisualScriptMathConstant::_bind_methods() {
cc += ",";
cc += const_name[i];
}
- ADD_PROPERTY(PropertyInfo(Variant::INT, "constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_math_constant", "get_math_constant");
}
VisualScriptMathConstant::VisualScriptMathConstant() {
@@ -1976,7 +2001,7 @@ void VisualScriptEngineSingleton::_bind_methods() {
cc += E->get().name;
}
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton");
+ ADD_PROPERTY(PropertyInfo(Variant::STRING, "constant/constant", PROPERTY_HINT_ENUM, cc), "set_singleton", "get_singleton");
}
VisualScriptEngineSingleton::VisualScriptEngineSingleton() {
@@ -3702,11 +3727,11 @@ void register_visual_script_nodes() {
VisualScriptLanguage::singleton->add_register_func("data/preload", create_node_generic<VisualScriptPreload>);
VisualScriptLanguage::singleton->add_register_func("data/action", create_node_generic<VisualScriptInputAction>);
- VisualScriptLanguage::singleton->add_register_func("constants/constant", create_node_generic<VisualScriptConstant>);
- VisualScriptLanguage::singleton->add_register_func("constants/math_constant", create_node_generic<VisualScriptMathConstant>);
- VisualScriptLanguage::singleton->add_register_func("constants/class_constant", create_node_generic<VisualScriptClassConstant>);
- VisualScriptLanguage::singleton->add_register_func("constants/global_constant", create_node_generic<VisualScriptGlobalConstant>);
- VisualScriptLanguage::singleton->add_register_func("constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>);
+ VisualScriptLanguage::singleton->add_register_func("constant/constants/constant", create_node_generic<VisualScriptConstant>);
+ VisualScriptLanguage::singleton->add_register_func("constant/constants/math_constant", create_node_generic<VisualScriptMathConstant>);
+ VisualScriptLanguage::singleton->add_register_func("constant/constants/class_constant", create_node_generic<VisualScriptClassConstant>);
+ VisualScriptLanguage::singleton->add_register_func("constant/constants/global_constant", create_node_generic<VisualScriptGlobalConstant>);
+ VisualScriptLanguage::singleton->add_register_func("constant/constants/basic_type_constant", create_node_generic<VisualScriptBasicTypeConstant>);
VisualScriptLanguage::singleton->add_register_func("custom/custom_node", create_node_generic<VisualScriptCustomNode>);
VisualScriptLanguage::singleton->add_register_func("custom/sub_call", create_node_generic<VisualScriptSubCall>);
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 7a3b26fe55..ff49417114 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -46,6 +46,7 @@ class VisualScriptFunction : public VisualScriptNode {
bool stack_less;
int stack_size;
ScriptInstance::RPCMode rpc_mode;
+ bool sequenced;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -79,9 +80,18 @@ public:
void set_stack_less(bool p_enable);
bool is_stack_less() const;
+ void set_sequenced(bool p_enable);
+ bool is_sequenced() const;
+
void set_stack_size(int p_size);
int get_stack_size() const;
+ void set_return_type_enabled(bool p_returns);
+ bool is_return_type_enabled() const;
+
+ void set_return_type(Variant::Type p_type);
+ Variant::Type get_return_type() const;
+
void set_rpc_mode(ScriptInstance::RPCMode p_mode);
ScriptInstance::RPCMode get_rpc_mode() const;
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 1b9b58ceb1..b4e045e43f 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -389,7 +389,7 @@ void Sprite3D::_draw() {
int axis = get_axis();
normal[axis] = 1.0;
- RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
+ RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
VS::get_singleton()->immediate_set_material(immediate, mat);
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
@@ -892,7 +892,8 @@ void AnimatedSprite3D::_draw() {
int axis = get_axis();
normal[axis] = 1.0;
- RID mat = VS::get_singleton()->material_2d_get(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
+ RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS);
+
VS::get_singleton()->immediate_set_material(immediate, mat);
VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLE_FAN, texture->get_rid());
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 11f750ea70..32725ebb8c 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -207,9 +207,10 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
GraphNode *gn = p_gn->cast_to<GraphNode>();
ERR_FAIL_COND(!gn);
- gn->raise();
if (gn->is_comment()) {
move_child(gn, 0);
+ } else {
+ gn->raise();
}
int first_not_comment = 0;
for (int i = 0; i < get_child_count(); i++) {
@@ -870,21 +871,19 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
if (b->get_button_index() == BUTTON_LEFT && b->is_pressed()) {
GraphNode *gn = NULL;
- GraphNode *gn_selected = NULL;
+
for (int i = get_child_count() - 1; i >= 0; i--) {
- gn_selected = get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn_selected = get_child(i)->cast_to<GraphNode>();
if (gn_selected) {
-
if (gn_selected->is_resizing())
continue;
- Rect2 r = gn_selected->get_rect();
- r.size *= zoom;
- if (r.has_point(get_local_mouse_pos()))
+ if (gn_selected->has_point(gn_selected->get_local_mouse_pos())) {
gn = gn_selected;
- break;
+ break;
+ }
}
}
@@ -1225,6 +1224,7 @@ GraphEdit::GraphEdit() {
connections_layer->connect("draw", this, "_connections_layer_draw");
connections_layer->set_name("CLAYER");
connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offseted
+ connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE);
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index 538dd846e4..4f07d21f4d 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -176,6 +176,7 @@ bool GraphNode::has_point(const Point2 &p_point) const {
if (Rect2(get_size() - resizer->get_size(), resizer->get_size()).has_point(p_point)) {
return true;
}
+
if (Rect2(0, 0, get_size().width, comment->get_margin(MARGIN_TOP)).has_point(p_point)) {
return true;
}
@@ -719,7 +720,7 @@ GraphNode::GraphNode() {
overlay = OVERLAY_DISABLED;
show_close = false;
connpos_dirty = true;
- set_mouse_filter(MOUSE_FILTER_PASS);
+ set_mouse_filter(MOUSE_FILTER_STOP);
comment = false;
resizeable = false;
resizing = false;
diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h
index 056b699aa6..a7d9e8ddb0 100644
--- a/scene/gui/graph_node.h
+++ b/scene/gui/graph_node.h
@@ -99,8 +99,6 @@ private:
Overlay overlay;
- bool has_point(const Point2 &p_point) const;
-
protected:
void _gui_input(const Ref<InputEvent> &p_ev);
void _notification(int p_what);
@@ -111,6 +109,8 @@ protected:
void _get_property_list(List<PropertyInfo> *p_list) const;
public:
+ bool has_point(const Point2 &p_point) const;
+
void set_slot(int p_idx, bool p_enable_left, int p_type_left, const Color &p_color_left, bool p_enable_right, int p_type_right, const Color &p_color_right, const Ref<Texture> &p_custom_left = Ref<Texture>(), const Ref<Texture> &p_custom_right = Ref<Texture>());
void clear_slot(int p_idx);
void clear_all_slots();
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 5a79e49240..d869e72f53 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -241,6 +241,7 @@ void SpatialMaterial::init_shaders() {
shader_names->rim_texture_channel = "rim_texture_channel";
shader_names->depth_texture_channel = "depth_texture_channel";
shader_names->refraction_texture_channel = "refraction_texture_channel";
+ shader_names->alpha_scissor_threshold = "alpha_scissor_threshold";
shader_names->texture_names[TEXTURE_ALBEDO] = "texture_albedo";
shader_names->texture_names[TEXTURE_METALLIC] = "texture_metallic";
@@ -259,8 +260,14 @@ void SpatialMaterial::init_shaders() {
shader_names->texture_names[TEXTURE_DETAIL_NORMAL] = "texture_detail_normal";
}
+Ref<SpatialMaterial> SpatialMaterial::materials_for_2d[SpatialMaterial::MAX_MATERIALS_FOR_2D];
+
void SpatialMaterial::finish_shaders() {
+ for (int i = 0; i < MAX_MATERIALS_FOR_2D; i++) {
+ materials_for_2d[i].unref();
+ }
+
#ifndef NO_THREADS
memdelete(material_mutex);
#endif
@@ -359,6 +366,9 @@ void SpatialMaterial::_update_shader() {
code += "uniform float grow;\n";
}
+ if (flags[FLAG_USE_ALPHA_SCISSOR]) {
+ code += "uniform float alpha_scissor_threshold;\n";
+ }
code += "uniform float roughness : hint_range(0,1);\n";
code += "uniform float point_size : hint_range(0,128);\n";
code += "uniform sampler2D texture_metallic : hint_white;\n";
@@ -674,7 +684,7 @@ void SpatialMaterial::_update_shader() {
code += "\tALBEDO *= 1.0 - ref_amount;\n";
code += "\tALPHA = 1.0;\n";
- } else if (features[FEATURE_TRANSPARENT]) {
+ } else if (features[FEATURE_TRANSPARENT] || features[FLAG_USE_ALPHA_SCISSOR]) {
code += "\tALPHA = albedo.a * albedo_tex.a;\n";
}
@@ -774,6 +784,10 @@ void SpatialMaterial::_update_shader() {
code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
code += "\tNORMALMAP = mix(NORMALMAP,detail_norm,detail_mask_tex.r);\n";
code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n";
+
+ if (flags[FLAG_USE_ALPHA_SCISSOR]) {
+ code += "\tALPHA_SCISSOR=alpha_scissor_threshold;\n";
+ }
}
code += "}\n";
@@ -1086,6 +1100,9 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) {
return;
flags[p_flag] = p_enabled;
+ if (p_flag == FLAG_USE_ALPHA_SCISSOR) {
+ _change_notify();
+ }
_queue_shader_change();
}
@@ -1130,9 +1147,6 @@ void SpatialMaterial::_validate_feature(const String &text, Feature feature, Pro
if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) {
property.usage = 0;
}
- if ((property.name == "depth_min_layers" || property.name == "depth_max_layers") && !deep_parallax) {
- property.usage = 0;
- }
}
void SpatialMaterial::_validate_property(PropertyInfo &property) const {
@@ -1154,6 +1168,14 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
if (property.name == "params_grow_amount" && !grow_enabled) {
property.usage = 0;
}
+
+ if (property.name == "params_alpha_scissor_threshold" && !flags[FLAG_USE_ALPHA_SCISSOR]) {
+ property.usage = 0;
+ }
+
+ if ((property.name == "depth_min_layers" || property.name == "depth_max_layers") && !deep_parallax) {
+ property.usage = 0;
+ }
}
void SpatialMaterial::set_line_width(float p_line_width) {
@@ -1329,6 +1351,16 @@ bool SpatialMaterial::is_grow_enabled() const {
return grow_enabled;
}
+void SpatialMaterial::set_alpha_scissor_threshold(float p_treshold) {
+ alpha_scissor_threshold = p_treshold;
+ VS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_treshold);
+}
+
+float SpatialMaterial::get_alpha_scissor_threshold() const {
+
+ return alpha_scissor_threshold;
+}
+
void SpatialMaterial::set_grow(float p_grow) {
grow = p_grow;
VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
@@ -1391,6 +1423,40 @@ SpatialMaterial::TextureChannel SpatialMaterial::get_refraction_texture_channel(
return refraction_texture_channel;
}
+RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass) {
+
+ int version = 0;
+ if (p_shaded)
+ version = 1;
+ if (p_transparent)
+ version |= 2;
+ if (p_cut_alpha)
+ version |= 4;
+ if (p_opaque_prepass)
+ version |= 8;
+ if (p_double_sided)
+ version |= 16;
+
+ if (materials_for_2d[version].is_valid()) {
+ return materials_for_2d[version]->get_rid();
+ }
+
+ Ref<SpatialMaterial> material;
+ material.instance();
+
+ material->set_flag(FLAG_UNSHADED, !p_shaded);
+ material->set_feature(FEATURE_TRANSPARENT, p_transparent);
+ material->set_cull_mode(p_double_sided ? CULL_DISABLED : CULL_BACK);
+ material->set_depth_draw_mode(p_opaque_prepass ? DEPTH_DRAW_ALPHA_OPAQUE_PREPASS : DEPTH_DRAW_OPAQUE_ONLY);
+ material->set_flag(FLAG_SRGB_VERTEX_COLOR, true);
+ material->set_flag(FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
+ material->set_flag(FLAG_USE_ALPHA_SCISSOR, p_cut_alpha);
+
+ materials_for_2d[version] = material;
+
+ return materials_for_2d[version]->get_rid();
+}
+
void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo);
@@ -1516,6 +1582,9 @@ void SpatialMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow);
ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow);
+ ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &SpatialMaterial::set_alpha_scissor_threshold);
+ ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &SpatialMaterial::get_alpha_scissor_threshold);
+
ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled);
ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled);
@@ -1553,6 +1622,8 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,10,0.01"), "set_grow", "get_grow");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "params_use_alpha_scissor"), "set_flag", "get_flag", FLAG_USE_ALPHA_SCISSOR);
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_alpha_scissor_threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_scissor_threshold", "get_alpha_scissor_threshold");
ADD_GROUP("Particles Anim", "particles_anim_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames");
ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames");
@@ -1697,9 +1768,13 @@ void SpatialMaterial::_bind_methods() {
BIND_CONSTANT(FLAG_USE_VERTEX_LIGHTING);
BIND_CONSTANT(FLAG_ONTOP);
BIND_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR);
- BIND_CONSTANT(FLAG_SRGB_VERTEX_COLOR)
- BIND_CONSTANT(FLAG_USE_POINT_SIZE)
- BIND_CONSTANT(FLAG_FIXED_SIZE)
+ BIND_CONSTANT(FLAG_SRGB_VERTEX_COLOR);
+ BIND_CONSTANT(FLAG_USE_POINT_SIZE);
+ BIND_CONSTANT(FLAG_FIXED_SIZE);
+ BIND_CONSTANT(FLAG_UV1_USE_TRIPLANAR);
+ BIND_CONSTANT(FLAG_UV2_USE_TRIPLANAR);
+ BIND_CONSTANT(FLAG_AO_ON_UV2);
+ BIND_CONSTANT(FLAG_USE_ALPHA_SCISSOR);
BIND_CONSTANT(FLAG_MAX);
BIND_CONSTANT(DIFFUSE_LAMBERT);
@@ -1757,6 +1832,7 @@ SpatialMaterial::SpatialMaterial()
set_particles_anim_h_frames(1);
set_particles_anim_v_frames(1);
set_particles_anim_loop(false);
+ set_alpha_scissor_threshold(0.98);
set_metallic_texture_channel(TEXTURE_CHANNEL_RED);
set_roughness_texture_channel(TEXTURE_CHANNEL_RED);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 1484b79fc6..25628e272a 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -164,6 +164,7 @@ public:
FLAG_UV1_USE_TRIPLANAR,
FLAG_UV2_USE_TRIPLANAR,
FLAG_AO_ON_UV2,
+ FLAG_USE_ALPHA_SCISSOR,
FLAG_MAX
};
@@ -207,7 +208,7 @@ private:
uint64_t blend_mode : 2;
uint64_t depth_draw_mode : 2;
uint64_t cull_mode : 2;
- uint64_t flags : 9;
+ uint64_t flags : 11;
uint64_t detail_blend_mode : 2;
uint64_t diffuse_mode : 3;
uint64_t specular_mode : 2;
@@ -298,6 +299,7 @@ private:
StringName rim_texture_channel;
StringName depth_texture_channel;
StringName refraction_texture_channel;
+ StringName alpha_scissor_threshold;
StringName texture_names[TEXTURE_MAX];
};
@@ -329,6 +331,7 @@ private:
float refraction;
float line_width;
float point_size;
+ float alpha_scissor_threshold;
bool grow_enabled;
float grow;
int particles_anim_h_frames;
@@ -369,6 +372,12 @@ private:
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
+ enum {
+ MAX_MATERIALS_FOR_2D = 32
+ };
+
+ static Ref<SpatialMaterial> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff
+
protected:
static void _bind_methods();
void _validate_property(PropertyInfo &property) const;
@@ -499,6 +508,9 @@ public:
void set_grow(float p_grow);
float get_grow() const;
+ void set_alpha_scissor_threshold(float p_treshold);
+ float get_alpha_scissor_threshold() const;
+
void set_metallic_texture_channel(TextureChannel p_channel);
TextureChannel get_metallic_texture_channel() const;
void set_roughness_texture_channel(TextureChannel p_channel);
@@ -512,6 +524,8 @@ public:
static void finish_shaders();
static void flush_changes();
+ static RID get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass);
+
SpatialMaterial();
virtual ~SpatialMaterial();
};
diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp
index 3de0841f2a..3f1403d532 100644
--- a/servers/visual/shader_types.cpp
+++ b/servers/visual/shader_types.cpp
@@ -109,6 +109,7 @@ ShaderTypes::ShaderTypes() {
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SCREEN_UV"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["POINT_COORD"] = ShaderLanguage::TYPE_VEC2;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["SIDE"] = ShaderLanguage::TYPE_FLOAT;
+ shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["ALPHA_SCISSOR"] = ShaderLanguage::TYPE_FLOAT;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["WORLD_MATRIX"] = ShaderLanguage::TYPE_MAT4;
shader_modes[VS::SHADER_SPATIAL].functions["fragment"]["INV_CAMERA_MATRIX"] = ShaderLanguage::TYPE_MAT4;
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 307f4107eb..aed2f243fd 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -136,11 +136,6 @@ void VisualServer::_free_internal_rids() {
free(white_texture);
if (test_material.is_valid())
free(test_material);
-
- for (int i = 0; i < 32; i++) {
- if (material_2d[i].is_valid())
- free(material_2d[i]);
- }
}
RID VisualServer::_make_test_cube() {
@@ -284,37 +279,6 @@ RID VisualServer::make_sphere_mesh(int p_lats, int p_lons, float p_radius) {
return mesh;
}
-RID VisualServer::material_2d_get(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass) {
-
- int version = 0;
- if (p_shaded)
- version = 1;
- if (p_transparent)
- version |= 2;
- if (p_cut_alpha)
- version |= 4;
- if (p_opaque_prepass)
- version |= 8;
- if (p_double_sided)
- version |= 16;
- if (material_2d[version].is_valid())
- return material_2d[version];
-
- //not valid, make
-
- /* material_2d[version]=fixed_material_create();
- fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_USE_ALPHA,p_transparent);
- fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,true);
- fixed_material_set_flag(material_2d[version],FIXED_MATERIAL_FLAG_DISCARD_ALPHA,p_cut_alpha);
- material_set_flag(material_2d[version],MATERIAL_FLAG_UNSHADED,!p_shaded);
- material_set_flag(material_2d[version], MATERIAL_FLAG_DOUBLE_SIDED, p_double_sided);
- material_set_depth_draw_mode(material_2d[version],p_opaque_prepass?MATERIAL_DEPTH_DRAW_OPAQUE_PRE_PASS_ALPHA:MATERIAL_DEPTH_DRAW_OPAQUE_ONLY);
- fixed_material_set_texture(material_2d[version],FIXED_MATERIAL_PARAM_DIFFUSE,get_white_texture());
- //material cut alpha?*/
-
- return material_2d[version];
-}
-
RID VisualServer::get_white_texture() {
if (white_texture.is_valid())
diff --git a/servers/visual_server.h b/servers/visual_server.h
index 95a03c1836..ddf32a9ea1 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -60,7 +60,6 @@ protected:
RID test_texture;
RID white_texture;
RID test_material;
- RID material_2d[32];
Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb);
@@ -914,8 +913,6 @@ public:
/* Materials for 2D on 3D */
- RID material_2d_get(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass);
-
/* TESTING */
virtual RID get_test_cube() = 0;