1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Use half float precision buffer for 3D when HDR2D is enabled

This is necessary for Environment effects like Glow to work correctly.
This commit is contained in:
clayjohn
2025-08-25 14:03:31 -07:00
parent c7b1767560
commit f61ee7bdf6
13 changed files with 60 additions and 53 deletions

View File

@@ -142,6 +142,8 @@ float sc_luminance_multiplier() {
return 1.0;
}
#define REFLECTION_MULTIPLIER 1.0
#define SDFGI_MAX_CASCADES 8
/* Set 0: Base Pass (never changes) */

View File

@@ -1563,7 +1563,7 @@ void main() {
indirect_specular_light = hvec3(textureLod(samplerCube(radiance_cubemap, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec3(ref_vec), lod).rgb);
#endif //USE_RADIANCE_CUBEMAP_ARRAY
indirect_specular_light *= sc_luminance_multiplier();
indirect_specular_light *= REFLECTION_MULTIPLIER;
indirect_specular_light *= half(scene_data.IBL_exposure_normalization);
indirect_specular_light *= horizon * horizon;
indirect_specular_light *= half(scene_data.ambient_light_color_energy.a);
@@ -1585,7 +1585,7 @@ void main() {
#else
hvec3 cubemap_ambient = hvec3(textureLod(samplerCube(radiance_cubemap, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), ambient_dir, MAX_ROUGHNESS_LOD).rgb);
#endif //USE_RADIANCE_CUBEMAP_ARRAY
cubemap_ambient *= sc_luminance_multiplier();
cubemap_ambient *= REFLECTION_MULTIPLIER;
cubemap_ambient *= half(scene_data.IBL_exposure_normalization);
ambient_light = mix(ambient_light, cubemap_ambient * half(scene_data.ambient_light_color_energy.a), half(scene_data.ambient_color_sky_mix));
}

View File

@@ -215,6 +215,10 @@ half sc_luminance_multiplier() {
return half(sc_packed_2());
}
// Like the luminance multiplier, but it is only for sky and reflection probes
// since they are always LDR.
#define REFLECTION_MULTIPLIER half(2.0)
/* Set 0: Base Pass (never changes) */
#include "../light_data_inc.glsl"

View File

@@ -957,7 +957,7 @@ void reflection_process(uint ref_index, vec3 vertex, hvec3 ref_vec, hvec3 normal
hvec4 reflection;
half reflection_blend = max(half(0.0), blend - reflection_accum.a);
reflection.rgb = hvec3(textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_ref_vec, reflections.data[ref_index].index), sqrt(roughness) * MAX_ROUGHNESS_LOD).rgb) * sc_luminance_multiplier();
reflection.rgb = hvec3(textureLod(samplerCubeArray(reflection_atlas, DEFAULT_SAMPLER_LINEAR_WITH_MIPMAPS_CLAMP), vec4(local_ref_vec, reflections.data[ref_index].index), sqrt(roughness) * MAX_ROUGHNESS_LOD).rgb) * REFLECTION_MULTIPLIER;
reflection.rgb *= half(reflections.data[ref_index].exposure_normalization);
reflection.a = reflection_blend;