forked from bartvdbraak/blender
Fix T79052: Cycles new sky texture fails with sun size zero
Clamp to a minimum angle to avoid precision issues.
This commit is contained in:
parent
c7a7a38b65
commit
2b896fc481
@ -137,7 +137,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
|
||||
float sun_rotation = nishita_data[7];
|
||||
float angular_diameter = nishita_data[8];
|
||||
float sun_intensity = nishita_data[9];
|
||||
bool sun_disc = (angular_diameter > 0.0f);
|
||||
bool sun_disc = (angular_diameter >= 0.0f);
|
||||
float3 xyz;
|
||||
/* convert dir to spherical coordinates */
|
||||
float2 direction = direction_to_spherical(dir);
|
||||
|
@ -634,7 +634,7 @@ void LightManager::device_update_background(Device *device,
|
||||
sun_direction = transform_direction(&sky_transform, sun_direction);
|
||||
|
||||
/* Pack sun direction and size. */
|
||||
float half_angle = sky->sun_size * 0.5f;
|
||||
float half_angle = sky->get_sun_size() * 0.5f;
|
||||
kbackground->sun = make_float4(
|
||||
sun_direction.x, sun_direction.y, sun_direction.z, half_angle);
|
||||
|
||||
|
@ -776,7 +776,7 @@ static void sky_texture_precompute_nishita(SunSky *sunsky,
|
||||
sunsky->nishita_data[5] = pixel_top[2];
|
||||
sunsky->nishita_data[6] = sun_elevation;
|
||||
sunsky->nishita_data[7] = sun_rotation;
|
||||
sunsky->nishita_data[8] = sun_disc ? sun_size : 0.0f;
|
||||
sunsky->nishita_data[8] = sun_disc ? sun_size : -1.0f;
|
||||
sunsky->nishita_data[9] = sun_intensity;
|
||||
}
|
||||
|
||||
@ -834,7 +834,7 @@ void SkyTextureNode::compile(SVMCompiler &compiler)
|
||||
|
||||
sky_texture_precompute_nishita(&sunsky,
|
||||
sun_disc,
|
||||
sun_size,
|
||||
get_sun_size(),
|
||||
sun_intensity,
|
||||
sun_elevation,
|
||||
sun_rotation,
|
||||
@ -930,7 +930,7 @@ void SkyTextureNode::compile(OSLCompiler &compiler)
|
||||
|
||||
sky_texture_precompute_nishita(&sunsky,
|
||||
sun_disc,
|
||||
sun_size,
|
||||
get_sun_size(),
|
||||
sun_intensity,
|
||||
sun_elevation,
|
||||
sun_rotation,
|
||||
|
@ -179,6 +179,12 @@ class SkyTextureNode : public TextureNode {
|
||||
float ozone_density;
|
||||
float3 vector;
|
||||
ImageHandle handle;
|
||||
|
||||
float get_sun_size()
|
||||
{
|
||||
/* Clamping for numerical precision. */
|
||||
return fmaxf(sun_size, 0.0005f);
|
||||
}
|
||||
};
|
||||
|
||||
class OutputNode : public ShaderNode {
|
||||
|
Loading…
Reference in New Issue
Block a user