|
@@ -33,6 +33,7 @@
|
|
#include "core/os/os.h"
|
|
#include "core/os/os.h"
|
|
#include "core/string/print_string.h"
|
|
#include "core/string/print_string.h"
|
|
#include "core/templates/local_vector.h"
|
|
#include "core/templates/local_vector.h"
|
|
|
|
+#include "servers/rendering/renderer_compositor.h"
|
|
#include "servers/rendering_server.h"
|
|
#include "servers/rendering_server.h"
|
|
#include "shader_types.h"
|
|
#include "shader_types.h"
|
|
|
|
|
|
@@ -3055,7 +3056,7 @@ const ShaderLanguage::BuiltinFuncConstArgs ShaderLanguage::builtin_func_const_ar
|
|
|
|
|
|
bool ShaderLanguage::is_const_suffix_lut_initialized = false;
|
|
bool ShaderLanguage::is_const_suffix_lut_initialized = false;
|
|
|
|
|
|
-bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str) {
|
|
|
|
|
|
+bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionInfo &p_function_info, OperatorNode *p_func, DataType *r_ret_type, StringName *r_ret_type_str, bool *r_is_custom_function) {
|
|
ERR_FAIL_COND_V(p_func->op != OP_CALL && p_func->op != OP_CONSTRUCT, false);
|
|
ERR_FAIL_COND_V(p_func->op != OP_CALL && p_func->op != OP_CONSTRUCT, false);
|
|
|
|
|
|
Vector<DataType> args;
|
|
Vector<DataType> args;
|
|
@@ -3479,6 +3480,9 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (r_is_custom_function) {
|
|
|
|
+ *r_is_custom_function = true;
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5251,7 +5255,8 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!_validate_function_call(p_block, p_function_info, func, &func->return_cache, &func->struct_name)) {
|
|
|
|
|
|
+ bool is_custom_func = false;
|
|
|
|
+ if (!_validate_function_call(p_block, p_function_info, func, &func->return_cache, &func->struct_name, &is_custom_func)) {
|
|
_set_error(vformat(RTR("No matching function found for: '%s'."), String(funcname->name)));
|
|
_set_error(vformat(RTR("No matching function found for: '%s'."), String(funcname->name)));
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
@@ -5391,6 +5396,16 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
|
|
//being sampler, this either comes from a uniform
|
|
//being sampler, this either comes from a uniform
|
|
ShaderNode::Uniform *u = &shader->uniforms[varname];
|
|
ShaderNode::Uniform *u = &shader->uniforms[varname];
|
|
ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously
|
|
ERR_CONTINUE(u->type != call_function->arguments[i].type); //this should have been validated previously
|
|
|
|
+
|
|
|
|
+ if (RendererCompositor::get_singleton()->is_xr_enabled() && is_custom_func) {
|
|
|
|
+ ShaderNode::Uniform::Hint hint = u->hint;
|
|
|
|
+
|
|
|
|
+ if (hint == ShaderNode::Uniform::HINT_DEPTH_TEXTURE || hint == ShaderNode::Uniform::HINT_SCREEN_TEXTURE || hint == ShaderNode::Uniform::HINT_NORMAL_ROUGHNESS_TEXTURE) {
|
|
|
|
+ _set_error(vformat(RTR("Unable to pass a multiview texture sampler as a parameter to custom function. Consider to sample it in the main function and then pass the vector result to it."), get_uniform_hint_name(hint)));
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//propagate
|
|
//propagate
|
|
if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) {
|
|
if (!_propagate_function_call_sampler_uniform_settings(name, i, u->filter, u->repeat)) {
|
|
return nullptr;
|
|
return nullptr;
|