mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Removed VisualShaders.
This commit is contained in:
parent
93d29cbc62
commit
84bd8ad20a
@ -156,7 +156,6 @@
|
||||
#include "editor/plugins/tile_set_editor_plugin.h"
|
||||
#include "editor/plugins/version_control_editor_plugin.h"
|
||||
#include "editor/plugins/viewport_preview_editor_plugin.h"
|
||||
#include "editor/plugins/visual_shader_editor_plugin.h"
|
||||
#include "editor/progress_dialog.h"
|
||||
#include "editor/project_export.h"
|
||||
#include "editor/project_settings_editor.h"
|
||||
@ -5902,10 +5901,6 @@ EditorNode::EditorNode() {
|
||||
Ref<EditorInspectorRootMotionPlugin> rmp;
|
||||
rmp.instance();
|
||||
EditorInspector::add_inspector_plugin(rmp);
|
||||
|
||||
Ref<EditorInspectorShaderModePlugin> smp;
|
||||
smp.instance();
|
||||
EditorInspector::add_inspector_plugin(smp);
|
||||
}
|
||||
|
||||
editor_selection = memnew(EditorSelection);
|
||||
@ -6890,7 +6885,6 @@ EditorNode::EditorNode() {
|
||||
|
||||
add_editor_plugin(VersionControlEditorPlugin::get_singleton());
|
||||
add_editor_plugin(memnew(ShaderEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));
|
||||
|
||||
add_editor_plugin(memnew(CameraEditorPlugin(this)));
|
||||
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
|
||||
@ -6964,10 +6958,6 @@ EditorNode::EditorNode() {
|
||||
Ref<ParticlesMaterialConversionPlugin> particles_mat_convert;
|
||||
particles_mat_convert.instance();
|
||||
resource_conversion_plugins.push_back(particles_mat_convert);
|
||||
|
||||
Ref<VisualShaderConversionPlugin> vshader_convert;
|
||||
vshader_convert.instance();
|
||||
resource_conversion_plugins.push_back(vshader_convert);
|
||||
}
|
||||
update_spinner_step_msec = OS::get_singleton()->get_ticks_msec();
|
||||
update_spinner_step_frame = Engine::get_singleton()->get_frames_drawn();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,357 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_shader_editor_plugin.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SHADER_EDITOR_PLUGIN_H
|
||||
#define VISUAL_SHADER_EDITOR_PLUGIN_H
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor/property_editor.h"
|
||||
#include "scene/gui/button.h"
|
||||
#include "scene/gui/graph_edit.h"
|
||||
#include "scene/gui/popup.h"
|
||||
#include "scene/gui/tree.h"
|
||||
#include "scene/resources/visual_shader.h"
|
||||
|
||||
class VisualShaderNodePlugin : public Reference {
|
||||
GDCLASS(VisualShaderNodePlugin, Reference);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node);
|
||||
};
|
||||
|
||||
class VisualShaderEditor : public VBoxContainer {
|
||||
GDCLASS(VisualShaderEditor, VBoxContainer);
|
||||
|
||||
CustomPropertyEditor *property_editor;
|
||||
int editing_node;
|
||||
int editing_port;
|
||||
|
||||
Ref<VisualShader> visual_shader;
|
||||
HSplitContainer *main_box;
|
||||
GraphEdit *graph;
|
||||
ToolButton *add_node;
|
||||
ToolButton *preview_shader;
|
||||
|
||||
OptionButton *edit_type;
|
||||
|
||||
PanelContainer *error_panel;
|
||||
Label *error_label;
|
||||
|
||||
bool pending_update_preview;
|
||||
bool shader_error;
|
||||
VBoxContainer *preview_vbox;
|
||||
TextEdit *preview_text;
|
||||
Label *error_text;
|
||||
|
||||
UndoRedo *undo_redo;
|
||||
Point2 saved_node_pos;
|
||||
bool saved_node_pos_dirty;
|
||||
|
||||
ConfirmationDialog *members_dialog;
|
||||
MenuButton *tools;
|
||||
|
||||
bool preview_showed;
|
||||
|
||||
enum ToolsMenuOptions {
|
||||
EXPAND_ALL,
|
||||
COLLAPSE_ALL
|
||||
};
|
||||
|
||||
Tree *members;
|
||||
AcceptDialog *alert;
|
||||
LineEdit *node_filter;
|
||||
RichTextLabel *node_desc;
|
||||
|
||||
void _tools_menu_option(int p_idx);
|
||||
void _show_members_dialog(bool at_mouse_pos);
|
||||
|
||||
void _update_graph();
|
||||
|
||||
struct AddOption {
|
||||
String name;
|
||||
String category;
|
||||
String sub_category;
|
||||
String type;
|
||||
String description;
|
||||
int sub_func;
|
||||
String sub_func_str;
|
||||
Ref<Script> script;
|
||||
int mode;
|
||||
int return_type;
|
||||
int func;
|
||||
float value;
|
||||
bool highend;
|
||||
bool is_custom;
|
||||
|
||||
AddOption(const String &p_name = String(), const String &p_category = String(), const String &p_sub_category = String(), const String &p_type = String(), const String &p_description = String(), int p_sub_func = -1, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) {
|
||||
name = p_name;
|
||||
type = p_type;
|
||||
category = p_category;
|
||||
sub_category = p_sub_category;
|
||||
description = p_description;
|
||||
sub_func = p_sub_func;
|
||||
return_type = p_return_type;
|
||||
mode = p_mode;
|
||||
func = p_func;
|
||||
value = p_value;
|
||||
highend = p_highend;
|
||||
is_custom = false;
|
||||
}
|
||||
|
||||
AddOption(const String &p_name, const String &p_category, const String &p_sub_category, const String &p_type, const String &p_description, const String &p_sub_func, int p_return_type = -1, int p_mode = -1, int p_func = -1, float p_value = -1, bool p_highend = false) {
|
||||
name = p_name;
|
||||
type = p_type;
|
||||
category = p_category;
|
||||
sub_category = p_sub_category;
|
||||
description = p_description;
|
||||
sub_func = 0;
|
||||
sub_func_str = p_sub_func;
|
||||
return_type = p_return_type;
|
||||
mode = p_mode;
|
||||
func = p_func;
|
||||
value = p_value;
|
||||
highend = p_highend;
|
||||
is_custom = false;
|
||||
}
|
||||
};
|
||||
|
||||
Vector<AddOption> add_options;
|
||||
int texture_node_option_idx;
|
||||
int custom_node_option_idx;
|
||||
List<String> keyword_list;
|
||||
|
||||
void _draw_color_over_button(Object *obj, Color p_color);
|
||||
|
||||
void _add_custom_node(const String &p_path);
|
||||
void _add_texture_node(const String &p_path);
|
||||
VisualShaderNode *_add_node(int p_idx, int p_op_idx = -1);
|
||||
void _update_options_menu();
|
||||
|
||||
void _show_preview_text();
|
||||
void _update_preview();
|
||||
String _get_description(int p_idx);
|
||||
|
||||
static VisualShaderEditor *singleton;
|
||||
|
||||
struct DragOp {
|
||||
VisualShader::Type type;
|
||||
int node;
|
||||
Vector2 from;
|
||||
Vector2 to;
|
||||
};
|
||||
List<DragOp> drag_buffer;
|
||||
bool drag_dirty = false;
|
||||
void _node_dragged(const Vector2 &p_from, const Vector2 &p_to, int p_node);
|
||||
void _nodes_dragged();
|
||||
bool updating;
|
||||
|
||||
void _connection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index);
|
||||
void _disconnection_request(const String &p_from, int p_from_index, const String &p_to, int p_to_index);
|
||||
|
||||
void _scroll_changed(const Vector2 &p_scroll);
|
||||
void _node_selected(Object *p_node);
|
||||
|
||||
void _delete_request(int);
|
||||
void _on_nodes_delete();
|
||||
|
||||
void _node_changed(int p_id);
|
||||
|
||||
void _edit_port_default_input(Object *p_button, int p_node, int p_port);
|
||||
void _port_edited();
|
||||
|
||||
int to_node;
|
||||
int to_slot;
|
||||
int from_node;
|
||||
int from_slot;
|
||||
|
||||
void _connection_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_position);
|
||||
void _connection_from_empty(const String &p_to, int p_to_slot, const Vector2 &p_release_position);
|
||||
|
||||
void _line_edit_changed(const String &p_text, Object *line_edit, int p_node_id);
|
||||
void _line_edit_focus_out(Object *line_edit, int p_node_id);
|
||||
|
||||
void _port_name_focus_out(Object *line_edit, int p_node_id, int p_port_id, bool p_output);
|
||||
|
||||
void _dup_copy_nodes(int p_type, List<int> &r_nodes, Set<int> &r_excluded);
|
||||
void _dup_update_excluded(int p_type, Set<int> &r_excluded);
|
||||
void _dup_paste_nodes(int p_type, int p_pasted_type, List<int> &r_nodes, Set<int> &r_excluded, const Vector2 &p_offset, bool p_select);
|
||||
|
||||
void _duplicate_nodes();
|
||||
|
||||
Vector2 selection_center;
|
||||
int copy_type; // shader type
|
||||
List<int> copy_nodes_buffer;
|
||||
Set<int> copy_nodes_excluded_buffer;
|
||||
|
||||
void _clear_buffer();
|
||||
void _copy_nodes();
|
||||
void _paste_nodes();
|
||||
|
||||
Vector<Ref<VisualShaderNodePlugin>> plugins;
|
||||
|
||||
void _mode_selected(int p_id);
|
||||
void _rebuild();
|
||||
|
||||
void _input_select_item(Ref<VisualShaderNodeInput> input, String name);
|
||||
void _uniform_select_item(Ref<VisualShaderNodeUniformRef> p_uniform, String p_name);
|
||||
|
||||
void _add_input_port(int p_node, int p_port, int p_port_type, const String &p_name);
|
||||
void _remove_input_port(int p_node, int p_port);
|
||||
void _change_input_port_type(int p_type, int p_node, int p_port);
|
||||
void _change_input_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
|
||||
|
||||
void _add_output_port(int p_node, int p_port, int p_port_type, const String &p_name);
|
||||
void _remove_output_port(int p_node, int p_port);
|
||||
void _change_output_port_type(int p_type, int p_node, int p_port);
|
||||
void _change_output_port_name(const String &p_text, Object *line_edit, int p_node, int p_port);
|
||||
|
||||
void _expression_focus_out(Object *text_edit, int p_node);
|
||||
|
||||
void _set_node_size(int p_type, int p_node, const Size2 &p_size);
|
||||
void _node_resized(const Vector2 &p_new_size, int p_type, int p_node);
|
||||
|
||||
void _preview_select_port(int p_node, int p_port);
|
||||
void _graph_gui_input(const Ref<InputEvent> &p_event);
|
||||
|
||||
void _member_filter_changed(const String &p_text);
|
||||
void _sbox_input(const Ref<InputEvent> &p_ie);
|
||||
void _member_selected();
|
||||
void _member_unselected();
|
||||
void _member_create();
|
||||
void _member_cancel();
|
||||
|
||||
Variant get_drag_data_fw(const Point2 &p_point, Control *p_from);
|
||||
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
|
||||
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
|
||||
|
||||
bool _is_available(int p_mode);
|
||||
void _update_created_node(GraphNode *node);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void update_custom_nodes();
|
||||
void add_plugin(const Ref<VisualShaderNodePlugin> &p_plugin);
|
||||
void remove_plugin(const Ref<VisualShaderNodePlugin> &p_plugin);
|
||||
|
||||
static VisualShaderEditor *get_singleton() { return singleton; }
|
||||
|
||||
void clear_custom_types();
|
||||
void add_custom_type(const String &p_name, const Ref<Script> &p_script, const String &p_description, int p_return_icon_type, const String &p_category, const String &p_subcategory);
|
||||
|
||||
virtual Size2 get_minimum_size() const;
|
||||
void edit(VisualShader *p_visual_shader);
|
||||
VisualShaderEditor();
|
||||
};
|
||||
|
||||
class VisualShaderEditorPlugin : public EditorPlugin {
|
||||
GDCLASS(VisualShaderEditorPlugin, EditorPlugin);
|
||||
|
||||
VisualShaderEditor *visual_shader_editor;
|
||||
EditorNode *editor;
|
||||
Button *button;
|
||||
|
||||
public:
|
||||
virtual String get_name() const { return "VisualShader"; }
|
||||
bool has_main_screen() const { return false; }
|
||||
virtual void edit(Object *p_object);
|
||||
virtual bool handles(Object *p_object) const;
|
||||
virtual void make_visible(bool p_visible);
|
||||
|
||||
VisualShaderEditorPlugin(EditorNode *p_node);
|
||||
~VisualShaderEditorPlugin();
|
||||
};
|
||||
|
||||
class VisualShaderNodePluginDefault : public VisualShaderNodePlugin {
|
||||
GDCLASS(VisualShaderNodePluginDefault, VisualShaderNodePlugin);
|
||||
|
||||
public:
|
||||
virtual Control *create_editor(const Ref<Resource> &p_parent_resource, const Ref<VisualShaderNode> &p_node);
|
||||
};
|
||||
|
||||
class EditorPropertyShaderMode : public EditorProperty {
|
||||
GDCLASS(EditorPropertyShaderMode, EditorProperty);
|
||||
OptionButton *options;
|
||||
|
||||
void _option_selected(int p_which);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void setup(const Vector<String> &p_options);
|
||||
virtual void update_property();
|
||||
void set_option_button_clip(bool p_enable);
|
||||
EditorPropertyShaderMode();
|
||||
};
|
||||
|
||||
class EditorInspectorShaderModePlugin : public EditorInspectorPlugin {
|
||||
GDCLASS(EditorInspectorShaderModePlugin, EditorInspectorPlugin);
|
||||
|
||||
public:
|
||||
virtual bool can_handle(Object *p_object);
|
||||
virtual void parse_begin(Object *p_object);
|
||||
virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
|
||||
virtual void parse_end();
|
||||
};
|
||||
|
||||
class VisualShaderNodePortPreview : public Control {
|
||||
GDCLASS(VisualShaderNodePortPreview, Control);
|
||||
Ref<VisualShader> shader;
|
||||
VisualShader::Type type;
|
||||
int node;
|
||||
int port;
|
||||
void _shader_changed(); //must regen
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual Size2 get_minimum_size() const;
|
||||
void setup(const Ref<VisualShader> &p_shader, VisualShader::Type p_type, int p_node, int p_port);
|
||||
VisualShaderNodePortPreview();
|
||||
};
|
||||
|
||||
class VisualShaderConversionPlugin : public EditorResourceConversionPlugin {
|
||||
GDCLASS(VisualShaderConversionPlugin, EditorResourceConversionPlugin);
|
||||
|
||||
public:
|
||||
virtual String converts_to() const;
|
||||
virtual bool handles(const Ref<Resource> &p_resource) const;
|
||||
virtual Ref<Resource> convert(const Ref<Resource> &p_resource) const;
|
||||
};
|
||||
|
||||
#endif // VISUAL_SHADER_EDITOR_PLUGIN_H
|
@ -383,7 +383,7 @@ void Control::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
hint |= PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_CHECKED;
|
||||
}
|
||||
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Shader,VisualShader", hint));
|
||||
p_list->push_back(PropertyInfo(Variant::OBJECT, "custom_shaders/" + E->get(), PROPERTY_HINT_RESOURCE_TYPE, "Shader", hint));
|
||||
}
|
||||
}
|
||||
{
|
||||
|
@ -169,8 +169,6 @@
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/tile_set.h"
|
||||
#include "scene/resources/video_stream.h"
|
||||
#include "scene/resources/visual_shader.h"
|
||||
#include "scene/resources/visual_shader_nodes.h"
|
||||
#include "scene/resources/world.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
@ -502,68 +500,6 @@ void register_scene_types() {
|
||||
AcceptDialog::set_swap_ok_cancel(GLOBAL_DEF_NOVAL("gui/common/swap_ok_cancel", bool(OS::get_singleton()->get_swap_ok_cancel())));
|
||||
|
||||
ClassDB::register_class<Shader>();
|
||||
ClassDB::register_class<VisualShader>();
|
||||
ClassDB::register_virtual_class<VisualShaderNode>();
|
||||
ClassDB::register_class<VisualShaderNodeCustom>();
|
||||
ClassDB::register_class<VisualShaderNodeInput>();
|
||||
ClassDB::register_virtual_class<VisualShaderNodeOutput>();
|
||||
ClassDB::register_class<VisualShaderNodeGroupBase>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarConstant>();
|
||||
ClassDB::register_class<VisualShaderNodeBooleanConstant>();
|
||||
ClassDB::register_class<VisualShaderNodeColorConstant>();
|
||||
ClassDB::register_class<VisualShaderNodeVec3Constant>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformConstant>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarOp>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorOp>();
|
||||
ClassDB::register_class<VisualShaderNodeColorOp>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformMult>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformVecMult>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeColorFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeDotProduct>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorLen>();
|
||||
ClassDB::register_class<VisualShaderNodeDeterminant>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarDerivativeFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorDerivativeFunc>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarClamp>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorClamp>();
|
||||
ClassDB::register_class<VisualShaderNodeFaceForward>();
|
||||
ClassDB::register_class<VisualShaderNodeOuterProduct>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorScalarStep>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarSmoothStep>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorSmoothStep>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorScalarSmoothStep>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorDistance>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorRefract>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarInterp>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorInterp>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorScalarMix>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorCompose>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformCompose>();
|
||||
ClassDB::register_class<VisualShaderNodeVectorDecompose>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformDecompose>();
|
||||
ClassDB::register_class<VisualShaderNodeTexture>();
|
||||
ClassDB::register_class<VisualShaderNodeCubeMap>();
|
||||
ClassDB::register_virtual_class<VisualShaderNodeUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeUniformRef>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeBooleanUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeColorUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeVec3Uniform>();
|
||||
ClassDB::register_class<VisualShaderNodeTransformUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeTextureUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeTextureUniformTriplanar>();
|
||||
ClassDB::register_class<VisualShaderNodeCubeMapUniform>();
|
||||
ClassDB::register_class<VisualShaderNodeIf>();
|
||||
ClassDB::register_class<VisualShaderNodeSwitch>();
|
||||
ClassDB::register_class<VisualShaderNodeScalarSwitch>();
|
||||
ClassDB::register_class<VisualShaderNodeFresnel>();
|
||||
ClassDB::register_class<VisualShaderNodeExpression>();
|
||||
ClassDB::register_class<VisualShaderNodeGlobalExpression>();
|
||||
ClassDB::register_class<VisualShaderNodeIs>();
|
||||
ClassDB::register_class<VisualShaderNodeCompare>();
|
||||
|
||||
ClassDB::register_class<ShaderMaterial>();
|
||||
ClassDB::register_virtual_class<CanvasItem>();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,559 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* visual_shader.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SHADER_H
|
||||
#define VISUAL_SHADER_H
|
||||
|
||||
#include "core/string_builder.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/resources/shader.h"
|
||||
|
||||
class VisualShaderNodeUniform;
|
||||
class VisualShaderNode;
|
||||
|
||||
class VisualShader : public Shader {
|
||||
GDCLASS(VisualShader, Shader);
|
||||
|
||||
public:
|
||||
enum Type {
|
||||
TYPE_VERTEX,
|
||||
TYPE_FRAGMENT,
|
||||
TYPE_LIGHT,
|
||||
TYPE_MAX
|
||||
};
|
||||
|
||||
struct Connection {
|
||||
int from_node;
|
||||
int from_port;
|
||||
int to_node;
|
||||
int to_port;
|
||||
};
|
||||
|
||||
struct DefaultTextureParam {
|
||||
StringName name;
|
||||
Ref<Texture> param;
|
||||
};
|
||||
|
||||
private:
|
||||
struct Node {
|
||||
Ref<VisualShaderNode> node;
|
||||
Vector2 position;
|
||||
List<int> prev_connected_nodes;
|
||||
};
|
||||
|
||||
struct Graph {
|
||||
Map<int, Node> nodes;
|
||||
List<Connection> connections;
|
||||
} graph[TYPE_MAX];
|
||||
|
||||
Shader::Mode shader_mode;
|
||||
mutable String previous_code;
|
||||
|
||||
Array _get_node_connections(Type p_type) const;
|
||||
|
||||
Vector2 graph_offset;
|
||||
|
||||
struct RenderModeEnums {
|
||||
Shader::Mode mode;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
HashMap<String, int> modes;
|
||||
Set<StringName> flags;
|
||||
|
||||
static RenderModeEnums render_mode_enums[];
|
||||
|
||||
mutable SafeFlag dirty;
|
||||
void _queue_update();
|
||||
|
||||
union ConnectionKey {
|
||||
struct {
|
||||
uint64_t node : 32;
|
||||
uint64_t port : 32;
|
||||
};
|
||||
uint64_t key;
|
||||
bool operator<(const ConnectionKey &p_key) const {
|
||||
return key < p_key.key;
|
||||
}
|
||||
};
|
||||
|
||||
Error _write_node(Type p_type, StringBuilder &global_code, StringBuilder &global_code_per_node, Map<Type, StringBuilder> &global_code_per_func, StringBuilder &code, Vector<DefaultTextureParam> &def_tex_params, const VMap<ConnectionKey, const List<Connection>::Element *> &input_connections, const VMap<ConnectionKey, const List<Connection>::Element *> &output_connections, int node, Set<int> &processed, bool for_preview, Set<StringName> &r_classes) const;
|
||||
|
||||
void _input_type_changed(Type p_type, int p_id);
|
||||
|
||||
protected:
|
||||
virtual void _update_shader() const;
|
||||
static void _bind_methods();
|
||||
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
|
||||
public:
|
||||
enum {
|
||||
NODE_ID_INVALID = -1,
|
||||
NODE_ID_OUTPUT = 0,
|
||||
};
|
||||
|
||||
void add_node(Type p_type, const Ref<VisualShaderNode> &p_node, const Vector2 &p_position, int p_id);
|
||||
void set_node_position(Type p_type, int p_id, const Vector2 &p_position);
|
||||
|
||||
Vector2 get_node_position(Type p_type, int p_id) const;
|
||||
Ref<VisualShaderNode> get_node(Type p_type, int p_id) const;
|
||||
|
||||
Vector<int> get_node_list(Type p_type) const;
|
||||
int get_valid_node_id(Type p_type) const;
|
||||
|
||||
int find_node_id(Type p_type, const Ref<VisualShaderNode> &p_node) const;
|
||||
void remove_node(Type p_type, int p_id);
|
||||
|
||||
bool is_node_connection(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
|
||||
|
||||
bool is_nodes_connected_relatively(const Graph *p_graph, int p_node, int p_target) const;
|
||||
bool can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const;
|
||||
Error connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
|
||||
void disconnect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
|
||||
void connect_nodes_forced(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port);
|
||||
bool is_port_types_compatible(int p_a, int p_b) const;
|
||||
|
||||
void rebuild();
|
||||
void get_node_connections(Type p_type, List<Connection> *r_connections) const;
|
||||
|
||||
void set_mode(Mode p_mode);
|
||||
virtual Mode get_mode() const;
|
||||
|
||||
virtual bool is_text_shader() const;
|
||||
|
||||
void set_graph_offset(const Vector2 &p_offset);
|
||||
Vector2 get_graph_offset() const;
|
||||
|
||||
String generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &r_default_tex_params) const;
|
||||
|
||||
String validate_port_name(const String &p_name, const List<String> &p_input_ports, const List<String> &p_output_ports) const;
|
||||
String validate_uniform_name(const String &p_name, const Ref<VisualShaderNodeUniform> &p_uniform) const;
|
||||
|
||||
VisualShader();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShader::Type)
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
class VisualShaderNode : public Resource {
|
||||
GDCLASS(VisualShaderNode, Resource);
|
||||
|
||||
int port_preview;
|
||||
|
||||
Map<int, Variant> default_input_values;
|
||||
Map<int, bool> connected_input_ports;
|
||||
Map<int, int> connected_output_ports;
|
||||
|
||||
protected:
|
||||
bool simple_decl;
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
enum PortType {
|
||||
PORT_TYPE_SCALAR,
|
||||
PORT_TYPE_VECTOR,
|
||||
PORT_TYPE_BOOLEAN,
|
||||
PORT_TYPE_TRANSFORM,
|
||||
PORT_TYPE_SAMPLER,
|
||||
PORT_TYPE_MAX,
|
||||
};
|
||||
|
||||
bool is_simple_decl() const;
|
||||
|
||||
virtual String get_caption() const = 0;
|
||||
|
||||
virtual int get_input_port_count() const = 0;
|
||||
virtual PortType get_input_port_type(int p_port) const = 0;
|
||||
virtual String get_input_port_name(int p_port) const = 0;
|
||||
|
||||
virtual void set_input_port_default_value(int p_port, const Variant &p_value);
|
||||
Variant get_input_port_default_value(int p_port) const; // if NIL (default if node does not set anything) is returned, it means no default value is wanted if disconnected, thus no input var must be supplied (empty string will be supplied)
|
||||
Array get_default_input_values() const;
|
||||
virtual void set_default_input_values(const Array &p_values);
|
||||
|
||||
virtual int get_output_port_count() const = 0;
|
||||
virtual PortType get_output_port_type(int p_port) const = 0;
|
||||
virtual String get_output_port_name(int p_port) const = 0;
|
||||
|
||||
virtual String get_input_port_default_hint(int p_port) const;
|
||||
|
||||
void set_output_port_for_preview(int p_index);
|
||||
int get_output_port_for_preview() const;
|
||||
|
||||
virtual bool is_port_separator(int p_index) const;
|
||||
|
||||
bool is_output_port_connected(int p_port) const;
|
||||
void set_output_port_connected(int p_port, bool p_connected);
|
||||
bool is_input_port_connected(int p_port) const;
|
||||
void set_input_port_connected(int p_port, bool p_connected);
|
||||
virtual bool is_generate_input_var(int p_port) const;
|
||||
|
||||
virtual bool is_code_generated() const;
|
||||
virtual bool is_show_prop_names() const;
|
||||
|
||||
virtual Vector<StringName> get_editable_properties() const;
|
||||
|
||||
virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const;
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
|
||||
virtual String generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
|
||||
virtual String generate_global_per_func(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const = 0; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
|
||||
|
||||
virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const;
|
||||
|
||||
VisualShaderNode();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VisualShaderNode::PortType)
|
||||
|
||||
class VisualShaderNodeCustom : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeCustom, VisualShaderNode);
|
||||
|
||||
struct Port {
|
||||
String name;
|
||||
int type;
|
||||
};
|
||||
|
||||
bool is_initialized = false;
|
||||
List<Port> input_ports;
|
||||
List<Port> output_ports;
|
||||
|
||||
friend class VisualShaderEditor;
|
||||
|
||||
protected:
|
||||
virtual String get_caption() const;
|
||||
|
||||
virtual int get_input_port_count() const;
|
||||
virtual PortType get_input_port_type(int p_port) const;
|
||||
virtual String get_input_port_name(int p_port) const;
|
||||
|
||||
virtual int get_output_port_count() const;
|
||||
virtual PortType get_output_port_type(int p_port) const;
|
||||
virtual String get_output_port_name(int p_port) const;
|
||||
|
||||
virtual void set_input_port_default_value(int p_port, const Variant &p_value);
|
||||
virtual void set_default_input_values(const Array &p_values);
|
||||
|
||||
protected:
|
||||
void _set_input_port_default_value(int p_port, const Variant &p_value);
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
virtual String generate_global_per_node(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
VisualShaderNodeCustom();
|
||||
void update_ports();
|
||||
|
||||
bool _is_initialized();
|
||||
void _set_initialized(bool p_enabled);
|
||||
};
|
||||
|
||||
/////
|
||||
|
||||
class VisualShaderNodeInput : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeInput, VisualShaderNode);
|
||||
|
||||
friend class VisualShader;
|
||||
VisualShader::Type shader_type;
|
||||
Shader::Mode shader_mode;
|
||||
|
||||
struct Port {
|
||||
Shader::Mode mode;
|
||||
VisualShader::Type shader_type;
|
||||
PortType type;
|
||||
const char *name;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
static const Port ports[];
|
||||
static const Port preview_ports[];
|
||||
|
||||
String input_name;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _validate_property(PropertyInfo &property) const;
|
||||
|
||||
public:
|
||||
virtual int get_input_port_count() const;
|
||||
virtual PortType get_input_port_type(int p_port) const;
|
||||
virtual String get_input_port_name(int p_port) const;
|
||||
|
||||
virtual int get_output_port_count() const;
|
||||
virtual PortType get_output_port_type(int p_port) const;
|
||||
virtual String get_output_port_name(int p_port) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
|
||||
void set_input_name(String p_name);
|
||||
String get_input_name() const;
|
||||
String get_input_real_name() const;
|
||||
|
||||
int get_input_index_count() const;
|
||||
PortType get_input_index_type(int p_index) const;
|
||||
String get_input_index_name(int p_index) const;
|
||||
|
||||
PortType get_input_type_by_name(String p_name) const;
|
||||
|
||||
virtual Vector<StringName> get_editable_properties() const;
|
||||
|
||||
VisualShaderNodeInput();
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
class VisualShaderNodeOutput : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeOutput, VisualShaderNode);
|
||||
|
||||
public:
|
||||
friend class VisualShader;
|
||||
VisualShader::Type shader_type;
|
||||
Shader::Mode shader_mode;
|
||||
|
||||
struct Port {
|
||||
Shader::Mode mode;
|
||||
VisualShader::Type shader_type;
|
||||
PortType type;
|
||||
const char *name;
|
||||
const char *string;
|
||||
};
|
||||
|
||||
static const Port ports[];
|
||||
|
||||
public:
|
||||
virtual int get_input_port_count() const;
|
||||
virtual PortType get_input_port_type(int p_port) const;
|
||||
virtual String get_input_port_name(int p_port) const;
|
||||
Variant get_input_port_default_value(int p_port) const;
|
||||
|
||||
virtual int get_output_port_count() const;
|
||||
virtual PortType get_output_port_type(int p_port) const;
|
||||
virtual String get_output_port_name(int p_port) const;
|
||||
|
||||
virtual bool is_port_separator(int p_index) const;
|
||||
|
||||
virtual String get_caption() const;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
|
||||
VisualShaderNodeOutput();
|
||||
};
|
||||
|
||||
class VisualShaderNodeUniform : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeUniform, VisualShaderNode);
|
||||
|
||||
private:
|
||||
String uniform_name;
|
||||
bool global_code_generated = false;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_global_code_generated(bool p_enabled);
|
||||
bool is_global_code_generated() const;
|
||||
|
||||
virtual bool is_show_prop_names() const;
|
||||
|
||||
void set_uniform_name(const String &p_name);
|
||||
String get_uniform_name() const;
|
||||
|
||||
VisualShaderNodeUniform();
|
||||
};
|
||||
|
||||
class VisualShaderNodeUniformRef : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeUniformRef, VisualShaderNode);
|
||||
|
||||
public:
|
||||
enum UniformType {
|
||||
UNIFORM_TYPE_SCALAR,
|
||||
UNIFORM_TYPE_BOOLEAN,
|
||||
UNIFORM_TYPE_VECTOR,
|
||||
UNIFORM_TYPE_TRANSFORM,
|
||||
UNIFORM_TYPE_COLOR,
|
||||
UNIFORM_TYPE_SAMPLER,
|
||||
};
|
||||
|
||||
struct Uniform {
|
||||
String name;
|
||||
UniformType type;
|
||||
};
|
||||
|
||||
private:
|
||||
String uniform_name;
|
||||
UniformType uniform_type;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static void add_uniform(const String &p_name, UniformType p_type);
|
||||
static void clear_uniforms();
|
||||
|
||||
public:
|
||||
virtual String get_caption() const;
|
||||
|
||||
virtual int get_input_port_count() const;
|
||||
virtual PortType get_input_port_type(int p_port) const;
|
||||
virtual String get_input_port_name(int p_port) const;
|
||||
|
||||
virtual int get_output_port_count() const;
|
||||
virtual PortType get_output_port_type(int p_port) const;
|
||||
virtual String get_output_port_name(int p_port) const;
|
||||
|
||||
void set_uniform_name(const String &p_name);
|
||||
String get_uniform_name() const;
|
||||
|
||||
int get_uniforms_count() const;
|
||||
String get_uniform_name_by_index(int p_idx) const;
|
||||
UniformType get_uniform_type_by_name(const String &p_name) const;
|
||||
UniformType get_uniform_type_by_index(int p_idx) const;
|
||||
|
||||
virtual Vector<StringName> get_editable_properties() const;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
|
||||
VisualShaderNodeUniformRef();
|
||||
};
|
||||
|
||||
class VisualShaderNodeGroupBase : public VisualShaderNode {
|
||||
GDCLASS(VisualShaderNodeGroupBase, VisualShaderNode);
|
||||
|
||||
private:
|
||||
void _apply_port_changes();
|
||||
|
||||
protected:
|
||||
Vector2 size;
|
||||
String inputs;
|
||||
String outputs;
|
||||
bool editable;
|
||||
|
||||
struct Port {
|
||||
PortType type;
|
||||
String name;
|
||||
};
|
||||
|
||||
Map<int, Port> input_ports;
|
||||
Map<int, Port> output_ports;
|
||||
Map<int, Control *> controls;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_caption() const;
|
||||
|
||||
void set_size(const Vector2 &p_size);
|
||||
Vector2 get_size() const;
|
||||
|
||||
void set_inputs(const String &p_inputs);
|
||||
String get_inputs() const;
|
||||
|
||||
void set_outputs(const String &p_outputs);
|
||||
String get_outputs() const;
|
||||
|
||||
bool is_valid_port_name(const String &p_name) const;
|
||||
|
||||
void add_input_port(int p_id, int p_type, const String &p_name);
|
||||
void remove_input_port(int p_id);
|
||||
virtual int get_input_port_count() const;
|
||||
bool has_input_port(int p_id) const;
|
||||
void clear_input_ports();
|
||||
|
||||
void add_output_port(int p_id, int p_type, const String &p_name);
|
||||
void remove_output_port(int p_id);
|
||||
virtual int get_output_port_count() const;
|
||||
bool has_output_port(int p_id) const;
|
||||
void clear_output_ports();
|
||||
|
||||
void set_input_port_type(int p_id, int p_type);
|
||||
virtual PortType get_input_port_type(int p_id) const;
|
||||
void set_input_port_name(int p_id, const String &p_name);
|
||||
virtual String get_input_port_name(int p_id) const;
|
||||
|
||||
void set_output_port_type(int p_id, int p_type);
|
||||
virtual PortType get_output_port_type(int p_id) const;
|
||||
void set_output_port_name(int p_id, const String &p_name);
|
||||
virtual String get_output_port_name(int p_id) const;
|
||||
|
||||
int get_free_input_port_id() const;
|
||||
int get_free_output_port_id() const;
|
||||
|
||||
void set_control(Control *p_control, int p_index);
|
||||
Control *get_control(int p_index);
|
||||
|
||||
void set_editable(bool p_enabled);
|
||||
bool is_editable() const;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
|
||||
VisualShaderNodeGroupBase();
|
||||
};
|
||||
|
||||
class VisualShaderNodeExpression : public VisualShaderNodeGroupBase {
|
||||
GDCLASS(VisualShaderNodeExpression, VisualShaderNodeGroupBase);
|
||||
|
||||
protected:
|
||||
String expression;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_caption() const;
|
||||
|
||||
void set_expression(const String &p_expression);
|
||||
String get_expression() const;
|
||||
|
||||
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const;
|
||||
|
||||
VisualShaderNodeExpression();
|
||||
};
|
||||
|
||||
class VisualShaderNodeGlobalExpression : public VisualShaderNodeExpression {
|
||||
GDCLASS(VisualShaderNodeGlobalExpression, VisualShaderNodeExpression);
|
||||
|
||||
public:
|
||||
virtual String get_caption() const;
|
||||
|
||||
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
|
||||
|
||||
VisualShaderNodeGlobalExpression();
|
||||
};
|
||||
|
||||
#endif // VISUAL_SHADER_H
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user