37 const float ctheta =
cosf(theta);
38 const float cgamma =
cosf(gamma);
40 return (1.0f + lam[0] *
expf(lam[1] / ctheta)) *
41 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] * cgamma * cgamma);
48 const float radiance_x,
49 const float radiance_y,
50 const float radiance_z,
57 float theta = spherical.
x;
58 const float phi = -spherical.
y +
M_PI_2_F;
84 const float ctheta =
cosf(theta);
85 const float cgamma =
cosf(gamma);
87 const float expM =
expf(configuration[4] * gamma);
88 const float rayM = cgamma * cgamma;
89 const float mieM = (1.0f + rayM) /
powf((1.0f + configuration[8] * configuration[8] -
90 2.0f * configuration[8] * cgamma),
92 const float zenith =
sqrtf(ctheta);
94 return (1.0f + configuration[0] *
expf(configuration[1] / (ctheta + 0.01f))) *
95 (configuration[2] + configuration[3] * expM + configuration[5] * rayM +
96 configuration[6] * mieM + configuration[7] * zenith);
102 const float suntheta,
103 const float radiance_x,
104 const float radiance_y,
105 const float radiance_z,
112 float theta = spherical.
x;
113 const float phi = -spherical.
y +
M_PI_2_F;
138 const uint32_t path_flag,
139 const float3 pixel_bottom,
142 const uint texture_id)
145 const float sun_elevation = sky_data[0];
146 const float sun_rotation = sky_data[1];
147 const float angular_diameter = sky_data[2];
148 const float sun_intensity = sky_data[3];
149 const float earth_intersection_angle = sky_data[4];
150 const bool sun_disc = (angular_diameter >= 0.0f);
155 const float half_angular = angular_diameter * 0.5f;
156 const float dir_elevation =
M_PI_2_F - direction.
x;
160 if (sun_disc && sun_dir_angle < half_angular && dir_elevation > earth_intersection_angle &&
164 const float y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
166 const float limb_darkening = (1.0f -
167 0.6f * (1.0f -
sqrtf(1.0f -
sqr(sun_dir_angle / half_angular))));
168 xyz =
mix(pixel_bottom, pixel_top,
y) * sun_intensity * limb_darkening;
182 const uint32_t path_flag,
188 const uint dir_offset = node.
y;
189 const uint out_offset = node.
z;
215 config_x[0] =
data.y;
216 config_x[1] =
data.z;
217 config_x[2] =
data.w;
220 config_x[3] =
data.x;
221 config_x[4] =
data.y;
222 config_x[5] =
data.z;
223 config_x[6] =
data.w;
226 config_x[7] =
data.x;
227 config_x[8] =
data.y;
228 config_y[0] =
data.z;
229 config_y[1] =
data.w;
232 config_y[2] =
data.x;
233 config_y[3] =
data.y;
234 config_y[4] =
data.z;
235 config_y[5] =
data.w;
238 config_y[6] =
data.x;
239 config_y[7] =
data.y;
240 config_y[8] =
data.z;
241 config_z[0] =
data.w;
244 config_z[1] =
data.x;
245 config_z[2] =
data.y;
246 config_z[3] =
data.z;
247 config_z[4] =
data.w;
250 config_z[5] =
data.x;
251 config_z[6] =
data.y;
252 config_z[7] =
data.z;
253 config_z[8] =
data.w;
286 pixel_top.
x =
data.w;
290 pixel_top.
y =
data.x;
291 pixel_top.
z =
data.y;
292 sky_data[0] =
data.z;
293 sky_data[1] =
data.w;
296 sky_data[2] =
data.x;
297 sky_data[3] =
data.y;
298 sky_data[4] =
data.z;
MINLINE float safe_acosf(float a)
BMesh const char void * data
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y)
ccl_device_inline float4 read_node_float(KernelGlobals kg, ccl_private int *const offset)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
CCL_NAMESPACE_BEGIN ccl_device float2 direction_to_spherical(const float3 dir)
ccl_device float3 spherical_to_direction(const float theta, const float phi)
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
@ PATH_RAY_IMPORTANCE_BAKE
ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, const float3 xyz)
ccl_device_inline float precise_angle(const float3 a, const float3 b)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
color xyY_to_xyz(float x, float y, float Y)
ccl_device float3 geographical_to_direction(const float lat, const float lon)
ccl_device float sky_perez_function(const ccl_private float *lam, const float theta, const float gamma)
CCL_NAMESPACE_BEGIN ccl_device float sky_angle_between(const float thetav, const float phiv, const float theta, const float phi)
ccl_device float3 sky_radiance_hosek(KernelGlobals kg, const float3 dir, const float sunphi, const float suntheta, const float radiance_x, const float radiance_y, const float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z)
ccl_device_noinline int svm_node_tex_sky(KernelGlobals kg, const uint32_t path_flag, ccl_private float *stack, const uint4 node, int offset)
ccl_device float3 sky_radiance_preetham(KernelGlobals kg, const float3 dir, const float sunphi, const float suntheta, const float radiance_x, const float radiance_y, const float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z)
ccl_device float sky_radiance_internal(const ccl_private float *configuration, const float theta, const float gamma)
ccl_device float3 sky_radiance_nishita(KernelGlobals kg, const float3 dir, const uint32_t path_flag, const float3 pixel_bottom, const float3 pixel_top, const ccl_private float *sky_data, const uint texture_id)