Skip to content

Commit a77a28c

Browse files
committed
Merge pull request godotengine#101971 from clayjohn/sky-light-size-fix
Pass angular diameter into light size constants for sky shaders.
2 parents 0fb0804 + 74989c6 commit a77a28c

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

drivers/gles3/rasterizer_scene_gles3.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -708,12 +708,7 @@ void RasterizerSceneGLES3::_setup_sky(const RenderDataGLES3 *p_render_data, cons
708708
sky_light_data.enabled = true;
709709

710710
float angular_diameter = light_storage->light_get_param(base, RS::LIGHT_PARAM_SIZE);
711-
if (angular_diameter > 0.0) {
712-
angular_diameter = Math::tan(Math::deg_to_rad(angular_diameter));
713-
} else {
714-
angular_diameter = 0.0;
715-
}
716-
sky_light_data.size = angular_diameter;
711+
sky_light_data.size = Math::deg_to_rad(angular_diameter);
717712
sky_globals.directional_light_count++;
718713
if (sky_globals.directional_light_count >= sky_globals.max_directional_lights) {
719714
break;

servers/rendering/renderer_rd/environment/sky.cpp

+1-9
Original file line numberDiff line numberDiff line change
@@ -1093,15 +1093,7 @@ void SkyRD::setup_sky(const RenderDataRD *p_render_data, const Size2i p_screen_s
10931093
sky_light_data.enabled = true;
10941094

10951095
float angular_diameter = light_storage->light_get_param(base, RS::LIGHT_PARAM_SIZE);
1096-
if (angular_diameter > 0.0) {
1097-
// I know tan(0) is 0, but let's not risk it with numerical precision.
1098-
// Technically this will keep expanding until reaching the sun, but all we care about
1099-
// is expanding until we reach the radius of the near plane. There can't be more occluders than that.
1100-
angular_diameter = Math::tan(Math::deg_to_rad(angular_diameter));
1101-
} else {
1102-
angular_diameter = 0.0;
1103-
}
1104-
sky_light_data.size = angular_diameter;
1096+
sky_light_data.size = Math::deg_to_rad(angular_diameter);
11051097
sky_scene_state.ubo.directional_light_count++;
11061098
if (sky_scene_state.ubo.directional_light_count >= sky_scene_state.max_directional_lights) {
11071099
break;

0 commit comments

Comments
 (0)