Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
5648924e
Commit
5648924e
authored
May 12, 2019
by
Chaosus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expression node for visual shaders
parent
d111d596
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
121 additions
and
0 deletions
+121
-0
editor_fonts.cpp
editor/editor_fonts.cpp
+3
-0
visual_shader_editor_plugin.cpp
editor/plugins/visual_shader_editor_plugin.cpp
+0
-0
visual_shader_editor_plugin.h
editor/plugins/visual_shader_editor_plugin.h
+24
-0
register_scene_types.cpp
scene/register_scene_types.cpp
+2
-0
visual_shader.cpp
scene/resources/visual_shader.cpp
+0
-0
visual_shader.h
scene/resources/visual_shader.h
+92
-0
No files found.
editor/editor_fonts.cpp
View file @
5648924e
...
...
@@ -239,6 +239,9 @@ void editor_register_fonts(Ref<Theme> p_theme) {
MAKE_SOURCE_FONT
(
df_code
,
int
(
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font_size"
))
*
EDSCALE
);
p_theme
->
set_font
(
"source"
,
"EditorFonts"
,
df_code
);
MAKE_SOURCE_FONT
(
df_expression
,
(
int
(
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font_size"
))
-
1
)
*
EDSCALE
);
p_theme
->
set_font
(
"expression"
,
"EditorFonts"
,
df_expression
);
MAKE_SOURCE_FONT
(
df_output_code
,
int
(
EDITOR_DEF
(
"run/output/font_size"
,
13
))
*
EDSCALE
);
p_theme
->
set_font
(
"output_source"
,
"EditorFonts"
,
df_output_code
);
...
...
editor/plugins/visual_shader_editor_plugin.cpp
View file @
5648924e
This diff is collapsed.
Click to expand it.
editor/plugins/visual_shader_editor_plugin.h
View file @
5648924e
...
...
@@ -84,6 +84,8 @@ class VisualShaderEditor : public VBoxContainer {
LineEdit
*
node_filter
;
RichTextLabel
*
node_desc
;
Timer
*
build_timer
;
void
_tools_menu_option
(
int
p_idx
);
void
_show_members_dialog
(
bool
at_mouse_pos
);
...
...
@@ -128,6 +130,7 @@ class VisualShaderEditor : public VBoxContainer {
};
Vector
<
AddOption
>
add_options
;
List
<
String
>
keyword_list
;
void
_draw_color_over_button
(
Object
*
obj
,
Color
p_color
);
...
...
@@ -160,14 +163,35 @@ class VisualShaderEditor : public VBoxContainer {
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
_duplicate_nodes
();
Vector
<
Ref
<
VisualShaderNodePlugin
>
>
plugins
;
void
_mode_selected
(
int
p_id
);
void
_rebuild
();
void
_input_select_item
(
Ref
<
VisualShaderNodeInput
>
input
,
String
name
);
void
_add_input_port
(
int
p_node
,
int
p_port
,
int
p_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_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
_start_rebuild_timer
(
int
p_delay
);
void
_set_expression
(
int
p_node
);
void
_rebuild_timeout
();
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
);
...
...
scene/register_scene_types.cpp
View file @
5648924e
...
...
@@ -476,6 +476,7 @@ void register_scene_types() {
ClassDB
::
register_virtual_class
<
VisualShaderNode
>
();
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
>
();
...
...
@@ -524,6 +525,7 @@ void register_scene_types() {
ClassDB
::
register_class
<
VisualShaderNodeIf
>
();
ClassDB
::
register_class
<
VisualShaderNodeSwitch
>
();
ClassDB
::
register_class
<
VisualShaderNodeFresnel
>
();
ClassDB
::
register_class
<
VisualShaderNodeExpression
>
();
ClassDB
::
register_class
<
ShaderMaterial
>
();
ClassDB
::
register_virtual_class
<
CanvasItem
>
();
...
...
scene/resources/visual_shader.cpp
View file @
5648924e
This diff is collapsed.
Click to expand it.
scene/resources/visual_shader.h
View file @
5648924e
...
...
@@ -135,7 +135,9 @@ public:
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
);
void
rebuild
();
void
get_node_connections
(
Type
p_type
,
List
<
Connection
>
*
r_connections
)
const
;
void
set_mode
(
Mode
p_mode
);
...
...
@@ -148,6 +150,7 @@ public:
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
();
...
...
@@ -314,4 +317,93 @@ public:
VisualShaderNodeUniform
();
};
class
VisualShaderNodeGroupBase
:
public
VisualShaderNode
{
GDCLASS
(
VisualShaderNodeGroupBase
,
VisualShaderNode
)
private
:
void
_apply_port_changes
();
protected
:
Vector2
size
;
String
inputs
;
String
outputs
;
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
;
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
);
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
)
private
:
String
expression
;
protected
:
static
void
_bind_methods
();
public
:
virtual
String
get_caption
()
const
;
void
set_expression
(
const
String
&
p_expression
);
String
get_expression
()
const
;
void
build
();
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
();
};
#endif // VISUAL_SHADER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment