23 float ctheta =
cosf(theta);
24 float cgamma =
cosf(gamma);
26 return (1.0f + lam[0] *
expf(lam[1] / ctheta)) *
27 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] * cgamma * cgamma);
43 float theta = spherical.x;
44 float phi = spherical.y;
68 float ctheta =
cosf(theta);
69 float cgamma =
cosf(gamma);
71 float expM =
expf(configuration[4] * gamma);
72 float rayM = cgamma * cgamma;
73 float mieM = (1.0f + rayM) /
powf((1.0f + configuration[8] * configuration[8] -
74 2.0f * configuration[8] * cgamma),
76 float zenith =
sqrtf(ctheta);
78 return (1.0f + configuration[0] *
expf(configuration[1] / (ctheta + 0.01f))) *
79 (configuration[2] + configuration[3] * expM + configuration[5] * rayM +
80 configuration[6] * mieM + configuration[7] * zenith);
96 float theta = spherical.x;
97 float phi = spherical.y;
129 float sun_elevation = nishita_data[0];
130 float sun_rotation = nishita_data[1];
131 float angular_diameter = nishita_data[2];
132 float sun_intensity = nishita_data[3];
133 bool sun_disc = (angular_diameter >= 0.0f);
142 float half_angular = angular_diameter * 0.5f;
143 float dir_elevation =
M_PI_2_F - direction.x;
147 if (sun_disc && sun_dir_angle < half_angular &&
154 if (sun_elevation - half_angular > 0.0f) {
155 if (sun_elevation + half_angular > 0.0f) {
156 y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
157 xyz =
interp(pixel_bottom, pixel_top, y) * sun_intensity;
161 if (sun_elevation + half_angular > 0.0f) {
162 y = dir_elevation / (sun_elevation + half_angular);
163 xyz =
interp(pixel_bottom, pixel_top, y) * sun_intensity;
167 float limb_darkening = (1.0f -
168 0.6f * (1.0f -
sqrtf(1.0f -
sqr(sun_dir_angle / half_angular))));
169 xyz *= limb_darkening;
190 float fade = 1.0f + dir.
z * 2.5f;
213 uint dir_offset = node.y;
214 uint out_offset = node.z;
215 int sky_model = node.w;
221 if (sky_model == 0 || sky_model == 1) {
223 float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
224 float config_x[9], config_y[9], config_z[9];
234 config_x[0] = data.y;
235 config_x[1] = data.z;
236 config_x[2] = data.w;
239 config_x[3] = data.x;
240 config_x[4] = data.y;
241 config_x[5] = data.z;
242 config_x[6] = data.w;
245 config_x[7] = data.x;
246 config_x[8] = data.y;
247 config_y[0] = data.z;
248 config_y[1] = data.w;
251 config_y[2] = data.x;
252 config_y[3] = data.y;
253 config_y[4] = data.z;
254 config_y[5] = data.w;
257 config_y[6] = data.x;
258 config_y[7] = data.y;
259 config_y[8] = data.z;
260 config_z[0] = data.w;
263 config_z[1] = data.x;
264 config_z[2] = data.y;
265 config_z[3] = data.z;
266 config_z[4] = data.w;
269 config_z[5] = data.x;
270 config_z[6] = data.y;
271 config_z[7] = data.z;
272 config_z[8] = data.w;
275 if (sky_model == 0) {
303 float nishita_data[4];
308 pixel_top.
x = data.w;
311 pixel_top.
y = data.x;
312 pixel_top.
z = data.y;
313 nishita_data[0] = data.z;
314 nishita_data[1] = data.w;
317 nishita_data[2] = data.x;
318 nishita_data[3] = data.y;
323 kg, dir, path_flag, pixel_bottom, pixel_top, nishita_data, texture_id);
MINLINE float safe_sqrtf(float a)
MINLINE float safe_acosf(float a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
CCL_NAMESPACE_BEGIN ccl_device float2 direction_to_spherical(float3 dir)
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, int id, float x, float y)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_inline float4 read_node_float(KernelGlobals kg, ccl_private int *offset)
ccl_device_inline void stack_store_float3(ccl_private float *stack, uint a, float3 f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(ccl_private float *stack, uint a)
@ PATH_RAY_IMPORTANCE_BAKE
ccl_device float3 xyz_to_rgb_clamped(KernelGlobals kg, float3 xyz)
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
color xyY_to_xyz(float x, float y, float Y)
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
ccl_device float3 sky_radiance_hosek(KernelGlobals kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z)
ccl_device float3 geographical_to_direction(float lat, float lon)
ccl_device float3 sky_radiance_preetham(KernelGlobals kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, ccl_private float *config_x, ccl_private float *config_y, ccl_private float *config_z)
CCL_NAMESPACE_BEGIN ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi)
ccl_device_noinline int svm_node_tex_sky(KernelGlobals kg, ccl_private ShaderData *sd, uint32_t path_flag, ccl_private float *stack, uint4 node, int offset)
ccl_device float sky_perez_function(ccl_private float *lam, float theta, float gamma)
ccl_device float sky_radiance_internal(ccl_private float *configuration, float theta, float gamma)
ccl_device float3 sky_radiance_nishita(KernelGlobals kg, float3 dir, uint32_t path_flag, float3 pixel_bottom, float3 pixel_top, ccl_private float *nishita_data, uint texture_id)
ccl_device_inline float sqr(float a)
ccl_device_inline float precise_angle(float3 a, float3 b)
ccl_device_inline float3 float4_to_float3(const float4 a)