blob: 2aae88be140b757f122f47771ea1451f8f9be246 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2021 Blender Foundation.
*/
/** \file
* \ingroup eevee
*
*/
#pragma once
#include "eevee_shader.hh"
#include "eevee_shader_shared.hh"
#include "eevee_wrapper.hh"
namespace blender::eevee {
/* -------------------------------------------------------------------- */
/** \name Subsurface
*
* \{ */
class Instance;
struct SubsurfaceModule {
private:
Instance &inst_;
/** Contains samples locations. */
SubsurfaceDataBuf data_;
/** Contains translucence profile for a single color channel. */
GPUTexture *transmittance_tx = nullptr;
public:
SubsurfaceModule(Instance &inst) : inst_(inst)
{
/* Force first update. */
data_.sample_len = -1;
};
~SubsurfaceModule()
{
GPU_TEXTURE_FREE_SAFE(transmittance_tx);
};
void end_sync();
const GPUUniformBuf *ubo_get(void) const
{
return data_;
}
GPUTexture **transmittance_ref_get(void)
{
return &transmittance_tx;
}
private:
void precompute_samples_location();
void precompute_transmittance_profile();
/** Christensen-Burley implementation. */
static float burley_setup(float radius, float albedo);
static float burley_sample(float d, float x_rand);
static float burley_eval(float d, float r);
static float burley_pdf(float d, float r);
};
/** \} */
} // namespace blender::eevee
|