Blender V5.0
volume_henyey_greenstein.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2024 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/types.h"
8
10
12
13/* HENYEY-GREENSTEIN CLOSURE */
14
20static_assert(sizeof(ShaderVolumeClosure) >= sizeof(HenyeyGreensteinVolume),
21 "HenyeyGreensteinVolume is too large!");
22
24{
26 /* clamp anisotropy to avoid delta function */
27 volume->g = signf(volume->g) * min(fabsf(volume->g), 1.0f - 1e-3f);
28
29 return SD_SCATTER;
30}
31
34 const float3 wo,
35 ccl_private float *pdf)
36{
38 svc;
39
40 /* note that wi points towards the viewer */
41 const float cos_theta = dot(-sd->wi, wo);
42 *pdf = phase_henyey_greenstein(cos_theta, volume->g);
43
44 return make_spectrum(*pdf);
45}
46
49 const float2 rand,
52 ccl_private float *pdf)
53{
55 svc;
56
57 /* note that wi points towards the viewer and so is used negated */
58 *wo = phase_henyey_greenstein_sample(-sd->wi, volume->g, rand, pdf);
59 *eval = make_spectrum(*pdf); /* perfect importance sampling */
60
62}
63
MINLINE float signf(float f)
ccl_device_inline float cos_theta(const float3 w)
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
#define make_spectrum(f)
#define ccl_private
#define CCL_NAMESPACE_END
@ CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID
@ SD_SCATTER
@ LABEL_VOLUME_SCATTER
#define fabsf
#define ccl_device
#define min(a, b)
Definition sort.cc:36
float3 Spectrum
ccl_device int volume_henyey_greenstein_setup(ccl_private HenyeyGreensteinVolume *volume)
ccl_device Spectrum volume_henyey_greenstein_eval(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, const float3 wo, ccl_private float *pdf)
ccl_device int volume_henyey_greenstein_sample(const ccl_private ShaderData *sd, const ccl_private ShaderVolumeClosure *svc, const float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device float3 phase_henyey_greenstein_sample(const float3 D, const float g, const float2 rand, ccl_private float *pdf)
Definition volume_util.h:36
ccl_device float phase_henyey_greenstein(const float cos_theta, const float g)
Definition volume_util.h:27