diff options
Diffstat (limited to 'intern/cycles/kernel/kernel_montecarlo.h')
-rw-r--r-- | intern/cycles/kernel/kernel_montecarlo.h | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index f51ce263ea2..bdd147f83d3 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -185,124 +185,6 @@ __device float2 regular_polygon_sample(float corners, float rotation, float u, f return make_float2(cr*p.x - sr*p.y, sr*p.x + cr*p.y); } -/* Spherical coordinates <-> Cartesian direction */ - -__device float2 direction_to_spherical(float3 dir) -{ - float theta = acosf(dir.z); - float phi = atan2f(dir.x, dir.y); - - return make_float2(theta, phi); -} - -__device float3 spherical_to_direction(float theta, float phi) -{ - return make_float3( - sinf(theta)*cosf(phi), - sinf(theta)*sinf(phi), - cosf(theta)); -} - -/* Equirectangular coordinates <-> Cartesian direction */ - -__device float2 direction_to_equirectangular(float3 dir) -{ - float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; - float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; - - return make_float2(u, v); -} - -__device float3 equirectangular_to_direction(float u, float v) -{ - float phi = M_PI_F*(1.0f - 2.0f*u); - float theta = M_PI_F*(1.0f - v); - - return make_float3( - sin(theta)*cos(phi), - sin(theta)*sin(phi), - cos(theta)); -} - -/* Fisheye <- Cartesian direction */ - -__device float3 fisheye_to_direction(float u, float v, float fov) -{ - u = (u - 0.5f) * 2.0f; - v = (v - 0.5f) * 2.0f; - - float r = sqrt(u*u + v*v); - - if(r > 1.0f) - return make_float3(0.0f, 0.0f, 0.0f); - - float phi = acosf((r != 0.0f)? u/r: 0.0f); - float theta = asinf(r) * (fov / M_PI_F); - - if(v < 0.0f) phi = -phi; - - return make_float3( - cosf(theta), - -cosf(phi)*sinf(theta), - sinf(phi)*sinf(theta) - ); -} - -__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) -{ - u = (u - 0.5f) * width; - v = (v - 0.5f) * height; - - float rmax = 2.0f * lens * sinf(fov * 0.25f); - float r = sqrt(u*u + v*v); - - if(r > rmax) - return make_float3(0.0f, 0.0f, 0.0f); - - float phi = acosf((r != 0.0f)? u/r: 0.0f); - float theta = 2.0f * asinf(r/(2.0f * lens)); - - if(v < 0.0f) phi = -phi; - - return make_float3( - cosf(theta), - -cosf(phi)*sinf(theta), - sinf(phi)*sinf(theta) - ); -} - -/* Mirror Ball <-> Cartesion direction */ - -__device float3 mirrorball_to_direction(float u, float v) -{ - /* point on sphere */ - float3 dir; - - dir.x = 2.0f*u - 1.0f; - dir.z = 2.0f*v - 1.0f; - dir.y = -sqrt(max(1.0f - dir.x*dir.x - dir.z*dir.z, 0.0f)); - - /* reflection */ - float3 I = make_float3(0.0f, -1.0f, 0.0f); - - return 2.0f*dot(dir, I)*dir - I; -} - -__device float2 direction_to_mirrorball(float3 dir) -{ - /* inverse of mirrorball_to_direction */ - dir.y -= 1.0f; - - float div = 2.0f*sqrt(max(-0.5f*dir.y, 0.0f)); - if(div > 0.0f) - dir /= div; - - float u = 0.5f*(dir.x + 1.0f); - float v = 0.5f*(dir.z + 1.0f); - - return make_float2(u, v); -} - CCL_NAMESPACE_END #endif /* __KERNEL_MONTECARLO_CL__ */ |