Skip to content

Commit 57eb762

Browse files
committed
Add option to enable HDR rendering in 2D
This is needed to allow 2D to fully make use of 3D effects (e.g. glow), and can be used to substantially improve quality of 2D rendering at the cost of performance Additionally, the 2D rendering pipeline is done in linear space (we skip linear_to_srgb conversion in 3D tonemapping) so the entire Viewport can be kept linear. This is necessary for proper HDR screen support in the future.
1 parent 237bd0a commit 57eb762

40 files changed

+309
-105
lines changed

doc/classes/ProjectSettings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -2650,6 +2650,9 @@
26502650
<member name="rendering/textures/webp_compression/lossless_compression_factor" type="float" setter="" getter="" default="25">
26512651
The default compression factor for lossless WebP. Decompression speed is mostly unaffected by the compression factor. Supported values are 0 to 100.
26522652
</member>
2653+
<member name="rendering/viewport/hdr_2d" type="bool" setter="" getter="" default="false">
2654+
If [code]true[/code], enables [member Viewport.use_hdr_2d] on the root viewport. This allows 2D rendering to take advantage of effects requiring high dynamic range (e.g. 2D glow).
2655+
</member>
26532656
<member name="rendering/viewport/transparent_background" type="bool" setter="" getter="" default="false">
26542657
If [code]true[/code], enables [member Viewport.transparent_bg] on the root viewport. This allows per-pixel transparency to be effective after also enabling [member display/window/size/transparent] and [member display/window/per_pixel_transparency/allowed].
26552658
</member>

doc/classes/RenderingServer.xml

+9
Original file line numberDiff line numberDiff line change
@@ -3756,6 +3756,15 @@
37563756
If [code]true[/code], enables debanding on the specified viewport. Equivalent to [member ProjectSettings.rendering/anti_aliasing/quality/use_debanding].
37573757
</description>
37583758
</method>
3759+
<method name="viewport_set_use_hdr_2d">
3760+
<return type="void" />
3761+
<param index="0" name="viewport" type="RID" />
3762+
<param index="1" name="enabled" type="bool" />
3763+
<description>
3764+
If [code]true[/code], 2D rendering will use a high dynamic range (HDR) format framebuffer matching the bit depth of the 3D framebuffer. When using the Forward+ renderer this will be a [code]RGBA16[/code] framebuffer, while when using the Mobile renderer it will be a [code]RGB10_A2[/code] framebuffer. Additionally, 2D rendering will take place in linear color space and will be converted to sRGB space immediately before blitting to the screen (if the Viewport is attached to the screen). Practically speaking, this means that the end result of the Viewport will not be clamped into the [code]0-1[/code] range and can be used in 3D rendering without color space adjustments. This allows 2D rendering to take advantage of effects requiring high dynamic range (e.g. 2D glow) as well as substantially improves the appearance of effects requiring highly detailed gradients. This setting has the same effect as [member Viewport.use_hdr_2d].
3765+
[b]Note:[/b] This setting will have no effect when using the GL Compatibility renderer as the GL Compatibility renderer always renders in low dynamic range for performance reasons.
3766+
</description>
3767+
</method>
37593768
<method name="viewport_set_use_occlusion_culling">
37603769
<return type="void" />
37613770
<param index="0" name="viewport" type="RID" />

doc/classes/Viewport.xml

+4
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@
348348
If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is [i]not[/i] affected by debanding unless the [member Environment.background_mode] is [constant Environment.BG_CANVAS]. See also [member ProjectSettings.rendering/anti_aliasing/quality/use_debanding].
349349
In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger.
350350
</member>
351+
<member name="use_hdr_2d" type="bool" setter="set_use_hdr_2d" getter="is_using_hdr_2d" default="false">
352+
If [code]true[/code], 2D rendering will use an high dynamic range (HDR) format framebuffer matching the bit depth of the 3D framebuffer. When using the Forward+ renderer this will be a [code]RGBA16[/code] framebuffer, while when using the Mobile renderer it will be a [code]RGB10_A2[/code] framebuffer. Additionally, 2D rendering will take place in linear color space and will be converted to sRGB space immediately before blitting to the screen (if the Viewport is attached to the screen). Practically speaking, this means that the end result of the Viewport will not be clamped into the [code]0-1[/code] range and can be used in 3D rendering without color space adjustments. This allows 2D rendering to take advantage of effects requiring high dynamic range (e.g. 2D glow) as well as substantially improves the appearance of effects requiring highly detailed gradients.
353+
[b]Note:[/b] This setting will have no effect when using the GL Compatibility renderer as the GL Compatibility renderer always renders in low dynamic range for performance reasons.
354+
</member>
351355
<member name="use_occlusion_culling" type="bool" setter="set_use_occlusion_culling" getter="is_using_occlusion_culling" default="false">
352356
If [code]true[/code], [OccluderInstance3D] nodes will be usable for occlusion culling in 3D for this viewport. For the root viewport, [member ProjectSettings.rendering/occlusion_culling/use_occlusion_culling] must be set to [code]true[/code] instead.
353357
[b]Note:[/b] Enabling occlusion culling has a cost on the CPU. Only enable occlusion culling if you actually plan to use it, and think whether your scene can actually benefit from occlusion culling. Large, open scenes with few or no objects blocking the view will generally not benefit much from occlusion culling. Large open scenes generally benefit more from mesh LOD and visibility ranges ([member GeometryInstance3D.visibility_range_begin] and [member GeometryInstance3D.visibility_range_end]) compared to occlusion culling.

drivers/gles3/shaders/canvas_uniforms_inc.glsl

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define FLAGS_CLIP_RECT_UV uint(1 << 9)
1414
#define FLAGS_TRANSPOSE_RECT uint(1 << 10)
15-
#define FLAGS_USING_LIGHT_MASK uint(1 << 11)
15+
// (1 << 11) is for FLAGS_CONVERT_ATTRIBUTES_TO_LINEAR in RD backends, unused here.
1616
#define FLAGS_NINEPACH_DRAW_CENTER uint(1 << 12)
1717
#define FLAGS_USING_PARTICLES uint(1 << 13)
1818

drivers/gles3/storage/texture_storage.h

+2
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ class TextureStorage : public RendererTextureStorage {
629629
void render_target_clear_used(RID p_render_target);
630630
virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override;
631631
virtual RS::ViewportMSAA render_target_get_msaa(RID p_render_target) const override;
632+
virtual void render_target_set_use_hdr(RID p_render_target, bool p_use_hdr_2d) override {}
633+
virtual bool render_target_is_using_hdr(RID p_render_target) const override { return false; }
632634

633635
// new
634636
void render_target_set_as_unused(RID p_render_target) override {

editor/editor_node.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,9 @@ void EditorNode::_update_from_settings() {
496496
Viewport::MSAA msaa = Viewport::MSAA(int(GLOBAL_GET("rendering/anti_aliasing/quality/msaa_2d")));
497497
scene_root->set_msaa_2d(msaa);
498498

499+
bool use_hdr_2d = GLOBAL_GET("rendering/viewport/hdr_2d");
500+
scene_root->set_use_hdr_2d(use_hdr_2d);
501+
499502
float mesh_lod_threshold = GLOBAL_GET("rendering/mesh_lod/lod_change/threshold_pixels");
500503
scene_root->set_mesh_lod_threshold(mesh_lod_threshold);
501504

editor/plugins/node_3d_editor_plugin.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,9 @@ void Node3DEditorViewport::_project_settings_changed() {
26582658
const bool transparent_background = GLOBAL_GET("rendering/viewport/transparent_background");
26592659
viewport->set_transparent_background(transparent_background);
26602660

2661+
const bool use_hdr_2d = GLOBAL_GET("rendering/viewport/hdr_2d");
2662+
viewport->set_use_hdr_2d(use_hdr_2d);
2663+
26612664
const bool use_debanding = GLOBAL_GET("rendering/anti_aliasing/quality/use_debanding");
26622665
viewport->set_use_debanding(use_debanding);
26632666

scene/main/scene_tree.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,9 @@ SceneTree::SceneTree() {
17331733
const bool transparent_background = GLOBAL_DEF("rendering/viewport/transparent_background", false);
17341734
root->set_transparent_background(transparent_background);
17351735

1736+
const bool use_hdr_2d = GLOBAL_DEF_RST_BASIC("rendering/viewport/hdr_2d", false);
1737+
root->set_use_hdr_2d(use_hdr_2d);
1738+
17361739
const int ssaa_mode = GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "rendering/anti_aliasing/quality/screen_space_aa", PROPERTY_HINT_ENUM, "Disabled (Fastest),FXAA (Fast)"), 0);
17371740
root->set_screen_space_aa(Viewport::ScreenSpaceAA(ssaa_mode));
17381741

scene/main/viewport.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,17 @@ bool Viewport::has_transparent_background() const {
11771177
return transparent_bg;
11781178
}
11791179

1180+
void Viewport::set_use_hdr_2d(bool p_enable) {
1181+
ERR_MAIN_THREAD_GUARD;
1182+
use_hdr_2d = p_enable;
1183+
RS::get_singleton()->viewport_set_use_hdr_2d(viewport, p_enable);
1184+
}
1185+
1186+
bool Viewport::is_using_hdr_2d() const {
1187+
ERR_READ_THREAD_GUARD_V(false);
1188+
return use_hdr_2d;
1189+
}
1190+
11801191
void Viewport::set_world_2d(const Ref<World2D> &p_world_2d) {
11811192
ERR_MAIN_THREAD_GUARD;
11821193
if (world_2d == p_world_2d) {
@@ -4271,6 +4282,8 @@ void Viewport::_bind_methods() {
42714282
ClassDB::bind_method(D_METHOD("get_visible_rect"), &Viewport::get_visible_rect);
42724283
ClassDB::bind_method(D_METHOD("set_transparent_background", "enable"), &Viewport::set_transparent_background);
42734284
ClassDB::bind_method(D_METHOD("has_transparent_background"), &Viewport::has_transparent_background);
4285+
ClassDB::bind_method(D_METHOD("set_use_hdr_2d", "enable"), &Viewport::set_use_hdr_2d);
4286+
ClassDB::bind_method(D_METHOD("is_using_hdr_2d"), &Viewport::is_using_hdr_2d);
42744287

42754288
ClassDB::bind_method(D_METHOD("set_msaa_2d", "msaa"), &Viewport::set_msaa_2d);
42764289
ClassDB::bind_method(D_METHOD("get_msaa_2d"), &Viewport::get_msaa_2d);
@@ -4435,6 +4448,8 @@ void Viewport::_bind_methods() {
44354448
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_occlusion_culling"), "set_use_occlusion_culling", "is_using_occlusion_culling");
44364449
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "mesh_lod_threshold", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_mesh_lod_threshold", "get_mesh_lod_threshold");
44374450
ADD_PROPERTY(PropertyInfo(Variant::INT, "debug_draw", PROPERTY_HINT_ENUM, "Disabled,Unshaded,Lighting,Overdraw,Wireframe"), "set_debug_draw", "get_debug_draw");
4451+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hdr_2d"), "set_use_hdr_2d", "is_using_hdr_2d");
4452+
44384453
#ifndef _3D_DISABLED
44394454
ADD_GROUP("Scaling 3D", "");
44404455
ADD_PROPERTY(PropertyInfo(Variant::INT, "scaling_3d_mode", PROPERTY_HINT_ENUM, "Bilinear (Fastest),FSR 1.0 (Fast)"), "set_scaling_3d_mode", "get_scaling_3d_mode");

scene/main/viewport.h

+4
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class Viewport : public Node {
243243
Rect2 last_vp_rect;
244244

245245
bool transparent_bg = false;
246+
bool use_hdr_2d = false;
246247
bool gen_mipmaps = false;
247248

248249
bool snap_controls_to_pixels = true;
@@ -526,6 +527,9 @@ class Viewport : public Node {
526527
void set_transparent_background(bool p_enable);
527528
bool has_transparent_background() const;
528529

530+
void set_use_hdr_2d(bool p_enable);
531+
bool is_using_hdr_2d() const;
532+
529533
Ref<ViewportTexture> get_texture() const;
530534

531535
void set_positional_shadow_atlas_size(int p_size);

servers/rendering/dummy/storage/texture_storage.h

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ class TextureStorage : public RendererTextureStorage {
177177
virtual void render_target_set_as_unused(RID p_render_target) override {}
178178
virtual void render_target_set_msaa(RID p_render_target, RS::ViewportMSAA p_msaa) override {}
179179
virtual RS::ViewportMSAA render_target_get_msaa(RID p_render_target) const override { return RS::VIEWPORT_MSAA_DISABLED; }
180+
virtual void render_target_set_use_hdr(RID p_render_target, bool p_use_hdr_2d) override {}
181+
virtual bool render_target_is_using_hdr(RID p_render_target) const override { return false; }
180182

181183
virtual void render_target_request_clear(RID p_render_target, const Color &p_clear_color) override {}
182184
virtual bool render_target_is_clear_requested(RID p_render_target) override { return false; }

servers/rendering/renderer_rd/effects/tone_mapper.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ void ToneMapper::tonemapper(RID p_source_color, RID p_dst_framebuffer, const Ton
8989

9090
memset(&tonemap.push_constant, 0, sizeof(TonemapPushConstant));
9191

92-
tonemap.push_constant.use_bcs = p_settings.use_bcs;
92+
tonemap.push_constant.flags |= p_settings.use_bcs ? TONEMAP_FLAG_USE_BCS : 0;
9393
tonemap.push_constant.bcs[0] = p_settings.brightness;
9494
tonemap.push_constant.bcs[1] = p_settings.contrast;
9595
tonemap.push_constant.bcs[2] = p_settings.saturation;
9696

97-
tonemap.push_constant.use_glow = p_settings.use_glow;
97+
tonemap.push_constant.flags |= p_settings.use_glow ? TONEMAP_FLAG_USE_GLOW : 0;
9898
tonemap.push_constant.glow_intensity = p_settings.glow_intensity;
9999
tonemap.push_constant.glow_map_strength = p_settings.glow_map_strength;
100100
tonemap.push_constant.glow_levels[0] = p_settings.glow_levels[0]; // clean this up to just pass by pointer or something
@@ -114,19 +114,21 @@ void ToneMapper::tonemapper(RID p_source_color, RID p_dst_framebuffer, const Ton
114114
}
115115

116116
tonemap.push_constant.tonemapper = p_settings.tonemap_mode;
117-
tonemap.push_constant.use_auto_exposure = p_settings.use_auto_exposure;
117+
tonemap.push_constant.flags |= p_settings.use_auto_exposure ? TONEMAP_FLAG_USE_AUTO_EXPOSURE : 0;
118118
tonemap.push_constant.exposure = p_settings.exposure;
119119
tonemap.push_constant.white = p_settings.white;
120120
tonemap.push_constant.auto_exposure_scale = p_settings.auto_exposure_scale;
121121
tonemap.push_constant.luminance_multiplier = p_settings.luminance_multiplier;
122122

123-
tonemap.push_constant.use_color_correction = p_settings.use_color_correction;
123+
tonemap.push_constant.flags |= p_settings.use_color_correction ? TONEMAP_FLAG_USE_COLOR_CORRECTION : 0;
124124

125-
tonemap.push_constant.use_fxaa = p_settings.use_fxaa;
126-
tonemap.push_constant.use_debanding = p_settings.use_debanding;
125+
tonemap.push_constant.flags |= p_settings.use_fxaa ? TONEMAP_FLAG_USE_FXAA : 0;
126+
tonemap.push_constant.flags |= p_settings.use_debanding ? TONEMAP_FLAG_USE_DEBANDING : 0;
127127
tonemap.push_constant.pixel_size[0] = 1.0 / p_settings.texture_size.x;
128128
tonemap.push_constant.pixel_size[1] = 1.0 / p_settings.texture_size.y;
129129

130+
tonemap.push_constant.flags |= p_settings.convert_to_srgb ? TONEMAP_FLAG_CONVERT_TO_SRGB : 0;
131+
130132
if (p_settings.view_count > 1) {
131133
// Use MULTIVIEW versions
132134
mode += 6;
@@ -185,13 +187,13 @@ void ToneMapper::tonemapper(RD::DrawListID p_subpass_draw_list, RID p_source_col
185187

186188
memset(&tonemap.push_constant, 0, sizeof(TonemapPushConstant));
187189

188-
tonemap.push_constant.use_bcs = p_settings.use_bcs;
190+
tonemap.push_constant.flags |= p_settings.use_bcs ? TONEMAP_FLAG_USE_BCS : 0;
189191
tonemap.push_constant.bcs[0] = p_settings.brightness;
190192
tonemap.push_constant.bcs[1] = p_settings.contrast;
191193
tonemap.push_constant.bcs[2] = p_settings.saturation;
192194

193195
ERR_FAIL_COND_MSG(p_settings.use_glow, "Glow is not supported when using subpasses.");
194-
tonemap.push_constant.use_glow = p_settings.use_glow;
196+
tonemap.push_constant.flags |= p_settings.use_glow ? TONEMAP_FLAG_USE_GLOW : 0;
195197

196198
int mode = p_settings.use_1d_color_correction ? TONEMAP_MODE_SUBPASS_1D_LUT : TONEMAP_MODE_SUBPASS;
197199
if (p_settings.view_count > 1) {
@@ -200,16 +202,18 @@ void ToneMapper::tonemapper(RD::DrawListID p_subpass_draw_list, RID p_source_col
200202
}
201203

202204
tonemap.push_constant.tonemapper = p_settings.tonemap_mode;
203-
tonemap.push_constant.use_auto_exposure = p_settings.use_auto_exposure;
205+
tonemap.push_constant.flags |= p_settings.use_auto_exposure ? TONEMAP_FLAG_USE_AUTO_EXPOSURE : 0;
204206
tonemap.push_constant.exposure = p_settings.exposure;
205207
tonemap.push_constant.white = p_settings.white;
206208
tonemap.push_constant.auto_exposure_scale = p_settings.auto_exposure_scale;
207209

208-
tonemap.push_constant.use_color_correction = p_settings.use_color_correction;
210+
tonemap.push_constant.flags |= p_settings.use_color_correction ? TONEMAP_FLAG_USE_COLOR_CORRECTION : 0;
209211

210-
tonemap.push_constant.use_debanding = p_settings.use_debanding;
212+
tonemap.push_constant.flags |= p_settings.use_debanding ? TONEMAP_FLAG_USE_DEBANDING : 0;
211213
tonemap.push_constant.luminance_multiplier = p_settings.luminance_multiplier;
212214

215+
tonemap.push_constant.flags |= p_settings.convert_to_srgb ? TONEMAP_FLAG_CONVERT_TO_SRGB : 0;
216+
213217
RID default_sampler = material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
214218
RID default_mipmap_sampler = material_storage->sampler_rd_get_default(RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED);
215219

servers/rendering/renderer_rd/effects/tone_mapper.h

+16-9
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,23 @@ class ToneMapper {
5959
TONEMAP_MODE_MAX
6060
};
6161

62+
enum {
63+
TONEMAP_FLAG_USE_BCS = (1 << 0),
64+
TONEMAP_FLAG_USE_GLOW = (1 << 1),
65+
TONEMAP_FLAG_USE_AUTO_EXPOSURE = (1 << 2),
66+
TONEMAP_FLAG_USE_COLOR_CORRECTION = (1 << 3),
67+
TONEMAP_FLAG_USE_FXAA = (1 << 4),
68+
TONEMAP_FLAG_USE_DEBANDING = (1 << 5),
69+
TONEMAP_FLAG_CONVERT_TO_SRGB = (1 << 6),
70+
};
71+
6272
struct TonemapPushConstant {
6373
float bcs[3]; // 12 - 12
64-
uint32_t use_bcs; // 4 - 16
74+
uint32_t flags; // 4 - 16
6575

66-
uint32_t use_glow; // 4 - 20
67-
uint32_t use_auto_exposure; // 4 - 24
68-
uint32_t use_color_correction; // 4 - 28
69-
uint32_t tonemapper; // 4 - 32
76+
float pixel_size[2]; // 8 - 24
77+
uint32_t tonemapper; // 4 - 28
78+
uint32_t pad; // 4 - 32
7079

7180
uint32_t glow_texture_size[2]; // 8 - 40
7281
float glow_intensity; // 4 - 44
@@ -79,10 +88,6 @@ class ToneMapper {
7988
float white; // 4 - 88
8089
float auto_exposure_scale; // 4 - 92
8190
float luminance_multiplier; // 4 - 96
82-
83-
float pixel_size[2]; // 8 - 104
84-
uint32_t use_fxaa; // 4 - 108
85-
uint32_t use_debanding; // 4 - 112
8691
};
8792

8893
/* tonemap actually writes to a framebuffer, which is
@@ -141,6 +146,8 @@ class ToneMapper {
141146
bool use_debanding = false;
142147
Vector2i texture_size;
143148
uint32_t view_count = 1;
149+
150+
bool convert_to_srgb = false;
144151
};
145152

146153
void tonemapper(RID p_source_color, RID p_dst_framebuffer, const TonemapSettings &p_settings);

servers/rendering/renderer_rd/environment/fog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Vector3 Fog::fog_volume_get_size(RID p_fog_volume) const {
143143
bool Fog::FogMaterialData::update_parameters(const HashMap<StringName, Variant> &p_parameters, bool p_uniform_dirty, bool p_textures_dirty) {
144144
uniform_set_updated = true;
145145

146-
return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, Fog::get_singleton()->volumetric_fog.shader.version_get_shader(shader_data->version, 0), VolumetricFogShader::FogSet::FOG_SET_MATERIAL, true);
146+
return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, Fog::get_singleton()->volumetric_fog.shader.version_get_shader(shader_data->version, 0), VolumetricFogShader::FogSet::FOG_SET_MATERIAL, true, true);
147147
}
148148

149149
Fog::FogMaterialData::~FogMaterialData() {

servers/rendering/renderer_rd/environment/sky.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool SkyRD::SkyMaterialData::update_parameters(const HashMap<StringName, Variant
185185

186186
uniform_set_updated = true;
187187

188-
return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, scene_singleton->sky.sky_shader.shader.version_get_shader(shader_data->version, 0), SKY_SET_MATERIAL, true);
188+
return update_parameters_uniform_set(p_parameters, p_uniform_dirty, p_textures_dirty, shader_data->uniforms, shader_data->ubo_offsets.ptr(), shader_data->texture_uniforms, shader_data->default_texture_params, shader_data->ubo_size, uniform_set, scene_singleton->sky.sky_shader.shader.version_get_shader(shader_data->version, 0), SKY_SET_MATERIAL, true, true);
189189
}
190190

191191
SkyRD::SkyMaterialData::~SkyMaterialData() {

servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1769,7 +1769,8 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co
17691769
case RS::ENV_BG_CANVAS: {
17701770
if (!is_reflection_probe) {
17711771
RID texture = RendererRD::TextureStorage::get_singleton()->render_target_get_rd_texture(rb->get_render_target());
1772-
copy_effects->copy_to_fb_rect(texture, color_only_framebuffer, Rect2i(), false, false, false, false, RID(), false, false, true);
1772+
bool convert_to_linear = !RendererRD::TextureStorage::get_singleton()->render_target_is_using_hdr(rb->get_render_target());
1773+
copy_effects->copy_to_fb_rect(texture, color_only_framebuffer, Rect2i(), false, false, false, false, RID(), false, false, convert_to_linear);
17731774
}
17741775
keep_color = true;
17751776
} break;

0 commit comments

Comments
 (0)