32 uint64_t render_sample_count = (inst_.view_layer->samples > 0) ? inst_.view_layer->samples :
35 sample_count_ = inst_.is_viewport() ? scene->
eevee.
taa_samples : render_sample_count;
37 if (inst_.is_image_render) {
41 if (sample_count_ == 0) {
43 sample_count_ = infinite_sample_count_;
46 if (inst_.is_viewport()) {
55 motion_blur_steps_ = !inst_.is_viewport() && ((scene->
r.
mode &
R_MBLUR) != 0) ?
58 sample_count_ =
divide_ceil_u(sample_count_, motion_blur_steps_);
61 if (sample_count_ == infinite_sample_count_) {
71 sample_count_ =
divide_ceil_u(sample_count_, dof_sample_count_) * dof_sample_count_;
75 dof_sample_count_ = 1;
79 sample_count_ *= motion_blur_steps_;
81 auto clamp_value_load = [](
float value) {
return (value > 0.0) ? value : 1e20; };
83 clamp_data_.sun_threshold = clamp_value_load(inst_.world.sun_threshold());
95 sample_count_ =
max_ii(1, lightprobe.grid_bake_samples);
102 viewport_sample_ = 0;
105 if (inst_.is_viewport()) {
107 interactive_mode_ = viewport_sample_ < interactive_mode_threshold;
110 inst_.is_viewport_image_render;
111 if (interactive_mode_disabled) {
112 interactive_mode_ =
false;
113 sample_ = viewport_sample_;
115 else if (interactive_mode_) {
116 int interactive_sample_count = interactive_sample_max_;
118 if (viewport_sample_ < interactive_sample_count) {
120 sample_ = sample_ % interactive_sample_count;
124 sample_ = interactive_sample_count;
134 uint64_t sample_filter = sample_ /
square_i(inst_.film.scaling_factor_get());
136 sample_filter = sample_filter % interactive_sample_aa_;
142 uint2 primes = {2, 3};
156 uint3 primes = {5, 7, 3};
173 sample_raytrace = sample_raytrace % interactive_sample_raytrace_;
178 uint3 primes = {5, 7, 11};
179 BLI_halton_3d(primes, offset, sample_raytrace * leap + 1, r);
190 uint3 primes = {2, 3, 5};
201 sample_volume = sample_volume % interactive_sample_volume_;
204 uint3 primes = {2, 3, 5};
215 uint2 primes = {2, 3};
266 sample.z = rand.x * 2.0f - 1.0f;
270 float omega = rand.y * 2.0f *
M_PI;
280 float omega = rand.y * 2.0f *
M_PI;
286 const float omega = rand.y * 2.0f *
M_PI;
294 const float omega = rand.y * 2.0f *
M_PI;
295 const float cos_theta = rand.x * 2.0f - 1.0f;
303 float omega = 4.0f *
M_PI * (1.0f +
sqrtf(5.0f)) * rand.x;
304 float r =
sqrtf(rand.x);
306 omega += rand.y * 2.0f *
M_PI;
312 if (dof_ring_count_ == 0) {
313 *r_radius = *r_theta = 0.0f;
319 int ring_sample_count = 1;
322 s = s * (dof_web_density_ - 1);
323 s = s % dof_sample_count_;
332 int samples_passed = 1;
333 while (s >= samples_passed) {
335 ring_sample_count = ring * dof_web_density_;
336 ring_sample = s - samples_passed;
337 ring_sample = (ring_sample + 1) % ring_sample_count;
338 samples_passed += ring_sample_count;
341 *r_radius = ring /
float(dof_ring_count_);
342 *r_theta = 2.0f *
M_PI * ring_sample /
float(ring_sample_count);
362 cdf[u] /= cdf.
last();
372 float x =
clamp_f(u /
float(inverted_cdf.
size() - 1), 1e-5f, 1.0f - 1e-5f);
375 float t = (
x - cdf[
i]) / (cdf[
i] - cdf[
i - 1]);
376 inverted_cdf[u] = (
float(
i) + t) /
float(cdf.
size() - 1);
int BKE_render_preview_pixel_size(const RenderData *r)
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int square_i(int a)
MINLINE int max_ii(int a, int b)
MINLINE float square_f(float a)
MINLINE float safe_sqrtf(float a)
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r)
void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r)
#define UNUSED_VARS_NDEBUG(...)
@ SCE_EEVEE_TAA_REPROJECTION
T & DRW_object_get_data_for_drawing(const Object &object)
ccl_device_inline float cos_theta(const float3 w)
ccl_device_inline float sin_theta(const float3 w)
unsigned long long int uint64_t
constexpr IndexRange drop_front(int64_t n) const
const T & last(const int64_t n=0) const
IndexRange index_range() const
static float3 sample_sphere(const float2 &rand)
static void cdf_invert(Vector< float > &cdf, Vector< float > &inverted_cdf)
bool interactive_mode() const
static float2 sample_disk(const float2 &rand)
void dof_disk_sample_get(float *r_radius, float *r_theta) const
void init(const Scene *scene)
static float2 sample_spiral(const float2 &rand)
static void cdf_from_curvemapping(const CurveMapping &curve, Vector< float > &cdf)
static float3 sample_hemisphere(const float2 &rand)
static float3 sample_ball(const float3 &rand)
#define SAMPLING_DIMENSION_COUNT
static int sampling_web_ring_count_get(int web_density, int sample_count)
static int sampling_web_sample_count_get(int web_density, int in_ring_count)
T max(const T &a, const T &b)
VecBase< uint32_t, 2 > uint2
VecBase< double, 2 > double2
VecBase< uint32_t, 3 > uint3
VecBase< float, 2 > float2
VecBase< double, 3 > double3
VecBase< float, 3 > float3
float clamp_surface_direct
float clamp_volume_indirect
float clamp_surface_indirect
float clamp_volume_direct