Blender V5.0
sky_math.h File Reference
#include <algorithm>
#include <cmath>

Go to the source code of this file.

Classes

struct  float2
struct  float3
struct  float4

Macros

#define M_PI_F   (3.1415926535897932f) /* pi */
#define M_PI_2_F   (1.5707963267948966f) /* pi/2 */
#define M_2PI_F   (6.2831853071795864f) /* 2*pi */
#define M_1_PI_F   (0.3183098861837067f) /* 1/pi */
#define M_4PI_F   (12.566370614359172f) /* 4*pi */
#define M_1_4PI_F   (0.0795774715459476f) /* 1/(4*pi) */

Functions

float sqr (float a)
float safe_sqrtf (const float f)
float2 make_float2 (float x, float y)
float dot (const float2 &a, const float2 &b)
float distance (const float2 &a, const float2 &b)
float len_squared (float2 f)
float len (float2 f)
float reduce_add (float2 f)
float3 make_float3 (float x, float y, float z)
float dot (const float3 &a, const float3 &b)
float distance (const float3 &a, const float3 &b)
float len_squared (float3 f)
float len (float3 f)
float reduce_add (float3 f)
float4 make_float4 (float x, float y, float z, float w)
float dot (const float4 a, const float4 b)
float distance (const float4 &a, const float4 &b)
float len_squared (float4 f)
float len (float4 f)
float reduce_add (float4 f)
float4 exp (float4 a)
float4 max (float4 a, float b)
float clamp (float x, float min, float max)
float saturate (const float a)
template<typename T>
T mix (T x, T y, float a)
float3 sun_direction (float sun_cos_theta)
float ray_sphere_intersection (float3 pos, float3 dir, float radius)
template<typename Function>
void SKY_parallel_for (const size_t begin, const size_t end, const size_t grainsize, const Function &function)

Macro Definition Documentation

◆ M_1_4PI_F

#define M_1_4PI_F   (0.0795774715459476f) /* 1/(4*pi) */

Definition at line 38 of file sky_math.h.

◆ M_1_PI_F

#define M_1_PI_F   (0.3183098861837067f) /* 1/pi */

Definition at line 32 of file sky_math.h.

◆ M_2PI_F

#define M_2PI_F   (6.2831853071795864f) /* 2*pi */

Definition at line 29 of file sky_math.h.

◆ M_4PI_F

#define M_4PI_F   (12.566370614359172f) /* 4*pi */

Definition at line 35 of file sky_math.h.

◆ M_PI_2_F

#define M_PI_2_F   (1.5707963267948966f) /* pi/2 */

Definition at line 26 of file sky_math.h.

◆ M_PI_F

#define M_PI_F   (3.1415926535897932f) /* pi */

Definition at line 23 of file sky_math.h.

Function Documentation

◆ clamp()

float clamp ( float x,
float min,
float max )
inline

Definition at line 436 of file sky_math.h.

References max, min, and x.

Referenced by saturate().

◆ distance() [1/3]

float distance ( const float2 & a,
const float2 & b )
inline

Definition at line 346 of file sky_math.h.

References b.

◆ distance() [2/3]

float distance ( const float3 & a,
const float3 & b )
inline

Definition at line 376 of file sky_math.h.

References b.

◆ distance() [3/3]

float distance ( const float4 & a,
const float4 & b )
inline

Definition at line 406 of file sky_math.h.

References b.

◆ dot() [1/3]

float dot ( const float2 & a,
const float2 & b )
inline

Definition at line 341 of file sky_math.h.

References b, float2::x, and float2::y.

Referenced by ray_sphere_intersection().

◆ dot() [2/3]

float dot ( const float3 & a,
const float3 & b )
inline

Definition at line 371 of file sky_math.h.

References b, float3::x, float3::y, and float3::z.

◆ dot() [3/3]

float dot ( const float4 a,
const float4 b )
inline

Definition at line 401 of file sky_math.h.

References b, float4::w, float4::x, float4::y, and float4::z.

◆ exp()

float4 exp ( float4 a)
inline

Definition at line 426 of file sky_math.h.

References expf, make_float4, float4::w, float4::x, float4::y, and float4::z.

◆ len() [1/3]

float len ( float2 f)
inline

Definition at line 356 of file sky_math.h.

References float2::length().

◆ len() [2/3]

float len ( float3 f)
inline

Definition at line 386 of file sky_math.h.

References float3::length().

◆ len() [3/3]

float len ( float4 f)
inline

Definition at line 416 of file sky_math.h.

References float4::length().

◆ len_squared() [1/3]

float len_squared ( float2 f)
inline

Definition at line 351 of file sky_math.h.

References float2::length_squared().

◆ len_squared() [2/3]

float len_squared ( float3 f)
inline

Definition at line 381 of file sky_math.h.

References float3::length_squared().

◆ len_squared() [3/3]

float len_squared ( float4 f)
inline

Definition at line 411 of file sky_math.h.

References float4::length_squared().

◆ make_float2()

float2 make_float2 ( float x,
float y )
inline

Definition at line 336 of file sky_math.h.

References x, and y.

◆ make_float3()

float3 make_float3 ( float x,
float y,
float z )
inline

Definition at line 366 of file sky_math.h.

References x, y, and z().

Referenced by sun_direction().

◆ make_float4()

float4 make_float4 ( float x,
float y,
float z,
float w )
inline

Definition at line 396 of file sky_math.h.

References w(), x, y, and z().

◆ max()

float4 max ( float4 a,
float b )
inline

Definition at line 431 of file sky_math.h.

References b, make_float4, float4::w, float4::x, float4::y, and float4::z.

◆ mix()

template<typename T>
T mix ( T x,
T y,
float a )
inline

Definition at line 452 of file sky_math.h.

References T, x, and y.

◆ ray_sphere_intersection()

float ray_sphere_intersection ( float3 pos,
float3 dir,
float radius )
inline

Definition at line 462 of file sky_math.h.

References b, dot(), pos, and sqrtf.

Referenced by SkyMultipleScattering::get_transmittance(), and SKY_multiple_scattering_precompute_texture().

◆ reduce_add() [1/3]

float reduce_add ( float2 f)
inline

Definition at line 361 of file sky_math.h.

References float2::x, and float2::y.

◆ reduce_add() [2/3]

float reduce_add ( float3 f)
inline

Definition at line 391 of file sky_math.h.

References float3::x, float3::y, and float3::z.

◆ reduce_add() [3/3]

float reduce_add ( float4 f)
inline

Definition at line 421 of file sky_math.h.

References float4::w, float4::x, float4::y, and float4::z.

◆ safe_sqrtf()

◆ saturate()

float saturate ( const float a)
inline

Definition at line 447 of file sky_math.h.

References clamp().

◆ SKY_parallel_for()

template<typename Function>
void SKY_parallel_for ( const size_t begin,
const size_t end,
const size_t grainsize,
const Function & function )
inline

◆ sqr()

float sqr ( float a)
inline

Definition at line 326 of file sky_math.h.

◆ sun_direction()