[Bf-blender-cvs] [9de09220fc5] master: EEVEE: Implement the missing Sky texture

Szymon Ulatowski noreply at git.blender.org
Thu Jul 9 16:48:05 CEST 2020


Commit: 9de09220fc5fcae72bba203c641f67e75eb7ebc5
Author: Szymon Ulatowski
Date:   Thu Jul 9 17:19:52 2020 +0200
Branches: master
https://developer.blender.org/rB9de09220fc5fcae72bba203c641f67e75eb7ebc5

EEVEE: Implement the missing Sky texture

I'm not sure if the Sky was deliberately left out or was just waiting for a
better moment, but so many I was disappointed that Sky in EEVEE is
completely white.

There are already 2 implementations (osl and gpu) so this is the third one.
Looking at other cases it seems that we are not supposed to share sources
between cycles and the rest? So the new util_sky_model files are just
copies of what is already in cycles, except that the data file uses the RGB
variant of the Hosek/Wilkie model, because we output RGB anyway (but can be
easily changed to XYZ if desired - the results are nearly identical).
I am not sure if it is okay to pass 3*9 float values as 3 mat4 uniforms (I
wanted to use mat3 but it does not work).
Also, should I cache the sky model data between renders if the parameters
do not change?

Reviewed By: fclem, brecht

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

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

M	intern/CMakeLists.txt
M	intern/cycles/app/CMakeLists.txt
M	intern/cycles/render/CMakeLists.txt
M	intern/cycles/render/image_sky.cpp
M	intern/cycles/render/nodes.cpp
M	intern/cycles/util/CMakeLists.txt
A	intern/sky/CMakeLists.txt
R094	intern/cycles/util/util_sky_model.h	intern/sky/include/sky_model.h
A	intern/sky/source/sky_float3.h
R096	intern/cycles/util/util_sky_model.cpp	intern/sky/source/sky_model.cpp
R099	intern/cycles/util/util_sky_model_data.h	intern/sky/source/sky_model_data.h
R098	intern/cycles/util/util_sky_nishita.cpp	intern/sky/source/sky_nishita.cpp
M	source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl
M	source/blender/imbuf/IMB_colormanagement.h
M	source/blender/imbuf/intern/colormanagement.c
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/shader/nodes/node_shader_tex_sky.c

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

diff --git a/intern/CMakeLists.txt b/intern/CMakeLists.txt
index fa18f4d793a..0758567bb78 100644
--- a/intern/CMakeLists.txt
+++ b/intern/CMakeLists.txt
@@ -30,6 +30,7 @@ add_subdirectory(opensubdiv)
 add_subdirectory(mikktspace)
 add_subdirectory(glew-mx)
 add_subdirectory(eigen)
+add_subdirectory(sky)
 
 if(WITH_AUDASPACE)
   add_subdirectory(audaspace)
diff --git a/intern/cycles/app/CMakeLists.txt b/intern/cycles/app/CMakeLists.txt
index ef374f91a65..a2b0ed03925 100644
--- a/intern/cycles/app/CMakeLists.txt
+++ b/intern/cycles/app/CMakeLists.txt
@@ -35,7 +35,7 @@ if(WITH_CYCLES_OSL)
 endif()
 
 if(NOT CYCLES_STANDALONE_REPOSITORY)
-  list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc bf_intern_numaapi)
+  list(APPEND LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc bf_intern_numaapi bf_intern_sky)
 endif()
 
 if(WITH_CYCLES_LOGGING)
diff --git a/intern/cycles/render/CMakeLists.txt b/intern/cycles/render/CMakeLists.txt
index e37a0407976..6a1335dc5dd 100644
--- a/intern/cycles/render/CMakeLists.txt
+++ b/intern/cycles/render/CMakeLists.txt
@@ -2,6 +2,7 @@
 set(INC
   ..
   ../../glew-mx
+  ../../sky/include
 )
 
 set(INC_SYS
@@ -92,6 +93,7 @@ set(LIB
   cycles_device
   cycles_subd
   cycles_util
+  bf_intern_sky
 )
 
 if(WITH_CYCLES_OSL)
diff --git a/intern/cycles/render/image_sky.cpp b/intern/cycles/render/image_sky.cpp
index 442e1d7941f..24d4834c2fa 100644
--- a/intern/cycles/render/image_sky.cpp
+++ b/intern/cycles/render/image_sky.cpp
@@ -16,10 +16,11 @@
 
 #include "render/image_sky.h"
 
+#include "sky_model.h"
+
 #include "util/util_image.h"
 #include "util/util_logging.h"
 #include "util/util_path.h"
-#include "util/util_sky_model.h"
 #include "util/util_task.h"
 
 CCL_NAMESPACE_BEGIN
@@ -62,17 +63,17 @@ bool SkyLoader::load_pixels(const ImageMetaData &metadata,
   const int rows_per_task = divide_up(1024, width);
   parallel_for(blocked_range<size_t>(0, height, rows_per_task),
                [&](const blocked_range<size_t> &r) {
-                 nishita_skymodel_precompute_texture(pixel_data,
-                                                     metadata.channels,
-                                                     r.begin(),
-                                                     r.end(),
-                                                     width,
-                                                     height,
-                                                     sun_elevation,
-                                                     altitude_f,
-                                                     air_density,
-                                                     dust_density,
-                                                     ozone_density);
+                 SKY_nishita_skymodel_precompute_texture(pixel_data,
+                                                         metadata.channels,
+                                                         r.begin(),
+                                                         r.end(),
+                                                         width,
+                                                         height,
+                                                         sun_elevation,
+                                                         altitude_f,
+                                                         air_density,
+                                                         dust_density,
+                                                         ozone_density);
                });
 
   return true;
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index ab392839e52..1e09b71b340 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -27,9 +27,10 @@
 #include "render/scene.h"
 #include "render/svm.h"
 
+#include "sky_model.h"
+
 #include "util/util_foreach.h"
 #include "util/util_logging.h"
-#include "util/util_sky_model.h"
 #include "util/util_transform.h"
 
 #include "kernel/svm/svm_color_util.h"
@@ -726,8 +727,8 @@ static void sky_texture_precompute_hosek(SunSky *sunsky,
   float solarElevation = M_PI_2_F - theta;
 
   /* Initialize Sky Model */
-  ArHosekSkyModelState *sky_state;
-  sky_state = arhosek_xyz_skymodelstate_alloc_init(
+  SKY_ArHosekSkyModelState *sky_state;
+  sky_state = SKY_arhosek_xyz_skymodelstate_alloc_init(
       (double)turbidity, (double)ground_albedo, (double)solarElevation);
 
   /* Copy values from sky_state to SunSky */
@@ -741,7 +742,7 @@ static void sky_texture_precompute_hosek(SunSky *sunsky,
   sunsky->radiance_z = (float)sky_state->radiances[2];
 
   /* Free sky_state */
-  arhosekskymodelstate_free(sky_state);
+  SKY_arhosekskymodelstate_free(sky_state);
 }
 
 /* Nishita improved */
@@ -758,7 +759,7 @@ static void sky_texture_precompute_nishita(SunSky *sunsky,
   float pixel_bottom[3];
   float pixel_top[3];
   float altitude_f = (float)altitude;
-  nishita_skymodel_precompute_sun(
+  SKY_nishita_skymodel_precompute_sun(
       sun_elevation, sun_size, altitude_f, air_density, dust_density, pixel_bottom, pixel_top);
   /* send data to svm_sky */
   sunsky->nishita_data[0] = pixel_bottom[0];
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index ad4ea9c86e0..23a47e064e2 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -98,10 +98,6 @@ set(SRC_HEADERS
   util_rect.h
   util_set.h
   util_simd.h
-  util_sky_model.cpp
-  util_sky_model.h
-  util_sky_model_data.h
-  util_sky_nishita.cpp
   util_avxf.h
   util_avxb.h
   util_semaphore.h
diff --git a/intern/sky/CMakeLists.txt b/intern/sky/CMakeLists.txt
new file mode 100644
index 00000000000..d46880367dc
--- /dev/null
+++ b/intern/sky/CMakeLists.txt
@@ -0,0 +1,35 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+  include
+)
+
+set(INC_SYS
+
+)
+
+set(SRC
+  source/sky_model.cpp
+  source/sky_nishita.cpp
+)
+
+set(LIB
+)
+
+blender_add_lib(bf_intern_sky "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/intern/cycles/util/util_sky_model.h b/intern/sky/include/sky_model.h
similarity index 94%
rename from intern/cycles/util/util_sky_model.h
rename to intern/sky/include/sky_model.h
index 36f1079a16d..9e7700f3042 100644
--- a/intern/cycles/util/util_sky_model.h
+++ b/intern/sky/include/sky_model.h
@@ -298,14 +298,14 @@ HINT #1:   if you want to model the sky of an earth-like planet that orbits
            previous paragraph.
 */
 
-#include "util/util_types.h"
+#ifndef __SKY_MODEL_H__
+#define __SKY_MODEL_H__
 
-CCL_NAMESPACE_BEGIN
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-#ifndef _SKY_MODEL_H_
-#  define _SKY_MODEL_H_
-
-typedef double ArHosekSkyModelConfiguration[9];
+typedef double SKY_ArHosekSkyModelConfiguration[9];
 
 //   Spectral version of the model
 
@@ -335,8 +335,8 @@ typedef double ArHosekSkyModelConfiguration[9];
 
 ---------------------------------------------------------------------------- */
 
-typedef struct ArHosekSkyModelState {
-  ArHosekSkyModelConfiguration configs[11];
+typedef struct SKY_ArHosekSkyModelState {
+  SKY_ArHosekSkyModelConfiguration configs[11];
   double radiances[11];
   double turbidity;
   double solar_radius;
@@ -344,7 +344,7 @@ typedef struct ArHosekSkyModelState {
   double emission_correction_factor_sun[11];
   double albedo;
   double elevation;
-} ArHosekSkyModelState;
+} SKY_ArHosekSkyModelState;
 
 /* ----------------------------------------------------------------------------
 
@@ -355,7 +355,7 @@ typedef struct ArHosekSkyModelState {
 
 ---------------------------------------------------------------------------- */
 
-ArHosekSkyModelState *arhosekskymodelstate_alloc_init(const double solar_elevation,
+SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alloc_init(const double solar_elevation,
                                                       const double atmospheric_turbidity,
                                                       const double ground_albedo);
 
@@ -388,31 +388,31 @@ ArHosekSkyModelState *arhosekskymodelstate_alloc_init(const double solar_elevati
 
 ---------------------------------------------------------------------------- */
 
-ArHosekSkyModelState *arhosekskymodelstate_alienworld_alloc_init(
+SKY_ArHosekSkyModelState *SKY_arhosekskymodelstate_alienworld_alloc_init(
     const double solar_elevation,
     const double solar_intensity,
     const double solar_surface_temperature_kelvin,
     const double atmospheric_turbidity,
     const double ground_albedo);
 
-void arhosekskymodelstate_free(ArHosekSkyModelState *state);
+void SKY_arhosekskymodelstate_free(SKY_ArHosekSkyModelState *state);
 
-double arhosekskymodel_radiance(ArHosekSkyModelState *state,
+double SKY_arhosekskymodel_radiance(SKY_ArHosekSkyModelState *state,
                                 double theta,
                                 double gamma,
                                 double wavelength);
 
 // CIE XYZ and RGB versions
 
-ArHosekSkyModelState *arhosek_xyz_skymodelstate_alloc_init(const double turbidity,
+SKY_ArHosekSkyModelState *SKY_arhosek_xyz_skymodelstate_alloc_init(const double turbidity,
                                                            const double albedo,
                                                            const double elevation);
 
-ArHosekSkyModelState *arhosek_rgb_skymodelstate_alloc_init(const double turbidity,
+SKY_ArHosekSkyModelState *SKY_arhosek_rgb_skymodelstate_alloc_init(const double turbidity,
                                       

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list