summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/resources/visual_shader_nodes.cpp27
-rw-r--r--scene/resources/visual_shader_nodes.h1
2 files changed, 25 insertions, 3 deletions
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index a94fdd9d7b..4c168b7c9b 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -3684,12 +3684,33 @@ String VisualShaderNodeFresnel::get_output_port_name(int p_port) const {
}
String VisualShaderNodeFresnel::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) const {
- return "\t" + p_output_vars[0] + " = " + p_input_vars[2] + " ? (pow(clamp(dot(" + p_input_vars[0] + ", " + p_input_vars[1] + "), 0.0, 1.0), " + p_input_vars[3] + ")) : (pow(1.0 - clamp(dot(" + p_input_vars[0] + ", " + p_input_vars[1] + "), 0.0, 1.0), " + p_input_vars[3] + "));";
+
+ String normal;
+ String view;
+ if (p_input_vars[0] == String()) {
+ normal = "NORMAL";
+ } else {
+ normal = p_input_vars[0];
+ }
+ if (p_input_vars[1] == String()) {
+ view = "VIEW";
+ } else {
+ view = p_input_vars[1];
+ }
+
+ return "\t" + p_output_vars[0] + " = " + p_input_vars[2] + " ? (pow(clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + ")) : (pow(1.0 - clamp(dot(" + normal + ", " + view + "), 0.0, 1.0), " + p_input_vars[3] + "));";
+}
+
+String VisualShaderNodeFresnel::get_input_port_default_hint(int p_port) const {
+ if (p_port == 0) {
+ return "default";
+ } else if (p_port == 1) {
+ return "default";
+ }
+ return "";
}
VisualShaderNodeFresnel::VisualShaderNodeFresnel() {
- set_input_port_default_value(0, Vector3(0.0, 0.0, 0.0));
- set_input_port_default_value(1, Vector3(0.0, 0.0, 0.0));
set_input_port_default_value(2, false);
set_input_port_default_value(3, 1.0);
}
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 339e59bda9..144350423c 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -1579,6 +1579,7 @@ public:
virtual PortType get_output_port_type(int p_port) const;
virtual String get_output_port_name(int p_port) const;
+ virtual String get_input_port_default_hint(int p_port) 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;
VisualShaderNodeFresnel();