Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions servers/rendering/shader_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene

bool is_texture_func = false;
bool is_screen_texture = false;
bool is_radiance_texture = false;
bool texture_func_no_uv = false;
bool texture_func_returns_data = false;

Expand Down Expand Up @@ -1314,10 +1315,16 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
}
}

if (texture_uniform == SNAME("RADIANCE")) {
is_radiance_texture = true;
}

String data_type_name = "";
if (actions.check_multiview_samplers && (is_screen_texture || is_depth_texture || is_normal_roughness_texture)) {
data_type_name = "multiviewSampler";
multiview_uv_needed = true;
} else if (is_radiance_texture) {
data_type_name = "sampler2D";
} else {
data_type_name = ShaderLanguage::get_datatype_name(onode->arguments[i]->get_datatype());
}
Expand Down Expand Up @@ -1350,6 +1357,10 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene
// UV coordinate after using color, depth or normal roughness texture.
node_code = "multiview_uv(" + node_code + ".xy)";

code += node_code;
} else if (is_radiance_texture && !texture_func_no_uv && i == 2) {
node_code = "vec3_to_oct_with_border(" + node_code + ", params.border_size)";

code += node_code;
} else {
code += node_code;
Expand Down
7 changes: 6 additions & 1 deletion servers/rendering/shader_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6473,7 +6473,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
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)));
_set_error(vformat(RTR("Unable to pass a multiview texture sampler as a parameter to a custom function. Consider sampling it in the main function and then passing the vector result to the custom function."), get_uniform_hint_name(hint)));
return nullptr;
}
}
Expand All @@ -6483,6 +6483,11 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
return nullptr;
}
} else if (p_function_info.built_ins.has(varname)) {
if (is_custom_func && varname == SNAME("RADIANCE")) {
_set_error(RTR("Unable to pass RADIANCE texture sampler as a parameter to a custom function. Consider sampling it in the main function and then passing the vector result to the custom function."));
return nullptr;
}

//a built-in
if (!_propagate_function_call_sampler_builtin_reference(name, i, varname)) {
return nullptr;
Expand Down