Blender V4.3
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
8
10
11/* HENYEY-GREENSTEIN CLOSURE */
12
18static_assert(sizeof(ShaderVolumeClosure) >= sizeof(HenyeyGreensteinVolume),
19 "HenyeyGreensteinVolume is too large!");
20
22{
24 /* clamp anisotropy to avoid delta function */
25 volume->g = signf(volume->g) * min(fabsf(volume->g), 1.0f - 1e-3f);
26
27 return SD_SCATTER;
28}
29
32 float3 wo,
33 ccl_private float *pdf)
34{
36 svc;
37
38 /* note that wi points towards the viewer */
39 float cos_theta = dot(-sd->wi, wo);
40 *pdf = phase_henyey_greenstein(cos_theta, volume->g);
41
42 return make_spectrum(*pdf);
43}
44
47 float2 rand,
50 ccl_private float *pdf)
51{
53 svc;
54
55 /* note that wi points towards the viewer and so is used negated */
56 *wo = phase_henyey_greenstein_sample(-sd->wi, volume->g, rand, pdf);
57 *eval = make_spectrum(*pdf); /* perfect importance sampling */
58
60}
61
MINLINE float signf(float f)
ccl_device_inline float cos_theta(const float3 w)
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
#define ccl_device
#define ccl_private
#define CCL_NAMESPACE_END
#define fabsf(x)
@ CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID
@ SD_SCATTER
struct ShaderVolumeClosure ShaderVolumeClosure
ShaderData
@ LABEL_VOLUME_SCATTER
#define min(a, b)
Definition sort.c:32
#define make_spectrum(f)
SPECTRUM_DATA_TYPE Spectrum
ccl_device int volume_henyey_greenstein_sample(ccl_private const ShaderData *sd, ccl_private const ShaderVolumeClosure *svc, float2 rand, ccl_private Spectrum *eval, ccl_private float3 *wo, ccl_private float *pdf)
ccl_device int volume_henyey_greenstein_setup(ccl_private HenyeyGreensteinVolume *volume)
CCL_NAMESPACE_BEGIN struct HenyeyGreensteinVolume HenyeyGreensteinVolume
ccl_device Spectrum volume_henyey_greenstein_eval(ccl_private const ShaderData *sd, ccl_private const ShaderVolumeClosure *svc, float3 wo, ccl_private float *pdf)
ccl_device float phase_henyey_greenstein(float cos_theta, float g)
Definition volume_util.h:26
ccl_device float3 phase_henyey_greenstein_sample(float3 D, float g, float2 rand, ccl_private float *pdf)
Definition volume_util.h:35