Blender  V2.93
sky_nishita.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2020 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "sky_float3.h"
18 #include "sky_model.h"
19 
20 /* Constants */
21 static const float rayleigh_scale = 8e3f; // Rayleigh scale height (m)
22 static const float mie_scale = 1.2e3f; // Mie scale height (m)
23 static const float mie_coeff = 2e-5f; // Mie scattering coefficient (m^-1)
24 static const float mie_G = 0.76f; // aerosols anisotropy
25 static const float sqr_G = mie_G * mie_G; // squared aerosols anisotropy
26 static const float earth_radius = 6360e3f; // radius of Earth (m)
27 static const float atmosphere_radius = 6420e3f; // radius of atmosphere (m)
28 static const int steps = 32; // segments of primary ray
29 static const int steps_light = 16; // segments of sun connection ray
30 static const int num_wavelengths = 21; // number of wavelengths
31 static const int min_wavelength = 380; // lowest sampled wavelength (nm)
32 static const int max_wavelength = 780; // highest sampled wavelength (nm)
33 // step between each sampled wavelength (nm)
34 static const float step_lambda = (max_wavelength - min_wavelength) / (num_wavelengths - 1);
35 /* Sun irradiance on top of the atmosphere (W*m^-2*nm^-1) */
36 static const float irradiance[] = {
37  1.45756829855592995315f, 1.56596305559738380175f, 1.65148449067670455293f,
38  1.71496242737209314555f, 1.75797983805020541226f, 1.78256407885924539336f,
39  1.79095108475838560302f, 1.78541550133410664714f, 1.76815554864306845317f,
40  1.74122069647250410362f, 1.70647127164943679389f, 1.66556087452739887134f,
41  1.61993437242451854274f, 1.57083597368892080581f, 1.51932335059305478886f,
42  1.46628494965214395407f, 1.41245852740172450623f, 1.35844961970384092709f,
43  1.30474913844739281998f, 1.25174963272610817455f, 1.19975998755420620867f};
44 /* Rayleigh scattering coefficient (m^-1) */
45 static const float rayleigh_coeff[] = {
46  0.00005424820087636473f, 0.00004418549866505454f, 0.00003635151910165377f,
47  0.00003017929012024763f, 0.00002526320226989157f, 0.00002130859310621843f,
48  0.00001809838025320633f, 0.00001547057129129042f, 0.00001330284977336850f,
49  0.00001150184784075764f, 0.00000999557429990163f, 0.00000872799973630707f,
50  0.00000765513700977967f, 0.00000674217203751443f, 0.00000596134125832052f,
51  0.00000529034598065810f, 0.00000471115687557433f, 0.00000420910481110487f,
52  0.00000377218381260133f, 0.00000339051255477280f, 0.00000305591531679811f};
53 /* Ozone absorption coefficient (m^-1) */
54 static const float ozone_coeff[] = {
55  0.00000000325126849861f, 0.00000000585395365047f, 0.00000001977191155085f,
56  0.00000007309568762914f, 0.00000020084561514287f, 0.00000040383958096161f,
57  0.00000063551335912363f, 0.00000096707041180970f, 0.00000154797400424410f,
58  0.00000209038647223331f, 0.00000246128056164565f, 0.00000273551299461512f,
59  0.00000215125863128643f, 0.00000159051840791988f, 0.00000112356197979857f,
60  0.00000073527551487574f, 0.00000046450130357806f, 0.00000033096079921048f,
61  0.00000022512612292678f, 0.00000014879129266490f, 0.00000016828623364192f};
62 /* CIE XYZ color matching functions */
63 static const float cmf_xyz[][3] = {{0.00136800000f, 0.00003900000f, 0.00645000100f},
64  {0.01431000000f, 0.00039600000f, 0.06785001000f},
65  {0.13438000000f, 0.00400000000f, 0.64560000000f},
66  {0.34828000000f, 0.02300000000f, 1.74706000000f},
67  {0.29080000000f, 0.06000000000f, 1.66920000000f},
68  {0.09564000000f, 0.13902000000f, 0.81295010000f},
69  {0.00490000000f, 0.32300000000f, 0.27200000000f},
70  {0.06327000000f, 0.71000000000f, 0.07824999000f},
71  {0.29040000000f, 0.95400000000f, 0.02030000000f},
72  {0.59450000000f, 0.99500000000f, 0.00390000000f},
73  {0.91630000000f, 0.87000000000f, 0.00165000100f},
74  {1.06220000000f, 0.63100000000f, 0.00080000000f},
75  {0.85444990000f, 0.38100000000f, 0.00019000000f},
76  {0.44790000000f, 0.17500000000f, 0.00002000000f},
77  {0.16490000000f, 0.06100000000f, 0.00000000000f},
78  {0.04677000000f, 0.01700000000f, 0.00000000000f},
79  {0.01135916000f, 0.00410200000f, 0.00000000000f},
80  {0.00289932700f, 0.00104700000f, 0.00000000000f},
81  {0.00069007860f, 0.00024920000f, 0.00000000000f},
82  {0.00016615050f, 0.00006000000f, 0.00000000000f},
83  {0.00004150994f, 0.00001499000f, 0.00000000000f}};
84 
85 static float3 geographical_to_direction(float lat, float lon)
86 {
87  return make_float3(cosf(lat) * cosf(lon), cosf(lat) * sinf(lon), sinf(lat));
88 }
89 
90 static float3 spec_to_xyz(const float *spectrum)
91 {
92  float3 xyz = make_float3(0.0f, 0.0f, 0.0f);
93  for (int i = 0; i < num_wavelengths; i++) {
94  xyz.x += cmf_xyz[i][0] * spectrum[i];
95  xyz.y += cmf_xyz[i][1] * spectrum[i];
96  xyz.z += cmf_xyz[i][2] * spectrum[i];
97  }
98  return xyz * step_lambda;
99 }
100 
101 /* Atmosphere volume models */
102 static float density_rayleigh(float height)
103 {
104  return expf(-height / rayleigh_scale);
105 }
106 
107 static float density_mie(float height)
108 {
109  return expf(-height / mie_scale);
110 }
111 
112 static float density_ozone(float height)
113 {
114  float den = 0.0f;
115  if (height >= 10000.0f && height < 25000.0f) {
116  den = 1.0f / 15000.0f * height - 2.0f / 3.0f;
117  }
118  else if (height >= 25000 && height < 40000) {
119  den = -(1.0f / 15000.0f * height - 8.0f / 3.0f);
120  }
121  return den;
122 }
123 
124 static float phase_rayleigh(float mu)
125 {
126  return 3.0f / (16.0f * M_PI_F) * (1.0f + sqr(mu));
127 }
128 
129 static float phase_mie(float mu)
130 {
131  return (3.0f * (1.0f - sqr_G) * (1.0f + sqr(mu))) /
132  (8.0f * M_PI_F * (2.0f + sqr_G) * powf((1.0f + sqr_G - 2.0f * mie_G * mu), 1.5));
133 }
134 
135 /* Intersection helpers */
137 {
138  if (dir.z >= 0) {
139  return false;
140  }
141  float b = -2.0f * dot(dir, -pos);
142  float c = len_squared(pos) - sqr(earth_radius);
143  float t = b * b - 4.0f * c;
144  if (t >= 0.0f) {
145  return true;
146  }
147  return false;
148 }
149 
151 {
152  float b = -2.0f * dot(dir, -pos);
153  float c = len_squared(pos) - sqr(atmosphere_radius);
154  float t = (-b + sqrtf(b * b - 4.0f * c)) / 2.0f;
155  return make_float3(pos.x + dir.x * t, pos.y + dir.y * t, pos.z + dir.z * t);
156 }
157 
158 static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir)
159 {
160  /* this code computes the optical depth along a ray through the atmosphere */
161  float3 ray_end = atmosphere_intersection(ray_origin, ray_dir);
162  float ray_length = distance(ray_origin, ray_end);
163 
164  /* to compute the optical depth, we step along the ray in segments and
165  * accumulate the optical depth along each segment */
166  float segment_length = ray_length / steps_light;
167  float3 segment = segment_length * ray_dir;
168 
169  /* instead of tracking the transmission spectrum across all wavelengths directly,
170  * we use the fact that the density always has the same spectrum for each type of
171  * scattering, so we split the density into a constant spectrum and a factor and
172  * only track the factors */
173  float3 optical_depth = make_float3(0.0f, 0.0f, 0.0f);
174 
175  /* the density of each segment is evaluated at its middle */
176  float3 P = ray_origin + 0.5f * segment;
177 
178  for (int i = 0; i < steps_light; i++) {
179  /* height above sea level */
180  float height = len(P) - earth_radius;
181 
182  /* accumulate optical depth of this segment (density is assumed to be constant along it) */
183  float3 density = make_float3(
185  optical_depth += density;
186 
187  /* advance along ray */
188  P += segment;
189  }
190 
191  return optical_depth * segment_length;
192 }
193 
194 static void single_scattering(float3 ray_dir,
195  float3 sun_dir,
196  float3 ray_origin,
197  float air_density,
198  float dust_density,
199  float ozone_density,
200  float *r_spectrum)
201 {
202  /* this code computes single-inscattering along a ray through the atmosphere */
203  float3 ray_end = atmosphere_intersection(ray_origin, ray_dir);
204  float ray_length = distance(ray_origin, ray_end);
205 
206  /* to compute the inscattering, we step along the ray in segments and accumulate
207  * the inscattering as well as the optical depth along each segment */
208  float segment_length = ray_length / steps;
209  float3 segment = segment_length * ray_dir;
210 
211  /* instead of tracking the transmission spectrum across all wavelengths directly,
212  * we use the fact that the density always has the same spectrum for each type of
213  * scattering, so we split the density into a constant spectrum and a factor and
214  * only track the factors */
215  float3 optical_depth = make_float3(0.0f, 0.0f, 0.0f);
216 
217  /* zero out light accumulation */
218  for (int wl = 0; wl < num_wavelengths; wl++) {
219  r_spectrum[wl] = 0.0f;
220  }
221 
222  /* phase function for scattering and the density scale factor */
223  float mu = dot(ray_dir, sun_dir);
224  float3 phase_function = make_float3(phase_rayleigh(mu), phase_mie(mu), 0.0f);
225  float3 density_scale = make_float3(air_density, dust_density, ozone_density);
226 
227  /* the density and in-scattering of each segment is evaluated at its middle */
228  float3 P = ray_origin + 0.5f * segment;
229 
230  for (int i = 0; i < steps; i++) {
231  /* height above sea level */
232  float height = len(P) - earth_radius;
233 
234  /* evaluate and accumulate optical depth along the ray */
235  float3 density = density_scale * make_float3(density_rayleigh(height),
238  optical_depth += segment_length * density;
239 
240  /* if the Earth isn't in the way, evaluate inscattering from the sun */
241  if (!surface_intersection(P, sun_dir)) {
242  float3 light_optical_depth = density_scale * ray_optical_depth(P, sun_dir);
243  float3 total_optical_depth = optical_depth + light_optical_depth;
244 
245  /* attenuation of light */
246  for (int wl = 0; wl < num_wavelengths; wl++) {
247  float3 extinction_density = total_optical_depth * make_float3(rayleigh_coeff[wl],
248  1.11f * mie_coeff,
249  ozone_coeff[wl]);
250  float attenuation = expf(-reduce_add(extinction_density));
251 
252  float3 scattering_density = density * make_float3(rayleigh_coeff[wl], mie_coeff, 0.0f);
253 
254  /* the total inscattered radiance from one segment is:
255  * Tr(A<->B) * Tr(B<->C) * sigma_s * phase * L * segment_length
256  *
257  * These terms are:
258  * Tr(A<->B): Transmission from start to scattering position (tracked in optical_depth)
259  * Tr(B<->C): Transmission from scattering position to light (computed in
260  * ray_optical_depth) sigma_s: Scattering density phase: Phase function of the scattering
261  * type (Rayleigh or Mie) L: Radiance coming from the light source segment_length: The
262  * length of the segment
263  *
264  * The code here is just that, with a bit of additional optimization to not store full
265  * spectra for the optical depth
266  */
267  r_spectrum[wl] += attenuation * reduce_add(phase_function * scattering_density) *
268  irradiance[wl] * segment_length;
269  }
270  }
271 
272  /* advance along ray */
273  P += segment;
274  }
275 }
276 
278  int stride,
279  int start_y,
280  int end_y,
281  int width,
282  int height,
283  float sun_elevation,
284  float altitude,
285  float air_density,
286  float dust_density,
287  float ozone_density)
288 {
289  /* calculate texture pixels */
290  float spectrum[num_wavelengths];
291  int half_width = width / 2;
292  float3 cam_pos = make_float3(0, 0, earth_radius + altitude);
293  float3 sun_dir = geographical_to_direction(sun_elevation, 0.0f);
294 
295  float latitude_step = M_PI_2_F / height;
296  float longitude_step = M_2PI_F / width;
297  float half_lat_step = latitude_step / 2.0f;
298 
299  for (int y = start_y; y < end_y; y++) {
300  /* sample more pixels toward the horizon */
301  float latitude = (M_PI_2_F + half_lat_step) * sqr((float)y / height);
302 
303  float *pixel_row = pixels + (y * width * stride);
304  for (int x = 0; x < half_width; x++) {
305  float longitude = longitude_step * x - M_PI_F;
306 
307  float3 dir = geographical_to_direction(latitude, longitude);
308  single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum);
309  float3 xyz = spec_to_xyz(spectrum);
310 
311  /* store pixels */
312  int pos_x = x * stride;
313  pixel_row[pos_x] = xyz.x;
314  pixel_row[pos_x + 1] = xyz.y;
315  pixel_row[pos_x + 2] = xyz.z;
316  /* mirror sky */
317  int mirror_x = (width - x - 1) * stride;
318  pixel_row[mirror_x] = xyz.x;
319  pixel_row[mirror_x + 1] = xyz.y;
320  pixel_row[mirror_x + 2] = xyz.z;
321  }
322  }
323 }
324 
325 /*********** Sun ***********/
326 static void sun_radiation(float3 cam_dir,
327  float altitude,
328  float air_density,
329  float dust_density,
330  float solid_angle,
331  float *r_spectrum)
332 {
333  float3 cam_pos = make_float3(0, 0, earth_radius + altitude);
334  float3 optical_depth = ray_optical_depth(cam_pos, cam_dir);
335 
336  /* compute final spectrum */
337  for (int i = 0; i < num_wavelengths; i++) {
338  /* combine spectra and the optical depth into transmittance */
339  float transmittance = rayleigh_coeff[i] * optical_depth.x * air_density +
340  1.11f * mie_coeff * optical_depth.y * dust_density;
341  r_spectrum[i] = irradiance[i] * expf(-transmittance) / solid_angle;
342  }
343 }
344 
345 void SKY_nishita_skymodel_precompute_sun(float sun_elevation,
346  float angular_diameter,
347  float altitude,
348  float air_density,
349  float dust_density,
350  float *r_pixel_bottom,
351  float *r_pixel_top)
352 {
353  /* definitions */
354  float half_angular = angular_diameter / 2.0f;
355  float solid_angle = M_2PI_F * (1.0f - cosf(half_angular));
356  float spectrum[num_wavelengths];
357  float bottom = sun_elevation - half_angular;
358  float top = sun_elevation + half_angular;
359  float elevation_bottom, elevation_top;
360  float3 pix_bottom, pix_top, sun_dir;
361 
362  /* compute 2 pixels for sun disc */
363  elevation_bottom = (bottom > 0.0f) ? bottom : 0.0f;
364  elevation_top = (top > 0.0f) ? top : 0.0f;
365  sun_dir = geographical_to_direction(elevation_bottom, 0.0f);
366  sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
367  pix_bottom = spec_to_xyz(spectrum);
368  sun_dir = geographical_to_direction(elevation_top, 0.0f);
369  sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
370  pix_top = spec_to_xyz(spectrum);
371 
372  /* store pixels */
373  r_pixel_bottom[0] = pix_bottom.x;
374  r_pixel_bottom[1] = pix_bottom.y;
375  r_pixel_bottom[2] = pix_bottom.z;
376  r_pixel_top[0] = pix_top.x;
377  r_pixel_top[1] = pix_top.y;
378  r_pixel_top[2] = pix_top.z;
379 }
_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 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 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 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 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
uint pos
#define sinf(x)
#define cosf(x)
#define expf(x)
#define powf(x, y)
#define sqrtf(x)
#define make_float3(x, y, z)
static float P(float k)
Definition: math_interp.c:41
static unsigned c
Definition: RandGen.cpp:97
Segment< FEdge *, Vec3r > segment
static const int num_wavelengths
Definition: sky_nishita.cpp:30
static float3 ray_optical_depth(float3 ray_origin, float3 ray_dir)
static float3 spec_to_xyz(const float *spectrum)
Definition: sky_nishita.cpp:90
static const float rayleigh_coeff[]
Definition: sky_nishita.cpp:45
static float phase_rayleigh(float mu)
static const float mie_coeff
Definition: sky_nishita.cpp:23
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:25
static const float earth_radius
Definition: sky_nishita.cpp:26
static const int steps_light
Definition: sky_nishita.cpp:29
static float3 geographical_to_direction(float lat, float lon)
Definition: sky_nishita.cpp:85
static const float irradiance[]
Definition: sky_nishita.cpp:36
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:27
static float density_mie(float height)
static bool surface_intersection(float3 pos, float3 dir)
static const float ozone_coeff[]
Definition: sky_nishita.cpp:54
static float density_rayleigh(float height)
static const float rayleigh_scale
Definition: sky_nishita.cpp:21
static const float step_lambda
Definition: sky_nishita.cpp:34
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:63
static float density_ozone(float height)
static const int min_wavelength
Definition: sky_nishita.cpp:31
static const int max_wavelength
Definition: sky_nishita.cpp:32
static const float mie_G
Definition: sky_nishita.cpp:24
static const int steps
Definition: sky_nishita.cpp:28
static const float mie_scale
Definition: sky_nishita.cpp:22
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
Definition: sky_float3.h:35
float y
Definition: sky_float3.h:35
float x
Definition: sky_float3.h:35
__forceinline int reduce_add(const avxi &v)
Definition: util_avxi.h:709
#define M_PI_2_F
Definition: util_math.h:46
ccl_device_inline float sqr(float a)
Definition: util_math.h:651
#define M_2PI_F
Definition: util_math.h:69
#define M_PI_F
Definition: util_math.h:43
ccl_device_inline float distance(const float2 &a, const float2 &b)
ccl_device_inline float dot(const float2 &a, const float2 &b)
ccl_device_inline float len_squared(const float3 a)
uint len