Blender  V3.3
sky_nishita.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2020 Blender Foundation. */
3 
8 #include "sky_float3.h"
9 #include "sky_model.h"
10 
11 /* Constants */
12 static const float rayleigh_scale = 8e3f; // Rayleigh scale height (m)
13 static const float mie_scale = 1.2e3f; // Mie scale height (m)
14 static const float mie_coeff = 2e-5f; // Mie scattering coefficient (m^-1)
15 static const float mie_G = 0.76f; // aerosols anisotropy
16 static const float sqr_G = mie_G * mie_G; // squared aerosols anisotropy
17 static const float earth_radius = 6360e3f; // radius of Earth (m)
18 static const float atmosphere_radius = 6420e3f; // radius of atmosphere (m)
19 static const int steps = 32; // segments of primary ray
20 static const int num_wavelengths = 21; // number of wavelengths
21 static const int min_wavelength = 380; // lowest sampled wavelength (nm)
22 static const int max_wavelength = 780; // highest sampled wavelength (nm)
23 // step between each sampled wavelength (nm)
24 static const float step_lambda = (max_wavelength - min_wavelength) / (num_wavelengths - 1);
25 /* Sun irradiance on top of the atmosphere (W*m^-2*nm^-1) */
26 static const float irradiance[] = {
27  1.45756829855592995315f, 1.56596305559738380175f, 1.65148449067670455293f,
28  1.71496242737209314555f, 1.75797983805020541226f, 1.78256407885924539336f,
29  1.79095108475838560302f, 1.78541550133410664714f, 1.76815554864306845317f,
30  1.74122069647250410362f, 1.70647127164943679389f, 1.66556087452739887134f,
31  1.61993437242451854274f, 1.57083597368892080581f, 1.51932335059305478886f,
32  1.46628494965214395407f, 1.41245852740172450623f, 1.35844961970384092709f,
33  1.30474913844739281998f, 1.25174963272610817455f, 1.19975998755420620867f};
34 /* Rayleigh scattering coefficient (m^-1) */
35 static const float rayleigh_coeff[] = {
36  0.00005424820087636473f, 0.00004418549866505454f, 0.00003635151910165377f,
37  0.00003017929012024763f, 0.00002526320226989157f, 0.00002130859310621843f,
38  0.00001809838025320633f, 0.00001547057129129042f, 0.00001330284977336850f,
39  0.00001150184784075764f, 0.00000999557429990163f, 0.00000872799973630707f,
40  0.00000765513700977967f, 0.00000674217203751443f, 0.00000596134125832052f,
41  0.00000529034598065810f, 0.00000471115687557433f, 0.00000420910481110487f,
42  0.00000377218381260133f, 0.00000339051255477280f, 0.00000305591531679811f};
43 /* Ozone absorption coefficient (m^-1) */
44 static const float ozone_coeff[] = {
45  0.00000000325126849861f, 0.00000000585395365047f, 0.00000001977191155085f,
46  0.00000007309568762914f, 0.00000020084561514287f, 0.00000040383958096161f,
47  0.00000063551335912363f, 0.00000096707041180970f, 0.00000154797400424410f,
48  0.00000209038647223331f, 0.00000246128056164565f, 0.00000273551299461512f,
49  0.00000215125863128643f, 0.00000159051840791988f, 0.00000112356197979857f,
50  0.00000073527551487574f, 0.00000046450130357806f, 0.00000033096079921048f,
51  0.00000022512612292678f, 0.00000014879129266490f, 0.00000016828623364192f};
52 /* CIE XYZ color matching functions */
53 static const float cmf_xyz[][3] = {{0.00136800000f, 0.00003900000f, 0.00645000100f},
54  {0.01431000000f, 0.00039600000f, 0.06785001000f},
55  {0.13438000000f, 0.00400000000f, 0.64560000000f},
56  {0.34828000000f, 0.02300000000f, 1.74706000000f},
57  {0.29080000000f, 0.06000000000f, 1.66920000000f},
58  {0.09564000000f, 0.13902000000f, 0.81295010000f},
59  {0.00490000000f, 0.32300000000f, 0.27200000000f},
60  {0.06327000000f, 0.71000000000f, 0.07824999000f},
61  {0.29040000000f, 0.95400000000f, 0.02030000000f},
62  {0.59450000000f, 0.99500000000f, 0.00390000000f},
63  {0.91630000000f, 0.87000000000f, 0.00165000100f},
64  {1.06220000000f, 0.63100000000f, 0.00080000000f},
65  {0.85444990000f, 0.38100000000f, 0.00019000000f},
66  {0.44790000000f, 0.17500000000f, 0.00002000000f},
67  {0.16490000000f, 0.06100000000f, 0.00000000000f},
68  {0.04677000000f, 0.01700000000f, 0.00000000000f},
69  {0.01135916000f, 0.00410200000f, 0.00000000000f},
70  {0.00289932700f, 0.00104700000f, 0.00000000000f},
71  {0.00069007860f, 0.00024920000f, 0.00000000000f},
72  {0.00016615050f, 0.00006000000f, 0.00000000000f},
73  {0.00004150994f, 0.00001499000f, 0.00000000000f}};
74 
75 /* Parameters for optical depth quadrature.
76  * See the comment in ray_optical_depth for more detail.
77  * Computed using sympy and following Python code:
78  * # from sympy.integrals.quadrature import gauss_laguerre
79  * # from sympy import exp
80  * # x, w = gauss_laguerre(8, 50)
81  * # xend = 25
82  * # print([(xi / xend).evalf(10) for xi in x])
83  * # print([(wi * exp(xi) / xend).evalf(10) for xi, wi in zip(x, w)])
84  */
85 static const int quadrature_steps = 8;
86 static const float quadrature_nodes[] = {0.006811185292f,
87  0.03614807107f,
88  0.09004346519f,
89  0.1706680068f,
90  0.2818362161f,
91  0.4303406404f,
92  0.6296271457f,
93  0.9145252695f};
94 static const float quadrature_weights[] = {0.01750893642f,
95  0.04135477391f,
96  0.06678839063f,
97  0.09507698807f,
98  0.1283416365f,
99  0.1707430204f,
100  0.2327233347f,
101  0.3562490486f};
102 
103 static float3 geographical_to_direction(float lat, float lon)
104 {
105  return make_float3(cosf(lat) * cosf(lon), cosf(lat) * sinf(lon), sinf(lat));
106 }
107 
108 static float3 spec_to_xyz(const float *spectrum)
109 {
110  float3 xyz = make_float3(0.0f, 0.0f, 0.0f);
111  for (int i = 0; i < num_wavelengths; i++) {
112  xyz.x += cmf_xyz[i][0] * spectrum[i];
113  xyz.y += cmf_xyz[i][1] * spectrum[i];
114  xyz.z += cmf_xyz[i][2] * spectrum[i];
115  }
116  return xyz * step_lambda;
117 }
118 
119 /* Atmosphere volume models */
120 static float density_rayleigh(float height)
121 {
122  return expf(-height / rayleigh_scale);
123 }
124 
125 static float density_mie(float height)
126 {
127  return expf(-height / mie_scale);
128 }
129 
130 static float density_ozone(float height)
131 {
132  float den = 0.0f;
133  if (height >= 10000.0f && height < 25000.0f) {
134  den = 1.0f / 15000.0f * height - 2.0f / 3.0f;
135  }
136  else if (height >= 25000 && height < 40000) {
137  den = -(1.0f / 15000.0f * height - 8.0f / 3.0f);
138  }
139  return den;
140 }
141 
142 static float phase_rayleigh(float mu)
143 {
144  return 3.0f / (16.0f * M_PI_F) * (1.0f + sqr(mu));
145 }
146 
147 static float phase_mie(float mu)
148 {
149  return (3.0f * (1.0f - sqr_G) * (1.0f + sqr(mu))) /
150  (8.0f * M_PI_F * (2.0f + sqr_G) * powf((1.0f + sqr_G - 2.0f * mie_G * mu), 1.5));
151 }
152 
153 /* Intersection helpers */
155 {
156  if (dir.z >= 0) {
157  return false;
158  }
159  float b = -2.0f * dot(dir, -pos);
160  float c = len_squared(pos) - sqr(earth_radius);
161  float t = b * b - 4.0f * c;
162  if (t >= 0.0f) {
163  return true;
164  }
165  return false;
166 }
167 
169 {
170  float b = -2.0f * dot(dir, -pos);
171  float c = len_squared(pos) - sqr(atmosphere_radius);
172  float t = (-b + sqrtf(b * b - 4.0f * c)) / 2.0f;
173  return make_float3(pos.x + dir.x * t, pos.y + dir.y * t, pos.z + dir.z * t);
174 }
175 
176 static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir)
177 {
178  /* This function computes the optical depth along a ray.
179  * Instead of using classic ray marching, the code is based on Gauss-Laguerre quadrature,
180  * which is designed to compute the integral of f(x)*exp(-x) from 0 to infinity.
181  * This works well here, since the optical depth along the ray tends to decrease exponentially.
182  * By setting f(x) = g(x) exp(x), the exponentials cancel out and we get the integral of g(x).
183  * The nodes and weights used here are the standard n=6 Gauss-Laguerre values, except that
184  * the exp(x) scaling factor is already included in the weights.
185  * The parametrization along the ray is scaled so that the last quadrature node is still within
186  * the atmosphere. */
187  float3 ray_end = atmosphere_intersection(ray_origin, ray_dir);
188  float ray_length = distance(ray_origin, ray_end);
189 
190  float3 segment = ray_length * ray_dir;
191 
192  /* instead of tracking the transmission spectrum across all wavelengths directly,
193  * we use the fact that the density always has the same spectrum for each type of
194  * scattering, so we split the density into a constant spectrum and a factor and
195  * only track the factors */
196  float3 optical_depth = make_float3(0.0f, 0.0f, 0.0f);
197 
198  for (int i = 0; i < quadrature_steps; i++) {
199  float3 P = ray_origin + quadrature_nodes[i] * segment;
200 
201  /* height above sea level */
202  float height = len(P) - earth_radius;
203 
206  optical_depth += density * quadrature_weights[i];
207  }
208 
209  return optical_depth * ray_length;
210 }
211 
212 static void single_scattering(float3 ray_dir,
213  float3 sun_dir,
214  float3 ray_origin,
215  float air_density,
216  float dust_density,
217  float ozone_density,
218  float *r_spectrum)
219 {
220  /* this code computes single-inscattering along a ray through the atmosphere */
221  float3 ray_end = atmosphere_intersection(ray_origin, ray_dir);
222  float ray_length = distance(ray_origin, ray_end);
223 
224  /* to compute the inscattering, we step along the ray in segments and accumulate
225  * the inscattering as well as the optical depth along each segment */
226  float segment_length = ray_length / steps;
227  float3 segment = segment_length * ray_dir;
228 
229  /* instead of tracking the transmission spectrum across all wavelengths directly,
230  * we use the fact that the density always has the same spectrum for each type of
231  * scattering, so we split the density into a constant spectrum and a factor and
232  * only track the factors */
233  float3 optical_depth = make_float3(0.0f, 0.0f, 0.0f);
234 
235  /* zero out light accumulation */
236  for (int wl = 0; wl < num_wavelengths; wl++) {
237  r_spectrum[wl] = 0.0f;
238  }
239 
240  /* phase function for scattering and the density scale factor */
241  float mu = dot(ray_dir, sun_dir);
242  float3 phase_function = make_float3(phase_rayleigh(mu), phase_mie(mu), 0.0f);
243  float3 density_scale = make_float3(air_density, dust_density, ozone_density);
244 
245  /* the density and in-scattering of each segment is evaluated at its middle */
246  float3 P = ray_origin + 0.5f * segment;
247 
248  for (int i = 0; i < steps; i++) {
249  /* height above sea level */
250  float height = len(P) - earth_radius;
251 
252  /* evaluate and accumulate optical depth along the ray */
253  float3 density = density_scale * make_float3(density_rayleigh(height),
256  optical_depth += segment_length * density;
257 
258  /* if the Earth isn't in the way, evaluate inscattering from the sun */
259  if (!surface_intersection(P, sun_dir)) {
260  float3 light_optical_depth = density_scale * ray_optical_depth(P, sun_dir);
261  float3 total_optical_depth = optical_depth + light_optical_depth;
262 
263  /* attenuation of light */
264  for (int wl = 0; wl < num_wavelengths; wl++) {
265  float3 extinction_density = total_optical_depth * make_float3(rayleigh_coeff[wl],
266  1.11f * mie_coeff,
267  ozone_coeff[wl]);
268  float attenuation = expf(-reduce_add(extinction_density));
269 
270  float3 scattering_density = density * make_float3(rayleigh_coeff[wl], mie_coeff, 0.0f);
271 
272  /* the total inscattered radiance from one segment is:
273  * Tr(A<->B) * Tr(B<->C) * sigma_s * phase * L * segment_length
274  *
275  * These terms are:
276  * Tr(A<->B): Transmission from start to scattering position (tracked in optical_depth)
277  * Tr(B<->C): Transmission from scattering position to light (computed in
278  * ray_optical_depth) sigma_s: Scattering density phase: Phase function of the scattering
279  * type (Rayleigh or Mie) L: Radiance coming from the light source segment_length: The
280  * length of the segment
281  *
282  * The code here is just that, with a bit of additional optimization to not store full
283  * spectra for the optical depth
284  */
285  r_spectrum[wl] += attenuation * reduce_add(phase_function * scattering_density) *
286  irradiance[wl] * segment_length;
287  }
288  }
289 
290  /* advance along ray */
291  P += segment;
292  }
293 }
294 
296  int stride,
297  int start_y,
298  int end_y,
299  int width,
300  int height,
301  float sun_elevation,
302  float altitude,
303  float air_density,
304  float dust_density,
305  float ozone_density)
306 {
307  /* calculate texture pixels */
308  float spectrum[num_wavelengths];
309  int half_width = width / 2;
310  float3 cam_pos = make_float3(0, 0, earth_radius + altitude);
311  float3 sun_dir = geographical_to_direction(sun_elevation, 0.0f);
312 
313  float latitude_step = M_PI_2_F / height;
314  float longitude_step = M_2PI_F / width;
315  float half_lat_step = latitude_step / 2.0f;
316 
317  for (int y = start_y; y < end_y; y++) {
318  /* sample more pixels toward the horizon */
319  float latitude = (M_PI_2_F + half_lat_step) * sqr((float)y / height);
320 
321  float *pixel_row = pixels + (y * width * stride);
322  for (int x = 0; x < half_width; x++) {
323  float longitude = longitude_step * x - M_PI_F;
324 
325  float3 dir = geographical_to_direction(latitude, longitude);
326  single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum);
327  float3 xyz = spec_to_xyz(spectrum);
328 
329  /* store pixels */
330  int pos_x = x * stride;
331  pixel_row[pos_x] = xyz.x;
332  pixel_row[pos_x + 1] = xyz.y;
333  pixel_row[pos_x + 2] = xyz.z;
334  /* mirror sky */
335  int mirror_x = (width - x - 1) * stride;
336  pixel_row[mirror_x] = xyz.x;
337  pixel_row[mirror_x + 1] = xyz.y;
338  pixel_row[mirror_x + 2] = xyz.z;
339  }
340  }
341 }
342 
343 /*********** Sun ***********/
344 static void sun_radiation(float3 cam_dir,
345  float altitude,
346  float air_density,
347  float dust_density,
348  float solid_angle,
349  float *r_spectrum)
350 {
351  float3 cam_pos = make_float3(0, 0, earth_radius + altitude);
352  float3 optical_depth = ray_optical_depth(cam_pos, cam_dir);
353 
354  /* compute final spectrum */
355  for (int i = 0; i < num_wavelengths; i++) {
356  /* combine spectra and the optical depth into transmittance */
357  float transmittance = rayleigh_coeff[i] * optical_depth.x * air_density +
358  1.11f * mie_coeff * optical_depth.y * dust_density;
359  r_spectrum[i] = irradiance[i] * expf(-transmittance) / solid_angle;
360  }
361 }
362 
363 void SKY_nishita_skymodel_precompute_sun(float sun_elevation,
364  float angular_diameter,
365  float altitude,
366  float air_density,
367  float dust_density,
368  float *r_pixel_bottom,
369  float *r_pixel_top)
370 {
371  /* definitions */
372  float half_angular = angular_diameter / 2.0f;
373  float solid_angle = M_2PI_F * (1.0f - cosf(half_angular));
374  float spectrum[num_wavelengths];
375  float bottom = sun_elevation - half_angular;
376  float top = sun_elevation + half_angular;
377  float elevation_bottom, elevation_top;
378  float3 pix_bottom, pix_top, sun_dir;
379 
380  /* compute 2 pixels for sun disc */
381  elevation_bottom = (bottom > 0.0f) ? bottom : 0.0f;
382  elevation_top = (top > 0.0f) ? top : 0.0f;
383  sun_dir = geographical_to_direction(elevation_bottom, 0.0f);
384  sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
385  pix_bottom = spec_to_xyz(spectrum);
386  sun_dir = geographical_to_direction(elevation_top, 0.0f);
387  sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
388  pix_top = spec_to_xyz(spectrum);
389 
390  /* store pixels */
391  r_pixel_bottom[0] = pix_bottom.x;
392  r_pixel_bottom[1] = pix_bottom.y;
393  r_pixel_bottom[2] = pix_bottom.z;
394  r_pixel_top[0] = pix_top.x;
395  r_pixel_top[1] = pix_top.y;
396  r_pixel_top[2] = pix_top.z;
397 }
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble bottom
__forceinline int reduce_add(const avxi &v)
Definition: avxi.h:696
#define sinf(x)
Definition: cuda/compat.h:102
#define cosf(x)
Definition: cuda/compat.h:101
#define expf(x)
Definition: cuda/compat.h:106
#define powf(x, y)
Definition: cuda/compat.h:103
int len
Definition: draw_manager.c:108
uint pos
ccl_device_inline float len_squared(const float3 a)
Definition: math_float3.h:423
static float P(float k)
Definition: math_interp.c:25
#define sqrtf(x)
Definition: metal/compat.h:243
#define make_float3(x, y, z)
Definition: metal/compat.h:204
static unsigned c
Definition: RandGen.cpp:83
Segment< FEdge *, Vec3r > segment
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
T distance(const T &a, const T &b)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken density("density", pxr::TfToken::Immortal)
static const int num_wavelengths
Definition: sky_nishita.cpp:20
static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir)
static float3 spec_to_xyz(const float *spectrum)
static const float rayleigh_coeff[]
Definition: sky_nishita.cpp:35
static float phase_rayleigh(float mu)
static const float mie_coeff
Definition: sky_nishita.cpp:14
static const int quadrature_steps
Definition: sky_nishita.cpp:85
static void single_scattering(float3 ray_dir, float3 sun_dir, float3 ray_origin, float air_density, float dust_density, float ozone_density, float *r_spectrum)
static const float sqr_G
Definition: sky_nishita.cpp:16
static const float earth_radius
Definition: sky_nishita.cpp:17
static float3 geographical_to_direction(float lat, float lon)
static const float irradiance[]
Definition: sky_nishita.cpp:26
static float phase_mie(float mu)
static void sun_radiation(float3 cam_dir, float altitude, float air_density, float dust_density, float solid_angle, float *r_spectrum)
static const float atmosphere_radius
Definition: sky_nishita.cpp:18
static float density_mie(float height)
static bool surface_intersection(float3 pos, float3 dir)
static const float ozone_coeff[]
Definition: sky_nishita.cpp:44
static float density_rayleigh(float height)
static const float rayleigh_scale
Definition: sky_nishita.cpp:12
static const float quadrature_nodes[]
Definition: sky_nishita.cpp:86
static const float step_lambda
Definition: sky_nishita.cpp:24
void SKY_nishita_skymodel_precompute_sun(float sun_elevation, float angular_diameter, float altitude, float air_density, float dust_density, float *r_pixel_bottom, float *r_pixel_top)
static float3 atmosphere_intersection(float3 pos, float3 dir)
static const float cmf_xyz[][3]
Definition: sky_nishita.cpp:53
static float density_ozone(float height)
static const int min_wavelength
Definition: sky_nishita.cpp:21
static const int max_wavelength
Definition: sky_nishita.cpp:22
static const float mie_G
Definition: sky_nishita.cpp:15
static const int steps
Definition: sky_nishita.cpp:19
static const float quadrature_weights[]
Definition: sky_nishita.cpp:94
static const float mie_scale
Definition: sky_nishita.cpp:13
void SKY_nishita_skymodel_precompute_texture(float *pixels, int stride, int start_y, int end_y, int width, int height, float sun_elevation, float altitude, float air_density, float dust_density, float ozone_density)
float z
float y
float x
#define M_PI_2_F
Definition: util/math.h:37
ccl_device_inline float sqr(float a)
Definition: util/math.h:746
#define M_2PI_F
Definition: util/math.h:60
#define M_PI_F
Definition: util/math.h:34