diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-13 02:49:25 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-13 04:08:11 +0300 |
commit | 41e6f9bd437cb5f23dd6a8ad41c6142b0520f65d (patch) | |
tree | 6bdc12625e7ed2f47d3ac93fa3362a514abc8d8a /intern/cycles/kernel | |
parent | e2736afdbefde486bc051627dbedeaa28cdb972e (diff) |
Cycles: Add control for sun intensity in Sky Texture and change altitude to km
Differential Revision: https://developer.blender.org/D8091
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/shaders/node_sky_texture.osl | 34 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_sky.h | 10 |
2 files changed, 24 insertions, 20 deletions
diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl index 20d379939ab..cbb37effc9d 100644 --- a/intern/cycles/kernel/shaders/node_sky_texture.osl +++ b/intern/cycles/kernel/shaders/node_sky_texture.osl @@ -127,12 +127,13 @@ float precise_angle(vector a, vector b) return 2.0 * atan2(length(a - b), length(a + b)); } -color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) +color sky_radiance_nishita(vector dir, float nishita_data[10], string filename) { /* definitions */ float sun_elevation = nishita_data[6]; float sun_rotation = nishita_data[7]; float angular_diameter = nishita_data[8]; + float sun_intensity = nishita_data[9]; int sun_disc = angular_diameter > 0; float alpha = 1.0; color xyz; @@ -158,13 +159,13 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) if (sun_elevation - half_angular > 0.0) { if ((sun_elevation + half_angular) > 0.0) { y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5; - xyz = mix(pixel_bottom, pixel_top, y); + xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity; } } else { if (sun_elevation + half_angular > 0.0) { y = dir_elevation / (sun_elevation + half_angular); - xyz = mix(pixel_bottom, pixel_top, y); + xyz = mix(pixel_bottom, pixel_top, y) * sun_intensity; } } /* limb darkening, coefficient is 0.6f */ @@ -206,19 +207,20 @@ color sky_radiance_nishita(vector dir, float nishita_data[9], string filename) return xyz_to_rgb(xyz[0], xyz[1], xyz[2]) * 120000.0; } -shader node_sky_texture(int use_mapping = 0, - matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), - vector Vector = P, - string type = "hosek_wilkie", - float theta = 0.0, - float phi = 0.0, - string filename = "", - color radiance = color(0.0, 0.0, 0.0), - float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - float nishita_data[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - output color Color = color(0.0, 0.0, 0.0)) +shader node_sky_texture( + int use_mapping = 0, + matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), + vector Vector = P, + string type = "hosek_wilkie", + float theta = 0.0, + float phi = 0.0, + string filename = "", + color radiance = color(0.0, 0.0, 0.0), + float config_x[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float config_y[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float config_z[9] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + float nishita_data[10] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + output color Color = color(0.0, 0.0, 0.0)) { vector p = Vector; diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h index 214c0cd1a9a..45b76fab007 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 */ @@ -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 */ @@ -301,7 +302,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 +318,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); |