From 6b4e26c479494b79ede05ddfe20e95b811deba43 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Thu, 8 Jan 2026 16:18:01 -0800 Subject: [PATCH] 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. --- servers/rendering/shader_compiler.cpp | 11 +++++++++++ servers/rendering/shader_language.cpp | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index e367b26df23..9324d4f71ec 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -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; diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index b772fa417de..c577e5c7863 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -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;