Skip to content

Commit 6232b90

Browse files
committed
Fix incorrect sun disk smoothing
1 parent 8eed1ea commit 6232b90

File tree

8 files changed

+18
-16
lines changed

8 files changed

+18
-16
lines changed

internal/AtmosphereRef.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,9 @@ Ray::Ref::fvec4 Ray::Ref::IntegrateScattering(const atmosphere_params_t &params,
843843
//
844844
if (light_angle > 0.0f && planet_intersection.get<0>() < 0.0f && light_brightness > 0.0f) {
845845
const float cos_theta = cosf(light_angle);
846+
const float smooth_blend_val = fminf(SKY_SUN_BLEND_VAL, 1.0f - cos_theta);
846847
fvec4 sun_disk =
847-
total_transmittance * smoothstep(cos_theta - SKY_SUN_BLEND_VAL, cos_theta + SKY_SUN_BLEND_VAL, costh);
848+
total_transmittance * smoothstep(cos_theta - smooth_blend_val, cos_theta + smooth_blend_val, costh);
848849
// 'de-multiply' by disk area (to get original brightness)
849850
const float radius = tanf(light_angle);
850851
sun_disk /= (PI * radius * radius);

internal/SceneCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void Ray::SceneCommon::SetCamera_nolock(const CameraHandle i, const camera_desc_
179179
#ifdef DUMP_SKY_ENV
180180
extern "C" {
181181
int SaveEXR(const float *data, int width, int height, int components, const int save_as_fp16,
182-
std::string_view outfilename, const char **err);
182+
const char *outfilename, const char **err);
183183
}
184184
#endif
185185

internal/SceneGPU.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ inline void Ray::NS::Scene::Rebuild_SWRT_TLAS_nolock() {
16351635
#ifdef DUMP_SKY_ENV
16361636
extern "C" {
16371637
int SaveEXR(const float *data, int width, int height, int components, const int save_as_fp16,
1638-
std::string_view outfilename, const char **err);
1638+
const char *outfilename, const char **err);
16391639
}
16401640
#endif
16411641

internal/shaders/output/bake_sky.comp.cso.inl

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/shaders/output/bake_sky.comp.spv.inl

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/shaders/output/shade_sky.comp.cso.inl

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/shaders/output/shade_sky.comp.spv.inl

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/shaders/shade_sky.comp.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,8 @@ vec3 IntegrateScattering(vec3 ray_start, const vec3 ray_dir, float ray_length, u
625625
//
626626
if (g_params.light_dir.w > 0.0 && planet_intersection.x < 0.0 && light_brightness > 0.0) {
627627
const float cos_theta = g_params.light_col.w;
628-
const vec3 sun_disk = total_transmittance * smoothstep(cos_theta - SKY_SUN_BLEND_VAL, cos_theta + SKY_SUN_BLEND_VAL, costh);
628+
const float smooth_blend_val = min(SKY_SUN_BLEND_VAL, 1.0 - cos_theta);
629+
const vec3 sun_disk = total_transmittance * smoothstep(cos_theta - smooth_blend_val, cos_theta + smooth_blend_val, costh);
629630
total_radiance += sun_disk * g_params.light_col.xyz;
630631
}
631632

0 commit comments

Comments
 (0)