Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorLukas Stockner <lukas.stockner@freenet.de>2020-07-13 02:51:13 +0300
committerLukas Stockner <lukas.stockner@freenet.de>2020-07-13 04:08:11 +0300
commit192bd2605f2580ee221d2e304fe2dfea573753d5 (patch)
tree42428c34790faed226ad9c12e9f0b529464807a2 /intern
parent41e6f9bd437cb5f23dd6a8ad41c6142b0520f65d (diff)
Cycles: Change precomputed Sky Texture mapping to prioritize the horizon
Differential Revision: https://developer.blender.org/D8091
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/shaders/node_sky_texture.osl5
-rw-r--r--intern/cycles/kernel/svm/svm_sky.h5
-rw-r--r--intern/sky/source/sky_nishita.cpp6
3 files changed, 10 insertions, 6 deletions
diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl
index cbb37effc9d..acb198a9852 100644
--- a/intern/cycles/kernel/shaders/node_sky_texture.osl
+++ b/intern/cycles/kernel/shaders/node_sky_texture.osl
@@ -150,7 +150,7 @@ color sky_radiance_nishita(vector dir, float nishita_data[10], string filename)
/* if ray inside sun disc render it, otherwise render sky */
if (sun_dir_angle < half_angular && sun_disc == 1) {
- /* get 3 pixels data */
+ /* get 2 pixels data */
color pixel_bottom = color(nishita_data[0], nishita_data[1], nishita_data[2]);
color pixel_top = color(nishita_data[3], nishita_data[4], nishita_data[5]);
float y;
@@ -177,7 +177,8 @@ color sky_radiance_nishita(vector dir, float nishita_data[10], string filename)
else {
/* sky interpolation */
float x = (direction[1] + M_PI + sun_rotation) / M_2PI;
- float y = 1.0 - (dir_elevation / M_PI_2);
+ /* more pixels toward horizon compensation */
+ float y = 1.0 - sqrt(dir_elevation / M_PI_2);
if (x > 1.0) {
x = x - 1.0;
}
diff --git a/intern/cycles/kernel/svm/svm_sky.h b/intern/cycles/kernel/svm/svm_sky.h
index 45b76fab007..be2c8ccdacf 100644
--- a/intern/cycles/kernel/svm/svm_sky.h
+++ b/intern/cycles/kernel/svm/svm_sky.h
@@ -152,7 +152,7 @@ ccl_device float3 sky_radiance_nishita(KernelGlobals *kg,
/* 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;
@@ -179,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;
}
diff --git a/intern/sky/source/sky_nishita.cpp b/intern/sky/source/sky_nishita.cpp
index 27286ddecac..a31d4b39f83 100644
--- a/intern/sky/source/sky_nishita.cpp
+++ b/intern/sky/source/sky_nishita.cpp
@@ -287,11 +287,13 @@ void SKY_nishita_skymodel_precompute_texture(float *pixels,
float latitude_step = M_PI_2_F / height;
float longitude_step = M_2PI_F / width;
+ float half_lat_step = latitude_step / 2.0f;
for (int y = start_y; y < end_y; y++) {
- float latitude = latitude_step * y;
+ /* sample more pixels toward the horizon */
+ float latitude = (M_PI_2_F + half_lat_step) * sqr((float)y / height);
- float *pixel_row = pixels + (y * width) * stride;
+ float *pixel_row = pixels + (y * width * stride);
for (int x = 0; x < half_width; x++) {
float longitude = longitude_step * x - M_PI_F;