[Bf-blender-cvs] [192bd2605f2] master: Cycles: Change precomputed Sky Texture mapping to prioritize the horizon

Lukas Stockner noreply at git.blender.org
Mon Jul 13 03:15:38 CEST 2020


Commit: 192bd2605f2580ee221d2e304fe2dfea573753d5
Author: Lukas Stockner
Date:   Mon Jul 13 01:51:13 2020 +0200
Branches: master
https://developer.blender.org/rB192bd2605f2580ee221d2e304fe2dfea573753d5

Cycles: Change precomputed Sky Texture mapping to prioritize the horizon

Differential Revision: https://developer.blender.org/D8091

===================================================================

M	intern/cycles/kernel/shaders/node_sky_texture.osl
M	intern/cycles/kernel/svm/svm_sky.h
M	intern/sky/source/sky_nishita.cpp

===================================================================

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;



More information about the Bf-blender-cvs mailing list