Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/material/gpu_shader_material_tex_sky.glsl
| float sky_angle_between(float thetav, float phiv, float theta, float phi) | float sky_angle_between(float thetav, float phiv, float theta, float phi) | ||||
| { | { | ||||
| float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta); | float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta); | ||||
| if (cospsi > 1.0) { | if (cospsi > 1.0) { | ||||
| return 0.0; | return 0.0; | ||||
| } | } | ||||
| if (cospsi < -1.0) { | if (cospsi < -1.0) { | ||||
| return M_PI; | return M_PI; | ||||
| } | } | ||||
| return acos(cospsi); | return acos(cospsi); | ||||
| } | } | ||||
| vec3 sky_spherical_coordinates(vec3 dir) | vec3 sky_spherical_coordinates(vec3 dir) | ||||
| { | { | ||||
| return vec3(acos(dir.z), atan(dir.x, dir.y), 0); | return vec3(M_PI_2 - atan(dir.z, length(dir.xy)), atan(dir.x, dir.y), 0); | ||||
| } | } | ||||
| /* Preetham */ | /* Preetham */ | ||||
| /* lam03+lam4: 5 floats passed as vec4+float */ | /* lam03+lam4: 5 floats passed as vec4+float */ | ||||
| float sky_perez_function(vec4 lam03, float lam4, float theta, float gamma) | float sky_perez_function(vec4 lam03, float lam4, float theta, float gamma) | ||||
| { | { | ||||
| float ctheta = cos(theta); | float ctheta = cos(theta); | ||||
| float cgamma = cos(gamma); | float cgamma = cos(gamma); | ||||
| ▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines | |||||