36 uint64_t render_sample_count = (inst_.view_layer->samples > 0) ? inst_.view_layer->samples :
39 sample_count_ = inst_.is_viewport() ? scene->
eevee.
taa_samples : render_sample_count;
42 if (inst_.is_image_render) {
46 if (sample_count_ == 0) {
48 sample_count_ = infinite_sample_count_;
51 if (inst_.is_viewport()) {
60 motion_blur_steps_ = !inst_.is_viewport() && ((scene->
r.
mode &
R_MBLUR) != 0) ?
63 sample_count_ =
divide_ceil_u(sample_count_, motion_blur_steps_);
66 if (sample_count_ == infinite_sample_count_) {
72 dof_ring_count_ = sampling_web_ring_count_get(dof_web_density_, sample_count_);
74 dof_sample_count_ = sampling_web_sample_count_get(dof_web_density_, dof_ring_count_);
76 sample_count_ =
divide_ceil_u(sample_count_, dof_sample_count_) * dof_sample_count_;
80 dof_sample_count_ = 1;
84 sample_count_ *= motion_blur_steps_;
86 auto clamp_value_load = [](
float value) {
return (value > 0.0) ? value : unclamped_max; };
88 clamp_data_.sun_threshold = clamp_value_load(inst_.world.sun_threshold());
100 &prop_scene,
"[\"override_pixel_jitter_sample\"]");
101 use_custom_pixel_jitter_sample_ =
false;
102 if (override_pixel_jitter_sample_prop) {
104 override_pixel_jitter_sample_prop);
105 if (array_length == 2) {
107 &prop_scene, override_pixel_jitter_sample_prop, &custom_pixel_jitter_sample_[0]);
108 use_custom_pixel_jitter_sample_ =
true;
110 else if (array_length != 0) {
111 printf(
"%s: scene.custom_pixel_jitter_sample length is not 0 or 2.\n", __func__);
115 if (!inst_.is_viewport()) {
126 sample_count_ =
max_ii(1, lightprobe.grid_bake_samples);
134 viewport_sample_ = 0;
138 if (inst_.is_viewport()) {
140 interactive_mode_ = viewport_sample_ < interactive_mode_threshold;
143 inst_.is_viewport_image_render;
144 if (interactive_mode_disabled) {
145 interactive_mode_ =
false;
146 sample_ = viewport_sample_;
148 else if (interactive_mode_) {
149 int interactive_sample_count = interactive_sample_max_;
151 if (viewport_sample_ < interactive_sample_count) {
153 sample_ = sample_ % interactive_sample_count;
157 sample_ = interactive_sample_count;
165 if (time_limit_ > 0.0f) {
170bool Sampling::check_time_limit_reached()
const
172 if (time_limit_ > 0.0f && sample_ > 0 && viewport_sample_ > 0) {
173 if (current_time_ - start_render_time_ >= time_limit_) {
184 uint64_t sample_filter = sample_ /
square_i(inst_.film.scaling_factor_get());
186 sample_filter = sample_filter % interactive_sample_aa_;
190 if (use_custom_pixel_jitter_sample_) {
191 r[0] = custom_pixel_jitter_sample_[0];
192 r[1] = custom_pixel_jitter_sample_[1];
199 uint2 primes = {2, 3};
214 uint3 primes = {5, 7, 3};
231 sample_raytrace = sample_raytrace % interactive_sample_raytrace_;
236 uint3 primes = {5, 7, 11};
237 BLI_halton_3d(primes, offset, sample_raytrace * leap + 1, r);
248 uint3 primes = {2, 3, 5};
259 sample_volume = sample_volume % interactive_sample_volume_;
262 uint3 primes = {2, 3, 5};
273 uint2 primes = {2, 3};
284 uint3 primes = {11, 13, 17};
292 double x, offset = 0;
300 uint2 primes = {5, 7};
306 for (
int i :
IndexRange(SAMPLING_DIMENSION_COUNT)) {
342 sample.z = rand.x * 2.0f - 1.0f;
346 float omega = rand.y * 2.0f *
M_PI;
356 float omega = rand.y * 2.0f *
M_PI;
362 const float omega = rand.y * 2.0f *
M_PI;
370 const float omega = rand.y * 2.0f *
M_PI;
371 const float cos_theta = rand.x * 2.0f - 1.0f;
379 float omega = 4.0f *
M_PI * (1.0f +
sqrtf(5.0f)) * rand.x;
380 float r =
sqrtf(rand.x);
382 omega += rand.y * 2.0f *
M_PI;
388 if (dof_ring_count_ == 0) {
389 *r_radius = *r_theta = 0.0f;
395 int ring_sample_count = 1;
398 s = s * (dof_web_density_ - 1);
399 s = s % dof_sample_count_;
408 int samples_passed = 1;
409 while (s >= samples_passed) {
411 ring_sample_count = ring * dof_web_density_;
412 ring_sample = s - samples_passed;
413 ring_sample = (ring_sample + 1) % ring_sample_count;
414 samples_passed += ring_sample_count;
417 *r_radius = ring /
float(dof_ring_count_);
418 *r_theta = 2.0f *
M_PI * ring_sample /
float(ring_sample_count);
438 cdf[u] /= cdf.
last();
448 float x =
clamp_f(u /
float(inverted_cdf.
size() - 1), 1e-5f, 1.0f - 1e-5f);
451 float t = (
x - cdf[i]) / (cdf[i] - cdf[i - 1]);
452 inverted_cdf[u] = (
float(i) + t) /
float(cdf.
size() - 1);
Platform independent time functions.
#define UNUSED_VARS_NDEBUG(...)
ccl_device_inline float cos_theta(const float3 w)
ccl_device_inline float sin_theta(const float3 w)
constexpr IndexRange()=default
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)
T max(const T &a, const T &b)
VecBase< uint32_t, 2 > uint2
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int BKE_render_preview_pixel_size(const RenderData *r)
unsigned __int64 uint64_t
void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r)
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
MINLINE float safe_sqrtf(float a)
MINLINE int square_i(int a)
PointerRNA RNA_id_pointer_create(ID *id)
VecBase< double, 2 > double2
MINLINE float fractf(float a)
MINLINE int max_ii(int a, int b)
VecBase< uint32_t, 3 > uint3
@ SCE_EEVEE_TAA_REPROJECTION
void BLI_halton_1d(unsigned int prime, double offset, int n, double *r)
VecBase< float, 2 > float2
T & DRW_object_get_data_for_drawing(const Object &object)
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r)
VecBase< double, 3 > double3
MINLINE uint divide_ceil_u(uint a, uint b)
MINLINE float square_f(float a)
double BLI_time_now_seconds()
VecBase< float, 3 > float3
float BKE_curvemapping_evaluateF(const CurveMapping *cumap, int cur, float value)
MINLINE float clamp_f(float value, float min, float max)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float indirect_light_intensity
float clamp_volume_direct
float clamp_surface_direct
float direct_light_intensity
float clamp_surface_indirect
float clamp_volume_indirect