Blender V5.3
eevee_sampling_lib.bsl.hh File Reference

Go to the source code of this file.

Classes

struct  eevee::Sampling

Namespaces

namespace  eevee
namespace  random
namespace  random::detail

Functions

float random::detail::van_der_corput_radical_inverse (uint bits)
float random::detail::interleaved_gradient (float2 v, float offset=0.0f)
uint random::detail::pcg (uint u)
float random::interleaved_gradient (float2 pixel, float seed, float offset)
float2 random::interleaved_gradient_2d (float2 pixel, float2 seed, float2 offset)
float3 random::interleaved_gradient_3d (float2 pixel, float3 seed, float3 offset)
float random::pcg (float v)
float random::pcg (float2 v)
float random::pcg (float3 v)
float3 random::pcg_3d (float3 v)
float4 random::pcg_4d (float4 v)
template<typename T>
float2 random::hammersley_2d (T i, T sample_count)
template float2 random::hammersley_2d< float > (float i, float sample_count)
template float2 random::hammersley_2d< uint > (uint i, uint sample_count)
template float2 random::hammersley_2d< int > (int i, int sample_count)
Random number generators: noise functions and hash sequences
float2 regular_grid_2d (int i, int sample_count)
Distribution mappings.

Functions mapping input random numbers in [0..1] to sampling shapes (i.e: hemisphere).

float2 sample_circle (float rand)
float2 sample_disk (float2 rand)
float3 sample_cylinder (float2 rand)
float3 sample_sphere (float2 rand)
float3 sample_ball (float3 rand)
float3 sample_hemisphere (float2 rand)
float3 sample_uniform_cone (float2 rand, float cos_angle)
float3 sample_cos_hemisphere (const float2 rand)
float3 sample_cos_hemisphere (const float3 rand_cylinder)

Variables

static constexpr float random::detail::pcg_rcp = 1.0f / float(0xffffffffU)

Detailed Description

Sampling data accessors, noise functions and hash sequences. Also contains several sample mapping functions.

References:

[damm2012] Holger Dammertz Hammersley Points on Spheres https://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html

[onei2014] Melissa O'Neill PCG: A Family of Simple Fast Space-Efficient Good Algorithms for Random Number Generation. 2014 https://www.pcg-random.org/pdf/hmc-cs-2014-0905.pdf

[jorg2014] Jorge Jimenez Next Generation Post-processing in COD Advanced Warfare SIGGRAPH 2014 Advances in Real-Time Rendering https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare/

[wymn2017] Chris Wyman and Morgan McGuire Hashed Alpha Testing ACM I3D 2017 https://research.nvidia.com/labs/rtr/publication/wyman2017hashed/

[jarz2020] Mark Jarzynski and Marc Olano Hash Functions for GPU Rendering JCGT 2020 https://www.jcgt.org/published/0009/03/02/

Definition in file eevee_sampling_lib.bsl.hh.

Function Documentation

◆ regular_grid_2d()

float2 regular_grid_2d ( int i,
int sample_count )

Definition at line 229 of file eevee_sampling_lib.bsl.hh.

References float, regular_grid_2d(), and sqrt.

Referenced by regular_grid_2d().

◆ sample_ball()

float3 sample_ball ( float3 rand)

Returns a point in a ball that is "uniformly" distributed after projection along any axis. PDF = unknown

Definition at line 283 of file eevee_sampling_lib.bsl.hh.

References sample_ball(), sample_sphere(), sqrt, and float3::z.

Referenced by sample_ball(), and eevee::light::shadow_setup_main().

◆ sample_circle()

◆ sample_cos_hemisphere() [1/2]

float3 sample_cos_hemisphere ( const float2 rand)

◆ sample_cos_hemisphere() [2/2]

float3 sample_cos_hemisphere ( const float3 rand_cylinder)

Cosine-weighted direction in hemisphere rand is a random point on a unit cylinder PDF = cos_angle / pi

Definition at line 333 of file eevee_sampling_lib.bsl.hh.

References cos_theta(), safe_sqrt(), sample_cos_hemisphere(), sin_from_cos(), and float3::x.

◆ sample_cylinder()

◆ sample_disk()

◆ sample_hemisphere()

float3 sample_hemisphere ( float2 rand)

Uniform hemisphere distribution. rand is 2 random float in the [0..1] range. Returns point on a Z positive hemisphere of radius 1 and centered on the origin. PDF = 1 / (2 * pi)

Definition at line 295 of file eevee_sampling_lib.bsl.hh.

References cos_theta(), safe_sqrt(), sample_circle(), sample_hemisphere(), sin_theta(), square(), float2::x, and float2::y.

Referenced by sample_hemisphere().

◆ sample_sphere()

float3 sample_sphere ( float2 rand)

Uniform sphere distribution. rand is 2 random float in the [0..1] range. Returns point on a Z positive hemisphere of radius 1 and centered on the origin. PDF = 1 / (4 * pi)

Definition at line 272 of file eevee_sampling_lib.bsl.hh.

References cos_theta(), safe_sqrt(), sample_circle(), sample_sphere(), sin_theta(), float2::x, and float2::y.

Referenced by sample_ball(), and sample_sphere().

◆ sample_uniform_cone()

float3 sample_uniform_cone ( float2 rand,
float cos_angle )

Uniform cone distribution. rand is 2 random float in the [0..1] range. cos_angle is the cosine of the half angle. Returns point on a Z positive hemisphere of radius 1 and centered on the origin. PDF = 1 / (2 * pi * (1 - cos_angle))

Definition at line 309 of file eevee_sampling_lib.bsl.hh.

References cos_theta(), mix, safe_sqrt(), sample_circle(), sample_uniform_cone(), sin_theta(), square(), float2::x, and float2::y.

Referenced by background_sun_sample(), bsdf_diffuse_toon_sample(), bsdf_glossy_toon_sample(), eevee::lightprobe::sphere::mip_convolve(), point_light_sample(), sample_uniform_cone(), sample_uniform_cone(), eevee::shadow_ray_generate_directional(), eevee::light::shadow_setup_main(), spot_light_sample(), and sun_light_sample().