Add compatibility handler to RADIANCE in sky shaders since the type was changed.
It was a textureCube, but now it is a texture2D. For compatibility purposes we need to continue exposing a cube texture. So we need to add this scaffolding to properly sample from it.
This commit is contained in:
parent
6f15a05b6c
commit
6b4e26c479
2 changed files with 17 additions and 1 deletions
|
|
@ -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;
|
||||
|
||||
|
|
@ -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());
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue