Blender V4.3
bsdf_ray_portal.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
8
15
16static_assert(sizeof(ShaderClosure) >= sizeof(RayPortalClosure), "RayPortalClosure is too large!");
17
19 const Spectrum weight,
20 uint32_t path_flag,
21 float3 position,
22 float3 direction)
23{
24 /* Check cutoff weight. */
25 float sample_weight = fabsf(average(weight));
26 if (!(sample_weight >= CLOSURE_WEIGHT_CUTOFF)) {
27 return;
28 }
29
30 sd->closure_transparent_extinction += weight;
31
33 sd, sizeof(RayPortalClosure), CLOSURE_BSDF_RAY_PORTAL_ID, weight);
34
35 if (pc) {
36 sd->flag |= SD_BSDF | SD_RAY_PORTAL;
37 if (is_zero(direction)) {
38 direction = -sd->wi;
39 }
40 pc->sample_weight = sample_weight;
41 pc->N = sd->N;
42 pc->P = position;
43 pc->D = direction;
44 }
45}
46
48 const float3 wi,
49 const float3 wo,
50 ccl_private float *pdf)
51{
52 *pdf = 0.0f;
53 return zero_spectrum();
54}
55
CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure * closure_alloc(ccl_private ShaderData *sd, int size, ClosureType type, Spectrum weight)
Definition alloc.h:9
ccl_device Spectrum bsdf_ray_portal_eval(ccl_private const ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
CCL_NAMESPACE_BEGIN struct RayPortalClosure RayPortalClosure
ccl_device void bsdf_ray_portal_setup(ccl_private ShaderData *sd, const Spectrum weight, uint32_t path_flag, float3 position, float3 direction)
#define ccl_device
#define ccl_private
#define CCL_NAMESPACE_END
#define fabsf(x)
@ CLOSURE_BSDF_RAY_PORTAL_ID
#define CLOSURE_WEIGHT_CUTOFF
@ SD_BSDF
@ SD_RAY_PORTAL
ShaderData
ShaderClosure
ccl_device_inline bool is_zero(const float2 a)
ccl_device_inline float average(const float2 a)
unsigned int uint32_t
Definition stdint.h:80
#define zero_spectrum
SPECTRUM_DATA_TYPE Spectrum