32 if (inst_.is_image_render) {
36 if (sample_count_ == 0) {
38 sample_count_ = infinite_sample_count_;
41 if (inst_.is_viewport()) {
50 motion_blur_steps_ = !inst_.is_viewport() && ((scene->
r.
mode &
R_MBLUR) != 0) ?
53 sample_count_ =
divide_ceil_u(sample_count_, motion_blur_steps_);
56 if (sample_count_ == infinite_sample_count_) {
66 sample_count_ =
divide_ceil_u(sample_count_, dof_sample_count_) * dof_sample_count_;
70 dof_sample_count_ = 1;
74 sample_count_ *= motion_blur_steps_;
76 auto clamp_value_load = [](
float value) {
return (value > 0.0) ? value : 1e20; };
78 clamp_data_.sun_threshold = clamp_value_load(inst_.world.sun_threshold());
90 sample_count_ =
max_ii(1, lightprobe.grid_bake_samples);
100 if (inst_.is_viewport()) {
102 interactive_mode_ = viewport_sample_ < interactive_mode_threshold;
105 inst_.is_viewport_image_render;
106 if (interactive_mode_disabled) {
107 interactive_mode_ =
false;
108 sample_ = viewport_sample_;
110 else if (interactive_mode_) {
111 int interactive_sample_count = interactive_sample_max_;
113 if (viewport_sample_ < interactive_sample_count) {
115 sample_ = sample_ % interactive_sample_count;
119 sample_ = interactive_sample_count;
129 uint64_t sample_filter = sample_ /
square_i(inst_.film.scaling_factor_get());
131 sample_filter = sample_filter % interactive_sample_aa_;
137 uint2 primes = {2, 3};
151 uint3 primes = {5, 7, 3};
168 sample_raytrace = sample_raytrace % interactive_sample_raytrace_;
173 uint3 primes = {5, 7, 11};
174 BLI_halton_3d(primes, offset, sample_raytrace * leap + 1, r);
185 uint3 primes = {2, 3, 5};
196 sample_volume = sample_volume % interactive_sample_volume_;
199 uint3 primes = {2, 3, 5};
210 uint2 primes = {2, 3};
261 sample.z = rand.x * 2.0f - 1.0f;
265 float omega = rand.y * 2.0f *
M_PI;
275 float omega = rand.y * 2.0f *
M_PI;
281 const float omega = rand.y * 2.0f *
M_PI;
289 const float omega = rand.y * 2.0f *
M_PI;
290 const float cos_theta = rand.x * 2.0f - 1.0f;
298 float omega = 4.0f *
M_PI * (1.0f +
sqrtf(5.0f)) * rand.x;
299 float r =
sqrtf(rand.x);
301 omega += rand.y * 2.0f *
M_PI;
307 if (dof_ring_count_ == 0) {
308 *r_radius = *r_theta = 0.0f;
314 int ring_sample_count = 1;
317 s = s * (dof_web_density_ - 1);
318 s = s % dof_sample_count_;
327 int samples_passed = 1;
328 while (s >= samples_passed) {
330 ring_sample_count = ring * dof_web_density_;
331 ring_sample = s - samples_passed;
332 ring_sample = (ring_sample + 1) % ring_sample_count;
333 samples_passed += ring_sample_count;
336 *r_radius = ring / float(dof_ring_count_);
337 *r_theta = 2.0f *
M_PI * ring_sample / float(ring_sample_count);
352 float x = float(u + 1) / float(cdf.
size() - 1);
357 cdf[u] /= cdf.
last();
367 float x =
clamp_f(u /
float(inverted_cdf.
size() - 1), 1e-5f, 1.0f - 1e-5f);
370 float t = (
x - cdf[
i]) / (cdf[
i] - cdf[
i - 1]);
371 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
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)
Mesh & DRW_object_get_data_for_drawing(const Object &object)
#define SAMPLING_DIMENSION_COUNT
MINLINE float fractf(float a)
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