Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_sky_nishita.cpp
| Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | void nishita_skymodel_precompute_texture(float *pixels, | ||||
| /* calculate texture pixels */ | /* calculate texture pixels */ | ||||
| float spectrum[num_wavelengths]; | float spectrum[num_wavelengths]; | ||||
| int half_width = width / 2; | int half_width = width / 2; | ||||
| float3 cam_pos = make_float3(0, 0, earth_radius + altitude); | float3 cam_pos = make_float3(0, 0, earth_radius + altitude); | ||||
| float3 sun_dir = geographical_to_direction(sun_elevation, 0.0f); | float3 sun_dir = geographical_to_direction(sun_elevation, 0.0f); | ||||
| float latitude_step = M_PI_2_F / height; | float latitude_step = M_PI_2_F / height; | ||||
| float longitude_step = M_2PI_F / width; | float longitude_step = M_2PI_F / width; | ||||
| float half_lat_step = latitude_step / 2.0f; | |||||
| for (int y = start_y; y < end_y; y++) { | for (int y = start_y; y < end_y; y++) { | ||||
| float latitude = latitude_step * y; | float latitude = (M_PI_2_F + half_lat_step) * powf((float)y / height, 2.0f); | ||||
lukasstockner97: As above, please prefer sqr() over pow() here. | |||||
| float *pixel_row = pixels + (y * width) * stride; | float *pixel_row = pixels + (y * width) * stride; | ||||
| for (int x = 0; x < half_width; x++) { | for (int x = 0; x < half_width; x++) { | ||||
| float longitude = longitude_step * x - M_PI_F; | float longitude = longitude_step * x - M_PI_F; | ||||
| float3 dir = geographical_to_direction(latitude, longitude); | float3 dir = geographical_to_direction(latitude, longitude); | ||||
| single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum); | single_scattering(dir, sun_dir, cam_pos, air_density, dust_density, ozone_density, spectrum); | ||||
| float3 xyz = spec_to_xyz(spectrum); | float3 xyz = spec_to_xyz(spectrum); | ||||
| ▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines | |||||
As above, please prefer sqr() over pow() here.