Blender V5.0
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
8
9#pragma once
10
12
13#ifndef GPU_SHADER
14namespace blender::eevee {
15#endif
16
51
56#define SAMPLING_DIMENSION_COUNT 32
57
58/* NOTE(@fclem): Needs to be used in #StorageBuffer because of arrays of scalar. */
64
65/* Returns total sample count in a web pattern of the given size. */
66static inline int sampling_web_sample_count_get(int web_density, int in_ring_count)
67{
68 return ((in_ring_count * in_ring_count + in_ring_count) / 2) * web_density + 1;
69}
70
71/* Returns lowest possible ring count that contains at least sample_count samples. */
72static inline int sampling_web_ring_count_get(int web_density, int sample_count)
73{
74 /* Inversion of web_sample_count_get(). */
75 float x = 2.0f * (float(sample_count) - 1.0f) / float(web_density);
76 /* Solving polynomial. We only search positive solution. */
77 float discriminant = 1.0f + 4.0f * x;
78 return int(ceilf(0.5f * (sqrtf(discriminant) - 1.0f)));
79}
80
81#ifndef GPU_SHADER
82} // namespace blender::eevee
83#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition BLI_assert.h:86
nullptr float
#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)
#define sqrtf
#define ceilf
float dimensions[SAMPLING_DIMENSION_COUNT]