36 const float ctheta =
cosf(theta);
37 const float cgamma =
cosf(gamma);
39 return (1.0f + lam[0] *
expf(lam[1] / ctheta)) *
40 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] * cgamma * cgamma);
47 const float radiance_x,
48 const float radiance_y,
49 const float radiance_z,
56 float theta = spherical.
x;
57 const float phi = -spherical.
y +
M_PI_2_F;
83 const float ctheta =
cosf(theta);
84 const float cgamma =
cosf(gamma);
86 const float expM =
expf(configuration[4] * gamma);
87 const float rayM = cgamma * cgamma;
88 const float mieM = (1.0f + rayM) /
powf((1.0f + configuration[8] * configuration[8] -
89 2.0f * configuration[8] * cgamma),
91 const float zenith =
sqrtf(ctheta);
93 return (1.0f + configuration[0] *
expf(configuration[1] / (ctheta + 0.01f))) *
94 (configuration[2] + configuration[3] * expM + configuration[5] * rayM +
95 configuration[6] * mieM + configuration[7] * zenith);
101 const float suntheta,
102 const float radiance_x,
103 const float radiance_y,
104 const float radiance_z,
111 float theta = spherical.
x;
112 const float phi = -spherical.
y +
M_PI_2_F;
137 const uint32_t path_flag,
138 const float3 pixel_bottom,
141 const uint texture_id)
144 const float sun_elevation = nishita_data[0];
145 const float sun_rotation = nishita_data[1];
146 const float angular_diameter = nishita_data[2];
147 const float sun_intensity = nishita_data[3];
148 const bool sun_disc = (angular_diameter >= 0.0f);
157 const float half_angular = angular_diameter * 0.5f;
158 const float dir_elevation =
M_PI_2_F - direction.
x;
162 if (sun_disc && sun_dir_angle < half_angular &&
169 if (sun_elevation - half_angular > 0.0f) {
170 if (sun_elevation + half_angular > 0.0f) {
171 y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
172 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
176 if (sun_elevation + half_angular > 0.0f) {
177 y = dir_elevation / (sun_elevation + half_angular);
178 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
182 const float limb_darkening = (1.0f - 0.6f * (1.0f -
sqrtf(1.0f -
sqr(sun_dir_angle /
184 xyz *= limb_darkening;
202 float fade = 1.0f + dir.
z * 2.5f;
216 const uint32_t path_flag,
222 const uint dir_offset = node.
y;
223 const uint out_offset = node.
z;
224 const int sky_model = node.
w;
230 if (sky_model == 0 || sky_model == 1) {
249 config_x[0] =
data.y;
250 config_x[1] =
data.z;
251 config_x[2] =
data.w;
254 config_x[3] =
data.x;
255 config_x[4] =
data.y;
256 config_x[5] =
data.z;
257 config_x[6] =
data.w;
260 config_x[7] =
data.x;
261 config_x[8] =
data.y;
262 config_y[0] =
data.z;
263 config_y[1] =
data.w;
266 config_y[2] =
data.x;
267 config_y[3] =
data.y;
268 config_y[4] =
data.z;
269 config_y[5] =
data.w;
272 config_y[6] =
data.x;
273 config_y[7] =
data.y;
274 config_y[8] =
data.z;
275 config_z[0] =
data.w;
278 config_z[1] =
data.x;
279 config_z[2] =
data.y;
280 config_z[3] =
data.z;
281 config_z[4] =
data.w;
284 config_z[5] =
data.x;
285 config_z[6] =
data.y;
286 config_z[7] =
data.z;
287 config_z[8] =
data.w;
290 if (sky_model == 0) {
318 float nishita_data[4];
323 pixel_top.
x =
data.w;
326 pixel_top.
y =
data.x;
327 pixel_top.
z =
data.y;
328 nishita_data[0] =
data.z;
329 nishita_data[1] =
data.w;
332 nishita_data[2] =
data.x;
333 nishita_data[3] =
data.y;
338 kg, dir, path_flag, pixel_bottom, pixel_top, nishita_data, texture_id);
MINLINE float safe_sqrtf(float a)
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
VecBase< float, 4 > float4
@ PATH_RAY_IMPORTANCE_BAKE
ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, const float3 xyz)
ccl_device_inline float sqr(const float a)
ccl_device_inline float interp(const float a, const float b, const float t)
MINLINE float fractf(float a)
ccl_device_inline float precise_angle(const float3 a, const float3 b)
color xyY_to_xyz(float x, float y, float Y)
CCL_NAMESPACE_BEGIN ccl_device float fade(const float t)
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_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 *nishita_data, const uint texture_id)
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 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_noinline int svm_node_tex_sky(KernelGlobals kg, ccl_private ShaderData *sd, const uint32_t path_flag, ccl_private float *stack, const uint4 node, int offset)