28 1.45756829855592995315f, 1.56596305559738380175f, 1.65148449067670455293f,
29 1.71496242737209314555f, 1.75797983805020541226f, 1.78256407885924539336f,
30 1.79095108475838560302f, 1.78541550133410664714f, 1.76815554864306845317f,
31 1.74122069647250410362f, 1.70647127164943679389f, 1.66556087452739887134f,
32 1.61993437242451854274f, 1.57083597368892080581f, 1.51932335059305478886f,
33 1.46628494965214395407f, 1.41245852740172450623f, 1.35844961970384092709f,
34 1.30474913844739281998f, 1.25174963272610817455f, 1.19975998755420620867f};
37 0.00005424820087636473f, 0.00004418549866505454f, 0.00003635151910165377f,
38 0.00003017929012024763f, 0.00002526320226989157f, 0.00002130859310621843f,
39 0.00001809838025320633f, 0.00001547057129129042f, 0.00001330284977336850f,
40 0.00001150184784075764f, 0.00000999557429990163f, 0.00000872799973630707f,
41 0.00000765513700977967f, 0.00000674217203751443f, 0.00000596134125832052f,
42 0.00000529034598065810f, 0.00000471115687557433f, 0.00000420910481110487f,
43 0.00000377218381260133f, 0.00000339051255477280f, 0.00000305591531679811f};
46 0.00000000325126849861f, 0.00000000585395365047f, 0.00000001977191155085f,
47 0.00000007309568762914f, 0.00000020084561514287f, 0.00000040383958096161f,
48 0.00000063551335912363f, 0.00000096707041180970f, 0.00000154797400424410f,
49 0.00000209038647223331f, 0.00000246128056164565f, 0.00000273551299461512f,
50 0.00000215125863128643f, 0.00000159051840791988f, 0.00000112356197979857f,
51 0.00000073527551487574f, 0.00000046450130357806f, 0.00000033096079921048f,
52 0.00000022512612292678f, 0.00000014879129266490f, 0.00000016828623364192f};
54static const float cmf_xyz[][3] = {{0.00136800000f, 0.00003900000f, 0.00645000100f},
55 {0.01431000000f, 0.00039600000f, 0.06785001000f},
56 {0.13438000000f, 0.00400000000f, 0.64560000000f},
57 {0.34828000000f, 0.02300000000f, 1.74706000000f},
58 {0.29080000000f, 0.06000000000f, 1.66920000000f},
59 {0.09564000000f, 0.13902000000f, 0.81295010000f},
60 {0.00490000000f, 0.32300000000f, 0.27200000000f},
61 {0.06327000000f, 0.71000000000f, 0.07824999000f},
62 {0.29040000000f, 0.95400000000f, 0.02030000000f},
63 {0.59450000000f, 0.99500000000f, 0.00390000000f},
64 {0.91630000000f, 0.87000000000f, 0.00165000100f},
65 {1.06220000000f, 0.63100000000f, 0.00080000000f},
66 {0.85444990000f, 0.38100000000f, 0.00019000000f},
67 {0.44790000000f, 0.17500000000f, 0.00002000000f},
68 {0.16490000000f, 0.06100000000f, 0.00000000000f},
69 {0.04677000000f, 0.01700000000f, 0.00000000000f},
70 {0.01135916000f, 0.00410200000f, 0.00000000000f},
71 {0.00289932700f, 0.00104700000f, 0.00000000000f},
72 {0.00069007860f, 0.00024920000f, 0.00000000000f},
73 {0.00016615050f, 0.00006000000f, 0.00000000000f},
74 {0.00004150994f, 0.00001499000f, 0.00000000000f}};
223 float ray_length =
distance(ray_origin, ray_end);
227 float segment_length = ray_length /
steps;
228 float3 segment = segment_length * ray_dir;
238 r_spectrum[wl] = 0.0f;
242 float mu =
dot(ray_dir, sun_dir);
247 float3 P = ray_origin + 0.5f * segment;
249 for (
int i = 0; i <
steps; i++) {
257 optical_depth += segment_length * density;
262 float3 total_optical_depth = optical_depth + light_optical_depth;
286 r_spectrum[wl] += attenuation *
reduce_add(phase_function * scattering_density) *
310 int half_width = width / 2;
314 float latitude_step =
M_PI_2_F / height;
315 float longitude_step =
M_2PI_F / width;
316 float half_lat_step = latitude_step / 2.0f;
318 for (
int y = start_y; y < end_y; y++) {
320 float latitude = (
M_PI_2_F + half_lat_step) *
sqr(
float(y) / height);
322 float *pixel_row = pixels + (y * width * stride);
323 for (
int x = 0; x < half_width; x++) {
324 float longitude = longitude_step * x -
M_PI_F;
327 single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum);
331 int pos_x = x * stride;
332 pixel_row[pos_x] = xyz.
x;
333 pixel_row[pos_x + 1] = xyz.
y;
334 pixel_row[pos_x + 2] = xyz.
z;
336 int mirror_x = (width - x - 1) * stride;
337 pixel_row[mirror_x] = xyz.
x;
338 pixel_row[mirror_x + 1] = xyz.
y;
339 pixel_row[mirror_x + 2] = xyz.
z;
365 float angular_diameter,
369 float *r_pixel_bottom,
373 float half_angular = angular_diameter / 2.0f;
374 float solid_angle =
M_2PI_F * (1.0f -
cosf(half_angular));
376 float bottom = sun_elevation - half_angular;
377 float top = sun_elevation + half_angular;
378 float elevation_bottom, elevation_top;
379 float3 pix_bottom, pix_top, sun_dir;
382 elevation_bottom = (bottom > 0.0f) ? bottom : 0.0f;
383 elevation_top = (top > 0.0f) ? top : 0.0f;
385 sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
388 sun_radiation(sun_dir, altitude, air_density, dust_density, solid_angle, spectrum);
392 r_pixel_bottom[0] = pix_bottom.
x;
393 r_pixel_bottom[1] = pix_bottom.
y;
394 r_pixel_bottom[2] = pix_bottom.
z;
395 r_pixel_top[0] = pix_top.
x;
396 r_pixel_top[1] = pix_top.
y;
397 r_pixel_top[2] = pix_top.
z;
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)