33 float ctheta =
cosf(theta);
34 float cgamma =
cosf(gamma);
36 return (1.0f + lam[0] *
expf(lam[1] / ctheta)) *
37 (1.0f + lam[2] *
expf(lam[3] * gamma) + lam[4] * cgamma * cgamma);
53 float theta = spherical.
x;
54 float phi = spherical.
y;
78 float ctheta =
cosf(theta);
79 float cgamma =
cosf(gamma);
81 float expM =
expf(configuration[4] * gamma);
82 float rayM = cgamma * cgamma;
83 float mieM = (1.0f + rayM) /
powf((1.0f + configuration[8] * configuration[8] -
84 2.0f * configuration[8] * cgamma),
86 float zenith =
sqrtf(ctheta);
88 return (1.0f + configuration[0] *
expf(configuration[1] / (ctheta + 0.01f))) *
89 (configuration[2] + configuration[3] * expM + configuration[5] * rayM +
90 configuration[6] * mieM + configuration[7] * zenith);
106 float theta = spherical.
x;
107 float phi = spherical.
y;
136 float sun_elevation = nishita_data[6];
137 float sun_rotation = nishita_data[7];
138 float angular_diameter = nishita_data[8];
139 float sun_intensity = nishita_data[9];
140 bool sun_disc = (angular_diameter >= 0.0f);
150 float half_angular = angular_diameter / 2.0f;
151 float dir_elevation =
M_PI_2_F - direction.
x;
154 if (sun_disc && sun_dir_angle < half_angular) {
156 float3 pixel_bottom =
make_float3(nishita_data[0], nishita_data[1], nishita_data[2]);
157 float3 pixel_top =
make_float3(nishita_data[3], nishita_data[4], nishita_data[5]);
161 if (sun_elevation - half_angular > 0.0f) {
162 if (sun_elevation + half_angular > 0.0f) {
163 y = ((dir_elevation - sun_elevation) / angular_diameter) + 0.5f;
164 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
168 if (sun_elevation + half_angular > 0.0f) {
169 y = dir_elevation / (sun_elevation + half_angular);
170 xyz =
interp(pixel_bottom, pixel_top,
y) * sun_intensity;
174 float limb_darkening = (1.0f -
175 0.6f * (1.0f -
sqrtf(1.0f -
sqr(sun_dir_angle / half_angular))));
176 xyz *= limb_darkening;
197 float fade = 1.0f + dir.
z * 2.5f;
218 int sky_model =
node.w;
224 if (sky_model == 0 || sky_model == 1) {
226 float sunphi, suntheta, radiance_x, radiance_y, radiance_z;
227 float config_x[9], config_y[9], config_z[9];
237 config_x[0] =
data.y;
238 config_x[1] =
data.z;
239 config_x[2] =
data.w;
242 config_x[3] =
data.x;
243 config_x[4] =
data.y;
244 config_x[5] =
data.z;
245 config_x[6] =
data.w;
248 config_x[7] =
data.x;
249 config_x[8] =
data.y;
250 config_y[0] =
data.z;
251 config_y[1] =
data.w;
254 config_y[2] =
data.x;
255 config_y[3] =
data.y;
256 config_y[4] =
data.z;
257 config_y[5] =
data.w;
260 config_y[6] =
data.x;
261 config_y[7] =
data.y;
262 config_y[8] =
data.z;
263 config_z[0] =
data.w;
266 config_z[1] =
data.x;
267 config_z[2] =
data.y;
268 config_z[3] =
data.z;
269 config_z[4] =
data.w;
272 config_z[5] =
data.x;
273 config_z[6] =
data.y;
274 config_z[7] =
data.z;
275 config_z[8] =
data.w;
278 if (sky_model == 0) {
306 float nishita_data[10];
309 nishita_data[0] =
data.x;
310 nishita_data[1] =
data.y;
311 nishita_data[2] =
data.z;
312 nishita_data[3] =
data.w;
315 nishita_data[4] =
data.x;
316 nishita_data[5] =
data.y;
317 nishita_data[6] =
data.z;
318 nishita_data[7] =
data.w;
321 nishita_data[8] =
data.x;
322 nishita_data[9] =
data.y;
MINLINE float safe_sqrtf(float a)
MINLINE float safe_acosf(float a)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline float4 read_node_float(KernelGlobals *kg, int *offset)
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
CCL_NAMESPACE_BEGIN ccl_device float3 xyz_to_rgb(KernelGlobals *kg, float3 xyz)
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
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)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
INLINE Rall1d< T, V, S > sin(const Rall1d< T, V, S > &arg)
color xyY_to_xyz(float x, float y, float Y)
CCL_NAMESPACE_BEGIN ccl_device float fade(float t)
ccl_device void svm_node_tex_sky(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, int *offset)
ccl_device float3 geographical_to_direction(float lat, float lon)
CCL_NAMESPACE_BEGIN ccl_device float sky_angle_between(float thetav, float phiv, float theta, float phi)
ccl_device float sky_perez_function(float *lam, float theta, float gamma)
ccl_device float3 sky_radiance_nishita(KernelGlobals *kg, float3 dir, float *nishita_data, uint texture_id)
ccl_device float3 sky_radiance_hosek(KernelGlobals *kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, float *config_x, float *config_y, float *config_z)
ccl_device float3 sky_radiance_preetham(KernelGlobals *kg, float3 dir, float sunphi, float suntheta, float radiance_x, float radiance_y, float radiance_z, float *config_x, float *config_y, float *config_z)
ccl_device float sky_radiance_internal(float *configuration, float theta, float gamma)
ccl_device_inline uint __float_as_uint(float f)
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)
ccl_device_inline float2 interp(const float2 &a, const float2 &b, float t)