diff options
Diffstat (limited to 'intern/cycles/kernel/svm/svm_sky.h')
-rw-r--r-- | intern/cycles/kernel/svm/svm_sky.h | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index e877bd9a5c8..be2c8ccdacf 100644 --- a/intern/cycles/kernel/svm/svm_sky.h +++ b/intern/cycles/kernel/svm/svm_sky.h @@ -136,6 +136,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, float sun_elevation = nishita_data[6]; 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); float3 xyz; /* convert dir to spherical coordinates */ @@ -145,13 +146,13 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, if (dir.z >= 0.0f) { /* definitions */ float3 sun_dir = geographical_to_direction(sun_elevation, sun_rotation + M_PI_2_F); - float sun_dir_angle = acos(dot(dir, sun_dir)); + float sun_dir_angle = precise_angle(dir, sun_dir); float half_angular = angular_diameter / 2.0f; float dir_elevation = M_PI_2_F - direction.x; /* if ray inside sun disc render it, otherwise render sky */ if (sun_disc && sun_dir_angle < half_angular) { - /* get 3 pixels data */ + /* get 2 pixels data */ float3 pixel_bottom = make_float3(nishita_data[0], nishita_data[1], nishita_data[2]); float3 pixel_top = make_float3(nishita_data[3], nishita_data[4], nishita_data[5]); float y; @@ -160,13 +161,13 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, if (sun_elevation - half_angular > 0.0f) { if (sun_elevation + half_angular > 0.0f) { y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f; - xyz = interp(pixel_bottom, pixel_top, y); + xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity; } } else { if (sun_elevation + half_angular > 0.0f) { y = dir_elevation / (sun_elevation + half_angular); - xyz = interp(pixel_bottom, pixel_top, y); + xyz = interp(pixel_bottom, pixel_top, y) * sun_intensity; } } /* limb darkening, coefficient is 0.6f */ @@ -178,7 +179,8 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, else { /* sky interpolation */ float x = (direction.y + M_PI_F + sun_rotation) / M_2PI_F; - float y = dir_elevation / M_PI_2_F; + /* more pixels toward horizon compensation */ + float y = safe_sqrtf(dir_elevation / M_PI_2_F); if (x > 1.0f) { x -= 1.0f; } @@ -301,7 +303,7 @@ ccl_device void svm_node_tex_sky( /* Nishita */ else { /* Define variables */ - float nishita_data[9]; + float nishita_data[10]; float4 data = read_node_float(kg, offset); nishita_data[0] = data.x; @@ -317,7 +319,8 @@ ccl_device void svm_node_tex_sky( data = read_node_float(kg, offset); nishita_data[8] = data.x; - uint texture_id = __float_as_uint(data.y); + nishita_data[9] = data.y; + uint texture_id = __float_as_uint(data.z); /* Compute Sky */ f = sky_radiance_nishita(kg, dir, nishita_data, texture_id); |