Blender V5.3
eevee_sampling_shared.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
14
15#ifndef GPU_SHADER
16namespace blender::eevee {
17#endif
18
56
61static constexpr int SAMPLING_DIMENSION_COUNT = 36;
62
63/* NOTE(@fclem): Needs to be used in #StorageBuffer because of arrays of scalar. */
68
69/* Returns total sample count in a web pattern of the given size. */
70static inline int sampling_web_sample_count_get(int web_density, int in_ring_count)
71{
72 return ((in_ring_count * in_ring_count + in_ring_count) / 2) * web_density + 1;
73}
74
75/* Returns lowest possible ring count that contains at least sample_count samples. */
76static inline int sampling_web_ring_count_get(int web_density, int sample_count)
77{
78 /* Inversion of web_sample_count_get(). */
79 float x = 2.0f * (float(sample_count) - 1.0f) / float(web_density);
80 /* Solving polynomial. We only search positive solution. */
81 float discriminant = 1.0f + 4.0f * x;
82 return int(ceilf(0.5f * (sqrtf(discriminant) - 1.0f)));
83}
84
85#ifndef GPU_SHADER
86} // namespace blender::eevee
87#endif
#define host_shared
static int sampling_web_ring_count_get(int web_density, int sample_count)
static constexpr int SAMPLING_DIMENSION_COUNT
static int sampling_web_sample_count_get(int web_density, int in_ring_count)
unsigned int uint32_t
Definition BKE_text.h:81
#define sqrtf
#define ceilf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float dimensions[SAMPLING_DIMENSION_COUNT]